标题:学籍管理系统,参考书上写的,编译报错,不知道什么情况,求高手帮忙看下, ...
只看楼主
weishen2011
Rank: 2
等 级:论坛游民
帖 子:92
专家分:70
注 册:2012-10-16
结帖率:80%
已结贴  问题点数:60 回复次数:4 
学籍管理系统,参考书上写的,编译报错,不知道什么情况,求高手帮忙看下,指点一二啊!谢谢了!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define M 3

void maininterface();
void findinterface();

void choice(long sno[],char sname[][20],int sage,float cs[],int N);
void findchoice(long sno[],char sname[][20],int sage,float cs[],int N);
void input(long sno[],char sname[][20],int sage,float cs[],int N);
void output(long sno[],char sname[][20],int sage,float cs[],int N);
void snofind(long sno[],char sname[][20],int sage,float cs[],int N);
void snamefind(long sno[],char sname[][20],int sage,float cs[],int N);
void cssort(long sno[],char sname[][20],int sage,float cs[],int N);
void total(long sno[],char sname[][20],int sage,float cs[],int N);

int main()
{
    //变量及数组定义
    long sno[M];
    char sname[M][20];
    int sage[M];
    float cs[M];
    int i,j;
      
    //显示界面
    maininterface();
    //选择操作
    choice(sno,sname,sage,cs,M);
}

void maininterface()
{
     printf("\t\t*************************************************\n");
     printf("\t\t*          欢迎使用学籍管理系统                 *\n");
     printf("\t\t*1.输入学生的基本信息    2.输出学生的基本信息   *\n");
     printf("\t\t*3.查找学生的基本信息    4.排序                 *\n");
     printf("\t\t*5.统计                  0.退出                 *\n");
     printf("\t\t*************************************************\n");
     printf("\t\t请输入0--5:\n");
}

void choice(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     int m;
     while(1)
     {
        scanf("%d",&m);
        switch(m)
        {
           case 1:
                input(sno,sname,sage,cs,N);
                maininterface();
                break;
           case 2:
                output(sno,sname,sage,cs,N);
                maininterface();
                break;
           case 3:
                findinterface();
                findchoice(sno,sname,sage,cs,N);
                break;
           case 4:
                cssort(sno,sname,sage,cs,N);
                break;
           case 5:
                total(sno,sname,sage,cs,N);
                maininterface();
                break;
           case 0:
                exit(1);
        }
     }
}

void findinterface()
{
     printf("\t\t***************************************\n");
     printf("\t\t*          欢迎使用查找操作          *\n");
     printf("\t\t*1.按学号查找                        *\n");
     printf("\t\t*2.按姓名查找                        *\n");
     printf("\t\t*0.返回上一级                        *\n");
     printf("\t\t***************************************\n");
     printf("\t\t请输入0--2:");
}

void findchoice(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     int m;
     while(1)
     {
        scanf("%d",&m);
        switch(m)
        {
           case 1:
                snofind(sno,sname,sage,cs,N);
                findinterface();
                break;
           case 2:
                snamefind(sno,sname,sage,cs,N);
                findinterface();
                break;
           case 0:
                break;
               
        }
        if(m==0)
        break;
     }
     maininterface();
}

void input(long sno[],char sname[][20],int sage,float cs[],int N)
{
   int i;
   //输入N个学生的基本信息
   printf("输入%d个学生的基本信息:\n",N);
   for(i=0;i<N;i++)
   {
      printf("输入第%d个学生的\n",i+1);
      printf("学号:");
      scanf("%ld",&sno[i]);
      getchar();
      
      printf("姓名:");
      gets(sname[i]);
      
      printf("年龄:");
      scanf("%d",&sage[i]);
      
      printf("成绩:");
      scanf("%f",&cs[i]);
   }
}

void output(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     int i;
     //输出N个学生的基本信息
     printf("\n%d个学生的基本信息为\n",N);
     for(i=0;i<N;i++)
     {
        printf("%-10ld",sno[i]);
        printf("%-16s",sname[i]);
        printf("%-4d",sage[i]);
        printf("%-6.0f",cs[i]);
        printf("\n");
     }
}

void snafind(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     long sno1;
     int i;
     //按学号查找
     printf("请输入您要查找的学号:\n");
     scanf("%ld",&sno1);
     for(i=0;i<N;i++)
     {
        if(sno[i]==sno1)
        break;
     }
     if(i<N)
     {
        printf("学号为%ld的学生的基本信息为:\n",sno1);
        printf("%-10ld",sno[i]);
        printf("%-16s",sname[i]);
        printf("%-4d",sage[i]);
        printf("%-6.0f",cs[i]);
        printf("\n");
     }
     else
     printf("您输入的学号有误!\n");
}

void snamefind(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     int i;
     char sname1[20];
     //按姓名查找
     printf("请输入您要查找的姓名:\n");
     getchar();
     gets(sname1);
     for(i=0;i<N;i++)
     {
        if(strcmp(sname[i],sname1)==0)     
        break;
     }
     if(i<N)
     {
        printf("姓名为%s的学生的基本信息为:\n",sname1);
        printf("%-10ld",sno[i]);
        printf("%-16s",sname[i]);
        printf("%-4d",sage[i]);
        printf("%-6.0f",cs[i]);
        printf("\n");  
     }
     else
     printf("您输入的姓名有误!\n");
}

void cssort(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     //按成绩降序排序
     int i,j,k;
     long tsno;
     char tsname[20];
     int tsage;
     float tcs;
     
     for(i=0;i<N-1;i++)
     {
        k=i;
        for(j=i+1;j<N;j++)
        {
           if(cs[j]>cs[k])
           k=j;
        }
        if(k!=i)
        {
           //交换下标i与k对应的学生信息
           tsno=sno[i];
           sno[i]=sno[k];
           sno[k]=tsno;//交换学号
           
           strcpy(tsname,sname[i]);
           strcpy(sname[i],sname[k]);
           strcpy(sname[k],tsname);//交换姓名
           
           tsage=sage[i];
           sage[i]=sage[k];
           sage[k]=tsage;//交换年龄
           
           tcs=cs[i];
           cs[i]=cs[k];
           cs[k]=tcs;//交换成绩
        }
     }     
}

void total(long sno[],char sname[][20],int sage[],float cs[],int N)
{
     //统计
     int i;
     //按优、良、不及格的顺序打印
     printf("\n优(成绩>=90)的学生为:\n");
     for(i=0;i<N;i++)
     {
        if(cs[i]>=90)
        {
           printf("%-10ld",sno[i]);
           printf("%-16s",sname[i]);
           printf("%-4d",sage[i]);
           printf("%-6.0f",cs[i]);
           printf("\n");
        }
     }
     
     printf("\n良(80=<成绩<90)的学生为:\n");
     for(i=0;i<N;i++)
     {
        if(cs[i]>=80&&cs[i]<90)
        {
           printf("%-10ld",sno[i]);
           printf("%-16s",sname[i]);
           printf("%-4d",sage[i]);
           printf("%-6.0f",cs[i]);
           printf("\n");  
        }
     }
     
     printf("\n中(成绩不小于70、小于80)的学生为:\n");
     for(i=0;i<N;i++)
     {
        if(cs[i]>=70&&cs[i]<80)
        {
           printf("%-10ld",sno[i]);
           printf("%-16s",sname[i]);
           printf("%-4d",sage[i]);
           printf("%-6.0f",cs[i]);
           printf("\n");
        }
     }
     
     printf("\n及格(成绩不小于60且小于70)的学生为:\n");
     for(i=0;i<N;i++)
     {
        if(cs[i]>=60&&cs[i]<70)
        {
           printf("%-10ld",sno[i]);
           printf("%-16s",sname[i]);
           printf("%-4d",sage[i]);
           printf("%-6.0f",cs[i]);
           printf("\n");
        }
     }
     
     printf("\n不及格(成绩低于60)的学生为:\n");
     for(i=0;i<N;i++)
     {
        if(cs[i]<60)
        {
           printf("%-10ld",sno[i]);
           printf("%-16s",sname[i]);
           printf("%-4d",sage[i]);
           printf("%-6.0f",cs[i]);
           printf("\n");
        }
     }
}
搜索更多相关主题的帖子: long void 学籍管理 include choice 
2012-11-16 01:07
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
得分:15 
回复 楼主 weishen2011
直接上一百分...
2012-11-16 08:31
雨缘桃思
Rank: 2
等 级:论坛游民
威 望:1
帖 子:8
专家分:30
注 册:2012-11-14
得分:15 
我最近也在做学生管理系统,,想撞豆腐块了,,现在连LS讲什么都不懂了,,,买豆腐块去了

凡有所学,皆成性格
2012-11-16 12:51
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
得分:15 
回复 3楼 雨缘桃思
这个...

你对对‘敌人’太仁慈了...
2012-11-16 14:24
一个孩子
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:356
专家分:954
注 册:2012-10-1
得分:15 
还是一个函数一个函数的测试,要不然的话不好下手!

重要的不是结果,是求一个结果的过程,哪怕千难万难,当你有想要的结果时,你已走的很远
2012-11-16 19:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-387216-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.224543 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved