View Code of Problem 96

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{

    char a[3];
    int b;
    long long c;
    while(scanf("%d",&b)!=EOF)
    {
        if(b==0)
        {
            break;
        }
    gets(a);
    if(strcmp(a,"KB")==0)
    {
        c=(1024-1000)*b;
    }
    else if(strcmp(a,"MB")==0)
    {
        c=(pow(1024,2)-pow(1000,2))*b;
    }
    else if(strcmp(a,"GB")==0)
    {
        c=(pow(1024,3)-pow(1000,3))*b;
    }
    else if(strcmp(a,"TB")==0)
    {
        c=(pow(1024,4)-pow(1000,4))*b;
    }
    else
    {
        c=0;
    }
    printf("%lld\n",c);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 96