AC代码(-1001输出是-1+0+0+1;-1100的输出是-1+100)
Select Code
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
freopen("easy.in", "r", stdin);
freopen("easy.out","w",stdout);
char a[1000+10];
int i = 0;
cin>>a;
while(a[i]!='\0')
{
if(a[i]=='-')
{
printf("%c",'-');
i++;
printf("%c",a[i]);
i++;
while(a[i]=='0'&&a[i]!='\0')
{
printf("%c%c",'+', '0');
i++;
}
if(a[i]>'0'&&a[i]<='9')
{
printf("%c",'+');
while(a[i]!='+'&&a[i]!='-'&&a[i]!='\0')
{
printf("%c",a[i]);
i++;
}
}
}
else
{
printf("%c",a[i]);
i++;
}
}
printf("\n");
return 0;
}