evil_paramecium @ 2022-09-23 12:50:22
#include<bits/stdc++.h>
using namespace std;
int main(){
int k=0;
char n[1000],o[1000];
scanf("%s",n);
for(int i=0;i<=strlen(n);i++){
if(n[i]=='-'){
n[i]='n';
cout<<'-';
}
}
for(int i=strlen(n);i>=0;i--)
{
if(n[i]=='0'){
if(k!=123){
k=1;
n[i]='n';
}
}
if(k==1){
if(n[i]!='0'){
k=123;
}
}
if(n[i]!='n'){
cout<<n[i];
}
}
}
-123
- 321
by DioxygenDifluoride @ 2022-09-23 12:53:01
这不是空格,是一个 ASCII 码为 0 的字符
by evil_paramecium @ 2022-09-23 12:53:32
求大神解答☺(●'◡'●)
by DioxygenDifluoride @ 2022-09-23 12:53:33
for(int i=strlen(n);i>=0;i--)
应该为·
for(int i=strlen(n)-1;i>=0;i--)
by evil_paramecium @ 2022-09-23 12:54:36
哦
by DioxygenDifluoride @ 2022-09-23 12:54:39
n[strlen(n)]
是 '\0' 字符,ASCII 码为 0
by evil_paramecium @ 2022-09-23 12:55:07
感谢您