论坛: 编程破解 标题: 帮我改一下错阿,c小程序,谢谢了 复制本贴地址    
作者: realpope [realpope]    论坛用户   登录
可能这个程序错误很多,很乱,请大家不要笑我菜
我在tc里面编译不了,总是说找不到头文件。可是头文件就在tc目录里面阿
不懂,所以那上来问问大家,谢谢了


编写一个考试成绩查询系统,有如下功能
1、输入20个同学的学号和成绩。
2、输入某个同学的学号,查询他或她的成绩。
3、查询最高分。
4、查询最低分。
5、查询平均分。
6、按分数从高到低排列。

功能键:1-查询成绩2-最高分3-最低分
    4-平均分5-降序排列   0-退出系统

/*---------------------------main block--------------------------*/

#include <stdio.h>

#define N 20

  typedef struct inf
{
  int num;
  float score;
}Sinf;

typedef struct node
{
  Sinf data;
  struct node * next;
}Snode;


void sea_score(Snode *)
void max_score(Snode *)
void min_score(Snode *)
void ave_score(Snode *)
void low_order(Snode *)
int get_Rint( )


int main()
{
int i;
int chioce;
Sinf infor;
Snode *p,*h;

h=(Snode *)malloc(sizeof(Snode));
h->next=NULL;
p=h;
 
printf("Please enter the student's  number and score:\n");

for(i=1;i<=N;i++)
{
  scanf("%d%f",&infor.num,&infor.score);

  p->next=p;
  p=(Snode *)malloc(sizeof(Snode));
  p->data.num=infor.num;
  p->data.score=infor.score;
 
  if(i==N)  p->next=NULL;
  }

printf("What do you want to do?Please make a choice:");
printf("\n 1.search score  2.the max-score");
printf("\n 3.the min-score  4.the average score");
printf("\n 5.store in low  ");
printf("\n 0.to quit");
 
choice=get_Rint();

switch(choice)
{
  case '1': sea_score(h); break;
  case '2': max_score(h); break;
  case '3': min_score(h); break;
  case '4': ave_score(h); break;
  case '5': low_order(h); break;
  case '0': printf("\nGoodbye,thanks for using");
}
 
  return 0;
}

/* ----------------- get choice --------------------------------*/
int get_Rint()
{
int n;

while(scanf("%d",&n)!=1)
printf("Please enter an integer from 0 to 5:\n");

while(n<0&&n>5)
printf("Please enter an integer from 0 to 5:\n");

return n;
}

/*----------------------search score----------------------------*/

void sea_score(Snode *h)
{
int m,i;
Snode *q;

q=h->next;

printf("Please enter the number of student:\n");
scanf("%d",&m);

for(i=1;i<=N;i++)
{
  if(q->data.num==m) contine;
  else q=q->next;
  }

printf("The score of the student is %f\n",q->data.score);
return 0;
}

/*--------------------max score--------------------------------*/

void max_score(Snode *h)
{
float s=0.0;
Snode *q;

q=h->next;

while(q->next!=NULL)
{
  if(s>=q->data.score)
    q=q->next;
  else  s=q.data.score;
  }

printf("The max score is %f",s);
return 0;
}

/*----------------------min score-------------------------------*/
       
   
void min_score(Snode *h)
{
float s=100.0;
Snode *q;

q=h->next;
 
while(q->next!=NULL)
{
  if(s<=q->data.score)
    q=q->next;
  else  s=q.data.score;
  }

printf("The min score is %f",s);
return 0;
}

/*-----------------------average score--------------------------*/

void ave_scroe(Snode *h)
{
float sum=0.0;
int i=0;
Snode *q;

q=h->next;
 
while(q->next!=NULL)
{
  sum+=q->data.scroe;
  q=q->next;
  i++;
  }

printf("The average score is %f\n",sum/i);
return 0;
}

/*-------------------------store in low-order-----------------------*/

void low_order(Snode *h)
{
Snode *p,*q;
int i,j;
float t;

p=h->next;
q=p->next;

for(i=1;i<N;i++)
    { for(j=19;j>=i;j--)
        { 
          if(p->data.scroe>q->data.score)
            {
              t=p->data.scroe;
              p->data.score=q->data.score;
              q->data.score=t;
              }
          q=q->next;
          }

      p=p->next;
      q=p->next;
    }
 
p=h->next;
while(p->next!=NULL)
{
  printf("%f",p->data.score);
  p=p->next;
}

return 0;

         






































[此贴被 远山之城(realpope) 在 12月26日21时27分 编辑过]


[此贴被 远山之城(realpope) 在 01月06日18时10分 编辑过]

地主 发表时间: 03-12-26 12:36

回复: ceo_8008 [ceo_8008]   论坛用户   登录
把错误提示贴上来看看

B1层 发表时间: 03-12-26 13:27

回复: jfyygymtdh [jfyygymtdh]   论坛用户   登录
#define N 20;
这句是什么意思啊?

能给我讲讲吗?

B2层 发表时间: 03-12-26 20:54

回复: realpope [realpope]   论坛用户   登录
哦 不好意思 打错了

是#define N 20

后面没有分号~~谢谢楼上两位~!!

B3层 发表时间: 03-12-26 21:26

回复: realpope [realpope]   论坛用户   登录
错误的提示就是找不到头文件

你们谁可以帮我编译运行一下么? 谢谢了

B4层 发表时间: 03-12-26 21:29

回复: sniper167 [sniper167]   论坛用户   登录
找不到头文件?
可能是你tc的设置有问题.

B5层 发表时间: 03-12-26 22:05

回复: realpope [realpope]   论坛用户   登录
可能吧  可是头文件的默认路径我不会改阿

B6层 发表时间: 03-12-26 22:09

回复: ysfilone [ysfilone]   论坛用户   登录
不好意思

你的程序不太好读  做好加点注释

呵呵~~

B7层 发表时间: 03-12-27 19:42

回复: realpope [realpope]   论坛用户   登录
哦 下次一定加上注释

B8层 发表时间: 03-12-29 17:10

回复: lovejiang [lovejiang]   论坛用户   登录
就是在程序中出现的N用20代替

B9层 发表时间: 04-01-01 23:39

回复: ysfilone [ysfilone]   论坛用户   登录
这个谁都知道 

我想jfyygymtdh兄的意思是后面多了个分号。

B10层 发表时间: 04-01-02 11:47

回复: f [yifanernei]   论坛用户   登录
同志,我把你这个程序给编了一下,错误可真不少呢!
也没仔细看,不过你在MAIN函数上面的几个函数声明有误,没加分号,还有第一个printf()的后面没引号,调用int_Rint()时没参数,反正很多了,自己看着办吧!
找不到头文件的话,也好办,在TC中的OPTION下拉菜单中选directories,把上面的INCLUDE及LIB路径设定好就可以了,然后再选save options 保存一下就可以了!

B11层 发表时间: 04-01-06 16:06

回复: realpope [realpope]   论坛用户   登录
真是太谢谢楼上的了

还希望以后多多指教,感激不尽~!!!

B12层 发表时间: 04-01-06 18:06

回复: f [yifanernei]   论坛用户   登录
哪的话嘛,大家共同进步吧!

B13层 发表时间: 04-01-07 09:30

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号