/* Note:Your choice is C IDE */
#include "stdio.h"
void main()
{ 
   //不同位数数字取个十百千位数字的代码
   int i,j,a;
   i = 78;
   j = 654;
   a = 4176;
   printf("-------两位数----------\n");
   //获取个位的数字
   printf("%d个位的数字是\t%d\n",i,i%10);
   //获取十位的数字
   printf("%d十位的数字是\t%d\n\n\n",i,i/10);
   printf("-------三位数----------\n");
   //获取个位的数字
   printf("%d个位的数字是\t%d\n",j,j%10);
   //获取十位的数字
   printf("%d十位的数字是\t%d\n",j,(j/10)%10);//三位数除以10得一个两位的数字,再取余的十位的数字
   //获取百位的数字
   printf("%d百位的数字是\t%d\n\n\n",j,j/100);//
   printf("-------四位数----------\n");
   //获取个位的数字
   printf("%d个位的数字是\t%d\n",a,a%10);
   //获取十位的数字
   printf("%d十位的数字是\t%d\n",a,(a/10)%10);
   //获取百位的数字
   printf("%d百位的数字是\t%d\n",a,a/100%10);//四位数除以100得一个两位的数字,再取余的十位的数字
   //取千位的数字
   printf("%d千位的数字是\t%d\n\n\n",a,a/1000); 
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2021-11-10
  • 2021-10-09
  • 2022-01-11
  • 2021-11-22
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
相关资源
相似解决方案