90分求助!!!
查看原帖
90分求助!!!
1530601
myh2006楼主2024/12/24 00:24
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include <string>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int gb = s.find("GB");
	int mb = s.find("MB");
	int kb = s.find("KB");
	int gb1 = s.find("GB",1);
	int mb1 = s.find("MB",1);
	int kb1 = s.find("KB",1);
	long double m = n;
	cout << fixed << setprecision(6);
	if (gb == 0)
	{
		if (gb1 > 0)cout << m;
		else if (mb1 > 0)  cout << m * 1024;
		else if (kb1 > 0)  cout << m * 1024 * 1024;
		else  cout << m * 1024 * 1024 * 1024;
	}
	else if (mb == 0)
	{
		if (gb1 > 0)cout << m/1024;
		if (mb1 > 0)  cout << m;
		else if (kb1 > 0)  cout << m * 1024;
		else  cout << m * 1024 * 1024;
	}
	else if (kb == 0)
	{
		if (gb1 > 0)cout << m /1024/1024;
		else if (mb1 > 0)  cout << m/1024;
		else if (kb1 > 0)  cout << m;
		else  cout << m * 1024;
	     }
	else 
	{
		if (gb1 > 0)cout << m / 1024/1024/1024;
		else if (mb1 > 0)  cout << m / 1024/1024;
		else if (kb1 > 0)  cout << m/1024;
		else  cout << m;
	}
	return 0;
}
2024/12/24 00:24
加载中...