fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int a=1537,b,c,d,f,sum;
  6. b=a/1000;
  7. printf("千位数是%d\n",b);
  8. c=a%10;
  9. printf("个位数是%d\n",c);
  10. f=(a-b*1000)/100;
  11. printf("百位数是%d\n",f);
  12. d=(a-b*1000-f*100)/10;
  13. printf("十位数是%d\n",d);
  14. sum=b+f+d+c;
  15. printf("sum=%d\n",sum);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
千位数是1
个位数是7
百位数是5
十位数是3
sum=16