View Code of Problem 96

#include <iostream>
#include <cstring>
using namespace std;

int main(){
    double n;
    string w;
    cin>>n>>w;
    while (n!=0){
        double trueValue=0;
        double sValue=0;//标准
        if (w=="KB"){
            sValue=n*1024;
            trueValue=n*1000;
        } else if (w=="MB"){
            sValue=n*1024*1024;
            trueValue=n*1000*1000;
        } else if (w=="GB"){
            sValue=n*1024*1024*1024;
            trueValue=n*1000*1000*1000;
        } else if (w=="TB"){
            sValue=n*1024*1024*1024*1024;
            trueValue=n*1000*1000*1000*1000;
        }
        printf("%.0f\n",sValue-trueValue);
        cin>>n>>w;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 96