#include<stdio.h> #include<math.h> int main(){ double n,s; char a[2]; while(scanf("%lf%c%c",&n,&a[0],&a[1])!=EOF){ s=0; if(n==0) break; else{ if(a[0]=='M'){ double s=(n*pow(1024,2)-n*pow(1000,2)); printf("%.0f\n",s); } if(a[0]=='G'){ double s=(n*pow(1024,3)-n*pow(1000,3)); printf("%.0f\n",s); } if(a[0]=='T'){ double s=(n*pow(1024,4)-n*pow(1000,4)); printf("%.0f\n",s); } if(a[0]=='K'){ double s=(n*pow(1024,1)-n*pow(1000,1)); printf("%.0f\n",s); } } } return 0; } |
Double click to view unformatted code.