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