云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 河南科技大学C语言课程设计选票问题实验报告

河南科技大学C语言课程设计选票问题实验报告

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 11:01:22

void search_player(struct player ply[M]) { int w; printf(\ scanf(\ if(w==1) search_num_player(ply); else if(w==2) search_name_player(ply); else printf(\ }

void search_num_vote(struct vote vot[N]) { int i,n,flag=0; printf(\ scanf(\ printf(\ printf(\ for(i=0;i

void super_player(struct player ply[M]) { int a,b,c; int i; FILE *fp; a=b=c=0; for(i=1;i

9

if(ply[i].score>ply[a].score) { c=b; b=a; a=i; } else if(ply[i].score==ply[a].score) { if(ply[i].votes>=ply[a].votes) { c=b; b=a; a=i; } else { c=b; b=i; } } else { if(ply[i].score>ply[b].score) { c=b; b=i; } else if(ply[i].score==ply[b].score) { if (ply[i].votes>=ply[c].votes) { c=b;b=i; } else c=i; } else if(ply[i].score>ply[c].score) c=i; } }

if((fp=fopen(\ { printf(\ exit(0); }

10

printf(\

printf(\

printf(\printf(\printf(\fprintf(fp,\ plays are:\\n\

fprintf(fp,\

fprintf(fp,\fprintf(fp,\fprintf(fp,\}

int main() { struct player ply[M]; struct vote vot[N]; int number,flag=1,first=0; menu(); printf(\ enter the number(0-6):\ scanf(\ while(number!=0) { switch(number) { case 1:load_mod(ply,vot);first=1;break; case 2:if(first)output_player(ply);break; case 3:if(first)output_vote(vot);break; case 4:if(first)search_player(ply);break; case 5:if(first)search_num_vote(vot);break; case 6:if(first)super_player(ply);break; default:flag=0; } if(flag==0) { printf(\ error!\\n\\n\ break; } else { if(first==0) printf(\ input player and vote first!\\n\ menu(); printf(\ enter the number(0-6):\ scanf(\

11

}

} }

return 0;

五、调试过程中的问题 出现的警告如下:

1)函数使用了未经初始化的变量,或定义了变量却没有使用。函数原型有返回值,但函数体内没有return值,反之亦然。

2)在信息输出函数中ply[M]指代不明。所以在调试过程中写清楚每个变量,如ply[1],ply[2],ply[3]等等。 3)警告多或少“{}”。在运行时由于使用了多层if嵌套语句,含有较多的“{“和”}”,有时会忘了或多添了“{}”。

4)某些变量表示不同的含义,但却用了同一字母符号来表示。在调试过程中换用其他字母。 出现的错误如下: 1)语句后少“;”。

2)括号不配对。在多层嵌套中,结构较复杂,会少写括号。

3)需要加头文件时没有用#include命令包含头文件。如在调用file函数时需加#include”stdio.h”头文件。 4)没有注意到函数参数的对应关系。如定义了name为字符变量,则不应用%d来控制类型,应用%s来控制。

5)没有注意到函数的对应顺序。

6)混淆了结构体类型与结构体变量的区别。

7)使用file函数时忽略了重新定义指针,导致文件读写错误。 8)函数的实参类型和形参类型不一样。

9)使用文件时忘记打开,或打开方式与使用情况不匹配。 10)忘记定义数据类型以及定义函数,导致运行出现错误 六、总结

通过程序设计实训,我们几个人一起合作巩固了以前所学的程序设计语言的基础知识,掌握了更多的综合程序设计的使用技巧和技能。与同学通力合作,锻炼了合作能力,丰富了人生经历。

希望学校以后多开设此类课程。带来的困难让我无法忘记,在调试程序的同时,

我也总结出来了一些调试的小技巧,让我在C语言课程设计中也受用匪浅,另外,我还感觉到一个好的程序编出来需要很多人的团结合作。我在检查自己编写的程序是否有错误未被找出的时候,我会让我的同学作为一个程序使用者来找出未发现的BUG并提出改进意见,这让我们的工作更加高效。

12

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

void search_player(struct player ply[M]) { int w; printf(\ scanf(\ if(w==1) search_num_player(ply); else if(w==2) search_name_player(ply); else printf(\ } void search_num_vote(struct vote vot[N]) { int i,n,flag=0; printf(\ scanf(\ printf(\ printf(\ for(i=0;i

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com