6 条题解
- 1
信息
- ID
- 22
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- (无)
- 递交数
- 37
- 已通过
- 29
- 上传者
直接给它干个字符串倒着输出干掉前导零就完了:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
bool flag=1;
for(int i=s.size()-1;i>-1;i--)
{
if(s[i]!='0')
{
flag=0;
cout<<s[i];
}
else if(!flag)
{
cout<<s[i];//干掉前导零
}
}
if(flag)
{
cout<<0;//如果那玩意儿是 0 直接输出 0
}
return 0;
}
有必要这么麻烦吗?
C++ :
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
cout<<n%10<<n/10%10<<n/100;
return 0;
}
Python :
# coding=utf-8
x=int(input())
a=x%10
b=x//10%10
c=x//100
print(str(a)+str(b)+str(c))