找回密码
 立即注册

C语言试题

[复制链接]
发表于 2022-9-22 14:58:56 | 显示全部楼层 |阅读模式
资源类型:行业应用 » 企业管理 . 资源来源:网友投递
附件称号: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
/
}
[Analysis] 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 .....)

[下载]14585789610.rar






上一篇:谭浩强C程序设计
下一篇:C语言编程手册

使用道具 举报

Archiver|手机版|小黑屋|English Version|吾爱开源 |网站地图

Copyright 2011 - 2012 Lnqq.NET.All Rights Reserved

关于本站 - 版权申明 - Ln Studio! - 广告联系

本站资源来自互联网,仅供用户测试使用,相关版权归原作者所有

快速回复 返回顶部 返回列表