wjc2821296948 @ 2024-06-05 21:18:43
#include<bits/stdc++.h>
using namespace std;
int main(){
char num[110];
scanf("%s",num);
long long len=strlen(num),check=0,w=len;
while(num[w-1] == 48) {check++;w--;}
if(num[0]=='-'){
printf("-");
for(int i=len-1-check;i>0;i--){
printf("%c",num[i]);
}
}else{
for(int i=len-1-check;i>=0;i--){
printf("%c",num[i]);
}
}
return 0;
}
by zjh201256 @ 2024-06-06 19:27:20
哪题啊
by CYH617 @ 2024-06-06 22:22:59
有0的情况
by wjc2821296948 @ 2024-06-08 09:50:13
@CYH617 嗯,我刚刚测出来了,但是不会加特判。
by wenxuliang @ 2024-06-10 20:52:15
@wjc2821296948
#include<bits/stdc++.h>
using namespace std;
int main(){
char num[110];
scanf("%s",num);
if(num[0]=='0')cout<<0;
else{
long long len=strlen(num),check=0,w=len;
while(num[w-1] == 48) {check++;w--;}
if(num[0]=='-'){
printf("-");
for(int i=len-1-check;i>0;i--){
printf("%c",num[i]);
}
}else{
for(int i=len-1-check;i>=0;i--){
printf("%c",num[i]);
}
}
}
return 0;
}
by wenxuliang @ 2024-06-10 20:53:18
@wenxuliang 特判就只是单纯if而已。
by wjc2821296948 @ 2024-06-10 20:53:42
@wenxuliang ok,谢谢啦
by CYH617 @ 2024-06-10 20:57:28
@wjc2821296948 不客气
by wjc2821296948 @ 2024-06-10 21:00:57
嗯