PAT 甲级 1073 Scientific Notation
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int zhengshu_part; string xiaoshu_part; int times;
scanf("%d.", &zhengshu_part);
int tmp;
while (tmp = getchar(), tmp != 'E') {
xiaoshu_part.push_back(tmp);
}
scanf("%d", ×);
if (zhengshu_part < 0) {
cout << '-';
zhengshu_part = abs(zhengshu_part);
}
if (times > 0) {
if (times >= xiaoshu_part.size()) {
printf("%d%s", zhengshu_part, xiaoshu_part.c_str());
for (int i = 0; i < times - xiaoshu_part.size(); ++i) cout << 0;
}
else {
printf("%d", zhengshu_part);
int i = 0;
for (i = 0; i < times; ++i) {
cout << xiaoshu_part[i];
}
cout << ".";
for (; i < xiaoshu_part.size(); ++i) {
cout << xiaoshu_part[i];
}
}
}
else if (times == 0) {
printf("%d.%s", zhengshu_part, xiaoshu_part.c_str());
}
else {
for (int i = 0; i < abs(times); ++i) {
cout << 0;
if (i == 0) {
cout << ".";
}
}
printf("%d%s", zhengshu_part, xiaoshu_part.c_str());
}
}