HDU 4788 Hard Disk Drive (2013成都H,水题) 进位换算

 1 #include <stdio.h>
 2 #include <algorithm>
 3 #include <string.h>
 4 #include<cmath>
 5 using namespace std;
 6 double a;
 7 char s[100];
 8 int fun(char s[]) {
 9     if(strcmp(s,"B]") == 0)return 0;
10     if(strcmp(s,"KB]") == 0)return 1;
11     if(strcmp(s,"MB]") == 0)return 2;
12     if(strcmp(s,"GB]") == 0)return 3;
13     if(strcmp(s,"TB]") == 0)return 4;
14     if(strcmp(s,"PB]") == 0)return 5;
15     if(strcmp(s,"EB]") == 0)return 6;
16     if(strcmp(s,"ZB]") == 0)return 7;
17     if(strcmp(s,"YB]") == 0)return 8;
18 }
19 int main() {
20 //    freopen("in.txt","r",stdin);
21     int t;
22     scanf("%d",&t);
23     int cas=0;
24     while(t--) {
25         scanf("%lf[%s",&a,s);
26         cas++;
27         int num=fun(s);
28         double ans=pow(1000.0,num)/pow(1024.0,num);
29         ans=1-ans;
30         printf("Case #%d: %.2lf%%
",cas,ans*100);
31     }
32     return 0;
33 }
View Code
原文地址:https://www.cnblogs.com/ITUPC/p/5298885.html