View Code of Problem 96

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

Double click to view unformatted code.


Back to problem 96