欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOC文档下载  

    [计算机]C语言课程设计.doc

    • 资源ID:4561004       资源大小:150KB        全文页数:25页
    • 资源格式: DOC        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    [计算机]C语言课程设计.doc

    1.电子档案.包括源代码.参考文献资料. 程序设计报告(Word文档。要求5页)2.纸质档案.把电子的打印出来.+封面. 封面(题目.班级.姓名.学号.指导老师.完成时间.) C语言课程设计题目一:选票系统某班从全班20人(学号120)中投票选举6位班委委员,每张选票内容包括:所选班委的学号,投票人学号。要求用菜单选择并完成下述系统功能:1:输入全班的名单(姓名与学号),并可显示。 2:选票输入:输入每张选票的投票人学号及所选班委的学号(可选6个,没有则键入空白)。 3:输出得票前6位的当选班委名单(如第6位有多位得票数相等,则从中任选一位输出)及其得票率(得票数总选票数) 4:可以输出6位班委名单全部选择与投票结果完全相符的投票人姓名。 5:退出程序。 示例程序源代码:示例一:#include <stdio.h>#include <stdlib.h>struct student int xh; /学号 char xm10; /姓名 int flag; /已投票数 int flag_p; /被票数 int xp_xh6; /被选人学号 stu20; /函数功能:录入学生信息 void lr() int i; for(i=0;i<=20;i+) printf("学号:%dn",i); printf("请输入姓名:"); stui.xh=(i+1); scanf("%c",&stui.xm); stui.flag=0; stui.flag_p=0; stui.xp_xh6=0; printf("n"); printf("继续输入? "); system("pause"); system("cls"); printf("学号t"); printf("姓名t"); printf("票数n"); for(i=0;i<=20;i+) printf("%dt",stui.xh); printf("%ct",&stui.xm); printf("%d",stui.flag_p); /函数功能:投票,对数据进行操作 ,输出结果 void tp(int tpr,int tp)int q=0;if (stutpr-1.flag<6) if (tpr>20 | tpr<0) printf("输入有误!n"); system("pause"); else q = stutpr-1.flag; stutpr-1.xp_xhq=(tp-1); stutpr-1.flag+; stutp-1.flag_p+; else printf("您已经投了6票!"); system("cls"); printf("投票结果:t"); printf("学号t姓名t票数t投票数n"); for (int k=0;k<=20;k+) printf("%dt%ct%dt%d",stuk.xh,&stuk.xm,stuk.flag_p,stuk.flag); system("/npause"); exit(1); int mian() int xh_tpr; /投票人学号 int xh_tp; /被投票人学号 lr(); start: printf("请输入你的学号:"); scanf("%d",&xh_tpr); printf("n请输入你要投票人的学号:"); scanf("%d",&xh_tp); tp(xh_tpr,xh_tp); goto start; 示例二:#include <stdio.h>#include <stdlib.h>typedef struct node / 候选人结构char name8;int num;int score;int tax;Node;void shellSort( Node *, int );int main(void)int n = 0;Node * pArray9=;/指针数组,长度9int count = 0;/int status = 1;int vote = -1;printf("Input the number of the candidates(1-9):n");scanf("%d", &n);while(getchar()!='n');while (n>9 | n<1)if (n>9)printf("No, there cannot be so many candidates. Retry.n");elseprintf("No candidates? It cannot be! Retry!n");scanf("%d", &n);while(getchar()!='n') ;for (count=0; count<n; count+)pArraycount = (Node *)malloc(sizeof(Node);pArraycount->num = count+1;pArraycount->tax = 0;pArraycount->score = 0;printf("Input No.%d candidate's name:n", count+1);gets(pArraycount->name);while (vote)printf("Now, let us vote:n*n");for (count=0; count<n; count+)printf("%d. %sn", count+1, pArraycount->name);printf("0.quitn*n");scanf("%d", &vote);while(getchar()!='n') ;while (vote<0 | vote>n)printf("No joke, thank you. Revote.n");scanf("%d", &vote);while(getchar()!='n') ;if (vote>0&&vote<=n)pArrayvote-1->score+;printf("Finish voting. Let's find the winner.nn");shellSort( pArray, n );for (count=0; count<n; count+)pArraycount->tax=count+1;printf("%d. %s %d votes.n", count+1, pArraycount->name, pArraycount->score);for(count=0; count<n; count+)free(pArraycount);pArraycount = NULL;return 0;void shellSort( Node *p, int len )const int Length = len;int i = 0;int j = 0;int gap = 0;Node *temp = NULL;gap = Length/2;while (gap>0)for (i=gap; i<Length; i+)j = i - gap;temp = *(p+i);while ( (j>=0) && (pj->score < temp->score) )*(p+j+gap) = *(p+j);j = j - gap;*(p+j+gap) = temp;gap /= 2;运行与输入方式:1.程序提示,输入候选人人数, 输入数字(1-9),大于9或小于1或者输入不合法字符会提示错误。2.程序提示依次输入候选人名字,不能超过7个字符(少了点,你题目给的,数组拉长点会更安全些)3.按照程序提示的数字开始投票,或者退出。4.投票过程结束后,程序调用shellSort(希尔排序)函数对所有参选人按照得票数目进行降序排序,并将排序结果输出。题目二:简单学生成绩管理系统从键盘输入一个班学生(小于30人)的数学、英语、计算机三门课程的成绩,并保存到文件中,要求:计算出每位学生的平均成绩和总成绩(每位学生的学号不能重复)。:按总成绩从高到低排序。:输人的学号、姓名、总成绩和排名次序。(思考:如何增加一位学生资料?如何删除一位学生资料?)知识点包括:分支语句、循环语句、结构体、文件打开关闭、输入输出函数、排序算法等。 示例程序一:#include "stdio.h"#include "stddef.h"#include "stdlib.h"#include "conio.h" /*屏幕操作函数*/#include "string.h"#define MAX 10typedef struct student char nameMAX; char numMAX; char sexMAX; int age; int chinese; int mathematic; int english; float aver; struct student *next; stu;stu *head;void print() /*输出菜单*/ textcolor(RED); /*设置文本显示颜色为红色*/ textbackground(GREEN); /*设置背景颜色为绿色*/ window(1,1,80,10); /* 制作显示菜单的窗口*/ clrscr();printf(" n");printf(" * welcome to use student manage *n");printf(" * MENU *n");printf(" * <1>Enter Record "); /*录入信息*/printf(" <2>Statistics *n"); /*显示成绩*/printf(" * <3>Quest "); /*查询*/printf(" <4>Updata *n"); /*修改*/printf(" * <5>Save "); /*保存到磁盘*/printf("<6>Display *n"); /*统计成绩*/printf(" * <7>Fresh "); /*刷新*/printf("<8>Quit *n"); /*退出系统*/printf(" $ Maker: zhangwantong Class:045 Date:2007.01.12 $n");printf(" n");void cin(stu *p1) /*录入学生信息 */ printf("Enter name:n"); scanf("%s",p1->name); printf("Enter num:n"); scanf("%s",p1->num); printf("Enter sex:n"); scanf("%s",&p1->sex); printf("Enter age:n"); scanf("%d",&p1->age); printf("Enter score:n"); printf("Enter chinese:n"); scanf("%d",&p1->chinese); printf("Enter math:n"); scanf("%d",&p1->mathematic); printf("Enter English:n"); scanf("%d",&p1->english);p1->aver=(p1->chinese+p1->mathematic+p1->english)/3.0; /*平均分*/ void cindata() /*是否继续录入*/ stu *p1,*p2; int i=1; char ch; head=(stu *)malloc(sizeof(stu); p1=head; /*头指针*/ while(i) cin(p1); printf("Do you Want to Continue?yes or no:"); ch=getchar(); ch=getchar(); if(ch='n'|ch='N') i=0; p1->next=NULL; else p2=p1; p1=(stu *)malloc(sizeof(stu); p2->next=p1; void lookdata(stu *p1) /*输出所有信息*/ printf("-n"); while(p1!=NULL) printf("Num:%s ",p1->num); printf("Name:%s ",p1->name); printf("Sex:%s ",p1->sex); printf("Age:%d ",p1->age); /* printf("n"); */ printf("Chinese:%d ",p1->chinese); printf("Math:%d ",p1->mathematic); printf("English:%d ",p1->english); printf("Average:%fn",p1->aver); printf("-n"); p1=p1->next; printf("-n"); /*已经完成的任务:1.录入保存磁盘2.按姓名学号查询3.输出成绩表4.修改处理5.统计学生成绩*/void find1(stu *p2) /* 按姓名查找信息 */ char name20; int b=0; printf("Enter the name of the student you want to find:"); scanf("%s",name); while(p2!=NULL) if(strcmp(name,p2->name)=0) printf("The data you want has be foundn"); printf("-n"); printf("Num:%st",p2->num); printf(" Name:%st",p2->name); printf("sex:%st",p2->sex); printf("age:%dt",p2->age); printf("n"); printf("Chinese:%dt",p2->chinese); printf("Math:%dt",p2->mathematic); printf("English:%dt",p2->english); printf("Average:%fn",p2->aver); printf("*n"); b=1; p2=p2->next; if(b=1) printf("Find onen"); else printf("Not findn");void find2(stu *p2) /* 按学号查找信息 */ char numMAX; int b=0; printf("Enter the num of the student you want to find:"); scanf("%s",&num); while(p2!=NULL) if(strcmp(num,p2->num)=0) printf("The data you want has be foundn"); printf("-n"); printf("Num:%st",p2->num); printf(" Name:%st",p2->name); printf("Sex:%st",p2->sex); printf("Age:%dt",p2->age); printf("n"); printf("Chinese:%dt",p2->chinese); printf("Math:%dt",p2->mathematic); printf("English:%dt",p2->english); printf("Average:%fn",p2->aver); printf("*n"); b=1; p2=p2->next; if(b=1) printf("Find onen"); else printf("Not findn");void find() /*查询记录*/ int i; printf("<1>Find with name <2>Find with num <3> Returnn"); printf("Please Enter your choice:"); scanf("%d",&i); switch(i) case 1: find1(head); break; case 2: find2(head); break; case 3: return; void update1(stu *p2) /*按姓名修改*/ char name10; int b=0; printf("Enter The Name:"); scanf("%s",name); while(p2!=NULL) if(strcmp(name,p2->name)=0) printf("Find you data!n"); printf("Enter the new name:"); scanf("%s",p2->name); printf("Enter the num:"); scanf("%s",p2->num); printf("Enter the sex:"); scanf("%s",p2->sex); printf("Enter the age:"); scanf("%d",&p2->age); printf("Enter the chinese score:"); scanf("%d",&p2->chinese); printf("Enter the math score:"); scanf("%d",&p2->mathematic); printf("Enter the english score:"); scanf("%d",&p2->english); p2->aver=p2->chinese+p2->mathematic+p2->english; printf("Success!n"); b=1; p2=p2->next; if(b=0) printf("Sorry not Find data!n"); else printf("Finish!n"); void update2(stu *p2) /*按学号修改*/ char numMAX; int b=0; printf("Enter The Num:"); scanf("%s",&num);while(p2!=NULL) if(strcmp(num,p2->num)=0) printf("Find you data!n"); printf("Enter the new name:"); scanf("%s",p2->name); printf("Enter the num:"); scanf("%s",p2->num); printf("Enter the sex:"); scanf("%s",p2->sex); printf("Enter the age:"); scanf("%d",&p2->age); printf("Enter the chinese score:"); scanf("%d",&p2->chinese); printf("Enter the math score:"); scanf("%d",&p2->mathematic); printf("Enter the english score:"); scanf("%d",&p2->english); p2->aver=(p2->chinese+p2->mathematic+p2->english)/3.0; printf("Success!n"); b=1; p2=p2->next; if(b=0) printf("Sorry not Find data!n"); else printf("Finish!n"); void update() /*修改记录*/ int i; printf("<1>Updata with name <2>Updata with num <3>Returnn"); printf("Please Enter your choice:"); scanf("%d",&i); switch(i) case 1: update1(head); break; case 2: update2(head); break; case 3: return; void saved(stu *p2) /*保存到磁盘student.dat文件中*/ FILE *fp; char file16="c:student.dat" char file1="num-name-sex-age-chinese-math-english-avern" if(fp=fopen(file,"wt")=NULL) printf("nCannot open the file <student>!n"); return; fprintf(fp,"%s",file1);while(p2!=NULL) fprintf(fp,"%s-",p2->num); fprintf(fp,"%s-",p2->name); fprintf(fp,"%s-",p2->sex); fprintf(fp,"%d-",p2->age); fprintf(fp,"%d-",p2->chinese); fprintf(fp,"%d-",p2->mathematic); fprintf(fp,"%d-",p2->english); fprintf(fp,"%fn",p2->aver); p2=p2->next; fclose(fp);printf("Saved successed!");void statistics(stu *p2) /*统计学生成绩*/ FILE *fp,*fp1; char file16="c:stufile.dat",file116="c:stugood.dat"if(fp=fopen(file,"wt")=NULL) printf("nCannot open the file <stufile>!n"); return; if(fp1=fopen(file1,"wt")=NULL) printf("nCannot open the file <stugood>!n"); return; while(p2!=NULL) if(p2->chinese<60)|(p2->english<60)|(p2->mathematic<60) fprintf(fp,"%s-",p2->num); fprintf(fp,"%s-",p2->name); fprintf(fp,"%s-",p2->sex); fprintf(fp,"%d-",p2->age); fprintf(fp,"%d-",p2->chinese); fprintf(fp,"%d-",p2->mathematic); fprintf(fp,"%d-",p2->english); fprintf(fp,"%fn",p2->aver); p2=p2->next; else if(p2->chinese>=90)&&(p2->english>=90)&&(p2->mathematic>=90) fprintf(fp1,"%s-",p2->num); fprintf(fp1,"%s-",p2->name); fprintf(fp1,"%s-",p2->sex); fprintf(fp1,"%d-",p2->age); fprintf(fp1,"%d-",p2->chinese); fprintf(fp1,"%d-",p2->mathematic); fprintf(fp1,"%d-",p2->english); fprintf(fp1,"%fn",p2->aver); p2=p2->next; elsep2=p2->next;

    注意事项

    本文([计算机]C语言课程设计.doc)为本站会员(sccc)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开