//
// main.cpp
// PATA1073
//
// Created by Phoenix on 2018/2/17.
// Copyright © 2018年 Phoenix. All rights reserved.
//
#include <iostream>
#include <cstdio>
#include <cstring>
int main(int argc, const char * argv[]) {
char str[10010];
scanf("%s", str);
if(str[0] == '-') printf("-");
int k, flag;
for(int i = 0; i < strlen(str); i++) {
if(str[i] == 'E') k = i;
if(str[i] == '+') flag = 1;
if(str[i] == '-') flag = -1;
}
int rate = 0;
for(int i = k + 2; i < strlen(str); i++) {
rate = rate * 10 + str[i] - '0';
}
if(flag == -1){
printf("0.");
for(int i = 1; i < rate; i++)
printf("0");
printf("%c", str[1]);
for(int i = 3; i < k; i++) {
printf("%c", str[i]);
}
} else {
if(rate + 3 >= k) {
printf("%c", str[1]);
for(int i = 3; i < k; i++) {
printf("%c", str[i]);
}
for(int i = 0; i < rate + 3 - k; i++) {
printf("0");
}
} else {
printf("%c", str[1]);
for(int i = 3; i < 3 + rate; i++) {
printf("%c", str[i]);
}
printf(".");
for(int i = 3 + rate; i < k; i++)
printf("%c", str[i]);
}
}
return 0;
}
PATA1073题解
最新推荐文章于 2022-01-21 16:37:24 发布