KryptonAu @ 2017-12-08 22:40:30
#include<iostream>
#include<cmath>
const int MAXN=10000;
using namespace std;
int main()
{
int a[MAXN];
int ru,i=0,ins;
long long chu=0;
cin>>ru;
while(ru!=0)
{
a[i]=ru%10;
ru/=10;
i++;
}
ins=i;
i-=1;
for(int j=0;j<ins,i>=0;i--,j++)
{
chu+=a[j]*pow(10,i);
}
cout<<chu;
return 0;
}
by ddwqwq @ 2017-12-09 01:44:14
//给你改得顺眼一点
#include<cstdio>
#include<iostream>
#include<cmath>
const int MAXN = 10000;
using namespace std;
int main()
{
int a[MAXN];
int ru, i = 0, ins;
scanf("%d", &ru);//scanf更快
if (ru < 0)//判断正负,输出符号
{
printf("-");
ru = fabs(ru);
}
while (ru != 0)//反向储存
{
a[i++] = ru % 10;
ru /= 10;
}
ins = i;
int flag = 0;//用于消去前面的零
for (i = 0; i < ins; i++)
{
if (a[i] != 0)
flag = 1;
if (flag == 1)
printf("%d", a[i]);//输出
}
if (flag == 0)
printf("0");//若没有输出过,输出0
// system("pause");
return 0;
}