1073 Scientific Notation (20 分)(字符串处理)
作者:互联网
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <unordered_map>
#include <algorithm>
#include <iostream>
using namespace std;
int n, m, e;
string s, t;
int arr[10000];
int main()
{
cin >> s;
int i = s.find("E");
int l = s.size();
t = s.substr(1, i-1);
e = stoi(s.substr(i+1, l-i-1));
if (e > 0) {
if (s[0] == '-') cout << '-';
cout << t[0];
int l2 = t.size();
for (int i = 1; i<l2; i++) {
if (t[i] == '.') continue;
if (e > 0) {
cout << t[i];
e--;
} else {
cout << '.';
cout << t.substr(i, l2-i);
break;
}
}
for (int i = 0; i<e; i++) cout << '0';
} else {
e = abs(e);
if (s[0] == '-') cout << '-';
cout << "0.";
int l2 = t.size();
while(--e > 0) {
cout << '0';
}
for (int i = 0; i<l2; i++) {
if (t[i] == '.') continue;
cout << t[i];
}
}
return 0;
}
标签:std,arr,20,Scientific,Notation,int,substr,include,cout 来源: https://blog.csdn.net/NCUscienceZ/article/details/100562842