main( )

10年積累的成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有靜安免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
{
long a, b, c, d, e, x;
scanf("%ld", x);
a = x / 10000; /* 分解出萬(wàn)位 */
b = x % 10000 / 1000; /* 分解出千位 */
c = x % 1000 / 100; /* 分解出百位 */
d = x % 100 / 10; /* 分解出十位 */
e = x % 10; /* 分解出個(gè)位 */
if (a!=0) printf("there are 5, %ld %ld %ld %ld %ld\n", e, d, c, b, a);
else if (b!=0) printf("there are 4, %ld %ld %ld %ld\n", e, d, c, b);
else if (c!=0) printf(" there are 3, %ld %ld %ld\n", e, d, c);
else if (d!=0) printf("there are 2, %ld %ld\n", e, d);
else if (e!=0) printf(" there are 1, %ld\n", e);
}
你好!!
程序?qū)懥艘粋€(gè),可以輸入任意長(zhǎng)度的數(shù)字,然后分割后個(gè)三個(gè)空格顯示:
#include?stdio.h
int?main()
{
long?int?x;?
int?i=0;
int?ii=0;
int?shu[20]={0};
scanf("%ld",x);
for(;;)
{
shu[i]?=?x?%?10;
x?=?x?/?10;
i++;
if(?x??10)
{
shu[i]=x;
break;
} ????
}
for(;i=0;i--)
printf("%d???",shu[i]);
}
分離每個(gè)位數(shù)存入棧,
int top = -1, n = 54321, stack[16];
while(n)
{
stack[++top] = n%10; //將最后一位存入stack
n /= 10; //去除最后一位
}
最后每個(gè)數(shù)都放在stack里,就可以按自己需要賦給別的變量
1、具體步驟如下:假設(shè)這個(gè)數(shù)是x,寫出來(lái)的形式是abced(a是萬(wàn)位,b是千位,c是百位數(shù)等等)
2、a=x整除10000
3、b=(x-a*10000)整除1000
4、c=(x-a*10000-b*1000)整除100
呃…我來(lái)了,最簡(jiǎn)單的方法這樣吧:
#include
stdio.h
#include
stdlib.h
int
main()
{
int
num[5];
int
a,b,c,d,e;
printf("輸入一個(gè)五位數(shù):");
scanf("%d",num);
a=num[0];
b=num[1];
c=num[2];
c=num[3];
d=num[4];
e=num[5];
printf("各個(gè)位上的數(shù)分別是:%d\n%d\n%d\n%d\n%d\n",a,b,c,d,e);
return
0;
}
因?yàn)椴盼逦唬苑浅7奖悖h(huán)都可以不用!
文章名稱:拆分五位數(shù)數(shù)的函數(shù)c語(yǔ)言 c語(yǔ)言分解五位數(shù)
分享鏈接:http://chinadenli.net/article16/hipidg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、品牌網(wǎng)站建設(shè)、ChatGPT、企業(yè)網(wǎng)站制作、網(wǎng)站內(nèi)鏈、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容