当前位置:首页 » 编程语言 » 石油大学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");
}

热点内容
bbs论坛源码java 发布:2025-08-23 04:39:21 浏览:636
如斯脚本 发布:2025-08-23 04:34:52 浏览:593
c语言等腰三角形 发布:2025-08-23 04:31:17 浏览:578
氦气压缩 发布:2025-08-23 04:28:20 浏览:257
android生成随机数 发布:2025-08-23 04:27:36 浏览:752
安卓应用程序隐藏了怎么找出来 发布:2025-08-23 04:26:59 浏览:547
php变量的引用 发布:2025-08-23 04:26:16 浏览:675
编程移动端 发布:2025-08-23 04:12:58 浏览:620
安卓手机微信怎么设置夜间模式 发布:2025-08-23 04:12:17 浏览:332
服务器运维都包含什么 发布:2025-08-23 04:12:14 浏览:45