View Code of Problem 96

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

Double click to view unformatted code.


Back to problem 96