C++ 中字节和千字节之间的转换
#include <iostream> #include <cmath> using namespace std; int main() { long double byte; long double kilobyte; long double megabyte; long double gigabyte; cout << "Enter the byte value"; cin>>byte; kilobyte = byte / 1024; megabyte = kilobyte / 1024; gigabyte = megabyte / 1024; cout << byte << " Equal to " << kilobyte << " Kilobyte's "<<"\n"; cout << byte << " Equal to " << megabyte << " Megabyte's "<<"\n"; cout << byte << " Equal to " << gigabyte << " Gigabyte's "<<"\n"; system("pause"); return 0; }