免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1387 | 回复: 7
打印 上一主题 下一主题

请教大虾——近日老师布置了个作业,但是不知如何下手。。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-06-05 17:15 |只看该作者 |倒序浏览
老师布置了一个学生成绩表的C语言作业,而且要像做软件一样写程序报告(关于需求,可行性,概要设计,详细设计等)。。。我看起码也要实现十来个功能吧(上一届的师兄实现了十二个功能)要有新意嘛。。但是要下手写报告和编程,就是不知道应该怎样下手。。。。毫无头绪啊。。。。。

论坛徽章:
0
2 [报告]
发表于 2004-06-05 17:20 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

首先写需求 然后进行可行性分析 接着概要设计 至于程序嘛 网上多的是

论坛徽章:
0
3 [报告]
发表于 2004-06-05 17:20 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

   看不懂楼主说啥!

论坛徽章:
0
4 [报告]
发表于 2004-06-05 17:53 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

你可以借鉴一下
  1. #include<stdio.h>;
  2. #include<string.h>;
  3. #define N 5
  4. #define M 5
  5. struct student
  6. {
  7.         int num;
  8.         char name[10];
  9.         int score[M];
  10.         float sum;
  11.         float aver;
  12. };

  13. typedef struct student STUDENT;
  14. void printdata(pt)//打印N个学生M门功课的成绩
  15. STUDENT *pt;
  16. {
  17.         STUDENT *p;
  18.         int j;
  19.         printf("number  name   score1 score2 score3 score4 score5 sum aver\n");
  20.         for(p=pt;p<pt;p++)
  21.         {
  22.                 printf("NO.%3d%8s",p->;num,p->;name);
  23.                 for(j=0;j<M;j++)
  24.                         printf("%7d",p->;score[j]);
  25.                 printf("%6.2f%6.2f\n",p->;sum,p->;aver);
  26.         }
  27. }

  28. void total(pt)//计算平均分和总分
  29. STUDENT *pt;
  30. {
  31.         STUDENT *p;
  32.         int j;
  33.         for(p=pt;p<pt+N;p++)
  34.         {
  35.                 p->;sum=0;
  36.                 for(j=0;j<M;j++)
  37.                         p->;sum=p->;sum+p->;score[j];
  38.                 p->;aver=p->;sum/M;
  39.         }
  40. }

  41. void sort(pt)//选择法排序
  42. STUDENT *pt;
  43. {
  44.         int i,j,k,t,m;
  45.         char temp[10];
  46.         for(i=0;i<N-1;i++)
  47.         {
  48.                 k=i;
  49.                 for(j=i;j<N;j++)
  50.                         if((pt+j)->;sum>;(pt+k)->;sum)k=j;
  51.                 if(k!=i)
  52.                 {
  53.                         t=(pt+k)->;num;
  54.                         (pt+k)->;num=(pt+i)->;num;
  55.                         (pt+i)->;num=t;
  56.                         strcpy(temp,(pt+k)->;name);
  57.                         strcpy((pt+k)->;name,(pt+i)->;name);
  58.                         strcpy((pt+i)->;name,temp);
  59.                         for(m=0;m<M;m++)
  60.                         {
  61.                                 t=(pt+k)->;score[m];
  62.                                 (pt+k)->;score[m]=(pt+i)->;score[m];
  63.                                 (pt+i)->;score[m]=i;
  64.                         }

  65.                         t=(pt+k)->;sum;
  66.                         (pt+k)->;sum=(pt+i)->;sum;
  67.                         (pt+i)->;sum=t;
  68.                         t=(pt+k)->;aver;
  69.                         (pt+k)->;aver=(pt+i)->;aver;
  70.                         (pt+i)->;aver=t;
  71.                 }
  72.         }
  73. }

  74. int search(pt,n)//折半查找法
  75. STUDENT *pt;
  76. int n;
  77. {
  78.         int top,bottom,m;
  79.         top=0;
  80.         bottom=N-1;
  81.         while(top<=bottom)
  82.         {
  83.                 m=(bottom+top)/2;
  84.                 if(n<(pt+m)->;num)
  85.                         top=m+1;
  86.                 else if(n>;(pt+m)->;num)
  87.                         bottom=m-1;
  88.                 else
  89.                         return(m);
  90.         }
  91.         return(-1);
  92. }

  93. main()
  94. {
  95.         int i,j,k,number;
  96.         STUDENT stu[N];
  97.         for(i=0;i<N;i++)
  98.         {
  99.                 printf("\n Input num,name,score1-5:");
  100.                 scanf("%d%s%d%d%d%d%d%d",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],
  101.                     &stu[i].score[2],&stu[i].score[3],&stu[i].score[4]);
  102.         }
  103.         total(stu);
  104.         printdata(stu);
  105.         sort(stu);
  106.         printf("sorted result:");
  107.         printdata(stu);
  108.         printf("Input the searching number:");
  109.         scanf("%d",&number);
  110.         k=search(number);
  111.         if(k==-1)
  112.                 printf("Not found!");
  113.         else
  114.         {
  115.                 printf("No.%3d%8s",stu[k].num,stu[k].name);
  116.                 for(j=0;j<M;j++)
  117.                         printf("%7d",stu[k].score[j]);
  118.                 printf("%6.2f%6.2f\n",stu[k].sum,stu[k].aver);
  119.         }
  120. }

复制代码

论坛徽章:
0
5 [报告]
发表于 2004-06-05 18:07 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

只有经过亲身实践,才是自己的!

论坛徽章:
0
6 [报告]
发表于 2004-06-05 19:00 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

单纯的模仿别人的 是不行的   有时候  自己写的可能比别人的简单  却实现了同样的功能

论坛徽章:
0
7 [报告]
发表于 2004-06-05 19:44 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

[quote]原帖由 "天祥星辰"]首先写需求 然后进行可行性分析 接着概要设计 至于程序嘛 网上多的是[/quote 发表:

好像要先写可行性分析,再写需求分析把!!

论坛徽章:
0
8 [报告]
发表于 2004-06-07 08:05 |只看该作者

请教大虾——近日老师布置了个作业,但是不知如何下手。。

至于那个先那个后的问题 要从不同的立场上考虑喽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP