C语言课程设计数据分节与删除字符学生成绩统计程序的设计_第1页
C语言课程设计数据分节与删除字符学生成绩统计程序的设计_第2页
C语言课程设计数据分节与删除字符学生成绩统计程序的设计_第3页
C语言课程设计数据分节与删除字符学生成绩统计程序的设计_第4页
C语言课程设计数据分节与删除字符学生成绩统计程序的设计_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、课程设计任务书学 院信息科学与工程专 业通信工程学 生 姓 名Neko学 号10030603*设 计 题 目C语言课程设计内容及要求:加深对C语言基础知识的掌握,使用C语言编程实现以下题目的设计。题目名称: 数据分节与删除字符、学生成绩统计程序的设计内容及要求:1、编写一个程序,将某个位数不确定的正整数进行三位分节后输出,比如输入87654321,应输出87,654,3212、编写函数fun(char a,int k,int n),其功能是:删除字符串中指定下标开始的n个字符,形参中,a数组中存放字符串,k中存放指定下标。例如,若输入字符串为:Helloloa World!,k的值是5,n的值

2、是3。应输出:Hello World!3、学生成绩统计程序设计设计结构体数组,结构中包含学生数据为:学号、姓名、物理分数、数学分数、外语分数、计算机分数。设计各个函数,分别实现以下功能:(1)输入学生数据 (2)显示所有学生信息 (3)统计每科的最高分、最低分;不及格人数、不及格学生的数据。设计菜单,通过选择菜单调用以上各函数。软件开发环境Windows XP,TC2.0或Visual C+ 6.0进度安排:第18周:C语言基础知识练习第18周:算法设计第19周:编写程序代码与程序调试第19周:答辩、验收程序指导教师(签字):年 月 日学院院长(签字):年 月 日目 录一、题目要求1二、算法设

3、计2三、编程实现12四、结果分析19五、参考文献24一、题目要求题目名称: 数据分节与删除字符、学生成绩统计程序的设计内容:1、编写一个程序,将某个位数不确定的正整数进行三位分节后输出,比如输入87654321,应输出87,654,3212、编写函数fun(char a,int k,int n),其功能是:删除字符串中指定下标开始的n个字符,形参中,a数组中存放字符串,k中存放指定下标。例如,若输入字符串为:Helloloa World!,k的值是5,n的值是3。应输出:Hello World!3、学生成绩统计程序设计设计结构体数组,结构中包含学生数据为:学号、姓名、物理分数、数学分数、外语分

4、数、计算机分数。设计各个函数,分别实现以下功能:(1)输入学生数据 (2)显示所有学生信息 (3)统计每科的最高分、最低分;不及格人数、不及格学生的数据。设计菜单,通过选择菜单调用以上各函数。要求:使用C语言完成上述程序的设计、编程和调试,开发环境可采用Turbo C 2.0、 WinTC或Visual C+ 6.0等。二、算法设计1.计算不确定位数正整数的位数,按照每三位为一节计算节数用于计算循环次数,计算并分配内存空间将其储存并逆序输出 是输入ai=1,temp=a,b=temp/10b0i=i+1,temp=b,b=temp/10i%3=0*p = (int *)malloc(c*siz

5、eof(int),j=0j<cc=i/3c=i/3+1j=j+1,d=a%1000,pc-j-1=d,a=a/1000开始否是否是否1j=0j<cjc-1输出,pj输出pj结束是j=j+1否12、编写函数fun(char a,int k,int n) a中存放字符串 k为指定下标,n为删除字符串的长度,利用循环按照要求依次删除开始输出input string:输入a输出input k,n:调用fun()结束输入k,n开始i<strlen(a)-ni=kai=ai+nai=0输出a是否结束i=i+13、学生成绩统计程序设计设计结构体数组,结构中包含学生数据为:学号、姓名、物理分

6、数、数学分数、外语分数、计算机分数。设计各个函数,分别实现以下功能:(1)录入:输入学生数据 (2)显示:所有学生信息 (3)统计:统计每科的最高分、最低分;输出不及格人数、不及格学生的数据。设计菜单,通过选择菜单调用以上各函数。开始system("cls")输出tt*Students' Grade Management System*ntt | 1. 输入 |ntt | 2. 显示|ntt | 3. 统计 |n tt | 0. 退出 |n tt*ntttGive your Choice(0-3):输入cc<'0'或c>'3

7、9;return(c-'0')结束是否menu_select()开始i=0signn且signN输出ttt学号:输出ttt姓名:输出ttt计算机分数:输入studn+i.num输出ttt外语分数:输入studn+i.m_Score.Mathematics输入studn+输出ttt物理分数:输入studn+i.m_Score.Computer输入studn+i.m_Score.ForeignLanguage输入studn+i.m_Score.Physics输入gets(x)输出tttany more records?(Y/N)输入sign输出ttt数学分数:i=i+1

8、return(n+i)结束1122是否33input(Student stud,int n)开始输出ttt-n输出ttnumber name Phy Math Fore Compn输出ttt-ni<n+1输出studi-1.num,,studi-1.m_Score.Physics,studi-1.m_Score.Mathematics,studi-1.m_Score.ForeignLanguage,studi-1.m_Score.Computeri=1i>1且i%10=0输出ttt-n输出tttsystem("pause")输出ttt-n

9、输出tttsystem("pause")结束是否是否i=i+111223344display(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 = 0i<n11是否studPhysics_high.m_Score.P

10、hysics < studi.m_Score.PhysicsPhysics_high = istudPhysics_low.m_Score.Physics > studi.m_Score.PhysicsPhysics_low=i是否是否studi.m_Score.Physics < 60输出studi.num,,studi.m_Score.PhysicsstudMathematics_high.m_Score.Mathematics < studi.m_Score.MathematicsMathematics_high = i是否是否2892stud

11、Mathematics_low.m_Score.Mathematics > studi.m_Score.MathematicsMathematics_low=istudi.m_Score.Mathematics < 60输出studi.num,,studi.m_Score.MathematicsstudForeignLanguage_high.m_Score.ForeignLanguage < studi.m_Score.ForeignLanguage是否是否33ForeignLanguage_high = i是否44studForeignLanguage

12、_low.m_Score.ForeignLanguage > studi.m_Score.ForeignLanguageForeignLanguage_low=i是否studi.m_Score.ForeignLanguage < 60是否56statistic(Student stud,int n)输出studi.num,,studi.m_Score.ForeignLanguage56studComputer_high.m_Score.Computer < studi.m_Score.ComputerComputer_high = istudCompute

13、r_low.m_Score.Computer > studi.m_Score.ComputerComputer_low=i是否是否77studi.m_Score.Computer < 60studi.num,,studi.m_Score.Physics是否i=i+18statistic(Student stud,int n)statistic(Student stud,int n)输出tttthe Physics hignest score:nstudPhysics_high.num,studPhysics_,studPhysics_high.

14、m_Score.Physicstttthe Mathematics hignest score:nstudMathematics_high.num,studMathematics_,studMathematics_high.m_Score.Mathematicstttthe Foreign Language hignest score:nstudForeignLanguage_high.num,studForeignLanguage_,studForeignLanguage_high.m_Score.ForeignLanguagetttthe Compute

15、r hignest score:nstudComputer_high.num,studComputer_,studComputer_high.m_Score.Computernntttthe Physics lowest score:nstudPhysics_low.num,studPhysics_,studPhysics_low.m_Score.Physicstttthe Mathematics lowest score:nstudMathematics_low.num,studMathematics_,studMathematics_low

16、.m_Score.Mathematicstttthe Foreign Language lowest score:nstudForeignLanguage_low.num,studForeignLanguage_,studForeignLanguage_low.m_Score.ForeignLanguagetttthe Computer lowest score:nstudComputer_low.num,studComputer_,studComputer_low.m_Score.Computer9结束开始n=0menu_select()=1menu_sele

17、ct()=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()三、编程实现程序的具体C语言代码如下:第1题:#incl

18、ude<stdio.h>#include<malloc.h> int main()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;j<c;j+) d=a%1000; pc-j-1 = d; a=a/1000; for(j=0;j<c;j+

19、) if(j !=c-1)printf("%d,",pj); else printf("%d",pj); getchar(); getchar(); 第2题:#include<stdio.h>#include<string.h>void 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,%

20、d",&k,&n); fun(a,k, n); return 0;void fun(char a,int k,int n) int i; for(i=k;i<strlen(a)-n;i+) ai=ai+n; ai='0' puts(a);第3题:#include<stdio.h> /*引用库函数*/ #include<stdlib.h> #include<ctype.h> #include<string.h> typedef structint Physics;/*物理成绩*/int Mathema

21、tics;/*数学成绩*/int ForeignLanguage;/*外语成绩*/int Computer;/*计算机成绩*/Score;typedef struct /*定义结构体数组*/ char num10; /*学号*/ char name20; /*姓名*/ /int score; /*成绩*/ Score m_Score;Student; Student stu80; /*结构体数组变量*/ int menu_select() /*菜单函数*/ char c; do system("cls"); /*运行前清屏*/ printf("tt*Student

22、s' Grade Management System*n"); /*菜单选择*/ printf("tt | 1. 输入 |n"); printf("tt | 2. 显示|n"); printf("tt | 3. 统计 |n"); printf("tt | 0. 退出 |n"); printf("tt*n"); printf("tttGive your Choice(0-3):"); c=getchar(); /*读入选择*/ while(c<'

23、0'|c>'3'); return(c-'0'); /*返回选择*/ int Input(Student stud,int n) /*输入若干条记录*/ int i=0; char sign,x10; /*x10为清除多余的数据所用*/ while(sign != 'n' && sign != 'N') /*判断*/ printf("ttt学号:"); /*交互输入*/ scanf("ttt%s",studn+i.num); printf("ttt姓名

24、:"); scanf("ttt%s",studn+); printf("ttt物理分数:"); scanf("ttt%d",&studn+i.m_Score.Physics);printf("ttt数学分数:"); scanf("ttt%d",&studn+i.m_Score.Mathematics); printf("ttt外语分数:"); scanf("ttt%d",&studn+i.m_Score.For

25、eignLanguage); printf("ttt计算机分数:");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

26、"); /*格式头*/ printf("ttnumber name Phy Math Fore Compn"); printf("ttt-n"); for(i=1;i<n+1;i+) /*循环输入*/ printf("tt%-8s%-8s%dt%dt%dt%dn",studi-1.num,,studi-1.m_Score.Physics,studi-1.m_Score.Mathematics,studi-1.m_Score.ForeignLanguage,studi-1.m_Score.Comp

27、uter); if(i>1&&i%10=0) /*每十个暂停*/ printf("ttt-n"); /*格式*/ printf("ttt"); system("pause"); printf("ttt-n"); printf("ttt"); system("pause"); void Statistic(Student stud,int n) /*新增功能,输出统计信息*/ int i,sum=0;int Physics_high = 0;/*物理成绩*

28、/int Mathematics_high = 0;/*数学成绩*/int ForeignLanguage_high = 0;/*外语成绩*/int Computer_high = 0;/*计算机成绩*/int Physics_low = 0;/*物理成绩*/int Mathematics_low = 0;/*数学成绩*/int ForeignLanguage_low = 0;/*外语成绩*/int Computer_low = 0;/*计算机成绩*/for(i=0;i<n;i+) /*循环输入判断*/ /*物理最高和最低分的判断*/if(studPhysics_high.m_Score

29、.Physics < studi.m_Score.Physics)Physics_high = i;if(studPhysics_low.m_Score.Physics > studi.m_Score.Physics)Physics_low=i;/*不及格科目*/if(studi.m_Score.Physics < 60)printf("ttt%-16s%-15s%d Phyn",studi.num,,studi.m_Score.Physics);/*数学最高和最低分的判断*/if(studMathematics_high.m_Scor

30、e.Mathematics < studi.m_Score.Mathematics)Mathematics_high = i;if(studMathematics_low.m_Score.Mathematics > studi.m_Score.Mathematics)Mathematics_low=i;/*不及格科目*/if(studi.m_Score.Mathematics < 60)printf("ttt%-16s%-15s%d Mathn",studi.num,,studi.m_Score.Mathematics);/*外语最高和

31、最低分的判断*/if(studForeignLanguage_high.m_Score.ForeignLanguage < studi.m_Score.ForeignLanguage)ForeignLanguage_high = i;if(studForeignLanguage_low.m_Score.ForeignLanguage > studi.m_Score.ForeignLanguage)ForeignLanguage_low=i;/*不及格科目*/if(studi.m_Score.ForeignLanguage < 60)printf("ttt%-16s%

32、-15s%d Foren",studi.num,,studi.m_Score.ForeignLanguage);/*计算机最高和最低分的判断*/if(studComputer_high.m_Score.Computer < studi.m_Score.Computer)Computer_high = i;if(studComputer_low.m_Score.Computer > studi.m_Score.Computer)Computer_low=i;/*不及格科目*/if(studi.m_Score.Computer < 60)printf

33、("ttt%-16s%-15s%d Compn",studi.num,,studi.m_Score.Computer);printf("tttthere are %d records.n",n*4); /*总共记录数*/ printf("tttthe Physics hignest score:n"); /*物理最高分*/ printf("tttnumber:%s name:%s score:%dn",studPhysics_high.num,studPhysics_,stud

34、Physics_high.m_Score.Physics); printf("tttthe Mathematics hignest score:n"); /*数学最高分*/ printf("tttnumber:%s name:%s score:%dn",studMathematics_high.num,studMathematics_,studMathematics_high.m_Score.Mathematics); printf("tttthe Foreign Language hignest score:n")

35、; /*外语最高分*/ 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 score:%dn",studComputer_h

36、igh.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:n"); /*数学最低分*/ printf("tttnumber:%s name:%s score:%dn",studMathematics_low.num,studMathematics_,stud

温馨提示

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

评论

0/150

提交评论