View Code of Problem 96

#include <stdio.h>
#include <string.h>
int main(){
	double  n;
	char s[2];
	while(scanf("%lf%s",&n,s)){
		if(n==0)break;
		double n1,n2,c;
		if(strcmp(s,"B")==0)
			c=n;
		else if(strcmp(s,"KB")==0) 
			c=n*(1024-1000);
		else if(strcmp(s,"MB")==0) 
//			n1=n*1024*1024;
//			n2=n*1000*1000;
			c=n*(1024*1024-1000*1000);
		else if(strcmp(s,"GB")==0){
			n1=n*1024*1024*1024;
		 	n2=n*1000*1000*1000;
			c=n1-n2;	
		} 
			
		else if(strcmp(s,"TB")==0) {
			n1=n*1024*1024*1024*1024;
			n2=n*1000*1000*1000*1000;
			c=n1-n2;	
		}
		
		printf("%.0lf\n",c);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 96