资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
2014卓越班C语言程序设计实验C语言程序设计实验十二force (youth teams) and County party leaders, aimed at weakening the anti-Japanese forces. Zhuang Shaozhen was removed from Office and to the underground revolution activities carried out in the country, political parties were dissolved. Zhejiang comrades and thus losing a foothold in Wujiang basis points. To make them stay, jindapeng served as captain of the young workers through activities, make the political player-wise into the youth team. Save a group of the backbone of the resistance, and gave the Communists . Commander Zhu Xi, led by Deputy Commander Wang Hesong, stationed along the junction of Jiangsu xincheng, Wuzhen. Zhu Xi troops KMT-CCP cooperation and anti-Japanese policy of solidarity, he moved to Jiangsu and Zhejiang provinces. Zhu Department times and day Army hand-to-hand combat made victory, grow has momentum, standing strict Tomb, and new Cheng of appeasement army giant Haru Brigade anyway, received adapted; living Taihu Lake of bin of two a even Hunan army with of allegiance; Jiangsu and Zhejiang junction area of Wang Chunlin Department about 500 people also has done a Yu Zhu Xi men; River, and Zhejiang, and Shanghai area many tour miscellaneous forces also attracted attached return, plus many local youth have joined forces, Zhu Xi strength big increased, from original more than 200 more people quickly development to more than 4,000 more than people, opened has a to Wuzhen for Center, including strict Tomb, and Shuanglin, practicing guerrilla base of the urban, new Cheng became strongest guerrilla forces of the Kuomintang along the border of Jiangsu and Zhejiang. In April, the Deputy Commander of the Zhu Xi Wang Hesong tomb of the eighth Brigade more than more than 100 guns into the country of Pakistan and a Hui, Miao, jijiaozhishi with the town. At this point, and underground I lost contact,实验目的 江苏省等级考试的上机考与全国等级考试的上机考形式完全不同,江苏省等考上机只考两题,一题是改错题,但并不提示错误的位置,需要自已动脑。改错题通常有34个错误。错误分为两大类,一类是语法出错,这类错误比较查错和容易修改,即修改通过编译程序提示的错误。另一类是结果出错,即程序的算法出错,这类错误需认真审题。另一题是编程题。这类题需要整体编程。要求必须常用算法和函数参数和传递。编程题必须掌握C语言的文件,应熟悉文件指针的定义,文件的打开及文件的输入输出。实验指导【12.1程序功能】 在一组数值给定的整数中查找次大数。【编程要求】1、编写函数int findsecmax(int data, int count)。函数功能:在data数组的前count个整数中查找次大数。2、编写函数main()。函数功能:声明一个整型数组a并用测试数据初始化,用数组a及数组元素个数作实参调用findsecmax 函数找出次大数,然后将原数组及次大数输出到屏幕及数据文件myf12_1.out中。最后将考生本人的准考证号字符串输出到文件myf12_1.out中。【测试数据与运行结果】测试数据:1,9,2,8,3,7,4,6,10,10屏幕输出: 1 9 2 8 37 4 6 10 10Sec_max: 9【要求】1.源程序文件名为myf12_1.c,输出结果文件名为myf12_1.out。2.数据文件的打开、使用、关闭均用C语言标准库中文件操作函数实现。3.源程序文件和运行结果文件均需保存到T盘上,供阅卷使用。4.不要复制扩展名为obj和exe的文件到T盘上。 #include /*库函数exit(0)需要*/#include /*定义文件指针时需要的头文件*/函数编程,按【编程要求】 1.编写函数int findsecmax(int data, int count) 要点:函数首部完整照抄。.int findsecmax(int data, int count) int main() FILE *fp; 所有数据类型的说明和定义 if(fp=fopen(t:myf2.out,w)=NULL) printf(nCant open the file!); exit (0); 函数调用(具体问题具体分析) 结果输出printf(nMy number is:120992340n); fprintf(fp,nMy number is:1292340n); fclose(fp); return 0;【参考源程序】#include #include int findsecmax(int data, int count) int i, j=0,secmax=0,max=data0,b10; for(i=1;imax) max=datai;for(i=0;icount;i+) /排除最大值后的整数数据放入临时数组b if(datai!=max) bj+=datai;for(i=0;isecmax) secmax=datai; return secmax;int main() FILE *fp; int i,a20=1,9,2,8,3,7,4,6,10,10,count=10,sec_max; if(fp=fopen(myf12_1.out,w)=NULL) printf(nCant open the file!); exit (0); sec_max=findsecmax(a,count);for(i=0;icount;i+) printf(i+1)%5=0?%4dn:%4d,ai),fprintf(fp,i%5=0?%4dn:%4d,ai);printf(nsec_max:%4d,sec_max),fprintf(fp, nsec_max:%4d,sec_max);printf(nMy number is:120992340n); fprintf(fp,nMy number is:1292340n); fclose(fp); return 0; 【要点】:1、 蓝色的内容是必需的部分,并且常将printf函数与 fprintf函数写在一起,用逗号分隔,这样程序不易出错;2、 本题要求数据初始化;3、 输出格式必须按要求输出;4、 编程时必须按照题中要求完成,不得擅自想当然,除非你不想得分。实验内容一、 程序编写题【12.2程序功能】将一个44二维数组中全部元素逆时针旋转90。【编程要求】1编写函数int rotate (int a44, int b44),将数组a中元素逆时针旋转90后的元素保存在数组b中,计算b数组主对角线上全部元素之和作为函数的返回值。2编写主函数main,从键盘上读入16个数据放入一个二维数组中,调用rotate函数,将旋转后的二维数组全部元素按行写入到结果文件myf2.out中,最后将旋转后数组中主对角线上全部元素之和写入到结果文件myf12_2.out中。并将考生本人的准考证号字符串输出到文件myf12_2.out中。【测试数据】使用以下测试数据: 旋转前: 旋转后:11 12 13 14 14 24 34 44 21 22 23 24 13 23 33 4331 32 33 34 12 22 32 4241 42 43 44 11 21 31 41 屏幕输出:14 24 34 44 13 23 33 43 12 22 32 42 11 21 31 41sum=110My number is:310292340二、程序
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号