《C语言程序设计A》形成性考核册

时间:2024-04-30 10:32:42 5A范文网 浏览: 平时作业 我要投稿
电大文库【C语言程序设计】形成性考核册作业答案

电大文库【C语言程序设计】作业一
一选择题
1A 2A 3B 4D 5B 6A 7C 8A 9B 10C 11C 12A 13B 14D 15B 16D 17A
二、填空题

1.;
2.}
3.//
4.*/
5.#include
6.用户
7.函数头
8 .printf( )
9 .void
10.43-18=25
11. warning
12 .error
13.0x19
14./n
15. D
16 .72
17 .4
18 .1
19. 4
20. 4
21.int
22. double
23 .const
24.定义类型和赋初值
25 .6
26 .7
27 .6.25
28. 4
29. x++
30. y+=1
31 .X
32. x+y<=5
33 .a<=b && (b>5 || b<5)
34. false
35. true
36. 10
37. DataType
38.整型
39. switch
40.不停止
41.10
42 .break
43 .return
44.主(main)


三、写出下列每个程序运行后的输出结果
1、11 14 switch end.
  Press any key to continue

2、s=91.
 Press any key to continue

3、25 20.
 Press any key to continue
4、y=21.
 Press any key to continue
5、1 1 2 3 5
 8 13 21 34 55
 Press any key to continue
6、2 3 5 7 11 13 17 19
 Press any key to continue
7、10 6 4
 Press any key to continue
8、1 5 7 11 13 37
 Press any key to continue
电大文库【C语言程序设计】作业二
一、 选择题
1、C
2、C
3、C
4、A
5、C
二、填空题
1. 8
2. 32
3. 60
4. M*N。
5. 0~M-1
6. 0~N-
7. BB
8. 1
9. 0
10. 1
11. 11
12. n+1
13.大小比较
14.复制到
15. 10
16. 19.
三、写出下列每个程序运行后的输出结果
1.
输出结果为:
6 4
Press any key to continue
2.
输出结果为:
worker cadre
Press any key to continue

3.
输出结果为:
42 24 33
Press any key to continue
4.
输出结果为:
2 3 11
Press any key to continue

输出结果为:
2 1 12
Press any key to continue

6.
输出结果为:
1 2 3 5 8 13 21 34
Press any key to continue
四、写出下列每个函数的功能

1.
函数功能为:
根据实参a大于、等于或小于实参b,返回1,0或-1

2.
函数功能为:
返回实参a、 b、c中的最大数
3.
函数功能为:
计算x+x2/2+x3/3+......+xn/(n+1)的值

4.
函数功能为:
判断一个整数是否是素数
5.
函数功能为:
将一个整数化成十六进制数


五、根据下列每个题目要求编写程序

1.编写一个函数,函数头格式为"void fun4(char *a , int b[])",分别求出由字符指针a所指向的字符串中包含的每种十进制数字出现的次数,把统计结果保存在数组b的相应元素。
#include
void fun4(char* a,int b[]){
do{
if(*a>='0' && *a<='9')b[*a-48]++;
}while(*a++);
}

/*void main()
{
char * a="122333444499888";
int b[10]={0};
fun4(a,b);
for(int i=0;i<10;i++)
printf("%d ",b[i]);
}*/

2. 编写一个函数,函数头格式为"double Mean(double a[M][N] , int m , int n)",要求返回二维数组a[m][n]中所有元素的平均值,假定在计算过程是采用变量v存放平均值。
#include
const int M=2,N=3;
double Mean(double a[M][N], int m,int n ){
double v=0;
for(int i=0;i for(int j=0;j v+=a[i][j];
return v/(m*n);
}

/*void main()
{
double a[2][3]={1,2,3,4,5,6};
printf("%lf/n",Mean(a,2,3));

}*/

3. 编写一个递归函数"int FF(int a[] , int n)",求出数组a中所有元素n个元素之积并返回。
#include
int FF(int a[] , int n){
int mul=1;
if(n==1)mul*=a[0];
else mul=a[n-1]*FF(a,n-1);
return mul;
}

/*void main()
{
int a[6]={1,2,3,4,5,6};
printf("%d/n",FF(a,6));

}*/

4. 编写一个主函数,利用while循环,求出并显示满足不等式1+1/2+1/3+......+1/n>5的最小n值。
#include
void main()
{
double sum=0;
int n=1;
while(true)
{
if(sum + 1/(double)n > 5)break;
else
sum += 1/(double)n;
n++;
}
printf("%d, %lf/n",n,sum);
}



5. 编写一个主函数,求满足不等式22+42+......+n2<1000的最大n值,假定分别用i和s为取偶数值和累加值的变量,并限定使用do循环编程。
#include
void main()
{
int s=0,i=2;
do
{
s+=i*i;
if(s+(i+2)*(i+2)>=1000)break;
else i+=2;
}while(true);
printf("i=%d,s=%d",i,s);
}


6. 编写一个主函数,计算并输出n 的值,其中n值由键盘输入。
#include
void main()
{
int s=0,n;
printf("请输入n的值:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
s+=i*i;
printf("n=%d,s=%d",n,s);
}
电大文库【C语言程序设计】作业三
7. 选择题
8. C2C3B4B5C6B7C8B9B10C11B12B13D14C15D16D
二、填空题
1.函数体2. 0
3static
4.递归
5.头
6.内部
7. 25
8. 46
9.46
10. 4。
11. (char*)p
12. int**
13. &p
14. *p
15. '/0' (ASCII码0)
三、写出下列每个程序运行后的输出结果
1.

输出结果为:
GGPPBBWW
Press any key to continue

2.

输出结果为:
12.00 160.00 2.50
Press any key to continue

3.

输出结果为:
main:x,y=18,23
subs:x,y=41,64
main:x,y=36,23
Press any key to continue

4

输出结果为:
432198765
Press any key to continue

5.
输出结果为:
47 36 32 28 20 15
Press any key to continue

6
输出结果为:
3 5 7 9
11 13 15 17
Press any key to continue

7.
输出结果为:
50 60
Press any key to continue

8.
输出结果为:
b=184
Press any key to continue

四、写出下列每个函数的功能

1.
函数功能为:
根据整型数组元素中是否能找到整数x,返回1或0

2.
函数功能为:
返回数组中前n个其值大于等于k的元素之和



3
函数功能为:
函数ff让两个数相加,要求输入其和,判断结果是否正确。在主函数中用随机函数产生两个20以内的随机整数,通过10次调用这个函数,算对一次得10分,计算所得分

4.
函数功能为:
此函数带有一个默认参数,若使用默认值,则通过递归调用,返回前2参数的最小公倍数;
不使用默认值时,若最后一个参数不小于前2个参数,则返回前2参数之乘积;
否则,通过递归调用,返回前2参数最小公倍数的n倍数。


5.
函数功能为:
将从键盘输入的n个整数逆序输出
6.
}
函数功能为:
求不小于数组元素之平均值的各元素之和(前n个)


电大文库【C语言程序设计】作业四答案
9. 选择题
1A2B3C4D5B6D

二、填空题
1. 12
2. 24
3. 20[电脑商场特别版1]
4. (Worker*)malloc(n*sizeof(Worker)); 5. x.(*a) 6. *(p->b) 7. fp->score


三、写出下列每个程序运行后的输出结果
1.

输出结果为:
wanghua 52 23.50
wanghua 52 23.50
Press any key to continue

2.

输出结果为:
louting 39 986.00
Press any key to continue

3.
输出结果为:
def 58 638.00
Press any key to continue

四、写出下列每个函数的功能

1.
函数功能为:
输入struct Worker 类型的对象a[n]的各个元素的值

2.
函数功能为:
建立一个具有n个结点,每个结点的类型是StrNode的链表



3.
函数功能为:
在一个具有n个结点,每个结点的类型是IntNode的链表中寻找data值最大的结点

4.

函数功能为:
计算一个具有n个结点,每个结点的类型是IntNode的链表的结点数

5.
函数功能为:
在类型为IntNode的链表后输入n个结点的数据



6.
函数功能为:
在已经存在的d:/xxk文件夹下(如不存在此文件夹程序运行会出错)打开xuxk1.txt文件,并向其中输入一系列长度小于20的字符串,直到输入字符串end结束。

[电脑商场特别版1]理论值。用sizeof(D)得到的结果是 24,说明编译系统采用的结构成员对齐方式是8个字节

来源:网络整理 免责声明:本文仅限学习分享,如产生版权问题,请联系我们及时删除。

相关文章:

《会计准则专题》形考一(单选题)04-30

《会计准则专题》形考一(多选题)04-30

《会计准则专题》形考三(单选题)04-30

《会计准则专题》形考三(多选题)04-30

《会计准则专题》形考二(单选题)04-30

清风给了我们祖先第一口呼吸修辞手法04-30

《个案工作》形成性考核作业(一) (暂无答案)04-30

《二十世纪外国文学专题》形成性考核册04-30

《仓储与配送管理》形成性考核册04-30

《会计信息系统》形成性考核册作业一04-30

热搜文章
最新文章