View Code of Problem 96

#include<stdio.h>
#include<string.h>
#include<math.h>
void main()
{
	double n;
	char a[2];
	while (scanf("%lf%c%c",&n,&a[0],&a[1])!=EOF)
	{
		if (n == 0)break;
		double c = 0;
		if (a[0] == 'B')printf("0\n");
		else if (a[0] == 'K')
		{
			c = n * (pow(2, 10) - pow(10, 3));
			printf("%.0f\n", c);
		}
		else if (a[0] == 'M')
		{
			c = n * (pow(2, 20) - pow(10, 6));
			printf("%.0f\n", c);
		}
		else if (a[0] == 'G')
		{
			c = n * (pow(2, 30) - pow(10, 9));
			printf("%.0f\n", c);
		}
		else if (a[0] == 'T')
		{
			c = n * (pow(2, 40) - pow(10, 12));
			printf("%.0f\n", c);
		}
	}
}

Double click to view unformatted code.


Back to problem 96