52ky 发表于 2022-9-22 14:58:56

C语言试题

附件称号:C言语试题
压缩包内文件格式:可执行文件
附件来源:互联网
运行方式:Windows方式
是不是经自己验证:是
附件性质:免费
详细说明:觉得有效就自己下
3.编程题
请编写一个函数intfun(int
s,intt,int
k),用来求出数组的最小元素在数组中的下标并存放在k所指的存储单元中。
例如,输入如下整数:
234345753134436458100321135760
则输出成果为6,100。
注意:部分源程序给出如下。
请勿改动主函数main和别的函数中的任何内容,仅在函数fun的花括号中填入所编写的若干句子。
试题程序:
#includelt;conio.hgt;
#includelt;stdio.hgt;
intfun(int
s,intt,int
k)
{
}
main()
{
inta={234,345,753,134,436,458,100,321,135,760},k;
clrscr();
fun(a,10,k);
printf(%d,%d\n,k,a);
}
答案及分析:
intfun(int
s,intt,int
k)
{
inti;
k=0;/
k所指的数是数组的下标值
/
for(i=0;ilt;t;i++)
if(sgt;s)
k=i;/
找到数组的最小元素,把该元素的下标赋给k所指的数
/
returns;/
回来数组的最小元素
/
}
【解析】本题中直接使用指针变量k,但在使用时要注意对k的指针运算,此外,一开始应让
k的值为数组中的某一下标值,即
k=0。
试题.doc
.....太多文件了略.....

(Attachment title: C language test questions
The file format in the compressed package: executable file
Attached source: Internet
Operation mode: Windows mode
Is it verified by yourself: yes
Attachment nature: free
Detailed description: If you think it works, you can download it yourself
3. Programming questions
Please write a function intfun(int
s,intt,int
k), which is used to find the subscript of the smallest element of the array in the array and store it in the storage unit pointed to by k.
For example, enter the following integers:
234345753134436458100321135760
The output is 6,100.
Note: Part of the source program is given below.
Do not change any content in the main function main and other functions, and only fill in some sentences written in the curly braces of the function fun.
Exam procedure:
#includelt;conio.hgt;
#includelt;stdio.hgt;
intfun(int
s,intt,int
k)
{
}
main()
{
inta={234,345,753,134,436,458,100,321,135,760},k;
clrscr();
fun(a,10,k);
printf(

n,k,a);
}
Answers and Analysis:
intfun(int
s,intt,int
k)
{
inti;
k=0;/
The number pointed to by k is the subscript value of the array
/
for(i=0;ilt;t;i)
if(sgt;s)
k=i;/
Find the smallest element of the array and assign the subscript of the element to the number pointed to by k
/
returns;/
returns the smallest element of the array
/
}
The pointer variable k is used directly in this question, but attention should be paid to the pointer operation on k when using it.
The value of k is a subscript value in the array, that is,
k=0.
test questions.doc
.....too many files .....)




页: [1]
查看完整版本: C语言试题