leaf_boyu @ 2023-10-10 19:41:37
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(void){
char str[100];
long long a,b,c,d=0,f,g;
f=0;
int s[100];
scanf("%lld",&a);
if(a<0){
a=a*-1;f=1;
}
b=a%10;
c=a;
while(c/10){
s[d]=c%10;
c=c/10;
d++;
}
s[0]=c;s[d]=b;
if(b==0){
d--;
}
g=1;
a=0;
for(int i=0;i<=d;i++){
//printf("%d\n",s[i]);
a=s[i]*g+a;
g=g*10;
}
if(f==1){
a=a*-1;
}
printf("%lld",a);
return 0;
}
by AceKnightPuppet @ 2023-10-10 20:05:43
其实不必那么麻烦的
#include <bits/stdc++.h>
using namespace std;
int main(){
// freopen("isbn.in", "r", stdin);
// freopen("isbn.out", "w", stdout);
int n,s;
cin>>n;
while(n) s=s*10+n%10,n/=10;
cout<<s;
//fclose(stdin);
//fclose(stdout);
return 0;
}
by tyl100908 @ 2023-10-14 14:47:22
建议把s赋值成0