East 编辑个性签名 VIP 正式会员 注册 2020/04/24 消息 266 金粒 5,417金粒 2021/06/28 #1 C: #include <stdio.h> int main()//整数逆序 { int x; //输入数 int a; //暂存数 int b=0; //结果 scanf("%d",&x); while(x!=0){ a=x%10; //获取x的个位数 b=b*10+a; //获取a的值并把原有的值乘10 x/=10; //去掉x的个位数 } printf("%d",b); //输出结果数 return 0; }
C: #include <stdio.h> int main()//整数逆序 { int x; //输入数 int a; //暂存数 int b=0; //结果 scanf("%d",&x); while(x!=0){ a=x%10; //获取x的个位数 b=b*10+a; //获取a的值并把原有的值乘10 x/=10; //去掉x的个位数 } printf("%d",b); //输出结果数 return 0; }
East 编辑个性签名 VIP 正式会员 注册 2020/04/24 消息 266 金粒 5,417金粒 2021/06/28 #2 写完运行的时候发现结果总是为零,调试的时候发现while直接跳过了,最后发现原来是条件成立记成不成立了