main() { int n1,n2=1298; while(n2!=0) { n1=n2%10;n2=n2/10;printf("%d",n1);} } 执行结果

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/28 20:10:17
main(){intn1,n2=1298;while(n2!=0){n1=n2%10;n2=n2/10;printf("%d",n1);}}执行结果main(){intn1,n2=1298;while

main() { int n1,n2=1298; while(n2!=0) { n1=n2%10;n2=n2/10;printf("%d",n1);} } 执行结果
main() { int n1,n2=1298; while(n2!=0) { n1=n2%10;n2=n2/10;printf("%d",n1);} } 执行结果

main() { int n1,n2=1298; while(n2!=0) { n1=n2%10;n2=n2/10;printf("%d",n1);} } 执行结果
结果应该是 8921 刚开始n2=1298 n1=n2%10=8 n2=n2/10=129, 第二次循环n2=129 n1=n2%10=9 n2=n2/10=12;第三次循环 n2=12 n1=n2%10=2 n2=n2/10=1;第四次
n2=1 n1=n2%10=1 n2=n2/10=0 跳出循环