View Code of Problem 96

#include<string.h>
#include<stdio.h>
#include<math.h>
int main(){
	int n;
	char b[20];
	while(scanf("%d%s",&n,b)!=EOF){
		if(n==0){
			break; 
		}
		if(strcmp(b,"B")==0){
			printf("%d",0);
		}
		else if(strcmp(b,"KB")==0){
			printf("%d\n",n*1024-n*1000);
		}
		else if(strcmp(b,"MB")==0){
			printf("%d\n",n*1024*1024-n*1000*1000);
		}
		else if(strcmp(b,"GB")==0){
			printf("%d\n",n*1024*1024*1024-n*1000*1000*1000);
		}
		else if(strcmp(b,"TB")==0){
			printf("%d\n",n*1024*1024*1024*1024-n*1000*100*100*1000);
		}
		
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 96