View Code of Problem 96

#include<stdio.h>
int main()
{
	int n;
	double b;
	char ch[5];
	while( scanf("%d%s",&n,ch)!=EOF)
	{
		if(n==0)
		 break;
		if(ch[0]=='B')
		{
			b = 0;
		}
		else if(ch[0]=='K')
		{
			b =n*24.0;
		}
		else if(ch[0]=='M')
		{
			b = n*1024.0*1024-n*1000.0*1000;
		}
		else if(ch[0]=='G')
		{
			b = n*1024.0*1024*1024-n*1000.0*1000*1000;
		}
		else if(ch[0]=='T')
		{
			b = n*1024.0*1024*1024*1024-n*1000.0*1000*1000*1000;
		}
		printf("%.0f\n",b);
	 } 
	 return 0;
 } 

Double click to view unformatted code.


Back to problem 96