View Code of Problem 96

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

Double click to view unformatted code.


Back to problem 96