BenChaut @ 2022-10-17 22:45:55
#include <stdio.h>
#include <math.h>
int main()
{
long long a, b = 0;
scanf("%lld", &a);
if (a == 0)
{
printf("0");
}
else if (a > 0)
{
again:
a = a / 10;
if (a % 10 ==0 )
{
goto again;
}
while(a)
{
long long c = a % 10;
printf("%lld", c);
a = a / 10;
}
}
else
{
long long d = (long long)fabsf(a);
flag:
d = d / 10;
if (d % 10 == 0)
{
goto flag;
}
printf("-");
while (d)
{
long long e = d % 10;
printf("%lld", e);
d = d / 10;
}
}
return 0;
}
by ryf_loser @ 2022-10-17 22:59:34
@BenChaut
#include <bits/stdc++.h>
using namespace std;
int main(){
char n;
int s=0,w=0,i=1,t=0;
int a[11];
int b[11];
b[1]=1;
scanf("%c",&n);
if (n<48){
t=1;
scanf ("%c",&n);
}
while(int(n)>47){
w++;
a[w]=char(n);
a[w]-=48;
i++;
b[i]=b[i-1]*10;
scanf("%c",&n);
}
i--;
do{
s=a[w]*b[i]+s;
i--;
w--;
}while (w>0);
if (t)
printf("-");
printf ("%d",s);
return 0;
}
by BenChaut @ 2022-10-17 23:14:37
@ryf20100124 看懂了dalao写的了,可我想知道我的有啥问题呢,因为这是我的第一反应
by JayUser @ 2022-10-26 16:48:19
@BenChaut 尽量还是少用goto语句,太不实用了很难debug