#include<iostream> #include<cstring> #include<math.h> using namespace std; int main(){ double x; long long k; char d[10]; while(cin>>x){ if(x==0) break; cin>>d; if(strcmp(d,"B")==0){ cout<<0<<endl; }else if(strcmp(d,"KB")==0){ k=x*24; cout<<k<<endl; }else if(strcmp(d,"MB")==0){ k=x*(pow(1024,2)-pow(1000,2)); cout<<k<<endl; }else if(strcmp(d,"GB")==0){ k=x*(pow(1024,3)-pow(1000,3)); cout<<k<<endl; }else if(strcmp(d,"TB")==0){ k=x*(pow(1024,4)-pow(1000,4)); cout<<k<<endl; } } return 0; } |
Double click to view unformatted code.