#include<stdio.h> #include<string.h> #include <math.h> #define Max 101 int main() { double a,sum,c; char b[3]; while(scanf("%lf",&a)!=EOF) { gets(b); if((a-0)<0.000000001) break; if(strcmp(b,"KB")==0) sum=a*(1024-1000); if(strcmp(b,"MB")==0) sum=a*(pow(1024,2)-pow(1000,2)); if(strcmp(b,"GB")==0) sum=a*(pow(1024,3)-pow(1000,3)); if(strcmp(b,"TB")==0) sum=a*(pow(1024,4)-pow(1000,4)); printf("%0.lf\n",sum); } return 0; } |
Double click to view unformatted code.