标题:急。要交的程序,好心人帮忙调试一下,在线等。谢谢。
只看楼主
fg612
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-7
 问题点数:0 回复次数:6 
急。要交的程序,好心人帮忙调试一下,在线等。谢谢。
#include<stdio.h>
#define  TERM 7
#define  CLAS 7
#define     ORDER 3
struct Student
   {
          char number[8];
          char name[10];
          int score;
          int sum;
          int average;
          int order;
  };

struct Student student[TERM][CLAS][ORDER];

void input()
{
    int i,j,k;
    for(i=1;i<=TERM;i++)
      for(j=1;j<=CLAS;j++)
         for(k=1;k<=ORDER;k++)
         {
             printf("Please input the student[%d][%d][%d] number\n",i,j,k);
             scanf("%s",student[i][j][k].number);
             printf("Please input the student[%d][%d][%d] name\n",i,j,k);
             scanf("%s",student[i][j][k].name);
             printf("Please input the student[%d][%d][%d] score\n",i,j,k);
             scanf("%s",student[i][j][k].score);
         }
}
void sumscore()
{
    int i,j,k;
    for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
        for(i=1;i<=TERM;i++)
      {

           student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
          printf(" student[%d][%d][%d] sum score is:%d",i,j,k, student[k][i][j].sum);
      }
}
void averagescore()
{
    int i,j,k;
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       for(i=1;i<=TERM;i++)
      {
           student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
           student[i][j][k].average= student[i][j][k].sum/TERM;
          printf(" student[%d][%d][%d] average score is:%d",i,j,k, student[i][j][k].average);
      }
}
void allorder()
{
    int i=6,j,k,m,n;
    int sam[CLAS*ORDER];
    int a=1;
    int t;
      for(j=1;j<=CLAS;j++)
         for(k=1;k<=ORDER;k++)
         {
             sam[a]=student[i][j][k].score;
             a++;
         }
       for(a=1;a<=CLAS*ORDER;a++)
        for(n=1;n<CLAS*ORDER-a;n++)
         {
            if(sam[a]<sam[a++])
             {
                 sam[a]=t;
                 sam[a]=sam[a++];
                 t=sam[a++];
                 sam[a]=student[i][j][k].order;
             }
        printf("the order is:sam[%d]:%d  student[%d][%d]:%d\n",a,student[i][j][k].order);
        }
}
void findnumber()
{
    int i,j,k;
    char c;
    printf("Please input the student's number:");
    scanf("%s",&c);
    printf("\n");
    for(i=1;i<=TERM;i++)
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(c==student[i][j][k].number)
        {
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
            printf("\n");
        }
        else printf("The number is error.\n");
        }
}
void findname()
{
    int i,j,k;
    char d;
    printf("Please input the student's name:");
    scanf("%s",&d);
    printf("\n");
    for(i=1;i<=TERM;i++)
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(d==student[i][j][k].name)
        {
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
            printf("\n");
        }
        else printf("The name is error.\n");
        }
}
void unfinash()
{
    int i=6;
    int j,k,f;
    printf("Please inpue the score line:");
    scanf("%d",&f);
    printf("/n");
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(student[i][j][k].order>=f)
        printf("finash\n");
        else printf("unfinash\n");
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
       }
}
void findclass()
{
    int i,j,k,e;
    printf("Please input the class(1-6):");
    scanf("%d",&e);
    printf("\n");
    for(i=1;i<=TERM;i++)
      for(k=1;k<=ORDER;k++)
      printf("the class %d information is:\n",e);
      {
          for(i=1;i<=TERM;i++)
          for(k=1;k<=ORDER;k++)
          printf("number:student[%d][%d][%d].number name:student[%d][%d][%d].name score:student[%d][%d][%d].score",i,e,k);
      }
}
void output()
{
    int o;
    printf("*********the system of the information of the student********\n");
    printf("the function include:\n");
    printf("1.you can input the students' information.\n");
    printf("2.you can count the all of the score of every student according to term.\n");
    printf("3.you can count the average of the score of every student.\n");
    printf("4.you can order the student according to the all of the score\n");
    printf("5.you can find the information of the student according to number.\n");
    printf("6.you can find the information of the student according to name.\n");
    printf("7.you can find the information of the student who do not finash the score.\n");
    printf("8.you can find the information of the student according to class.\n");
    printf("1.If you want input the students' information,please input '1'.\n");
    printf("2.If you want to know the all of the score of every student,please input '2'.\n");
    printf("3.If you want to know the average of the score,please input '3'.\n");
    printf("4.If you want to know the order of the student according score,please input '4'.\n");
    printf("5.If you want to know the information of the student accordind to number,please input '5'.\n");
    printf("6.If you want to know the information of the student accordind to name,please input '6'.\n");
    printf("7.If you want to know the information of the student who do not finash the score,please input '7'.\n");
    printf("8.If you want to know the information of the student accordind to class,please input '8'.\n");
    printf("Please input the massage:\n");
    scanf("%d",o);
    printf("\n");
}
void main()
{
    int o;
    
    void output();
    if(o==1) void input();
    else if(o==2) void allscore();
    else if(o==3) void averagescore();
    else if(o==4) void sumorder();
    else if(o==5) void findnumber();
    else if(o==6) void findname();
    else if(o==7) void unfinash();
    else if(o==8) void findclass();
}
搜索更多相关主题的帖子: int define TERM 
2008-07-07 11:16
fg612
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-7
得分:0 
哪位好心人能给修改一下,谢谢了。
2008-07-07 11:30
himpo
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:192
专家分:123
注 册:2008-5-16
得分:0 
#include<stdio.h>
#define  TERM 7
#define  CLAS 7
#define     ORDER 3
void findnumber();
struct Student
   {
          char number[8];
          char name[10];
          int score;
          int sum;
          int average;
          int order;
  };

struct Student student[TERM][CLAS][ORDER];

void input()
{
    int i,j,k;
    for(i=1;i<=TERM;i++)
      for(j=1;j<=CLAS;j++)
         for(k=1;k<=ORDER;k++)
         {
             printf("Please input the student[%d][%d][%d] number\n",i,j,k);
             scanf("%s",student[i][j][k].number);
             printf("Please input the student[%d][%d][%d] name\n",i,j,k);
             scanf("%s",student[i][j][k].name);
             printf("Please input the student[%d][%d][%d] score\n",i,j,k);
             scanf("%s",student[i][j][k].score);
         }
}
void sumscore()
{
    int i,j,k;
    for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
        for(i=1;i<=TERM;i++)
      {

           student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
          printf(" student[%d][%d][%d] sum score is:%d",i,j,k, student[k][i][j].sum);
      }
}
void averagescore()
{
    int i,j,k;
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       for(i=1;i<=TERM;i++)
      {
           student[i][j][k].sum= student[i][j][k].sum+ student[i][j][k].score;
           student[i][j][k].average= student[i][j][k].sum/TERM;
          printf(" student[%d][%d][%d] average score is:%d",i,j,k, student[i][j][k].average);
      }
}
void allorder()
{
    int i=6,j,k,m,n;
    int sam[CLAS*ORDER];
    int a=1;
    int t;
      for(j=1;j<=CLAS;j++)
         for(k=1;k<=ORDER;k++)
         {
             sam[a]=student[i][j][k].score;
             a++;
         }
       for(a=1;a<=CLAS*ORDER;a++)
        for(n=1;n<CLAS*ORDER-a;n++)
         {
            if(sam[a]<sam[a++])
             {
                 sam[a]=t;
                 sam[a]=sam[a++];
                 t=sam[a++];
                 sam[a]=student[i][j][k].order;
             }
        printf("the order is:sam[%d]:%d  student[%d][%d]:%d\n",a,student[i][j][k].order);
        }
}
void findnumber()
{
    int i,j,k;
    char c[8];
    printf("Please input the student's number:");
    scanf("%s",c);
    printf("\n");
    for(i=1;i<=TERM;i++)
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(strcmp(c,student[i][j][k].number)==0)
        {
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
            printf("\n");
        }
        else printf("The number is error.\n");
        }
}
void findname()
{
    int i,j,k;
    char d[10];
    printf("Please input the student's name:");
    scanf("%s",d);
    printf("\n");
    for(i=1;i<=TERM;i++)
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(strcmp(d,student[i][j][k].name)==0)
        {
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
            printf("\n");
        }
        else printf("The name is error.\n");
        }
}
void unfinash()
{
    int i=6;
    int j,k,f;
    printf("Please inpue the score line:");
    scanf("%d",&f);
    printf("/n");
     for(j=1;j<=CLAS;j++)
      for(k=1;k<=ORDER;k++)
       {
           if(student[i][j][k].order>=f)
        printf("finash\n");
        else printf("unfinash\n");
            printf("the student's information is:\n");
            printf("term:%d clas:%d number:%s name:%s score:%d\n",i,j,k,student[i][j][k].number,student[i][j][k].name,student[i][j][k].score);
            printf("average score:%d order:%d",student[i][j][k].average,student[i][j][k].order);
       }
}
void findclass()
{
    int i,j,k,e;
    printf("Please input the class(1-6):");
    scanf("%d",&e);
    printf("\n");
    for(i=1;i<=TERM;i++)
      for(k=1;k<=ORDER;k++)
      printf("the class %d information is:\n",e);
      {
          for(i=1;i<=TERM;i++)
          for(k=1;k<=ORDER;k++)
          printf("number:student[%d][%d][%d].number name:student[%d][%d][%d].name score:student[%d][%d][%d].score",i,e,k);
      }
}
void output()
{
    int o;
    printf("*********the system of the information of the student********\n");
    printf("the function include:\n");
    printf("1.you can input the students' information.\n");
    printf("2.you can count the all of the score of every student according to term.\n");
    printf("3.you can count the average of the score of every student.\n");
    printf("4.you can order the student according to the all of the score\n");
    printf("5.you can find the information of the student according to number.\n");
    printf("6.you can find the information of the student according to name.\n");
    printf("7.you can find the information of the student who do not finash the score.\n");
    printf("8.you can find the information of the student according to class.\n");
    printf("1.If you want input the students' information,please input '1'.\n");
    printf("2.If you want to know the all of the score of every student,please input '2'.\n");
    printf("3.If you want to know the average of the score,please input '3'.\n");
    printf("4.If you want to know the order of the student according score,please input '4'.\n");
    printf("5.If you want to know the information of the student accordind to number,please input '5'.\n");
    printf("6.If you want to know the information of the student accordind to name,please input '6'.\n");
    printf("7.If you want to know the information of the student who do not finash the score,please input '7'.\n");
    printf("8.If you want to know the information of the student accordind to class,please input '8'.\n");
    printf("Please input the massage:\n");
    scanf("%d",o);
    printf("\n");
}
int main()
{
    int o;
   
    void output();
    if(o==1) input();
    else if(o==2) sumscore();
    else if(o==3) averagescore();
    else if(o==4) allorder();
    else if(o==5) findnumber();
    else if(o==6) findname();
    else if(o==7) unfinash();
    else if(o==8) findclass();
 system("pause");
 return 0;
}



改正了,没改动你的算法。

gcc编译通过。。
2008-07-07 11:32
fg612
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-7
得分:0 
谢谢,好像还有问题,我在vc下编译,提示有错误。
Compiling...
111111.cpp
c:\program files\microsoft visual studio\myprojects\111111\111111.cpp(201) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

111111.exe - 1 error(s), 0 warning(s)
2008-07-07 11:44
himpo
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:192
专家分:123
注 册:2008-5-16
得分:0 
头文件的问题?

第一行加上
#include "stdafx.h"
看看

[[it] 本帖最后由 himpo 于 2008-7-7 11:56 编辑 [/it]]
2008-07-07 11:47
fg612
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-7
得分:0 
谢谢,加上之后出现以下错误,不好意啊,本人是个菜鸟。

Compiling...
23.cpp
c:\program files\microsoft visual studio\myprojects\23\23.cpp(3) : fatal error C1083: Cannot open precompiled header file: 'Debug/23.pch': No such file or directory
Error executing cl.exe.

23.obj - 1 error(s), 0 warning(s)
2008-07-07 13:30
fg612
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-7-7
得分:0 
Compiling...
23.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\23\23.cpp(62) : warning C4101: 'm' : unreferenced local variable
C:\Program Files\Microsoft Visual Studio\MyProjects\23\23.cpp(96) : error C2065: 'strcmp' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\23\23.cpp(198) : error C2065: 'system' : undeclared identifier
Error executing cl.exe.

23.exe - 2 error(s), 1 warning(s)
2008-07-07 13:31



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




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

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