C语言课程设计报告3714206.docx

上传人:b****3 文档编号:4472725 上传时间:2022-12-01 格式:DOCX 页数:21 大小:185.39KB
下载 相关 举报
C语言课程设计报告3714206.docx_第1页
第1页 / 共21页
C语言课程设计报告3714206.docx_第2页
第2页 / 共21页
C语言课程设计报告3714206.docx_第3页
第3页 / 共21页
C语言课程设计报告3714206.docx_第4页
第4页 / 共21页
C语言课程设计报告3714206.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

C语言课程设计报告3714206.docx

《C语言课程设计报告3714206.docx》由会员分享,可在线阅读,更多相关《C语言课程设计报告3714206.docx(21页珍藏版)》请在冰豆网上搜索。

C语言课程设计报告3714206.docx

C语言课程设计报告3714206

(此文档为word格式,下载后您可任意编辑修改!

 

C语言课程设计报告

ExperimentDesigningreporter

 

课程名称:

C语言课程设计

英文名称:

CProgramExperimentDesigning

专业:

交通+软件工程08-1

学号:

姓名:

张尧

指导教师:

邱占芝

日期:

2009年6月8日 至2009年6月19日

 

大连交通大学软件学院

《C语言课程设计》报告

CProgramExperimentDesigning

课程编号:

学时:

40学时

适用专业:

软件工程专业授课单位:

软件学院

一、C语言课程设计目的及要求

目的:

根据课堂讲授内容,学生做相应的自主练习,消化课堂所讲解的内容;通过调试典型例题或习题积累调试C程序的经验;通过完成辅导教材中的编程题,逐渐培养学生的编程能力、用计算机解决实际问题的能力。

要求:

1.熟悉TurboC的编程环境、主要菜单功能。

2.通过上机验证运算符、表达式、运算规则、函数使用。

3.熟练使用C语言的典型语句编写简单程序。

4.调试典型例题或习题。

5.提高上机编程能力

二、实验类型

设计类型

三、实验学时

40学时

四、实验设备

微型计算机、WINDOWS98以上版本的操作系统、TurboC2.0软件一套

五、C语言课程参考教材:

1.李瑞戚海英徐克圣刘月凡.C语言程序设计北京:

清华大学出版社,2008

2.谭浩强.C程序设计(第三版)北京:

高等教育出版社,2002

3.黄明梁旭万洪丽.C语言课程设计北京:

电子工业出版社,2006

4.马靖善秦玉平.C语言程序设计北京:

清华大学出版社,2005

5.(美)DavidM.Collopy.IntroductiontoCProgramming:

AModularApproach(SecondEdition)罗铁庚译北京:

清华大学出版社,2004

课程设计(报告)任务书

任务及要求:

1.设计(研究)内容和要求

研究内容:

统计要求的字符串中字符数,统计字符串中字母、数字、空格和其他字符个数,学生成绩简单处理,投票统计,小型家庭财务管理系统。

任务和要求:

(1).学习C语言基础知识,掌握C语言编程和程序调试的基本技能。

(2).对指导教师下达的题目进行系统分析。

(3).根据分析结果完成系统设计。

(4).编程:

在计算机上实现题目的代码实现。

(5).完成对该系统的测试和调试。

(6).提交课程设计报告。

(7).指标:

要求完成课程设计报告3千字以上(约二、三十页).

完成若干综合性程序设计题目,每个综合设计题目的语句行数的和在300行语句以上.

2.原始依据

了解C语言的基础知识,有一定的语言编程基础,能够熟练运用C语言进行程序设计。

通过用C语言完成的题目,提高用C语言解决实际问题的能力。

3.参考文献

[1]黄明等.C语言程序设计辅导教材.大连理工大学出版社,2006

[2]李瑞等.C语言程序设计.清华大学出版社,2008

[3]谭浩强.C语言程序设计(第二版).北京:

高等教育出版社,2002

指导教师签字:

                   2009年6月8日

目录

C语言课程设计报告1

[1]黄明等.C语言程序设计辅导教材.大连理工大学出版社,20063

1统计字符串个数1

1.1设计说明1

1.2程序运行截图1

1.3源程序代码1

2.1设计说明2

2.2程序运行截图2

2.3源程序代码2

3排列数的大小4

3.1设计说明4

3.2程序运行截图4

3.3源程序代码4

4统计句子中字母个数5

4.1设计说明5

4.2程序运行截图5

4.3源程序代码5

5学生成绩管理系统7

5.1功能介绍7

5.2程序运行截图7

5.5源程序代码7

1统计字符串个数

1.1设计说明

统计一个字符串的长度是多少,随意输入一个任意长度的数。

系统会统计它的长度

1.2程序运行截图

1.3源程序代码

#include"stdio.()

{charstr[81],*p=str;

intnum=0;

printf("shuruyigeshu:

");

gets(str);

while(*p++)

{

num++;

}

printf("shizidechandeshi%d\n",num);

getch();

}

2投票

2.1设计说明

为五个人投票,分别是zhang,wang,zhao,li.liu,五位同学,1开始投票,2显示结果,0停止投票,随时显示投票结果

2.2程序运行截图

2.3源程序代码

#include

charname[10];

intpiaoshu;

}ren[5]={{"zhang",0},{"wang",0},{"zhao",0},{"li",0},{"liu",0}};

main(){

charch,j;

inti;

while

(1){

system("cls");

printf("\n\n........1.kaishitoupiao");

printf("\n\n........2.xianshitoupiaojieguo");

while

(1){

fflush(stdin);

ch=getche();

if(ch=='1'||ch=='2'||ch=='3')

break;

}

system("cls");

switch(ch){

case'1':

while

(1){

printf("\n\n\n.....");

printf("%d.toupiaojieshu\n\n\n.....",0);

for(i=0;i<5;i++){

printf("%d.%s",i+1,ren[i].name);

}

fflush(stdin);

while

(1){

printf("\nqingtoupiao(0-5):

");

j=getche();

fflush(stdin);

if(j>='0'&&j<'6')

break;

}

if(j=='0')

break;

ren[j-49].piaoshu++;

printf("%s\n",ren[j-49].name);

}

break;

case'2':

for(i=0;i<5;i++)

printf("\n%s%dpiao.",ren[i].name,ren[i].piaoshu);

getch();

break;

case'3':

getch();

exit(0);

}

}

}

3排列数的大小

3.1设计说明

可以输入4个数,系统会排列出4个数字的大小,并且显示出来

3.2程序运行截图

3.3源程序代码

#include"stdio.()

{inti;

floata[4];

printf("shurusigeshu\n");

for(i=0;i<4;i++)

{scanf("%f",&a[i]);}

Daxiao(a);

for(i=0;i<4;i++)

{

printf("%4.3f\n",a[i]);

}

getch();

}

4统计句子中字母个数

4.1设计说明

输入一个句子系统会统计处这个句子中英文字母的个数

4.2程序运行截图

4.3源程序代码

main()

{

charstr[100],*p;

intnum[4],i;

p=str;

printf("qingshuruyigejuzi:

");

gets(str);

for(i=0;i<4;i++)

num[i]=0;

for(;*p!

='\0';p++)

{

if((*p<='z'&&*p>='a')||(*p<='Z'&&*p>='A'))num[0]++;

elseif(*p=='')num[1]++;

elseif((*p<='9'&&*p>='0'))num[2]++;

elsenum[3]++;

}

printf("%d\n",num[0]);

getch();

}

5学生成绩管理系统

5.1功能介绍

创建学生信息文件,增加学生信息,删除,修改,查询成绩以及浏览学生成绩排行。

5.2程序运行截图

5.5源程序代码

*HELLO.C--Hello,world*

#include"stdio.();

voidstartprogram();

menu();

typedefstructs1

{

charno[11];

charname[15];

intscore[N];

floatsum;

floataverage;

intorder;

structs1*next;

}STUDENT;

voidframe()

{

gotoxy(1,12);

printf("\xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf\n");

printf("\xb3\xb3\n");

printf("\xb3\xb3\n");

printf("\xb3\xb3\n");

printf("\xb3\xb3\n");

printf("\xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9\n");

}

voidlogin()

{

charid[3][8]={"admin","wangcai","xuxu"},pw[3][8]={"123456","888888","000000"},id2[8],pw2[8];

inti,success=0;

again:

frame();

gotoxy(20,14);

printf("PleaseputinID:

");

scanf("%s",id2);

gotoxy(20,15);

printf("PleaseputinPassword:

");

for(i=0;i<6;i++)

{

pw2[i]=getch();

putchar('*');

}

pw2[6]='\0';

for(i=0;i<3;i++)

{

if((strcmp(id2,id[i])==0)&&(strcmp(pw2,pw[i])==0))

{

printf("\nYES");

success=1;

return;

}

}

if(success!

=1)

{

charch;

while

(1)

{

printf("\nYou.(YN):

");

ch=getch();

if(ch=='Y'||ch=='y')

{

clrscr();

gotoagain;

}

elseif(ch=='N'||ch=='n')

exit(0);

else

;

}

}

}

voidstartprogram()

{

clrscr();

printf("welcomtothemenu");

}

menu()

{char*menu[]={"*****menu*****",

"0.Initiallist",

"1.Enterrecord",

"2.Deletearecordfrom",

"3.Printrist",

"4.Searchrecordonname",

"5.Saveasfile",

"6.Loadfromfile",

"7putethescore",

"8.Insertrecordtolist",

"9.Sorttomakenewfile",

"10.appendrecord",

"11.Quit"};

chars[3];

intc,i;

gotoxy(1,25);

printf("pressanykeyentermenu...\n");

getch();

clrscr();

gotoxy(1,1);

textcolor(YELLOW);

textbackground(RED);

gotoxy(19,2);

putch(0xc9);

for(i=1;i<44;i++)

putch(0xcd);

putch(0xbb);

for(i=3;i<20;i++)

{gotoxy(19,i);

putch(0xba);

gotoxy(63,i);

putch(0xba);

}

gotoxy(19,20);

putch(0xc8);

for(i=1;i<44;i++)

putch(0xcd);

putch(0xbc);

window();

clrscr();

for(i=0;i<13;i++)

{gotoxy(10,i+1);

printf("%s",menu[i]);

}

textbackground(BLUE);

window();

gotoxy(10,21);

do{printf("\nEnteryouchoice(0~11):

");

scanf("%s",s);

c=atoi(s);

}while(c<0||c>11);

returnc;

}

*菜单*

*voidmenu()

{

chars[3];

intc,i;

gotoxy(1,25);

printf("pressanykeyentermenu...\n");

getch();

clrscr();

gotoxy(1,1);

textcolor(YELLOW);

textbackground(BLUE);

gotoxy(10,2);

putch(0xc9);

for(i=1;i<44;i++)

putch(0xcd);

putch(0xbb);

for(i=3;i<20;i++)

{

gotoxy(10,i);

putch(0xba);

gotoxy(54,i);

putch(0xba);

}

gotoxy(10,20);

putch(0xc8);

for(i=1;i<44;i++)

putch(0xcd);

putch(0xbc);

window();

clrscr();

textbackground(BLACK);

window();

gotoxy(10,21);

gotoxy(17,3);

printf("*****menu*****\n");

gotoxy(17,4);

printf("0.Initiallist\n");

gotoxy(17,5);

printf("1.Enterrecord\n");

gotoxy(17,6);

printf("2.Deletearecordfromlist\n");

gotoxy(17,7);

printf("3.Printlist\n");

gotoxy(17,8);

printf("4.Searchrecordonname\n");

gotoxy(17,9);

printf("5.Saveasfile\n");

gotoxy(17,10);

printf("6.Loadfromfile\n");

gotoxy(17,11);

printf("7putethescore\n");

gotoxy(17,12);

printf("8.Insertrecordtolist\n");

gotoxy(17,13);

printf("9.Sorttomakenewfile\n");

gotoxy(17,14);

printf("10.Quit\n");

do{gotoxy(20,17);

printf("Enteryouchoice(0~10):

");

scanf("%s",s);

c=atoi(s);

}while(c<0||c>11);

}*

*成绩录入*

STUDENT*init()

{

returnNULL;

}

STUDENT*create()

{

inti;

ints;

STUDENT*NULL;

}

inputs("Pleaseenterstudent'snumber:

",info->no,11);

if(info->no[0]=='t')

break;

inputs("Pleaseenterstudent'sname:

",info->name,15);

printf("PleaseinputMath,Chinese,Englishscore\n");

s=0;

for(i=0;i

{

do

{printf("Score%d:

",i+1);

scanf("%d",&info->score[i]);

if(info->score[i]>100||info->score[i]<0)

printf("baddatd,repeatinput\n");

}while(info->score[i]>100||info->score[i]<0);

s=s+info->score[i];

}

info->sum=s;

info->average=(float)sN;

info->order=0;

info->next=((p)>count)

printf("\ntoolong");

}while(strlen(p)>count);

strcpy(s,p);

}

*输出链表中结点信息*

voidprint(STUDENT*\n\n************StudentScores************\n");

printf("|Rec|StuNum.|Name|Math|Chin|Engl|Sum|Ave|Order|\n");

printf("|----|||----|----|----|||-----|\n");

while(p!

=NULL)

{

i++;

printf("|%4d|%10s|%7s|%4d|%4d|%4d|%7.2f|%7.2f|%5d|\n",i,p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);

p=p->next;

}

printf("*********************************End**********************************");

}

*删除记录*

STUDENT*delete(STUDENT*",s);

else

{

printf("*********");

printf("|no|name|sc1|sc2|sc3|sum|ave|order|\n");

printf("||---|----|----|----|||-----|\n");

printf("|%-10s|%-15s|%4d|%4d|%4d|%4.2f|%4.2f|%3d|\n",p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);

printf("***************end***************\n");

getch();

if(p==",s);

printf("Dont'tforgetsave\n");

}

return(");

scanf("%s",s);

p=",s);

else

{printf("\n\n**********");

printf("|no|name|sc1|sc2|sc3|sum|ave|order|\n");

printf("||--|----|----|----|||-----|\n");

printf("|%-10s|%-15s|%4d|%4d|%4d|%4.2f|%4.2f|%7d|\n",p->no,p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);

printf("***************end***************");

}

}

*插入记录*

STUDENT*insert(STUDENT*beforethenumber\n");

scanf("%s",s);

printf("\nPleaseenternewrecord\n");

info=(STUDENT*)malloc(sizeof(STUDENT));

if(!

info)

{

printf("\noutofmemory");

returnNULL;

}

inputs("Pleaseenterstudent'snumber:

",info->no,11);

inputs("Pleaseenterstudent'sname:

",info->name,15);

printf("Pleaseinput%dscore\n",N);

s1=0;

for(i=0;i

{

do{printf("Score%d:

",i+1);

scanf("%d",&info->score[i]);

if

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1