View Code of Problem 96

#include<stdio.h>
#include<string.h>

int main()
{
  double n;
  char dw[5];
  while(scanf("%lf%s",&n,dw)!=EOF)
  {
    if(n==0)
      break;
    double lost=0;
    if(strcmp(dw,"KB")==0)
      lost=n*1024-n*1000;
    if(strcmp(dw,"MB")==0)
      lost=n*1024*1024-n*1000*1000;
    if(strcmp(dw,"GB")==0)
      lost=n*1024*1024*1024-n*1000*1000*1000;
    if(strcmp(dw,"TB")==0)
      lost=n*1024*1024*1024*1024-n*1000*1000*1000*1000;
    printf("%.lf\n",lost);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 96