哈工大C語言實驗題_第1頁
哈工大C語言實驗題_第2頁
哈工大C語言實驗題_第3頁
已閱讀5頁,還剩49頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Q3O8(io 分)第5章實驗2:體型判斷。醫(yī)務工作者經(jīng)廣泛的調(diào)查和統(tǒng)計分析,根據(jù)身高與體重因素給出了以下按 “體指數(shù)”進行體型判斷的方法。體指數(shù)計算公式是:t = w /(h*h)其中:t是體指數(shù);w是體重,其單位為千克;h是身高,其單位為米。根據(jù)給 定的體指數(shù)t計算公式,可判斷你的體重屬于何種類型:當t<18時,為低體重;當18 <t<25時,為正常體重;當25 < t<27時,為超重體重;當t >27時,為肥胖。*輸入提示信息格式:"Please enter h,w:n"*輸入數(shù)據(jù)格式要求:"f,%f"(先讀入身

2、高,再讀入體重,身高以米讀入, 體重以千克讀入)*輸出數(shù)據(jù)格式要求:當 t<18 時,輸出:"Lower weight!n"當 18 <t<25 時,輸出:"Standard weight!n"當 25 <t<27 時,輸出:"Higher weight!n"當 t >27 時, 輸出:"Too fat!n"#in clude <stdio.h>#in clude <stdlib.h> mai n()float t,w,h;printf("Ple

3、ase enter h,w:n");scanf("%f,%f",&h,&w);t = w/(h*h);if(t<18)printf("Lower weight!n");else if(t>=18&&t<25)printf("Standard weight!n");else if(t>=25&&t<27)printf("Higher weight!n");elseprintf("Too fat!n");retu

4、rn 0;Q586(10分)編寫一個程序,輸入年份和月份,判斷該年是否是閏年,并根據(jù)給出的月份判斷是什么季節(jié)和該月有多少天?(閏年的條件是年份能被4整除但不能被100整除,或者能被400整除;規(guī)定35月為春季,68月為夏季,911月為秋 季,1、2和12月為冬季)。* 輸入格式要求:"d,%d"提示信息:"Please enter year,month:"* 輸出格式要求:"d is leap yearn" "%d is not leap yearn" "The seasonis spring/summe

5、r/autumn/winter""The numberof days of this month is %dn"程序運行示例如下:實例1:Please en ter year,mo nth:2012,112012 is leap yearThe seas on is autu mnThe 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 th

6、is month is 31#i nclude <stdio.h>#i nclude <stdlib.h>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)|(year%100=0&&year%400=0)printf("%d is leap yearn",year);l

7、eap=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 11:p

8、rintf("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多分支條件判斷語句編程設(shè)計一個簡單的計

9、 算器程序。要求:(1)請用戶按以下形式從鍵盤輸入表達式:操作數(shù)運算符op操作數(shù)(2)然后計算表達式的值*輸入提示信息* :無*輸入數(shù)據(jù)格式* :"%f%c%f"* 輸出數(shù)據(jù)格式 * : "%.2f%c%.2f=%.2fn"若若輸入的運算符是除法運算符/,當除數(shù)為0時,輸出數(shù)據(jù)格式為:"dat is0!Error!n"若輸入的運算符不是加(+)、減(-)、乘(*)、除(/),則輸出數(shù)據(jù)格式 為:"Error!n"友情提示: 用戶輸入的運算符為算術(shù)運算符:加(+)、減(-)、乘(*)、除(/) 用字符變量op表示;

10、操作數(shù)和操作數(shù) 為浮點型數(shù)據(jù),分別用浮點型變量 datl、dat2表示。 程序運行結(jié)果如下所示:1+2/1.00+2.00=3.00#in elude <stdio.h>#in elude <stdlib.h> 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("

11、;%.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 0!Error!n ”);elseprin tf("Error!n");Q3185 .(10分)實驗二(2016春劉秉權(quán)C語言課):根據(jù)輸入的百分制成 績

12、score,轉(zhuǎn)換成相應的五分制成績grade后輸出。轉(zhuǎn)換規(guī)則為(要求用switch語句實現(xiàn)):當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-A"、"75-C"、"0-E"當輸入分數(shù)不正確時,輸出:&quo

13、t;In put error!#include<stdio.h> main()int s,m;printf("Please enter score:");scanf("%d",&s);m=s<0|s>100?-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:print

14、f("%d-Dn",s);break;case 5:case 4:case 3:case 2:case 1:case O:pri ntf("%d-En" ,s);break;default:pri ntf("l nput error!");Q221 .(10分)編程從鍵盤輸入某年某月(包括閏年),用 switch語句編程 輸出該年的該月?lián)碛械奶鞌?shù)。要求考慮閏年以及輸入月份不在合法范圍內(nèi)的情 況。已知閏年的2月有29天,平年的2月有28天。*輸入格式要求:"d, %d"提示信息:"Input year,mo

15、nth:"* 輸出格式要求:"31 daysn" "29 daysn" "28 daysn" "Input error!n"程序運行示例如下:In put year,mo nth:2004,229 days#in clude<stdio.h> mai n()int a, b;printf("Input year,month:");scanf("%4d, %2d", &a, &b);switch (b)case 1:case 3:case

16、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 days'n");break;default:prin tf("I nput error!&

17、#39; n");return 0;Q210(i。 分)第7章實驗任務1:所謂素數(shù)是指這個數(shù)只能被1和自身整除。要求在主函數(shù)輸入一個數(shù),調(diào)用函數(shù)Fun()判斷該數(shù)是否是素數(shù)。打印信息在主函數(shù)中進行。例如:從鍵盤輸入5,5是素數(shù)則打印如下信息:"5 is a prime number".又如:從鍵盤輸入4, 4不是素數(shù)則打印如下信息:"4 is not a prime number"負數(shù)、0和1均不是素數(shù)。對輸入的數(shù)據(jù)要考慮數(shù)據(jù)的合法性,不滿足條件的數(shù)要重新輸入直到滿足條件為止。不能使用全局變量,不按給定的函數(shù)原型編寫程 序不給分。Fun()函數(shù)

18、原型如下:int Fun (i nt m);* 輸入數(shù)據(jù)提示信息:"Please in put a number:n"注:該提示信息請放在循環(huán)體外*輸入數(shù)據(jù)格式為:"%d"*輸出格式要求:若是素數(shù)輸出數(shù)據(jù)格式為:"%d is a prime nu mber n"若不是素數(shù)輸出數(shù)據(jù)格式為:"%d is not a prime number'n"#in elude <stdio.h>#in clude <stdlib.h> int Fun (i nt m);main ()int a;pr

19、in tf("Please in put a nu mber:n");while (sca nf("%d",&a)if (a <= 0 | a = 1)con ti nue;else if (a > 0 && a != 1 && Fun (a) = 1)prin tf("%d is a prime nu mberin ",a);elseprintf("%d is not a prime numbern", a);break;return 0;int Fun (i

20、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春劉秉權(quán)C語言課):根據(jù)輸入的百分制成 績score,轉(zhuǎn)換成相應的五分制成績grade后輸出。轉(zhuǎn)換規(guī)則為(要求用switch語句實現(xiàn)):當score大于等于90且小于等于100時,grade=A;當score大于等于80且小于90時,grade=B;當score大于等于70且小于80時,grade=C;當score大于等于60且小于70

21、時,grade=D;當score大于等于0且小于60時,grade=E。格式要求:輸入提示:"Please en ter score:"輸出形式形如:"100-A"、"75-C"、"0-E"當輸入分數(shù)不正確時,輸出:"In put error!#in clude<stdio.h>main ()int s,m;prin tf("Please en ter score:");scan f("%d", &s);m=s<0|s>100?-1:

22、s/10;switch(m)二湄俅w9«(o 260 卜 LOe0 Indu&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相傳國際象棋是古印度舍罕王的宰相達依爾發(fā)明的。舍罕王十分喜歡象棋,決定讓宰相自己選擇何種賞賜。這位聰明的宰相指著8X 8

23、共64格的象棋盤說:陛下, 請您賞給我一些麥子吧,就在棋盤的第1個格子中放1粒,第2格中放2粒,第 3格中放4粒,以后每一格都比前一格增加一倍,依此放完棋盤上的64個格子,我就感恩不盡了。舍罕王讓人扛來一袋麥子,他要兌現(xiàn)他的許諾。請問:國王能 兌現(xiàn)他的許諾嗎?試編程計算舍罕王共要多少麥子賞賜他的宰相,這些麥子合多少立方米(已知1立方米麥子約1.42e8粒)?注:(1)不能使用指針、結(jié)構(gòu)體、共用體、文件、goto、枚舉類型進行編程。(2) 用標準C語言編程,所有變量必須在第一條可執(zhí)行語句前定義。(3) 輸入輸出格式要和以下給定格式完全一致。*輸入格式:無*輸出格式:"sum = %en

24、""volum = %en"%e表示double類型#in clude<stdio.h>#in clude<math.h> main ()int i;double 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從鍵盤任意輸入一個整數(shù)n,編程計算并輸出1

25、n之間的所有素數(shù)之和輸入提示信息:"In put n:"輸入格式:"%d"輸出格式:"sum = %dn"#in clude <stdio.h>#in clude <stdlib.h> int Fun (i nt m);main ()int n,i,s;s=0;printf("Input n:");scan f("%d", &n);for(i=2;i<=n;i+)if(Fun(i)=1)s=s+i;printf("sum = %dn",s

26、);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從鍵盤任意輸入一個整數(shù) m若m不是素數(shù),則對m進行質(zhì)因數(shù)分解,并將 m表 示為質(zhì)因數(shù)從小到大順序排列的乘積形式輸出,否則輸出"It is a primenumber"0例如,用戶輸入90時,程序輸出90 = 2 * 3 * 3 * 5 ;用戶輸入17 時,程序輸出"It is a

27、 prime number"。輸入提示信息:"In put m:"輸入格式:"%d"輸出格式:是素數(shù)時輸出"It is a prime number'n"否則輸出用"%d = " , "%d * "運行示例1:In put m:90 /90 = 2 * 3 * 3 * 5運行示例2:In put m:13 /It is a prime nu mber#in clude<stdio.h>int Fun (i nt m);int IsPerfect(int m);mai

28、n()int m,i,p;printf("Input m:");scanf("%d",&m);p=m;if(Fun(m)=1)printf("It is a prime numbern");elseprintf("%d = ",m);for(i=2;i<m;i+)if(p%IsPerfect(i)=0&&p/IsPerfect(i)!=1&&IsPerfect(i)!=1)printf("%d * ",i);else if(p%IsPerfect(i

29、)=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;int Fun(int m)int i, result;result = 1;if (m != 2)for (i = 2; i < m; i+)if (m % i = 0)result = 0;

30、 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章實驗任務5 如果一個正整數(shù)m的所有小于m的不同因子(包括1)加起來正好等于 m本身, 那么就被稱它為完全數(shù)。它是指這樣的一些特殊的自然數(shù),它所有的真因子(即 除了自

31、身以外的約數(shù))的和,恰好等于它本身。注意:1沒有真因子,所以不是完全數(shù)。例如,6就是一個完全數(shù),是因為6 = 1 + 2 + 3 o請編寫一個判斷完全數(shù)的函數(shù)lsPerfect(),然后判斷從鍵盤輸入的整數(shù)是否是 完全數(shù)。要求:按如下原型編寫判斷完全數(shù)的函數(shù),若函數(shù)返回0,則代表不是完全數(shù),若返回1則代表是完全數(shù)。int lsPerfect(i nt x);*要求輸入提示信息為:"Input m:n"*要求輸入格式為:"%d"*要求輸出格式為"%d is a perfect nu mber n""%d is not a pe

32、rfect nu mber n"注:不能使用指針、結(jié)構(gòu)體、共用體、文件、goto、枚舉類型進行編程,主函數(shù) 不能使用int main 和return 0。#in clude<stdio.h> 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 n

33、ot a perfect nu mber n", a);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。 分)編程從鍵盤輸入一個小寫英文字母,將其轉(zhuǎn)換為大寫英文 字母,并將轉(zhuǎn)換后的大寫英文字母及其十進制的ASCII碼值顯示到屏幕上。* 輸入提示信息 * : "Please in put a low-case l

34、etter from keyboard:"*輸入數(shù)據(jù)格式* :"%c"* 輸出數(shù)據(jù)格式 * : "The capital letter and its ASCII value are:%c and %d.II提示:從鍵盤輸入一個字符可用scanf也可用getchar#in clude<stdio.h> main ()char a;prin tf("Please in put a low-case letter from keyboard:");a = getchar();a = a - 32;printf("Th

35、e capital letter and its ASCII value are:%c and %d.", a, a);Q3241(10分)實驗三(2016春劉秉權(quán)C語言課):已知公式e = 1 + 1/1! + 1/2! + 1/3! + . +1/n!,編程計算e的近似值,直到最后一項的絕對值小于1e-7時為止,輸入e的值并統(tǒng)計累加的項數(shù)。要求:按順序輸出每一個e值, 小數(shù)點后保留8位有效數(shù)字,輸出格式形如:e = 2.66666667, count = 4 (回 車換行,count為累加的項數(shù))#in clude<stdio.h> double fun (i nt

36、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 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和自身的因子;否任意輸

37、入一個整數(shù)m若m不是素數(shù),則輸出其所有不包括 則輸出“沒有因子,是素數(shù)”的相關(guān)提示信息。輸入提示信息:"Please en ter a number:"輸入格式:"%d"輸出格式:有因子時:"%dn"無因子時:"It is a prime number.No divisor!'n"輸入為 1, 0,-1 時:"It is not a prime number.No divisor!n"#in clude<stdio.h>#in clude<math.h>int F

38、un (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;if (m !=

39、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:身高預測。每個做父母的都關(guān)心自己孩子成人后的身高, 據(jù)有關(guān)生理衛(wèi)生知識與數(shù)理統(tǒng)計分 析表明,影響小孩成人后的身高的因素包括遺傳、飲食習慣與體育鍛煉等。小孩成人后的身高與其父母的身高和自身的性別密切相關(guān)。設(shè)faHeight為其父身高,moHeight為其母身高,身高預測公式為男性成人時身高 =(faHeight + mo

40、Height) x 0.54 cm女性成人時身高 =(faHeight x 0.923 + moHeight) / 2 cm此外,如果喜愛體育鍛煉,那么可增加身高 2%如果有良好的衛(wèi)生飲食習慣, 那么可增加身高1.5%。請編程從鍵盤輸入用戶的性別(用字符型變量sex存儲,輸入字符F表示女性,輸入字符M表示男性)、父母身高(用實型變量存儲,faHeight為其父身高, moHeight為其母身高)、是否喜愛體育鍛煉(用字符型變量sports存儲,輸入字符丫表示喜愛,輸入字符N表示不喜愛)、是否有良好的飲食習慣等條件(用 字符型變量diet存儲,輸入字符丫表示良好,輸入字符N表示不好),利用給 定

41、公式和身高預測方法對身高進行預測。運行示例:Are you a boy(M) or a girl(F)?F /Please in put your father's height(cm):182/Please in put your mother's 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<stdio.h> main ()float fh, mh, h;

42、char sex, sports, diet;prin tf("Are you a boy(M) or a girl(F)?");sex = getchar();getchar();prin tf("Please in put your father's height(cm):");scan f("%f", &fh);getchar();printf("Please input your mother's height(cm):");scanf("%f", &mh

43、);getchar();printf("Do you like sports(Y/N)?");sports = getchar();getchar();printf("Do you have a good habit of 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

44、(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 future height will be %.0f(cm)n", h);R:return 0;Q3134(.(10分)第8章實

45、驗1:學生成績管理系統(tǒng)V1.0某班有最多不超過30人(具體人數(shù)由鍵盤輸入)參加某門課程的考試,用一維 數(shù)組作函數(shù)參數(shù)編程實現(xiàn)如下學生成績管理:(1)錄入每個學生的學號和考試成績;(2)計算課程的總分和平均分;(3)按成績由高到低排出名次表;(4)按學號由小到大排出成績表;(5)按學號查詢學生排名及其考試成績;(6)按優(yōu)秀(90100)、良好(8089)、中等(7079)、及格(6069)、不 及格(059) 5個類別,統(tǒng)計每個類別的人數(shù)以及所占的百分比;(7)輸出每個學生的學號、考試成績。程序運行結(jié)果示例:In put stude nt nu mber( n< 30):6/Man age

46、me 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/In put stude nt's ID, n ame and score:1100300

47、1 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 mber6.Statistic an alysis7.List record0.Exi

48、tPlease 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 recordO.ExitPlease In put your choic

49、e: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 5.Search by nu mber6.Statisti

50、c 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 order by score4.Sort in a

51、sce 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 nding order by score

52、4.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 course3.Sort

53、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 average scor

54、e 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 n

55、ding 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 )錄入學生的人數(shù):*輸入數(shù)據(jù)格式:"%d"*提示信息:"In put stude nt number( * 30):n"(2 )錄入每個學生的學號和考試成績:*輸入數(shù)據(jù)格式:"ld%f"提示信息:"

56、I nput stude nt's ID, n ame and score:n"輸出格式: 菜單項的輸出顯示: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

57、In put your choice:計算課程的總分和平均分:*輸出總分與平均分格式:"sum=%.0f,aver=%.2fn"按成績由高到低排出名次表:*輸出格式:"%ldt%.Ofn"*提示信息:"Sort in desce nding order by score: n"按學號由小到大排出成績表:*輸出格式:"%ldt%.Ofn"*提示信息:"Sort in asce nding order by nu mber:n"按學號查詢學生排名及其考試成績:*如果未查到此學號的學生,提示信息:&q

58、uot;Not foun d!n按優(yōu)秀(90100)、良好(8089)、中等(7079)、及格(6069)、不及格(059) 5個類別,統(tǒng)計每個類別的人數(shù)以及所占的百分比:*成績 <60 輸出格式:"<60t%dt%.2f%n"*成績=100 輸出格式:"%dt%dt%.2f%n"*其他輸出百分比格式:"%d-%dt%dt%.2f%n"#in clude<stdio.h>#in clude<stdlib.h>#defi ne N 30 main ()int n ,i,j,temp1,temp2,ch

59、oice,p,mark;long ids;float sum;printf("Input student number(n<30):n");while(sca nf("%d", &n)if(n<30&&n>0)break;elseprintf("Invalid Input!");continue;long idN;float scoreN;Choice:printf("Management for Students' scoresn");printf("1

60、.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.L

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論