View Code of Problem 96

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	string a;
	cout <<fixed<<setprecision(0);
	while(cin >>a){
		string c;
		double b=0;
		for(int i=0;i<a.length();i++){
			if(a[i]>='0'&&a[i]<='9'){
				b*=10;
				b+=a[i]-'0';
				
			}
			else{
				c+=a[i];
			}
		}
		if(b==0){
			break;
		}
		if(c=="B"){
			cout <<"0"<<endl;
		}
		else if(c=="KB"){
			cout << (double)b*24<<endl;
		}
		else if(c=="MB"){
			cout << (double)b*(1024*1024-1000*1000)<<endl;
		}
		else if(c=="GB"){
			cout << (double)b*(1024*1024*1024-1000*1000*1000)<<endl;
		}
		else if(c=="TB"){
			cout << b*99511627776<<endl;
		}
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 96