Andrews123 @ 2024-02-20 14:31:51
也没看出问题在哪里,但是只能AC一半
#include <iostream>
using namespace std;
int main(){
long long int number,flag=0;
cin>>number;
if(number<0){
cout<<"-";
}
while(number){
if(number%10==0 && flag==0){
number=number/10;
continue;
}else{
cout<<number%10;
flag=1;
}
number=number/10;
}
return 0;
}
by MrPython @ 2024-02-20 14:55:04
cpp 处理负数取模一向臭名昭著。
当你检测到这是个负数并输出负号时,请将其变回正数。
by Andrews123 @ 2024-02-20 15:07:24
@MrPython 谢谢,加了几个特判,过了
by wangqicheng1637 @ 2024-03-09 09:48:57
@Andrews123负数能不能先求绝对值,再加负号