當前位置:首頁 » 編程語言 » 石油大學c語言答案

石油大學c語言答案

發布時間: 2023-08-01 04:20:47

c語言關於strlen函數的

設有定義語句:char str[][20]={"Beijing","123456"},*p=str; /*把逗號去掉,把中文變數字*/
則printf("%d\n",strlen(p+20)); 輸出結果是
A)10 B) 6 C) 0 D) 20

選擇B

希望回答對你有幫助

㈡ 求:中國石油大學(華東)現代遠程教育 C語言 在線考試答案

1.從鍵盤輸入10個整數,求其和。
#include <stdio.h>
main()
{
int i,x,s=0;
printf("請輸入10個整數:");
for(i=0;i<猛賀10;i++)
{
scanf("%d",&x);
s=s+x;
}
printf("s=%d\n",s);
}
2.計算s=1!+2!+…+10!
方法1:
#include <stdio.h>
main()
{
int i,j;
long s=0,t;
for(i=1;i<=10;i++)
{
t=1;
for(j=1;j<=i;j++)
t=t*j;
s=s+t;
}
printf("1!+2!+...+10!=%ld\n",s);
}
方法2:
#include <stdio.h>
main()
{
int i;
long s=0,t=1;
for(i=1;i<=10;i++)
{
t=t*i;
s=s+t;
}
printf("1!+2!+...+10!=%ld\n",s);
}
3.求100-999中的水仙花數。所謂水仙花數是明拆指一個數的各位數字的立方和等於該數自身的數。如:153=1*1*1+5*5*5+3*3*3 。
方法1:
#include <stdio.h>
main()
{
int n,g,s,b;
for(n=100;n<1000;n++)
{
g=n%10;
s=n/10%10;
b=n/100;
if(n==b*b*b+s*s*s+g*g*g)
printf("%d=%d%d%d\n",n,b,s,g);
}
printf("\n");
}
方法2:
#include <stdio.h>
main()
{
int n,g,s,b;
for(b=1;b<=9;b++)
for(s=0;s<=9;s++)
for(g=0;g<枝槐派=9;g++)
{
n=100*b+10*s+g;
if(n==b*b*b+s*s*s+g*g*g)
printf("%d%d%d=%d\n",b,s,g,n);
}
printf("\n");
}

熱點內容
我配置很高了ae為什麼卡 發布:2025-05-17 14:54:50 瀏覽:167
python數據分析實戰pdf 發布:2025-05-17 14:49:42 瀏覽:950
海瀾之家廣告腳本 發布:2025-05-17 13:56:06 瀏覽:30
手文件夾恢復 發布:2025-05-17 13:53:32 瀏覽:993
linux怎麼看進程 發布:2025-05-17 13:53:30 瀏覽:303
thinkphp欄位緩存 發布:2025-05-17 13:52:01 瀏覽:575
山靈app安卓版如何設置 發布:2025-05-17 13:51:49 瀏覽:388
帆布壓縮袋 發布:2025-05-17 13:26:27 瀏覽:460
c語言16進製表示方法 發布:2025-05-17 13:11:25 瀏覽:482
ftp單位 發布:2025-05-17 13:10:03 瀏覽:144