这题怎么做急c++
展开全部
#include <regex>
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
cout <<"Input:";
cin >> s;
const regex pattern("^([1-9]\\.[0-9])\\*10\\^([0-9]*)$");
match_results<string::const_iterator> result;
bool valid = regex_match(s, result, 升埋和pattern);
if (!valid) {
液枝 cout << "The input number [" << s << "] is not valid!" << endl;
return -1;
}
string r1 = result[1];
string r2 = result[2];
double base=atof(r1.c_str());
int exponent = atoi(r2.c_str());
double n = base * pow(10, exponent);
cout << "The actual value for " << s << " is " << 吵盯n;
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询