View Code of Problem 96

#include<stdio.h>
#include<string.h>
int main(){
	double n,ss;
	char danwei[2];
	while(1){
		ss=0;
		scanf("%lf%s",&n,danwei);
		if(n==0){
			break;
		}
		if(strcmp(danwei,"KB")==0){
			ss=n*(1024.0-1000.0);
		}
		else if(strcmp(danwei,"MB")==0){
			ss=n*(1024.0*1024-1000.0*1000);
		}
		else if(strcmp(danwei,"GB")==0){
			ss=n*(1024.0*1024*1024-1000.0*1000*1000);
		}
		else if(strcmp(danwei,"TB")==0){
			
			ss=n*(1024.0*1024*1024*1024-1000.0*1000*1000*1000);
		}
		printf("%.0f\n",ss);
	}
} 

Double click to view unformatted code.


Back to problem 96