ChickenDrinkingMilk @ 2021-09-11 15:06:23
#include<bits/stdc++.h>
using namespace std;
char a[100];
int main(){
int i,f=1,x=0,fl=1;
scanf("%s",a);
for (i=strlen(a)-1;i>=x;i--){
if (a[0]=='-'&&fl){
cout<<'-';
x=1;
fl=0;
}
if (f==1){
if (a[i]=='0') continue;
else f=0;
}
cout<<a[i];
}
}
大家帮本蒟蒻看一看哪里错了?
by Marnek_36 @ 2021-09-11 16:01:44
#include<bits/stdc++.h>
using namespace std;
int k,m=0;
int main(){
cin>>k;
while(k!=0){
m=m*10+k%10;
k/=10;
}
cout<<m;
return 0;
}
其实这样就行了
by Carnival @ 2021-09-11 16:03:04
为什么你提交的代码和你摆出来的代码不一样?
千万不要用 gets 函数读入字符串。
by ChickenDrinkingMilk @ 2021-09-11 20:13:14
@Luojingyuan666 感谢!
by ChickenDrinkingMilk @ 2021-09-11 20:14:03
@Gamemode 什么意思?
by FateReset_ @ 2021-09-11 22:15:48
string类型直接cin不就好了