C語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)_第1頁
C語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)_第2頁
C語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)_第3頁
C語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)_第4頁
C語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)_第5頁
已閱讀5頁,還剩23頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、-作者xxxx-日期xxxxC語言課程設計(數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計)【精品文檔】課程設計任務書學 院信息科學與工程專 業(yè)通信工程學 生 姓 名Neko學 號10030603*設 計 題 目C語言課程設計內容及要求:加深對C語言基礎知識的掌握,使用C語言編程實現(xiàn)以下題目的設計。題目名稱: 數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計內容及要求:1、編寫一個程序,將某個位數(shù)不確定的正整數(shù)進行三位分節(jié)后輸出,比如輸入87654321,應輸出87,654,3212、編寫函數(shù)fun(char a,int k,int n),其功能是:刪除字符串中指定下標開始的n個字符,形參中,a數(shù)組中存

2、放字符串,k中存放指定下標。例如,若輸入字符串為:Helloloa World!,k的值是5,n的值是3。應輸出:Hello World!3、學生成績統(tǒng)計程序設計設計結構體數(shù)組,結構中包含學生數(shù)據(jù)為:學號、姓名、物理分數(shù)、數(shù)學分數(shù)、外語分數(shù)、計算機分數(shù)。設計各個函數(shù),分別實現(xiàn)以下功能:(1)輸入學生數(shù)據(jù) (2)顯示所有學生信息 (3)統(tǒng)計每科的最高分、最低分;不及格人數(shù)、不及格學生的數(shù)據(jù)。設計菜單,通過選擇菜單調用以上各函數(shù)。軟件開發(fā)環(huán)境Wi進度安排:第18周:C語言基礎知識練習第18周:算法設計第19周:編寫程序代碼與程序調試第19周:答辯、驗收程序指導教師(簽字):年 月 日學院院長(簽字

3、):年 月 日【精品文檔】目 錄一、題目要求1二、算法設計2三、編程實現(xiàn)12四、結果分析19五、參考文獻24一、題目要求題目名稱: 數(shù)據(jù)分節(jié)與刪除字符、學生成績統(tǒng)計程序的設計內容:1、編寫一個程序,將某個位數(shù)不確定的正整數(shù)進行三位分節(jié)后輸出,比如輸入87654321,應輸出87,654,3212、編寫函數(shù)fun(char a,int k,int n),其功能是:刪除字符串中指定下標開始的n個字符,形參中,a數(shù)組中存放字符串,k中存放指定下標。例如,若輸入字符串為:Helloloa World!,k的值是5,n的值是3。應輸出:Hello World!3、學生成績統(tǒng)計程序設計設計結構體數(shù)組,結構

4、中包含學生數(shù)據(jù)為:學號、姓名、物理分數(shù)、數(shù)學分數(shù)、外語分數(shù)、計算機分數(shù)。設計各個函數(shù),分別實現(xiàn)以下功能:(1)輸入學生數(shù)據(jù) (2)顯示所有學生信息 (3)統(tǒng)計每科的最高分、最低分;不及格人數(shù)、不及格學生的數(shù)據(jù)。設計菜單,通過選擇菜單調用以上各函數(shù)。要求:使用C語言完成上述程序的設計、編程和調試、 WinTC或等。二、算法設計1.計算不確定位數(shù)正整數(shù)的位數(shù),按照每三位為一節(jié)計算節(jié)數(shù)用于計算循環(huán)次數(shù),計算并分配內存空間將其儲存并逆序輸出 是輸入ai=1,temp=a,b=temp/10b0i=i+1,temp=b,b=temp/10i%3=0*p = (int *)malloc(c*sizeof(

5、int),j=0jcc=i/3c=i/3+1j=j+1,d=a%1000,pc-j-1=d,a=a/1000開始否是否是否1j=0jcjc-1輸出,pj輸出pj結束是j=j+1否12、編寫函數(shù)fun(char a,int k,int n) a中存放字符串 k為指定下標,n為刪除字符串的長度,利用循環(huán)按照要求依次刪除開始輸出input string:輸入a輸出input k,n:調用fun()結束輸入k,n開始istrlen(a)-ni=kai=ai+nai=0輸出a是否結束i=i+13、學生成績統(tǒng)計程序設計設計結構體數(shù)組,結構中包含學生數(shù)據(jù)為:學號、姓名、物理分數(shù)、數(shù)學分數(shù)、外語分數(shù)、計算機分

6、數(shù)。設計各個函數(shù),分別實現(xiàn)以下功能:(1)錄入:輸入學生數(shù)據(jù) (2)顯示:所有學生信息 (3)統(tǒng)計:統(tǒng)計每科的最高分、最低分;輸出不及格人數(shù)、不及格學生的數(shù)據(jù)。設計菜單,通過選擇菜單調用以上各函數(shù)。開始system(cls)輸出tt*Students Grade Management System*ntt | 1. 輸入 |ntt | 2. 顯示|ntt | 3. 統(tǒng)計 |n tt | 0. 退出 |n tt*ntttGive your Choice(0-3):輸入cc3return(c-0)結束是否menu_select()開始i=0signn且signN輸出ttt學號:輸出ttt姓名:輸出

7、ttt計算機分數(shù):輸入studn+i.num輸出ttt外語分數(shù):輸入輸入studn+輸出ttt物理分數(shù):輸入輸入輸入輸入gets(x)輸出tttany more records?(Y/N)輸入sign輸出ttt數(shù)學分數(shù):i=i+1return(n+i)結束1122是否33input(Student stud,int n)開始輸出ttt-n輸出ttnumber name Phy Math Fore Compn輸出ttt-ni1且i%10=0輸出ttt-n輸出tttsystem(pause)輸出ttt-n輸出tttsystem(pause)結束是否是否i=i+111223344disp

8、lay(Student stud,int n)statistic(Student stud,int n)開始i=0sum=0Physics_high = 0Mathematics_high = 0ForeignLanguage_high =0Computer_high = 0Physics_low = 0Mathematics_low = 0ForeignLanguage_low = 0Computer_low = 0in11是否Physics_high = iPhysics_low=i是否是否studi.m_Score.Physics 60輸出Mathematics_high = i是否是否

9、2892Mathematics_low=istudi.m_Score.Mathematics 60輸出是否是否33ForeignLanguage_high = i是否44ForeignLanguage_low=i是否studi.m_Score.ForeignLanguage 60是否56statistic(Student stud,int n)輸出56Computer_high = iComputer_low=i是否是否77studi.m_Score.Computer 60是否i=i+18statistic(Student stud,int n)statistic(Student stud,i

10、nt n)輸出tttthe Physics hignest score:ntttthe Mathematics hignest score:ntttthe Foreign Language hignest score:ntttthe Computer hignest score:nnntttthe Physics lowest score:ntttthe Mathematics lowest score:ntttthe Foreign Language lowest score:ntttthe Computer lowest score:n9結束開始n=0menu_select()=1menu

11、_select()=2menu_select()=3menu_select()=0輸出tttInput RecordsntttStatisticn輸出tttDisplay All Recordsn輸出tttn=Input(stu,n) breakDisplay(stu,n) breakStatistic(stu,n)system(pause) exit(0)輸出tttsystem(pause) break輸出tttHave a Good Luck,Bye-bye!n結束是否是否是否是否是否main()三、編程實現(xiàn)程序的具體C語言代碼如下:第1題:#include#include int mai

12、n()int a;scanf(%d,&a);int i=1,b;int temp =a; b = temp/10; while(b) i+; temp = b; b = temp/10; int c=(i%3=0)?i/3:(i/3+1);int *p = (int *)malloc(c*sizeof(int);int j,d; for(j=0;jc;j+) d=a%1000; pc-j-1 = d; a=a/1000; for(j=0;jc;j+) if(j !=c-1)printf(%d,pj); else printf(%d,pj); getchar(); getchar(); 第2題:

13、#include#includevoid fun(char a,int k,int n);main() char a80; int k; int n; printf(input string:n); gets(a); printf(input k,n:n); scanf(%d,%d,&k,&n); fun(a,k, n); return 0;void fun(char a,int k,int n) int i; for(i=k;istrlen(a)-n;i+) ai=ai+n; ai=0; puts(a);第3題:#include /*引用庫函數(shù)*/ #include #include #in

14、clude typedef structint Physics;/*物理成績*/int Mathematics;/*數(shù)學成績*/int ForeignLanguage;/*外語成績*/int Computer;/*計算機成績*/Score;typedef struct /*定義結構體數(shù)組*/ char num10; /*學號*/ char name20; /*姓名*/ /int score; /*成績*/ Score m_Score;Student; Student stu80; /*結構體數(shù)組變量*/ int menu_select() /*菜單函數(shù)*/ char c; do system(

15、cls); /*運行前清屏*/ printf(tt*Students Grade Management System*n); /*菜單選擇*/ printf(tt | 1. 輸入 |n); printf(tt | 2. 顯示|n); printf(tt | 3. 統(tǒng)計 |n); printf(tt | 0. 退出 |n); printf(tt*n); printf(tttGive your Choice(0-3):); c=getchar(); /*讀入選擇*/ while(c3); return(c-0); /*返回選擇*/ int Input(Student stud,int n) /*輸

16、入若干條記錄*/ int i=0; char sign,x10; /*x10為清除多余的數(shù)據(jù)所用*/ while(sign != n & sign != N) /*判斷*/ printf(ttt學號:); /*交互輸入*/ scanf(ttt%s,studn+i.num); printf(ttt姓名:); scanf(ttt%s,studn+); printf(ttt物理分數(shù):); scanf(ttt%d,&studn+i.m_Score.Physics);printf(ttt數(shù)學分數(shù):); scanf(ttt%d,&studn+i.m_Score.Mathematics); pr

17、intf(ttt外語分數(shù):); scanf(ttt%d,&studn+i.m_Score.ForeignLanguage); printf(ttt計算機分數(shù):);scanf(ttt%d,&studn+i.m_Score.Computer); gets(x); /*清除多余的輸入*/ printf(tttany more records?(Y/N); scanf(ttt%c,&sign); /*輸入判斷*/ i+; return(n+i); void Display(Student stud,int n) /*顯示所有記錄*/ int i; printf(ttt-n); /*格式頭*/ prin

18、tf(ttnumber name Phy Math Fore Compn); printf(ttt-n); for(i=1;i1&i%10=0) /*每十個暫停*/ printf(ttt-n); /*格式*/ printf(ttt); system(pause); printf(ttt-n); printf(ttt); system(pause); void Statistic(Student stud,int n) /*新增功能,輸出統(tǒng)計信息*/ int i,sum=0;int Physics_high = 0;/*物理成績*/int Mathematics_high = 0;/*數(shù)學成績*

19、/int ForeignLanguage_high = 0;/*外語成績*/int Computer_high = 0;/*計算機成績*/int Physics_low = 0;/*物理成績*/int Mathematics_low = 0;/*數(shù)學成績*/int ForeignLanguage_low = 0;/*外語成績*/int Computer_low = 0;/*計算機成績*/for(i=0;in;i+) /*循環(huán)輸入判斷*/ /*物理最高和最低分的判斷*/if(studPhysics_high.m_Score.Physics studi.m_Score.Physics)Physic

20、s_high = i;sics)Physics_low=i;/*不及格科目*/if(studi.m_Score.Physics 60)printf(ttt%-16s%-15s%d Phyn,studi.num,,studi.m_Score.Physics);/*數(shù)學最高和最低分的判斷*/if(studMathematics_high.m_Score.Mathematics studi.m_Score.Mathematics)Mathematics_low=i;/*不及格科目*/if(studi.m_Score.Mathematics 60)printf(ttt%-16s%-

21、15s%d Mathn,studi.num,,studi.m_Score.Mathematics);/*外語最高和最低分的判斷*/if(studForeignLanguage_high.m_Score.ForeignLanguage studi.m_Score.ForeignLanguage)ForeignLanguage_low=i;/*不及格科目*/if(studi.m_Score.ForeignLanguage 60)printf(ttt%-16s%-15s%d Foren,studi.num,,studi.m_Score.ForeignLangu

22、age);/*計算機最高和最低分的判斷*/if(studComputer_high.m_Score.Computer studi.m_Score.Computer)Computer_low=i;/*不及格科目*/if(studi.m_Score.Computer 60)printf(ttt%-16s%-15s%d Compn,studi.num,,studi.m_Score.Computer);printf(tttthere are %d records.n,n*4); /*總共記錄數(shù)*/ printf(tttthe Physics hignest score:n); /*

23、物理最高分*/ printf(tttnumber:%s name:%s score:%dn,studPhysics_high.num,studPhysics_,studPhysics_high.m_Score.Physics); printf(tttthe Mathematics hignest score:n); /*數(shù)學最高分*/ printf(tttnumber:%s name:%s score:%dn,studMathematics_high.num,studMathematics_,studMathematics_high.m_Score.Math

24、ematics); printf(tttthe Foreign Language hignest score:n); /*外語最高分*/ printf(tttnumber:%s name:%s score:%dn,studForeignLanguage_high.num,studForeignLanguage_,studForeignLanguage_high.m_Score.ForeignLanguage); printf(tttthe Computer hignest score:n); /*計算機最高分*/ printf(tttnumber:%s name:%s sco

25、re:%dn,studComputer_high.num,studComputer_,studComputer_high.m_Score.Computer); printf(nn);printf(tttthe Physics lowest score:n); /*物理最低分*/ printf(tttnumber:%s name:%s score:%dn,studPhysics_low.num,studPhysics_,studPhysics_low.m_Score.Physics);printf(tttthe Mathematics lowest score:

26、n); /*數(shù)學最低分*/ printf(tttnumber:%s name:%s score:%dn,studMathematics_low.num,studMathematics_,studMathematics_low.m_Score.Mathematics);printf(tttthe Foreign Language lowest score:n); /*外語最低分*/ printf(tttnumber:%s name:%s score:%dn,studForeignLanguage_low.num,studForeignLanguage_,studForeignLan

溫馨提示

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

評論

0/150

提交評論