lingHUA123 @ 2022-01-20 11:36:03
#include<iostream>
using namespace std;
int main() {
long long N;
cin >> N;
while (N!=0)
{
int a = N% 10;
if (a > 0)
{
cout << a;
}
else if (a < 0)
{
cout << a;
N = -N;
}
N /= 10;
}
system("pause");
return 0;
}
by xhz_ @ 2022-01-20 11:39:24
输入: 0 输出:什么也没有
by Bug_Automation @ 2022-01-20 11:39:45
system("pause");
干什么呢
by xhz_ @ 2022-01-20 11:40:36
输入:101
输出:11
正确答案:101
by xhz_ @ 2022-01-20 11:42:12
代码我懒得看了,你根据我给你的数据自己调试吧。
by xhz_ @ 2022-01-20 11:42:43
@lingHUA123
by Bug_Automation @ 2022-01-20 11:45:49
@lingHUA123
#include<iostream>
using namespace std;
int main() {
long long N,t=0;
bool flag=false;
cin >> N;
if(N<0)N=-N,flag=true;
while (N!=0)
{
t=(t<<1)+(t<<3)+N%10;
N/=10;
}
if(flag)t=-t;
cout<<t;
return 0;
}
改了下,应该能过
by lingHUA123 @ 2022-01-20 13:20:58
@xhz_ 谢了谢了
by lingHUA123 @ 2022-01-20 13:21:48
@Bug_Automation 谢谢大佬
by HPs_V @ 2022-07-11 16:14:28
我之前情况一样,如果只考虑0,他会省去数字中间的0,加个判断是不是首位是0的语句就好了