當前位置:編程學習大全網 - 電腦編程 - 用C語言編程 輸入5位數字 各位數字按原順序輸出

用C語言編程 輸入5位數字 各位數字按原順序輸出

#include<stdio.h>

void hanshu(int A);

int main()

{

int inputN;

scanf("%d",&inputN);

hanshu(inputN);

return 0;

}

void hanshu(int A)

{

int i,j;

int a[5];

int temp;

int aa = 10;

int bb =1;

for(i = 4;i>=0;i--) //註意學習這種通用的方法。

{

a[i] = A%aa/bb;

aa *=10;

bb *=10;

}

for(i = 0;i<5;i++)

{

printf(" %d",a[i]);

}

}

  • 上一篇:哪有好的北師大版七年級上冊數學追趕小明的講課視頻
  • 下一篇:rtthread消息隊列滿後如何處理
  • copyright 2024編程學習大全網