输入一个四位数,分离各个位的数字(若是三位数x1=0,若是四位数x1就大于10)
#include(stdio.h)void main()
{
int a,x1,x2,x3;
printf("input a");
scanf("%d",&a);
if((a<=999)&&(a>=10000))
printf("N")
else
{
x1=a/1000;
x2=(a-x1*1000)/100;
x3=(a-x1*1000-x2*100)/10
x4=a%10;
}
}
#include<stdio.h> ;err int main() { int a,x1,x2,x3,x4; ;少x4 printf("input a:"); scanf("%d",&a); if((a<=999)||(a>=10000)) printf("N"); ;err else { x1=a/1000; x2=(a-x1*1000)/100; x3=(a-x1*1000-x2*100)/10; ;miss x4=a%10; printf("x1=%d,x2=%d,x3=%d,x4=%d\n",x1,x2,x3,x4); ;display } getch(); ;pause return 0; }