View Code of Problem 96

#include <iostream>
#include <string.h>

using namespace std;
int main(){
  int n;
  char s[5];
  double m;
  while(scanf("%d%s",&n,s)!=EOF&&n){
    if(!strcmp(s,"KB")){
      m = n*1024 - n*1000;
    }
    else if(!strcmp(s,"MB")){
      m = n*1024*1024 - n*1000*1000;
    }
    else if(!strcmp(s,"GB")){
      m = n*1024*1024*1024 - n*1000000000;
    }
    else if(!strcmp(s,"TB")){
      m = n*1024*1024*1024*1024 - n*1000000000000;
    }
    
    printf("%.0lf\n",m);
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 96