src2020/lg_numfenjie/main.cpp

44 lines
721 B
C++

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
int qian=-1,hou=0,now;
char tou[2000],wei[2000],a[4000];
bool ce=0;
while(cin>>a[++now]){
if(ce==1){
hou++;
wei[hou]=a[now];
}
if(a[now]=='.'){
ce=1;
}
if(ce==0){
qian++;
tou[qian]=a[now];
}
}
printf("%c*",tou[0]);
for(int j=1;j<qian;j++){
printf("0");
}
for(int i=1;i<=qian;i++){
if(tou[i]!='0'){
printf("+%c*1",tou[i]);
for(int j=1;j<=qian-i;j++){
printf("0");
}
}
}
for(int i=1;i<=hou;i++){
if(wei[i]!='0'){
printf("+%c*0.",wei[i]);
for(int j=1;j<=qian-i;j++){
printf("0");
}
printf("1");
}
}
return 0;
}