#include<stdio.h>
int main(){
int a;
printf("請輸入一個四位數(shù):");
scanf("%d",&a);
if(a>=1000&&a<9999){
printf("千位數(shù)是:%d\n",a/1000);
printf("百位數(shù)是:%d\n",a/100%10);
printf("十位數(shù)是:%d\n",a/10%10);
printf("個位數(shù)是:%d\n",a%10);
}
else
printf("輸入不是四位數(shù)");
return 0;
}
文章來源:http://www.zghlxwxcb.cn/news/detail-735461.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-735461.html
到了這里,關(guān)于編寫程序,輸入一個4位十進制整數(shù),分別輸出千位、百位、十位及個位上的數(shù)。(注:首先判斷輸入的數(shù)是否是四位數(shù)即在[1000,9999]范圍內(nèi))。的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!