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