View Code of Problem 96

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

Double click to view unformatted code.


Back to problem 96