c语言旋转的五角星动画程序软件设计报告,校运动会管理系统报告C语言(含完整代码)...

}

fscanf(fp,"运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:\n"); printf("打不开文件Cannot open the file\n"); return;

//若打不开则返回菜单

&stu[i].scoreq,&stu[i].scoreg,&stu[i].scorey,&stu[i].ximing); printf("%s\t%s\t%d\t%d\t%d\t%d\t%s\n",stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing); } fclose(fp);

//关闭文件 做菜单功能多次选择时,令用户输入字符进行选择,然而程序总是退出,后来才知道‘\n’也被算入用户输入的字符内,要在字符输入后添加getchar()才能避免菜单失效 做显示函数,屏幕显示异常,总是反复显示相同数据和乱码,原来是结构体初始化,当中的数组已经存储了数据,在显示时与函数同时输出了,要再定义一个相同的数组应用它输出。 (1) 登陆

(2) 菜单

(3) 输入

(4)查找

(5)排序

(6)修改

(7)得分

(8)删除

(9)插入

(10)保存

(11)退出

五、程序有待改进的地方

六、本次实习的收获和建议

通过这次课程设计我得出一个结论:知识必须通过应用才能实现其价值!有些东西以为学会了,但真正到用的时候才发现是两回事,所以我认为只有到真正会用的时候才是真的学会了。同时在设计的过程中发现了自己的不足之处,对一些前面学过的知识理解得不够深刻,掌握得不够牢固,比如说指针。编程时要养成良好的风格,注意相同内容的缩进和对齐。这样做,可以使程序代码出错的情况下,可以快速并且便捷的查找到错误的行,利于很好的修改。

在整个设计中我懂得了许多东西,也培养了我独立工作的能力,树立了对自己工作能力的信心,相信会对今后的学习工作生活有非常重要的影响。而且大大提高了动手的能力,使我充分体会到了在创造过程中探索的艰难和成功时的喜悦。虽然这个设计做的也不太好,但是在设计过程中所学到的东西是这次课程设计的最大收获和财富,使我终身受益。

在本次实践中,给我印象最为深刻的是在文件删除程序的编译过程中,这个程序将是关键。老天不会让我太过顺利,他在这最后的时刻设置的障碍,但是我鼓起勇气,到处查找资料,终于让我实现了这个函数,谢谢给我指点迷津的朋友和同学。对我而言,知识上的收获重要,精神上的丰收是可喜的。挫折是一份财富,经历是一份拥有。这次实际操作必将成为我们人生旅途上一个非常美好的回忆!

#include#include#include#include

int shoudsave = 0; int count1 = 0, count2 = 0, mark = 0, mark1 = 0; structtrain {

}; structman {

}; typedefstructnode { structtrain data; structnode * next; char num[10]; char name[10]; int bookNum; char num[10]; char city[10]; char takeoffTime[10]; char receiveTime[10]; int price; int bookNum; }Node, *Link; typedefstructpeople { structman data; structpeople*next; }bookMan, *bookManLink; void printInterface() {

puts("********************************************************"); puts("* Welcome to use the system of booking tickets *"); puts("********************************************************"); puts("* You can choose the operation: *"); puts("* 1:Insert a train information *"); puts("* 2:Inquire a train information *"); puts("* 3:Book a train ticket *");

} puts("* 4:Update the train information *"); puts("* 5:Advice to you about the train *"); puts("* 6:save information to file *"); puts("* 7:quit the system *"); puts("********************************************************"); /*添加一个火车信息*/

void InsertTraininfo(Linklinkhead) {

structnode *p, *r, *s; char num[10]; r = linkhead; s = linkhead->next; while (r->next != NULL) {

printf("please input the number of the train(0-return)"); scanf("%s", num); if (strcmp(num, "0") == 0) {

} p = (structnode*)malloc(sizeof(structnode)); strcpy(p->data.num, num); printf("Input the city where the train will reach:"); scanf("%s", p->data.city); printf("Input the time which the train take off:"); scanf("%s", p->data.takeoffTime); printf("Input the time which the train receive:"); scanf("%s", &p->data.receiveTime); printf("Input the price of ticket:"); scanf("%d", &p->data.price); printf("Input the number of booked tickets:"); if (strcmp(s->data.num, num) == 0) {

} s = s->next; printf("the train '%s'has been born!\n", num); return; break; while (s) r = r->next; while (1)

scanf("%d", &p->data.bookNum);

p->next = NULL;

r->next = p;

r = p;

shoudsave = 1; } } void printTrainInfo(structnode*p) { puts("\nThe following is the record you want:"); printf(">>number of train: %s\n", p->data.num); printf(">>city the train will reach: %s\n", p->data.city); printf(">>the time the train take off: %s\nthe time the train reach: %s\n"p->data.takeoffTime, p->data.receiveTime); printf(">>the price of the ticket: %d\n", p->data.price); printf(">>the number of booked tickets: %d\n", p->data.bookNum); }

structnode * Locate1(Linkl, charfindmess[], charnumorcity[]) { Node*r; if (strcmp(numorcity, "num") == 0) {

r = l->next;

while (r)

{

if (strcmp(r->data.num, findmess) == 0)

return r;

r = r->next;

} } elseif (strcmp(numorcity, "city") == 0) {

r = l->next;

while (r)

{

if (strcmp(r->data.city, findmess) == 0)

return r;

r = r->next;

} }

, } return 0; void QueryTrain(Linkl) {

Node *p; int sel; char str1[5], str2[10]; if (!l->next) {

} printf("Choose the way:\n>>1:according to the number of train;\n>>2:according to the scanf("%d", &sel); if (sel == 1) {

} elseif (sel == 2) {

printf("Input the city:"); scanf("%s", str2); p = Locate1(l, str2, "city"); if (p) { } printTrainInfo(p); printf("Input the the number of train:"); scanf("%s", str1); p = Locate1(l, str1, "num"); if (p) { } else {

} mark1 = 1; printf("\nthe file can't be found!"); printTrainInfo(p); printf("There is not any record !"); return; city:\n");

}

} else {

} mark1 = 1; printf("\nthe file can't be found!"); void BookTicket(Linkl, bookManLinkk) {

Node*r[10], *p; char ch, dem; bookMan*v, *h; int i = 0, t = 0; char str[10], str1[10], str2[10]; v = k; while (v->next != NULL) v = v->next; printf("Input the city you want to go: "); scanf("%s", &str); p = l->next; while (p != NULL) {

} printf("\n\nthe number of record have %d\n", i); for (t = 0; t

{

printf("\ndo you want to book it?<1/0>\n"); scanf("%d", &ch); if (ch == 1) { h = (bookMan*)malloc(sizeof(bookMan)); printTrainInfo(r[t]); printf("\n\t\t\tSorry!Can't find the train for you!\n"); if (i == 0) else if (strcmp(p->data.city, str) == 0) {

} p = p->next; r[i] = p; i++;

}

}

} printf("Input your name: "); scanf("%s", &str1); strcpy(h->data.name, str1); printf("Input your id: "); scanf("%s", &str2); strcpy(h->data.num, str2); printf("Input your bookNum: "); scanf("%d", &dem); h->data.bookNum = dem; h->next = NULL; v->next = h; v = h; printf("\nLucky!you have booked a ticket!"); getch(); shoudsave = 1; bookMan*Locate2(bookManLinkk, charfindmess[]) {

} /*修改火车信息*/ void UpdateInfo(Linkl) {

Node*p; char findmess[20], ch; if (!l->next) { printf("\nthere isn't record for you to modify!\n"); bookMan*r; r = k->next; while (r) {

} return 0; if (strcmp(r->data.num, findmess) == 0) {

} r = r->next; mark = 1; return r;

} } return; else {

} QueryTrain(l); if (mark1 == 0) {

} else mark1 = 0; printf("\nDo you want to modify it?\n"); getchar(); scanf("%c", &ch); if (ch == 'y'); {

} printf("\nInput the number of the train:"); scanf("%s", findmess); p = Locate1(l, findmess, "num"); if (p) {

} else printf("\t\t\tcan't find the record!"); printf("Input new number of train:"); scanf("%s", &p->data.num); printf("Input new city the train will reach:"); scanf("%s", &p->data.city); printf("Input new time the train take off"); scanf("%s", &p->data.takeoffTime); printf("Input new time the train reach:"); scanf("%s", &p->data.receiveTime); printf("Input new price of the ticket::"); scanf("%d", &p->data.price); printf("Input new number of people who have booked ticket:"); scanf("%d", &p->data.bookNum); printf("\nmodifying record is sucessful!\n"); shoudsave = 1; void AdvicedTrains(Linkl) {

} void SaveTrainInfo(Linkl) {

FILE*fp; Node*p; int count = 0, flag = 1; fp = fopen("D:rain.txt", "wb"); if (fp == NULL) {

} p = l->next; while (p) {

if (fwrite(p, sizeof(Node), 1, fp) == 1) {

} p = p->next; count++; printf("the file can't be opened!"); return; Node*r; char str[10]; int mar = 0; r = l->next; printf("Iuput the city you want to go: "); scanf("%s", str); while (r) {

} if (mar == 0) printf("\n\t\t\tyou can't book any ticket now!\n"); if (strcmp(r->data.city, str) == 0 && r->data.bookNum < 200) {

} r = r->next; mar = 1; printf("\nyou can select the following train!\n"); printf("\n\nplease select the fourth operation to book the ticket!\n"); printTrainInfo(r);

}

} else {

} flag = 0; break; if (flag) {

} fclose(fp); printf("the number of the record which have been saved is %d\n", count); shoudsave = 0; void SaveBookmanInfo(bookManLinkk) {

FILE*fp; bookMan*p; int count = 0, flag = 1; fp = fopen("D:\man.txt", "wb"); if (fp == NULL) {

} p = k->next; while (p) {

} if (flag) { printf("the number of the record which have been saved is %d\n", count); if (fwrite(p, sizeof(bookMan), 1, fp) == 1) {

} else {

} flag = 0; break; p = p->next; count++; printf("the file can't be opened!"); return;

} } shoudsave = 0; fclose(fp); int main() {

FILE*fp1, *fp2; Node*p, *r; char ch1, ch2; Link l; bookManLink k; bookMan*t, *h; int sel; l = (Node*)malloc(sizeof(Node)); l->next = NULL; r = l; k = (bookMan*)malloc(sizeof(bookMan)); k->next = NULL; h = k; fp1 = fopen("D:rain.txt", "ab+"); if ((fp1 == NULL)) {

} while (!feof(fp1)) {

} fclose(fp1); fp2 = fopen("D:\man.txt", "ab+"); if ((fp2 == NULL)) { p = (Node*)malloc(sizeof(Node)); if (fread(p, sizeof(Node), 1, fp1) == 1) {

} p->next = NULL; r->next = p; r = p; count1++; printf("can't open the file!"); return 0;

} printf("can't open the file!"); return 0; while (!feof(fp2)) {

} fclose(fp2); while (1) {

system("cls"); printInterface(); printf("please choose the operation: "); scanf("%d", &sel); system("cls"); if (sel == 8) {

} switch (sel) if (shoudsave == 1) {

} printf("\nThank you!!You are welcome too\n"); break; getchar(); printf("\nthe file have been changed!do you want to save it(y/n)?\n"); scanf("%c", &ch1); if (ch1 == 'y' || ch1 == 'Y') {

} SaveBookmanInfo(k); SaveTrainInfo(l); t = (bookMan*)malloc(sizeof(bookMan)); if (fread(t, sizeof(bookMan), 1, fp2) == 1) {

} t->next = NULL; h->next = t; h = t; count2++;

}

} { case 1:

} printf("\nplease press any key to continue......."); getch(); InsertTraininfo(l); break; QueryTrain(l); break; BookTicket(l, k); break; UpdateInfo(l); break; AdvicedTrains(l); break; SaveTrainInfo(l); SaveBookmanInfo(k); break; return 0; case 2: case 3: case 4: case 5: case 6: case 7: return 0;

#include#include#include#include

#define SIZE 9 #define N

#define WM

3

void bsxm();

//比赛项目 void csxx();

//参赛学校 void ttzf() ;

//团体总分 void Information(); void main(); void menu(); void printf_back(); void saveathlete(); void saveprogram(); void saveschool(); void savescore(); void Search();

int i; FILE *fp1,*fp2,*fp3,*fp4;

struct athlete

//定义运动员信息 { char univ[5]; char name[8]; char prog[15];

char mingci[5]; int score; } at[SIZE];

struct xuexiao

//定义学校信息 { char univ[5]; char prog[15]; int num_athlete; } xx[N];

struct program { char prog[5]; int quming;

char ath1[5]; char ath2[5]; char univ1[5]; char univ2[5]; } pro[WM];

//定义项目信息

struct zongfen

//定义学校得分信息 { char univ[5]; char prog1[5]; char prog2[5]; char prog3[5]; int score1; int score2; int score3; int total_score; } zf[N];

void Information()//进入信息录入系统选择系统子函数 {

int n,w ;

do

{

puts("\n\n\n");

puts("\t\t***^__^

Welcome to load 信息录入 system!

^__^***\n");

puts("\t\t*************************MENU*************************\n");

puts("\t\t******** 1.saveathlete

**************\n");//运动员姓名录入

puts("\t\t******** 2.saveschool

**************\n");//运动员学校录入

puts("\t\t******** 3.saveprogram()

**************\n");//参加项目录入

puts("\t\t******** 4.back

**************\n");//退出

puts("\t\t******************************************************\n");

printf("Choic your number(1-4):[ ]\b\b");

scanf("%d",&n);

if (n<1||n>4)

{

w=1;

printf("\n\n\t\t----------------------DATAERROR!----------------------\n\n\n");

getchar();

}

else w=0;

}

while (w==1);

switch(n)

{

case 1 : saveathlete(); break;// 保存运动员信息子函数

case 2 : saveschool(); break;//保存学校信息子函数

case 3 : saveprogram();break;//保存项目比赛信息子函数

case 4 : exit(0);

} }

void saveathlete() { //保存运动员信息子函数

printf("\n请输入各项目获奖运动员的信息:");

for(i=0;iprintf("\n请输入第%d个运动员的信息:\n",i+1);

printf("姓名:");

scanf("%s",at[i].name);

printf("学校:");

scanf("%s",at[i].univ);

printf("参赛项目:");

scanf("%s",at[i].prog); printf("名次:"); scanf("%s",at[i].mingci);

printf("得分:");

scanf("%d",&at[i].score);

} fp1=fopen("ath","w");

for(i=0;iprintf("File write error!\n"); }

fclose(fp1); fp1=fopen("ath","r");

printf("\n现在各运动员的信息如下:\n\n");

printf("姓名

学校

项目

名次

得分\n"); for(i=0;ifread(&at[i],sizeof(struct athlete),1,fp1);

printf("%-10s%-10s%-18s%-10s%d\n",at[i].name,at[i].univ,at[i].prog,at[i].mingci,at[i].score); } fclose(fp1); printf_back(); }

void saveschool() //保存学校信息子函数 { printf("\n请输入各参赛学校的信息:");

for(i=0;iprintf("\n请输入第%d个学校的信息:\n",i+1);

printf("学校:");

scanf("%s",xx[i].univ);

printf("参赛的项目:");

scanf("%s",xx[i].prog);

printf("参赛者数:");

scanf("%d",&xx[i].num_athlete); }

fp3=fopen("xxiao","w"); for(i=0;iif(fwrite(&xx[i],sizeof(struct xuexiao),1,fp3)!=1)

printf("File write error!\n"); } fclose(fp3);

printf_back(); }

void saveprogram() //保存项目比赛信息子函数 { printf("\n请输入关于比赛项目的信息:");

for(i=0;iprintf("\n请输入第%d项比赛的信息:\n",i+1); printf("项目:"); scanf("%s",pro[i].prog); printf("取分情况:"); scanf("%d",&pro[i].quming); printf("参赛者1:"); scanf("%s",pro[i].ath1); printf("所属学校:"); scanf("%s",pro[i].univ1); printf("参赛者2:"); scanf("%s",pro[i].ath2);

printf("所属学校:");

scanf("%s",pro[i].univ2); }

fp4=fopen("pr","w"); for(i=0;iif(fwrite(&pro[i],sizeof(struct program),1,fp4)!=1)

printf("File write error!\n"); } fclose(fp4);

printf_back(); }

void savescore() //保存学校得分情况子函数 { printf("N-参赛学校总数,M-男子竞赛项目数,W-女子竞赛项目数。\n"); printf("W.100-女子一百米比赛,M.100-男子一百米,M.200-男子两百米。\n"); printf("\n各项名次得分权值如下:\n"); printf("取前三名:第一名5分

第二名3分

第三名2分\n");

printf("\n请输入各学校的得分情况:");

for(i=0;iprintf("\n请输入第%d个学校的得分情况:\n",i+1);

printf("学校:"); scanf("%s",zf[i].univ);

printf("参赛项目1:"); scanf("%s",zf[i].prog1); printf("得分:"); scanf("%d",&zf[i].score1); printf("参赛项目2:"); scanf("%s",zf[i].prog2); printf("得分:"); scanf("%d",&zf[i].score2);

printf("参赛项目3:"); scanf("%s",zf[i].prog3);

printf("得分:");

scanf("%d",&zf[i].score3);

zf[i].total_score=zf[i].score1+zf[i].score2+zf[i].score3; }

fp2=fopen("zfen","w"); for(i=0;iif(fwrite(&zf[i],sizeof(struct zongfen),1,fp2)!=1)

printf("File write error!\n"); } fclose(fp2);

printf_back(); }

void Search() //进入查询系统子函数 { int n,w2; do

{

puts("\t\t***^__^

Welcome to load search system!

^__^***\n");

puts("\t\t*************************MENU*************************\n");

puts("\t\t******** 1.search ttzf **************\n");//查看团体总分

puts("\t\t******** 2.search csxx **************\n");//查看参赛学校信息!

puts("\t\t******** 3.search bsxm **************\n");//查看比赛项目信息!

puts("\t\t******** 4.Exit

**************\n");//退出

puts("\t\t***************************************\n");

printf("Choose your number(1-4):[ ]\b\b");

scanf("%d",&n);

if (n<1||n>4)

{

w2=1;

printf("\n\n\t\t----------------------DATAERROR!----------------------\n\n\n");

getchar();

}

else w2=0; } while (w2==1); switch(n) { case 1: ttzf();break; case 2: csxx();break; case 3: bsxm();break; case 4: exit(0);break; default: printf("未进行任何操作!"); }

}

void ttzf() //查看学校团体总分子函数 { fp2=fopen("zfen","r");

printf("\n各学校的团体总分情况如下:\n\n");

printf("学校

参赛项目

总分\n"); for(i=0;ifread(&zf[i],sizeof(struct zongfen),1,fp2);

printf("%-8s%s,%s,%-12s%-12d\n",zf[i].univ,zf[i].prog1,zf[i].prog2,zf[i].prog3,zf[i].total_score); } fclose(fp2); printf_back(); }

void csxx() //查看参赛学校信息子函数 {

fp3=fopen("xxiao","r");

printf("\n各参赛学校的情况如下:\n\n");

printf("学校

参赛项目

参赛者数\n"); for(i=0;ifread(&xx[i],sizeof(struct xuexiao),1,fp3);

printf("%-8s%-20s%-12d\n",xx[i].univ,xx[i].prog,xx[i].num_athlete); } fclose(fp3);

printf_back(); }

void bsxm() //查看比赛项目子函数 {

fp4=fopen("pr","r");

printf("\n各比赛项目的信息如下:\n\n");

printf("项目

取分情况

参赛者1 所属学校

参赛者2 所属学校\n"); for(i=0;ifread(&pro[i],sizeof(struct program),1,fp4);

printf("%-12s%-10d%-10s%-12s%-10s%-12s\n",pro[i].prog,pro[i].quming,pro[i].ath1,pro[i].univ1,pro[i].ath2,pro[i].univ2); } fclose(fp4); printf_back(); }

void main() { menu();

}

void menu()//主菜单程序 { int n,w1; do {

puts("\t\t***^__^

Welcome to load sports system!

^__^***\n");

puts("\t\t*************************MENU*************************\n");

puts("\t\t******** 1.Enter the information

**************\n");//进入信息录入

puts("\t\t******** 2.Score

**************\n");//进入比赛结果录入

puts("\t\t******** 3.Search

**************\n");//进入查询功能

puts("\t\t******** 4.Exit

**************\n");//退出

puts("\t\t******************************************************\n");

printf("Choose your number(1-4):[ ]\b\b");

scanf("%d",&n);

if (n<1||n>4)

{

w1=1;

printf("\n\n\t\t----------------------DATAERROR!----------------------\n\n\n");

getchar();

}

else w1=0; } while (w1==1);

switch(n)

{

case 1:Information();break; //输入信息

case 2:savescore();break;//比赛结果录入

case 3:Search();break;//查询模块

case 4:exit(0);

}

}

//公共函数

void printf_back() { int w; printf("\n\n\tSUCCESSFUL!\n\n"); printf("What do you want to do next?\n\n\t1).exit \t2).menu:[ ]\b\b"); scanf("%d",&w); if(w==1) exit(0); else menu(); }

#include #includeusing namespace std; int main() {

int i1,j1,k1,i2,j2,k2,i3,j3,k3,i4,j4,k4,m4,n4; printf("五角星:\n"); for(i1=1;i1<6;i1++)

// /*这是五角星的上面一个角*/ { for(j1=1;j1<19-i1;j1++)

// /*这是空格*/

printf(" ");

for(k1=1;k1<=2*i1-1;k1++) ///*这是“*”*/

printf("*");

printf("\n"); } for(i2=1;i2<5;i2++)

// /*这是五角星的中间两个角*/ { for(j2=1;j2<3*i2-3;j2++)

printf(" ");

for(k2=1;k2<=42-6*i2;k2++)

printf("*");

printf("\n"); } for(i3=1;i3<3;i3++)

//

/*这是中间与下部相接的部分*/ { for(j3=1;j3<12-i3;j3++)

printf(" ");

for(k3=1;k3<=12+2*i3;k3++)

printf("*");

printf("\n"); } for(i4=1;i4<5;i4++)

//

/*这是五角星的下面两个角*/ { for(j4=1;j4<10-i4;j4++)

printf(" ");

for(k4=1;k4<=10-2*i4;k4++)

printf("*");

for(m4=1;m4<6*i4-3;m4++)

printf(" ");

for(n4=1;n4<=10-2*i4;n4++)

printf("*");

printf("\n"); } printf("Congratulations!\nWe've successfully drawn a we?\n(*^_^*)\n");

return 0; }

beautiful pentagon,haven't

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值