View Code of Problem 96

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

Double click to view unformatted code.


Back to problem 96