View Code of Problem 96

#include<stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define Max 100
int main()
{
	char a[3];
	double b,cha;
	while(scanf("%lf",&b)!=EOF)
	{
		gets(a);
		if((b-0)<0.000000001)
		break;
		if(strcmp(a,"KB")==0)
		  cha=(1024-1000)*b;
		else if(strcmp(a,"MB")==0)
		  cha=(1024*1024-1000*1000)*b;
		else if(strcmp(a,"GB")==0)
		  cha=(pow(1024,3)-pow(1000,3))*b;
		else if(strcmp(a,"TB")==0)
		  cha=(pow(1024,4)-pow(1000,4))*b;
		  
		printf("%0.lf\n",cha);
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 96