哈工大C语言实验题

上传人:ba****u 文档编号:52829555 上传时间:2022-02-09 格式:DOC 页数:54 大小:194.50KB
收藏 版权申诉 举报 下载
哈工大C语言实验题_第1页
第1页 / 共54页
哈工大C语言实验题_第2页
第2页 / 共54页
哈工大C语言实验题_第3页
第3页 / 共54页
资源描述:

《哈工大C语言实验题》由会员分享,可在线阅读,更多相关《哈工大C语言实验题(54页珍藏版)》请在装配图网上搜索。

1、Q3O8(io 分)第5章实验2:体型判断。医务工作者经广泛的调查和统计分析,根据身高与体重因素给出了以下按 “体指数”进行体型判断的方法。体指数计算公式是:t = w /(h*h)其中:t是体指数;w是体重,其单位为千克;h是身高,其单位为米。根据给 定的体指数t计算公式,可判断你的体重属于何种类型:当t18时,为低体重;当18 t25时,为正常体重;当25 t27时,为肥胖。*输入提示信息格式:Please enter h,w:n*输入数据格式要求:f,%f(先读入身高,再读入体重,身高以米读入, 体重以千克读入)*输出数据格式要求:当 t18 时,输出:Lower weight!n当 1

2、8 t25 时,输出:Standard weight!n当 25 t27 时, 输出:Too fat!n#in clude #in clude mai n()float t,w,h;printf(Please enter h,w:n);scanf(%f,%f,&h,&w);t = w/(h*h);if(t=18&t=25&t27)printf(Higher weight!n);elseprintf(Too fat!n);return 0;Q586(10分)编写一个程序,输入年份和月份,判断该年是否是闰年,并根据给出的月份判断是什么季节和该月有多少天?(闰年的条件是年份能被4整除但不能被100整

3、除,或者能被400整除;规定35月为春季,68月为夏季,911月为秋 季,1、2和12月为冬季)。* 输入格式要求:d,%d提示信息:Please enter year,month:* 输出格式要求:d is leap yearn %d is not leap yearn The seasonis spring/summer/autumn/winterThe numberof days of this month is %dn程序运行示例如下:实例1:Please en ter year,mo nth:2012,112012 is leap yearThe seas on is autu mn

4、The nu mber of days of this month is 30实例2:Please en ter year,mo nth:2013,122013 is not leap yearThe seas on is win terThe nu mber of days of this month is 31#i nclude #i nclude main ()int year=0,leap=0,mon=0,day=0;printf(Please enter year,month:);scanf(%d,%d,&year,&mon);if(year%100!=0&year%4=0)|(ye

5、ar%100=0&year%400=0)printf(%d is leap yearn,year);leap=1;elseprintf(%d is not leap yearn,year);switch(mon)case 1:case 2:case 12:printf(The season is wintern);break;case 3:case 4:case 5:printf(The season is springn);break;case 6:case 7:case 8:printf(The season is summern); break;case 9:case 10:case 1

6、1:printf(The season is autumnn); break;switch(mon)case 1:case 3:case 5:case 7:case 8:case 10:case 12:day=31;break;case 4:case 6:case 9:case 11:day=30;break;case 2:if(leap=1)day=29;elseday=28;prin tf(The nu mber of days of this month is %dn ”,day);Q3161d。 分)请用else if多分支条件判断语句编程设计一个简单的计 算器程序。要求:(1)请用户

7、按以下形式从键盘输入表达式:操作数运算符op操作数(2)然后计算表达式的值*输入提示信息* :无*输入数据格式* :%f%c%f* 输出数据格式 * : %.2f%c%.2f=%.2fn若若输入的运算符是除法运算符/,当除数为0时,输出数据格式为:dat is0!Error!n若输入的运算符不是加(+)、减(-)、乘(*)、除(/),则输出数据格式 为:Error!n友情提示: 用户输入的运算符为算术运算符:加(+)、减(-)、乘(*)、除(/) 用字符变量op表示; 操作数和操作数 为浮点型数据,分别用浮点型变量 datl、dat2表示。 程序运行结果如下所示:1+2/1.00+2.00=3

8、.00#in elude #in elude main ()float a=0,b=0;char op;scan f(%f%c%f,&a, &op,&b);if(op=+)prin tf(%.2f%e%.2f=%.2fn,a,op,b,a+b);else if(op=-)prin tf(%.2f%e%.2f=%.2fn,a,op,b,a-b);else if(op=*)prin tf(%.2f%e%.2f=%.2fn,a,op,b,a*b);else if(op=/)if(b!=O)prin tf(%.2f%c%.2f=%.2fn,a,op,b,a/b);elseprin tf(dat is

9、0!Error!n ”);elseprin tf(Error!n);Q3185 .(10分)实验二(2016春刘秉权C语言课):根据输入的百分制成 绩score,转换成相应的五分制成绩grade后输出。转换规则为(要求用switch语句实现):当score大于等于90且小于等于100时,grade=A;当score大于等于80且小于90时,grade=B;当score大于等于70且小于80时,grade=C;当score大于等于60且小于70时,grade=D;当score大于等于0且小于60时,grade=E。格式要求:输入提示:Please en ter score:输出形式形如:100-

10、A、75-C、0-E当输入分数不正确时,输出:In put error!#include main()int s,m;printf(Please enter score:);scanf(%d,&s);m=s100?-1:s/10;switch(m)case 10:case 9:printf(%d-An,s);break;case 8:printf(%d-Bn,s);break;case 7:printf(%d-Cn,s);break;case 6:printf(%d-Dn,s);break;case 5:case 4:case 3:case 2:case 1:case O:pri ntf(%d

11、-En ,s);break;default:pri ntf(l nput error!);Q221 .(10分)编程从键盘输入某年某月(包括闰年),用 switch语句编程 输出该年的该月拥有的天数。要求考虑闰年以及输入月份不在合法范围内的情 况。已知闰年的2月有29天,平年的2月有28天。*输入格式要求:d, %d提示信息:Input year,month:* 输出格式要求:31 daysn 29 daysn 28 daysn Input error!n程序运行示例如下:In put year,mo nth:2004,229 days#in clude mai n()int a, b;pri

12、ntf(Input year,month:);scanf(%4d, %2d, &a, &b);switch (b)case 1:case 3:case 5:case 7:case 8:case 10:case 12:printf(31 daysn);break;case 4:case 6:case 9:case 11:printf(30 daysn);break;case 2:if (a % 4 = 0 & a % 100 != 0) | a % 400 = 0)printf(29 daysn);elseprintf(28 daysn);break;default:prin tf(I nput

13、 error! n);return 0;Q210(i。 分)第7章实验任务1:所谓素数是指这个数只能被1和自身整除。要求在主函数输入一个数,调用函数Fun()判断该数是否是素数。打印信息在主函数中进行。例如:从键盘输入5,5是素数则打印如下信息:5 is a prime number.又如:从键盘输入4, 4不是素数则打印如下信息:4 is not a prime number负数、0和1均不是素数。对输入的数据要考虑数据的合法性,不满足条件的数要重新输入直到满足条件为止。不能使用全局变量,不按给定的函数原型编写程 序不给分。Fun()函数原型如下:int Fun (i nt m);* 输入数

14、据提示信息:Please in put a number:n注:该提示信息请放在循环体外*输入数据格式为:%d*输出格式要求:若是素数输出数据格式为:%d is a prime nu mber n若不是素数输出数据格式为:%d is not a prime numbern#in elude #in clude int Fun (i nt m);main ()int a;prin tf(Please in put a nu mber:n);while (sca nf(%d,&a)if (a 0 & a != 1 & Fun (a) = 1)prin tf(%d is a prime nu mbe

15、rin ,a);elseprintf(%d is not a prime numbern, a);break;return 0;int Fun (i nt m)int i, result;result = 1;if (m != 2)for (i = 2; i m; i+)if (m % i = 0)result = 0;break;return result;Q3185 .(10分)实验二(2016春刘秉权C语言课):根据输入的百分制成 绩score,转换成相应的五分制成绩grade后输出。转换规则为(要求用switch语句实现):当score大于等于90且小于等于100时,grade=A;当

16、score大于等于80且小于90时,grade=B;当score大于等于70且小于80时,grade=C;当score大于等于60且小于70时,grade=D;当score大于等于0且小于60时,grade=E。格式要求:输入提示:Please en ter score:输出形式形如:100-A、75-C、0-E当输入分数不正确时,输出:In put error!#in cludemain ()int s,m;prin tf(Please en ter score:);scan f(%d, &s);m=s100?-1:s/10;switch(m)二湄俅w9(o 260 卜 LOe0 Indu&

17、luudl-nep三 eaiqMs-=s山-1p%=)tu_do SB。 -L SB。 N SB。 c SB。 & SB。In Seo 三 eaiqMS-=sQ-p%=)tu_dCD SB。三 eaiqMs-=so-p%=)tu_d2 SB。 三 eaiqMS-=s8-1p%=)tu_d60 SB。三 eaiqMs-=uw-1p%=)tu_ck6 SB。OL Seo相传国际象棋是古印度舍罕王的宰相达依尔发明的。舍罕王十分喜欢象棋,决定让宰相自己选择何种赏赐。这位聪明的宰相指着8X 8共64格的象棋盘说:陛下, 请您赏给我一些麦子吧,就在棋盘的第1个格子中放1粒,第2格中放2粒,第 3格中放4粒

18、,以后每一格都比前一格增加一倍,依此放完棋盘上的64个格子,我就感恩不尽了。舍罕王让人扛来一袋麦子,他要兑现他的许诺。请问:国王能 兑现他的许诺吗?试编程计算舍罕王共要多少麦子赏赐他的宰相,这些麦子合多少立方米(已知1立方米麦子约1.42e8粒)?注:(1)不能使用指针、结构体、共用体、文件、goto、枚举类型进行编程。(2) 用标准C语言编程,所有变量必须在第一条可执行语句前定义。(3) 输入输出格式要和以下给定格式完全一致。*输入格式:无*输出格式:sum = %envolum = %en%e表示double类型#in clude#in clude main ()int i;double

19、s, v;s = 0;for (i = 0; i = 63; i+)s = s + pow(2, i);v = s / 1.42e8;prin tf(sum = %en, s);prin tf(volum = %en, v);return 0;Q1719 .(10分)第7章实验任务3从键盘任意输入一个整数n,编程计算并输出1n之间的所有素数之和输入提示信息:In put n:输入格式:%d输出格式:sum = %dn#in clude #in clude int Fun (i nt m);main ()int n,i,s;s=0;printf(Input n:);scan f(%d, &n);

20、for(i=2;i=n;i+)if(Fun(i)=1)s=s+i;printf(sum = %dn,s);return 0;int Fun(int m)int i, result;result = 1;if (m != 2)for (i = 2; i m; i+)if (m % i = 0)result = 0;retur n result;Q1720(i。 分)第7章实验任务6从键盘任意输入一个整数 m若m不是素数,则对m进行质因数分解,并将 m表 示为质因数从小到大顺序排列的乘积形式输出,否则输出It is a primenumber0例如,用户输入90时,程序输出90 = 2 * 3 *

21、 3 * 5 ;用户输入17 时,程序输出It is a prime number。输入提示信息:In put m:输入格式:%d输出格式:是素数时输出It is a prime numbern否则输出用%d = , %d * 运行示例1:In put m:90 /90 = 2 * 3 * 3 * 5运行示例2:In put m:13 /It is a prime nu mber#in cludeint Fun (i nt m);int IsPerfect(int m);main()int m,i,p;printf(Input m:);scanf(%d,&m);p=m;if(Fun(m)=1)

22、printf(It is a prime numbern);elseprintf(%d = ,m);for(i=2;im;i+)if(p%IsPerfect(i)=0&p/IsPerfect(i)!=1&IsPerfect(i)!=1)printf(%d * ,i);else if(p%IsPerfect(i)=0&p/IsPerfect(i)=1&IsPerfect(i)!=1)printf(%d,i);elsecontinue;p=p/i;while(p%i=0)if(p/i!=1)printf(%d * ,i);p=p/i;elseprintf(%d,i); break;return 0

23、;int Fun(int m)int i, result;result = 1;if (m != 2)for (i = 2; i m; i+)if (m % i = 0)result = 0; break;return result;int IsPerfect(int m)int i, result;result=1;if (m != 2)for (i = 2; i = m; i+)if (m % i = 0)break;else if(m%i!=1 &m/i!=1) con ti nue;elseresult=m;elseresult=2;retur n result;Q198d。 分)第7

24、章实验任务5 如果一个正整数m的所有小于m的不同因子(包括1)加起来正好等于 m本身, 那么就被称它为完全数。它是指这样的一些特殊的自然数,它所有的真因子(即 除了自身以外的约数)的和,恰好等于它本身。注意:1没有真因子,所以不是完全数。例如,6就是一个完全数,是因为6 = 1 + 2 + 3 o请编写一个判断完全数的函数lsPerfect(),然后判断从键盘输入的整数是否是 完全数。要求:按如下原型编写判断完全数的函数,若函数返回0,则代表不是完全数,若返回1则代表是完全数。int lsPerfect(i nt x);*要求输入提示信息为:Input m:n*要求输入格式为:%d*要求输出格

25、式为%d is a perfect nu mber n%d is not a perfect nu mber n注:不能使用指针、结构体、共用体、文件、goto、枚举类型进行编程,主函数 不能使用int main 和return 0。#in clude int IsPerfect(i nt m);main ()int a;printf(Input m:n);scan f(%d, & a);if (IsPerfect(a) = 1)prin tf(%d is a perfect nu mber n, a);elseprin tf(%d is not a perfect nu mber n, a)

26、;int lsPerfect(i nt m)int i, s, find;s = 0;for (i = 1; i m; i+)if (m % i = 0)s = s + i;elsecon ti nue;if (s = m)find = 1;elsefind = 0;retur n find;Q3168d。 分)编程从键盘输入一个小写英文字母,将其转换为大写英文 字母,并将转换后的大写英文字母及其十进制的ASCII码值显示到屏幕上。* 输入提示信息 * : Please in put a low-case letter from keyboard:*输入数据格式* :%c* 输出数据格式 *

27、: The capital letter and its ASCII value are:%c and %d.II提示:从键盘输入一个字符可用scanf也可用getchar#in clude main ()char a;prin tf(Please in put a low-case letter from keyboard:);a = getchar();a = a - 32;printf(The capital letter and its ASCII value are:%c and %d., a, a);Q3241(10分)实验三(2016春刘秉权C语言课):已知公式e = 1 + 1

28、/1! + 1/2! + 1/3! + . +1/n!,编程计算e的近似值,直到最后一项的绝对值小于1e-7时为止,输入e的值并统计累加的项数。要求:按顺序输出每一个e值, 小数点后保留8位有效数字,输出格式形如:e = 2.66666667, count = 4 (回 车换行,count为累加的项数)#in clude double fun (i nt n);main()int i, c;double e;c = 0;e = 0;for (i = 0; i=11; i+)e = e + fun(i);c+;printf(e = %.8lf, count = %dn, e, c);double

29、 fun(int n) double result;int i;i = 1;result = 1;doresult = result * i;i+;while (i = n); result = 1.0 / result; return result;Q1710 .(10分)第7章实验任务4:1和自身的因子;否任意输入一个整数m若m不是素数,则输出其所有不包括 则输出“没有因子,是素数”的相关提示信息。输入提示信息:Please en ter a number:输入格式:%d输出格式:有因子时:%dn无因子时:It is a prime number.No divisor!n输入为 1, 0,

30、-1 时:It is not a prime number.No divisor!n#in clude#in cludeint Fun (i nt m);mai n()int a, i;printf(Please enter a number:);scanf(%d, &a);if (Fun(fabs(a) = 1)printf(It is a prime number.No divisor!n);elsefor (i = 2; i fabs(a); i+)if ( a % i = 0)printf(%dn, i);int Fun(int m)int i, result;result = 1;i

31、f (m != 2 & m != 1)for (i = 2; i m; i+)if (m % i = 0)result = 0;break;else if (m = 1)result = 0;else;return result;Q1718 .(10分)第5章实验1:身高预测。每个做父母的都关心自己孩子成人后的身高, 据有关生理卫生知识与数理统计分 析表明,影响小孩成人后的身高的因素包括遗传、饮食习惯与体育锻炼等。小孩成人后的身高与其父母的身高和自身的性别密切相关。设faHeight为其父身高,moHeight为其母身高,身高预测公式为男性成人时身高 =(faHeight + moHeight

32、) x 0.54 cm女性成人时身高 =(faHeight x 0.923 + moHeight) / 2 cm此外,如果喜爱体育锻炼,那么可增加身高 2%如果有良好的卫生饮食习惯, 那么可增加身高1.5%。请编程从键盘输入用户的性别(用字符型变量sex存储,输入字符F表示女性,输入字符M表示男性)、父母身高(用实型变量存储,faHeight为其父身高, moHeight为其母身高)、是否喜爱体育锻炼(用字符型变量sports存储,输入字符丫表示喜爱,输入字符N表示不喜爱)、是否有良好的饮食习惯等条件(用 字符型变量diet存储,输入字符丫表示良好,输入字符N表示不好),利用给 定公式和身高预

33、测方法对身高进行预测。运行示例:Are you a boy(M) or a girl(F)?F /Please in put your fathers height(cm):182/Please in put your mothers height(cm):162 /Do you like sports(Y/N)?N /Do you have a good habit of diet(Y/N)?Y /Your future height will be 167(cm)#in clude main ()float fh, mh, h;char sex, sports, diet;prin tf(

34、Are you a boy(M) or a girl(F)?);sex = getchar();getchar();prin tf(Please in put your fathers height(cm):);scan f(%f, &fh);getchar();printf(Please input your mothers height(cm):);scanf(%f, &mh);getchar();printf(Do you like sports(Y/N)?);sports = getchar();getchar();printf(Do you have a good habit of

35、diet(Y/N)?);diet = getchar();if (sex = M)h = (fh + mh) * 0.54;else if (sex = F)h = (fh * 0.923 + mh) / 2;elseprintf(Error!n);goto R;if (sports = Y)h = h * 1.02;else if (sports = N);elseprin tf(Error!n);goto R;if (diet = Y)h = h * 1.015;else if (diet = N);elseprin tf(Error!n);goto R;prin tf(Your futu

36、re height will be %.0f(cm)n, h);R:return 0;Q3134(.(10分)第8章实验1:学生成绩管理系统V1.0某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维 数组作函数参数编程实现如下学生成绩管理:(1)录入每个学生的学号和考试成绩;(2)计算课程的总分和平均分;(3)按成绩由高到低排出名次表;(4)按学号由小到大排出成绩表;(5)按学号查询学生排名及其考试成绩;(6)按优秀(90100)、良好(8089)、中等(7079)、及格(6069)、不 及格(059) 5个类别,统计每个类别的人数以及所占的百分比;(7)输出每个学生的学号

37、、考试成绩。程序运行结果示例:In put stude nt nu mber( n 30):6/Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis 7.List recordO.ExitPlease In put your choice:1

38、/In put stude nts ID, n ame and score:11003001 87 /11003005 98 /11003003 75 /11003002 48 /11003004 65 /11003006 100 /Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mbe

39、r6.Statistic an alysis7.List record0.ExitPlease In put your choice:2/sum=473,aver=78.83Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List r

40、ecordO.ExitPlease In put your choice:3/Sort in desce nding order by score:1100300610011003005981100300187110030037511003004651100300248Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber

41、 5.Search by nu mber6.Statistic an alysis 7.List recordO.ExitPlease In put your choice:4/Sort in asce nding order by nu mber:1100300187110030024811003003751100300465110030059811003006100Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding

42、order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List recordO.ExitPlease In put your choice:In put the nu mber you want to search:110030041100300465Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce

43、nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List record0.ExitPlease In put your choice:6/60116.67%60-69116.67%70-79116.67%80-89116.67%90-99116.67%100116.67%Man ageme nt for Stude nts scores1.ln put record 2.Caculate total and average score of co

44、urse3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List recordO.ExitPlease In put your choice:7/1100300187110030024811003003751100300465110030059811003006100Man ageme nt for Stude nts scores1.ln put record2.Caculate total and averag

45、e score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List record 0.ExitPlease In put your choice: 8/In put error!Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce

46、nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List recordO.ExitPlease In put your choice:0/End of program!输入格式:(1 )录入学生的人数:*输入数据格式:%d*提示信息:In put stude nt number( * 30):n(2 )录入每个学生的学号和考试成绩:*输入数据格式:ld%f提示信息:I nput stude nts ID, n ame and score:n输出格

47、式: 菜单项的输出显示:Man ageme nt for Stude nts scores1.ln put record2.Caculate total and average score of course3.Sort in desce nding order by score4.Sort in asce nding order by nu mber5.Search by nu mber6.Statistic an alysis7.List recordO.ExitPlease In put your choice:计算课程的总分和平均分:*输出总分与平均分格式:sum=%.0f,aver=

48、%.2fn按成绩由高到低排出名次表:*输出格式:%ldt%.Ofn*提示信息:Sort in desce nding order by score: n按学号由小到大排出成绩表:*输出格式:%ldt%.Ofn*提示信息:Sort in asce nding order by nu mber:n按学号查询学生排名及其考试成绩:*如果未查到此学号的学生,提示信息:Not foun d!n按优秀(90100)、良好(8089)、中等(7079)、及格(6069)、不及格(059) 5个类别,统计每个类别的人数以及所占的百分比:*成绩 60 输出格式:60t%dt%.2f%n*成绩=100 输出格式:

49、%dt%dt%.2f%n*其他输出百分比格式:%d-%dt%dt%.2f%n#in clude#in clude#defi ne N 30 main ()int n ,i,j,temp1,temp2,choice,p,mark;long ids;float sum;printf(Input student number(n30):n);while(sca nf(%d, &n)if(n0)break;elseprintf(Invalid Input!);continue;long idN;float scoreN;Choice:printf(Management for Students sco

50、resn);printf(1.Input recordn);printf(2.Caculate total and average score of coursen);printf(3.Sort in descending order by scoren);printf(4.Sort in ascending order by numbern);printf(5.Search by numbern);printf(6.Statistic analysisn);printf(7.List recordn);printf(0.Exitn);printf(Please Input your choi

51、ce:n);scanf(%d,&choice);switch(choice)case1:goto a;case2:goto b;case3:goto c;case4:goto d;case5:goto e;case6:goto f;case7:goto g;case0:goto end;default:printf(Input error!n);goto Choice;a:printf(Input students ID, name and score:n);for(i=1;i=n;i+)scanf(%ld %f,&idi,&scorei);goto Choice;b:sum=0;for(i=

52、1;i=n;i+)sum=sum+scorei;printf(sum=%.0f,aver=%.2fn,sum,sum/n);goto Choice;c:printf(Sort in descending order by score:n);for(i=1;in;i+)for(j=i+1;jscorei)temp1=scorei,temp2=idi;scorei=scorej,idi=idj;scorej=temp1,idj=temp2;for(i=1;i=n;i+)printf(%ldt%.0fn,idi,scorei);goto Choice;d:printf(Sort in ascendi

53、ng order by number:n);for(i=1;in;i+)for(j=i+1;jidj)temp1=scorei,temp2=idi;scorei=scorej,idi=idj;scorej=temp1,idj=temp2;for(i=1;i=n;i+)printf(%ldt%.0fn,idi,scorei);goto Choice;e:printf(Input the number you want to search:n);scanf(%ld,&ids);getchar();for(i=1;i=n;i+)if(ids=idi)printf(%ldt%.0fn,idi,scor

54、ei);goto Choice;elsecontinue;printf(Not found!n);goto Choice;f:for(i=5;i=10;i+)p=0;for(j=1;j=n;j+)mark=scorej60?5:(int)scorej/10;if(mark=i)p+;if(i=5)printf(=6&i=9)printf(%d-%dt%dt%.2f%n,i*10,i*10+9,p,(float)p/n*100); continue;elseprintf(%dt%dt%.2f%n,i*10,p,(float)p/n*100);goto Choice;g:for(i=1;i=n;i+)printf(%ldt%.0fn,idi,scorei);goto Choice;end:printf(End of program!n);return 0;Q3262(i。 分)题目:一个整数,它加上100后是一个完全平方数,再加 上168又是一个完全平方数,请按从小到大的顺序,连续输出3个满足这样条件 的数?程序分析:使用穷举法,如果找到三个这样的数据,就停止。提示:判断一个数是否为完全平方数,可以先将该数开方,在平方,如果结果与 原数相等,即该数为完全平方数。要求输入,每行一个满足条件的数,例如:结果1结果2结果3#in clude#in clude int

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!