Starriuniversky @ 2022-03-16 23:03:02
Subtask 1 过不了
求 dalao 帮忙
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
if(n<0)
{
cout<<"-";
n*=-1;
bool o=1;
while(o)
{
if(n%10==0)
{
n/=10;
}
else
{
o=0;
}
}
while(n>0)
{
cout<<n%10;
n/=10;
}
}
else
{
bool o=1;
while(o)
{
if(n%10==0)
{
n/=10;
}
else
{
o=0;
}
}
while(n>0)
{
cout<<n%10;
n/=10;
}
}
return 0;
}
by Jasper08 @ 2022-03-17 23:45:01
@Starriuniversky
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
if (n < 0) //取绝对值
{
cout << "-";
n = -n;
}
int sum = 0;
while(n != 0) //计算新数
{
int k = n % 10;
sum = sum * 10 + k;
n /= 10;
}
printf("%d", sum);
return 0;
}
by Starriuniversky @ 2022-03-18 21:14:05
@Jasper08 谢谢 dalao
by 违规用户名ddc277a @ 2022-03-26 18:50:19
@Jasper08
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
if (n < 0) //取绝对值
{
cout << "-";
n = -n;
}
int sum = 0;
while(n != 0) //计算新数
{
int k = n % 10;
sum = sum * 10 + k;
n /= 10;
}
printf("%d", sum);
return 0;
}
你的scanf()没加头文件:cstdio