#include <stdio.h> #include <stdlib.h> #include<ctype.h> #include<string.h> #include<math.h> #include<stdbool.h> int main() { int i, j; double n, sum; char a[5]; while (scanf("%lf%s",&n,a)) { if (n == 0) break; if (a[0] == 'K') sum = n * (1024) - n * 1000; else if (a[0] == 'M') sum = n * 1024 * 1024 - n * 1000 * 1000; else if (a[0] == 'G') sum = n * 1024 * 1024 * 1024 - n * 1000 * 1000 * 1000; else if (a[0] == 'T') sum = n * 1024 * 1024 * 1024 * 1024 - n * 1000 * 1000 * 1000 * 1000; printf("%.0lf\n", sum); } return 0; } |
Double click to view unformatted code.