ImageVerifierCode 换一换
格式:DOCX , 页数:50 ,大小:29.77KB ,
资源ID:19320216      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19320216.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(哈尔滨工程大学c语言Word文档下载推荐.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

哈尔滨工程大学c语言Word文档下载推荐.docx

1、#includevoid main() char ch7=12ab56 int i,s=0; for(i=0;chi=0&chi9i+=2) s=10*s+chi- printf(%dn,s); 答案:12. int a10=1,2,2,3,4,3,4,5,1,5; int n=0,i,j,c,k;i10-n;i+) c=ai; for(j=i+1;jj+) if(aj=c) n+;for(k=j;kk+) ak=ak+1; (10-n);,ai);123453. #include aai=0;j-) c=n0j+n1j-2* n0j=c%10+ for(j=0;=1;j+) puts(nj)

2、;7078 9198三、程序填空程序的功能是在a数组中查找与x值相同的元素的所在位置。int a11,x,i;Enter 10 integers :nfor(i=1;=10;scanf(Enter x :x);a0=x;i=10;while(x!=ai) (1) ;if( (2) )%5ds position is : %4dn,x, (3) );else%d Not been found!,x);(1) i(2) i=1(3) i数组a包括10个整型元素,从数组a的第2个元素开始,分别将后项减前项之差存入数组b,并按每行3个元素的格式输出数组b。例如b0=a1-a0。 int a10,b10

3、,i;i+) ai); for(i=1; (2) ; bi=ai-ai-1;10; printf(%3d,bi); if( (3) ) (1) i=9(2) istring.hvoid fun (char s, char t) int i, d; d = strlen(s); id; i+) /* found */ ti=sd-1-i; i+) td+i=si; t2*d = /0 char s100, t100; clrscr();nPlease enter string S:%s, &s); fun(s, t);nThe result is: %sn, t);(1) for(i=0;(2)

4、 t2*d=0 (3) scanf(“%s”,s)五、程序问答int a100, i, j, n, p;输入数值的个数n 和数列ana0);=n-1; p=ai; j=i-1; while(paj&=0) aj+1=aj; j-; aj+1=p;n;%d 问题1:该程序的功能是什么?问题2:如果先输入一个10,再输入下面的10个数: 1 9 2 8 3 7 4 6 5 5 则该程序输出什么?(1). 升序 (2). 1 2 3 4 5 5 6 7 8 9void main( )int a=11,33,27,33,-1,22,-8,12;int i,t,j;for (i=0;8-1;for (j

5、=8-1;i;if (aj-1则程序的运行结果是什么?(1). 33 33 27 22 12 11 -1 -8(2). -8 -1 11 12 22 27 33 33六、编程1. 在一组数中找出最大与最小值之差。 int a10,i,x,y;please input the number: x=a0; y=a0; if(aix) x=ai; if(aiak) k=j; t=ak; ak=ai; ai=t; %d3. 在一个按升序排列的数组中插入一个数,使数组仍有序。 int a7=3,5,7,9,11,23; int b,i,k;b); a6=b; i=5; while(b ai+1=ai;

6、ai=b; i-;cha ru hou de shu zu n7;4. 用“顺序”查找法,在一组数中查找一个值为K的元素。若有,输出YES;若无,输出NO。 int a10,i,j,k;please input the aim number:k); if(ai=k) break; if(i9)NOn elseYESn5. 输出以下形式的图案: * * * * int i,j;=4; for(j=1;=i-1; =9-2*i;6. 将一个数组按逆序重新存放在该数组中。 int a10,i,t;10/2; t=ai; ai=a10-1-i; a10-1-i=t;7. 打印一个5行的杨辉三角形。 i

7、nt a55=0,i,j; ai0=aii=1; for(i=2; aij=ai-1j+ai-1j-1;=i; %3d,aij);8. 用二维字符数组存储下列图形并输出。* * * char c55=5; for(j=i; cij=*,cij);9. 计算二维数组主对角线元素之和。 int a33,i,j,x;aij); x=0; x=x+aii;the answer is %dn10. 用“折半”查找法,在一组按降序排列的数中查找一个值为K的元素。 int a10=10,9,8,7,6,5,4,3,2,1,l,r,m,k; l=0; r=9; m=(1+r)/2; while(lam) r=

8、m-1; l=m+1; m=(l+r)/2; if(lS2 ,输出1;若S1=S2,输出0;若S1S2输出-1。 char s180,s280; int i,n; gets(s1); gets(s2); i=0; while(s1i&s2i&s1i=s2i)i+; if(!s1i|s1i n=1;s1i&! n=0;jie guo shi %d13. 用“冒泡”法将一组数按升序排序。 int a10,i,j,x;9;9-j;ai+1) ai=ai+1; ai+1=x;%4d14. 在一个二维数组中形成并输出如下矩阵 1 1 1 1 1 2 1 1 1 1 3 2 1 1 1 4 3 2 1 1

9、 5 4 3 2 1 int a55; if(i x=aij; l=i; r=j;Max number is %d,position is %d,%dn,x,l,r);1. 根据下面的定义,能打印出字母M的语句是( D )。struct personchar name9;int age; ;struct person class10=John,17,Paul,19,Mary,18,Adam,16;A.printf(%cn,class3.name);B.printf(,class3.name1);C.printf(,class2.name1);D.printf(,class2.name0);2.

10、 若有以下结构体定义:struct exampleint x1;int y1;则 B 是正确的使用方式。Astruct example.x1=100; Bstruct example xy;xy.x1=100;Cstruct xy; Dstruct example xy=100;3. 下面结构体数组的定义,错误的是( D )。Astruct student int num; char name10; float score;struct student stu30;B structstu30;C struct student D struct stu30 二、写出以下程序的运行结果(1) st

11、ruct cmplx int x; int y; cnum2=1,3,2,7;,cnum0.y/cnum0.x*cnum1.x);6(2) struct date int year,month,dat; today;,sizeof(struct date);(3) struct MING struct int x; int y; in; int a;int b;e; e.a=1;e.b=2; e.in.x=e.a*e.b; e.in.y=e.a+e.b;%d,%d,e.in.x,e.in.y);2,3(4) struct abc int a,b,c;struct abc s2=1,2,3,4,5,6;int t; t=s0.a+s1.b;,t); (5)struct studentch

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1