您的位置:首页 > 其它

【NOIP2011普及组真题】数字反转

2018-03-29 17:06 381 查看


水题。#include<iostream>
#include<cstring>
#pragma G++ optamize (2)
using namespace std;
char a[2000];
char b[2000];
int main(){
//-16
// freopen("reverse.in","r",stdin);
// freopen("reverse.out","w",stdout);
cin>>a;
int lenth=strlen(a);
while(a[lenth-1]=='0'&&lenth!=0){
lenth--;
}
for(int i=0;i<lenth;i++){
b[lenth-i-1]=a[i];
}
if(a[0]=='-')
cout<<"-";
if(b[lenth-1]=='-')
lenth--;
for(int i=0;i<lenth;i++){
cout<<b[i];
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: