#include<stdio.h> #include<string.h> int main() { double n,m; char str[2]; while(scanf("%lf%s",&n,&str)!=EOF&&n!=0) { if(strcmp(str,"B")==0) m=0; else if(strcmp(str,"KB")==0) m=n*1024-n*1000; else if(strcmp(str,"MB")==0) m=n*1024*1024-n*1000*1000; else if(strcmp(str,"GB")==0) m=n*1024*1024*1024-n*1000*1000*1000; else if(strcmp(str,"TB")==0) m=n*1024*1024*1024*1024-n*1000*1000*1000*1000; printf("%.0lf\n",m); } return 0; } |
Double click to view unformatted code.