View Code of Problem 96

#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		if(n == 0) break;
		char a[5];
		scanf("%s",a);
		double sum;
		if(strcmp("TB",a)==0){
			sum = n*(pow(1024,4)-pow(1000,4));
		}
		else if(strcmp("GB",a)==0){
			sum = n*(pow(1024,3)-pow(1000,3));
		}
		else if(strcmp("MB",a)==0){
			sum = n*(pow(1024,2)-pow(1000,2));
		}
		else if(strcmp("KB",a)==0){
			sum = n*(pow(1024,1)-pow(1000,1));
		}
		else if(strcmp("B",a)==0){
			sum = 0;
		}
		printf("%.0f\n",sum);
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 96