#include<stdio.h>
main()
{
int x,b2,b1,b0,sum;
printf("请输入一个三位整数:");
scanf("%d",&x);
b2=x/100;
b1=(x-b2*100)/10;
b0=x%10;
sum=b2+b1+b0+sum;
printf("b2=%d,b1=%d,b0=%d,sum=%d",b2,b1,b0,sum);
}
运行结果:
知识点:算术运算符* / %的优先级高于+ -