| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1692 人关注过本帖
标题:[求助]关于读取函数与显示的问题
只看楼主 加入收藏
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:14 
[求助]关于读取函数与显示的问题
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>


struct table_game//定义一个全局的结构体
{
     char xmmc[11];//项目名称
    char xymc[13];//所属学院名称
    int mc;   //名次
};
struct table_zf
 {
     char xymc[13];
     int fs;
 };
//定义结构体数组(全局)
struct table_game GAME[1000];
struct table_zf   ZF[100];
int x = 0;//定义项目数


          //定义一个全局变量存放实际的人数
int sjs;
//输入比赛成绩
void input()
 {
     int n, i, j , index = 0;
     char temp[11];
     char wrong[100];//用来存放输入选择时候手误输入可能的字符
    system("cls");
     printf("***************************************************************************\n");
     printf("***             亲,欢迎来到运动员成绩录入功能!                         ***\n");
     printf("***************************************************************************\n");

     sjs = 0;

     for (i = 0; i <= 999; i++)
     {
         printf("\n********************************************************************\n");
         printf("*****                      亲,是否要录入比赛成绩!               *****\n");
         printf("---                             1、是哒!                           ---\n");
         printf("---                             2、不是哒!                         ---\n");
         printf("\n********************************************************************\n");

         printf("亲,请输入你的选择(1 or 2):");
         scanf("%d", &n);
         gets(wrong);

         while (n != 1 && n != 2)
         {
             printf("亲,你输得不是(1 or 2),请重新输入(1 or 2):");
             scanf("%d", &n);
             gets(wrong);
         }
         if (n == 2)
         {
             printf("over\n");
             break;
         }
         else
         {

             //正常情况下一个运动员的所有信息录入
            
             printf("输入项目名称:");
            gets(temp);

             for(j = 0;j<7;j++)
            {

                GAME[index].xmmc[j] = temp[j];

                printf("输入运动员所属学院名称:");
                gets(GAME[index].xymc);

                printf("输入名次:");
                int temp = 0;
                scanf("%d", &temp);
                GAME[index].mc = temp;

                gets(wrong);

                index++;
            }
         }
     }
     system("pause");
 }


void output()
 {
     int i, j;
     system("cls");
     printf("%-11s", "项目名称");
     printf("%-13s", "所属学院名称");
     printf("%-7s", "名次");
     printf("\n");

     for (i = 0; i <= 999; i++)
     {
         printf("%-11s", GAME[i].xmmc);
         printf("%-13s", GAME[i].xymc);
         printf("%-7d", GAME[i].mc);
     }
     system("pause");
 }
//保存数据
void save()
 {
     FILE *p;
     int n;
     char wrong[100];
     system("cls");

     printf("************************************************************************\n");
     printf("***                    亲,欢迎来到数据保存功能                      ***\n");
     printf("***                    1、确定保存   2、放弃保存                     ***\n");
     printf("************************************************************************\n");

     printf("亲,请输入你的选择(1 or 2):");
     scanf("%d", &n);
     gets(wrong);
     while (n != 1 && n != 2)
     {
         printf("亲,你输入的不是(1 or 2),请重新输入(1 or 2)");
         scanf("%d", &n);
         gets(wrong);
     }
     if (n == 1)
     {
         p = fopen("保存数据.txt", "w+");
         if (p == NULL)
         {
             printf("数据保存失败!\n");
             exit(0);
         }
         else
         {
             fwrite(GAME, sizeof(struct table_game), 1000, p);
             printf("亲,数据保存成功了哟!\n");
             fclose(p);
         }
     }
     else
     {
         printf("放弃数据保存,返回主菜单!\n");
     }
     system("pause");
 }
//读取函数
void load()
 {
     FILE*p;
     int n;
     char wrong[100];
     system("cls");
     printf("************************************************************************\n");
     printf("***                    亲,欢迎进入信息读取功能                      ***\n");
     printf("***                    1、确定读取      2、放弃读取                  ***\n");
     printf("************************************************************************\n");
     printf("亲,请输入你的选择(1 or 2):");
     scanf("%d", &n);
     gets(wrong);
     while (n != 1 && n != 2)
     {
         printf("亲,你输入的不是(1 or 2),请重新输入(1 or 2):");
         scanf("%d", &n);
         gets(wrong);
     }
     if (n == 1)
     {
         p = fopen("保存数据.txt", "r+");
         if (p == NULL)
         {
             printf("文件打开失败!\n");
             exit(0);
         }
         else
         {
             fwrite(GAME, sizeof(struct table_game), 1000, p);
             printf("亲,数据读取成功了哟!\n");
             fclose(p);
         }
     }
     else
     {
         printf("确定放弃数据读取,即将返回主菜单\n");
     }
     system("pause");
 }

//查询比赛成绩
void search()
 {
     int n, i, j, flag;
     char search_xmmc[11];
     int  search_mc;
     char search_xymc[13];
     char wrong[100];

     system("cls");

     printf("***********************************************************************\n");
     printf("***                 亲,欢迎来到查询比赛成绩功能                    ***\n");
     printf("***                     1、按照项目名称查询                         ***\n");
     printf("***                     2、按照名次查询                             ***\n");
     printf("***                     3、查询参赛院信息                           ***\n");
     printf("***                     4、退出查询 返回菜单                        ***\n");
     printf("***********************************************************************\n");
     printf("亲,请输入你的选择(1 or 2 or 3 or 4):");
     scanf("%d", &n);
     gets(wrong);
     while (n != 1 && n != 2 && n != 3 && n != 4)
     {
         printf("亲,你输入的不是(1 or 2 or 3 or 4),请重新输入(1 or 2 or 3 or 4)");
         scanf("%d", &n);
         gets(wrong);
     }

     switch (n)
     {
     case 1:
         printf("请输入要查询的项目名称:");
         gets(search_xmmc);


         for (j = 0; j<1000; j++)

         {
             flag = 0;
             //puts(GAME[i].xmmc == 0);
            if (strcmp(search_xmmc, GAME[j].xmmc) == 0)
             {
                 flag = 1;
                 printf("******                 按项目名称查询有以下结果         ******\n");
                 printf("***                      名次       学院                 ***\n ");
                 printf("*************************************************************\n");
                 printf("%7d%7s\n", GAME[j].mc, GAME[j].xymc);
                 break;
             }
         }


         if (flag == 0)
         {
             printf("查无此项目!\n");
         }
         break;
     case 2:
         printf("请输入名次:");
         scanf("%d", &search_mc);

         for (j = 0; j<1000; j++)
         {
             flag = 0;
             //puts(GAME[i].mc == 0);
            if (search_mc == GAME[j].mc)
             {
                 flag = 1;
                 printf("******                 按名次查询有以下结果           ******\n");
                 printf("***                  项目名称       学院                 ***\n ");
                 printf("*************************************************************\n");
                 printf("%11s%7s\n", GAME[j].xmmc, GAME[j].xymc);
                 break;
             }
         }

         if (flag == 0)
         {
             printf("该名次不存在!\n");
         }
         break;
     case 3:
         printf("请输入学院名称:");
         gets(search_xymc);

         for (j = 0; j<1000; j++)
         {
             flag = 0;
             //puts(GAME[i].xymc == 0);
            if (strcmp(search_xymc, GAME[j].xymc) == 0)
             {
                 flag = 1;
                 printf("******                 按学院名称查询有以下结果        ******\n");
                 printf("***                  项目名称       名次                 ***\n ");
                 printf("*************************************************************\n");

                 printf("%11s%7d\n", GAME[j].xmmc, GAME[j].mc);
                 break;
             }
         }

         if (flag == 0)
         {
             printf("该学院不存在!\n");
         }
         break;
     case 4: break;
     }
     system("pause");
 }

//显示团体总分排序
void sort()
 {
     int i, j;
     struct table_game t;
     system("cls");
     printf("******                   团体总分显示如下              *****\n");
     printf("******                  学院    总成绩     名次        *****\n");
     printf("************************************************************\n");
     for (i = 0; i <= 999; i++);
     {
         for (j = 0; j<999 - 1; j++)
         {
             if (GAME[j].mc<GAME[j + 1].mc)
             {
                 t = GAME[j];
                 GAME[j] = GAME[j + 1];
                 GAME[j + 1] = t;
             }

         }

     }
     output();
 }
//统计总分
void tongji()
 {
     int i;
     char wrong[100];
     system("cls");
     printf("***         亲,欢迎来到总分统计栏目      ***\n");

     for (i = 0; i <= 19; i++)
     {
         if (GAME[i].mc == 1)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 10;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 10;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 10;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 10;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 10;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 10;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 10;
         }
         if (GAME[i].mc == 2)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 8;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 8;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 8;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 8;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 8;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 8;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 8;
         }
         if (GAME[i].mc == 3)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 6;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 6;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 6;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 6;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 6;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 6;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 6;
         }
         if (GAME[i].mc == 4)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 5;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 5;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 5;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 5;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 5;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 5;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 5;
         }
         if (GAME[i].mc == 5)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 4;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 4;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 4;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 4;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 4;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 4;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 4;
         }
         if (GAME[i].mc == 6)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 3;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 3;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 3;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 3;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 3;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 3;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 3;
         }
         if (GAME[i].mc == 7)
         {
             if (strcmp(GAME[i].xymc, "建管学院") == 0)
                 ZF[1].fs += 1;
             if (strcmp(GAME[i].xymc, "土木学院") == 0)
                 ZF[2].fs += 1;
             if (strcmp(GAME[i].xymc, "经管学院") == 0)
                 ZF[3].fs += 1;
             if (strcmp(GAME[i].xymc, "人文学院") == 0)
                 ZF[4].fs += 1;
             if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                 ZF[5].fs += 1;
             if (strcmp(GAME[i].xymc, "电气学院") == 0)
                 ZF[6].fs += 1;
             if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                 ZF[7].fs += 1;
         }


     }

     system("pause");

 }

//菜单函数
void menu()
 {
     time_t t;
     struct tm *p;
     int n;

     t = time(NULL);
     p = (struct tm *)localtime(&t);

     system("cls");

     printf("                             运动会管理系统                \n");
     printf("          %d-%d-%d  %d:%d:%d\n", p->tm_year + 1990, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
     printf("***********************************************************\n");
     printf("---               1、录入比赛成绩功能                  ----\n");
     printf("---               2、查询各个比赛项目的成绩            ----\n");
     printf("---               3、显示团体总分报表                  ----\n");
     printf("---               4、统计总分                          ----\n");
     printf("---               5、保存数据                          ----\n");
     printf("---               6、读取数据                          ----\n");
     printf("---               7、退出系统                          ----\n");
     printf("***********************************************************\n");

     printf("请输入你的选择(1-7):");
     scanf("%d", &n);

     while (n<0 || n>7)
     {
         printf("亲,输错了,请重新输入(1-7)");
         scanf("%d", &n);
     }
     switch (n)
     {
     case 1: input(); menu(); break;
     case 2: search(); menu(); break;
     case 3: sort();  menu(); break;
     case 4: tongji(); menu(); break;
     case 5: save();  menu(); break;
     case 6: load();  menu(); break;
     case 7: exit(0); menu(); break;
     }
 }
//主函数
void main()
 {
     menu();//直接调用
     system("pause");

}
问题:1、读取函数没有写错,但是退出系统再进入后数据无法读出
      2、在查询功能中,项目名称显示不出来并且在保存的数据中项目名称显示为乱码
      3、关于统计总分的代码无从下手求指教
搜索更多相关主题的帖子: 学院 项目 结构体 include 
2016-06-22 09:55
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
收藏
得分:20 
修改了录入和读取,你先试试。统计总分的要求是什么?

程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>


struct table_game//定义一个全局的结构体
{
    char xmmc[11];//项目名称
    char xymc[13];//所属学院名称
    int mc;   //名次
};
struct table_zf
{
    char xymc[13];
    int fs;
};
//定义结构体数组(全局)
struct table_game GAME[1000];
struct table_zf   ZF[100];
int x = 0;//定义项目数


          //定义一个全局变量存放实际的人数
int sjs;
//输入比赛成绩
void input()
{
    int n, i, j, index = 0;
    char temp[11];
    char wrong[100];//用来存放输入选择时候手误输入可能的字符
    system("cls");
    printf("***************************************************************************\n");
    printf("***             亲,欢迎来到运动员成绩录入功能!                         ***\n");
    printf("***************************************************************************\n");

    sjs = 0;

    for (i = 0; i <= 999; i++)
    {
        printf("\n********************************************************************\n");
        printf("*****                      亲,是否要录入比赛成绩!               *****\n");
        printf("---                             1、是哒!                           ---\n");
        printf("---                             2、不是哒!                         ---\n");
        printf("\n********************************************************************\n");

        printf("亲,请输入你的选择(1 or 2):");
        scanf("%d", &n);
        gets(wrong);

        while (n != 1 && n != 2)
        {
            printf("亲,你输得不是(1 or 2),请重新输入(1 or 2):");
            scanf("%d", &n);
            gets(wrong);
        }
        if (n == 2)
        {
            printf("over\n");
            break;
        }
        else
        {

            //正常情况下一个运动员的所有信息录入

            printf("输入项目名称:");
            gets(GAME[i].xmmc);

            //for (j = 0; j<7; j++)
            {

                //GAME[index].xmmc[j] = temp[j];

                printf("输入运动员所属学院名称:");
                gets(GAME[i].xymc);

                printf("输入名次:");
                int temp = 0;
                scanf("%d", &temp);
                GAME[i].mc = temp;

                gets(wrong);

                index++;
            }
        }
    }
    system("pause");
}


void output()
{
    int i, j;
    system("cls");
    printf("%-11s", "项目名称");
    printf("%-13s", "所属学院名称");
    printf("%-7s", "名次");
    printf("\n");

    for (i = 0; i <= 999; i++)
    {
        printf("%-11s", GAME[i].xmmc);
        printf("%-13s", GAME[i].xymc);
        printf("%-7d", GAME[i].mc);
    }
    system("pause");
}
//保存数据
void save()
{
    FILE *p;
    int n;
    char wrong[100];
    system("cls");

    printf("************************************************************************\n");
    printf("***                    亲,欢迎来到数据保存功能                      ***\n");
    printf("***                    1、确定保存   2、放弃保存                     ***\n");
    printf("************************************************************************\n");

    printf("亲,请输入你的选择(1 or 2):");
    scanf("%d", &n);
    gets(wrong);
    while (n != 1 && n != 2)
    {
        printf("亲,你输入的不是(1 or 2),请重新输入(1 or 2)");
        scanf("%d", &n);
        gets(wrong);
    }
    if (n == 1)
    {
        p = fopen("保存数据.txt", "w+");
        if (p == NULL)
        {
            printf("数据保存失败!\n");
            exit(0);
        }
        else
        {
            fwrite(GAME, sizeof(struct table_game), 1000, p);
            printf("亲,数据保存成功了哟!\n");
            fclose(p);
        }
    }
    else
    {
        printf("放弃数据保存,返回主菜单!\n");
    }
    system("pause");
}
//读取函数
void load()
{
    FILE*p;
    int n;
    char wrong[100];
    system("cls");
    printf("************************************************************************\n");
    printf("***                    亲,欢迎进入信息读取功能                      ***\n");
    printf("***                    1、确定读取      2、放弃读取                  ***\n");
    printf("************************************************************************\n");
    printf("亲,请输入你的选择(1 or 2):");
    scanf("%d", &n);
    gets(wrong);
    while (n != 1 && n != 2)
    {
        printf("亲,你输入的不是(1 or 2),请重新输入(1 or 2):");
        scanf("%d", &n);
        gets(wrong);
    }
    if (n == 1)
    {
        p = fopen("保存数据.txt", "r+");
        if (p == NULL)
        {
            printf("文件打开失败!\n");
            exit(0);
        }
        else
        {
            fread(GAME, sizeof(struct table_game), 1000, p);
            printf("亲,数据读取成功了哟!\n");
            fclose(p);
        }
    }
    else
    {
        printf("确定放弃数据读取,即将返回主菜单\n");
    }
    system("pause");
}

//查询比赛成绩
void search()
{
    int n, i, j, flag;
    char search_xmmc[11];
    int  search_mc;
    char search_xymc[13];
    char wrong[100];

    system("cls");

    printf("***********************************************************************\n");
    printf("***                 亲,欢迎来到查询比赛成绩功能                    ***\n");
    printf("***                     1、按照项目名称查询                         ***\n");
    printf("***                     2、按照名次查询                             ***\n");
    printf("***                     3、查询参赛院信息                           ***\n");
    printf("***                     4、退出查询 返回菜单                        ***\n");
    printf("***********************************************************************\n");
    printf("亲,请输入你的选择(1 or 2 or 3 or 4):");
    scanf("%d", &n);
    gets(wrong);
    while (n != 1 && n != 2 && n != 3 && n != 4)
    {
        printf("亲,你输入的不是(1 or 2 or 3 or 4),请重新输入(1 or 2 or 3 or 4)");
        scanf("%d", &n);
        gets(wrong);
    }

    switch (n)
    {
    case 1:
        printf("请输入要查询的项目名称:");
        gets(search_xmmc);


        for (j = 0; j<1000; j++)

        {
            flag = 0;
            //puts(GAME[i].xmmc == 0);
            if (strcmp(search_xmmc, GAME[j].xmmc) == 0)
            {
                flag = 1;
                printf("******                 按项目名称查询有以下结果         ******\n");
                printf("***                      名次       学院                 ***\n ");
                printf("*************************************************************\n");
                printf("%7d%7s\n", GAME[j].mc, GAME[j].xymc);
                break;
            }
        }


        if (flag == 0)
        {
            printf("查无此项目!\n");
        }
        break;
    case 2:
        printf("请输入名次:");
        scanf("%d", &search_mc);

        for (j = 0; j<1000; j++)
        {
            flag = 0;
            //puts(GAME[i].mc == 0);
            if (search_mc == GAME[j].mc)
            {
                flag = 1;
                printf("******                 按名次查询有以下结果           ******\n");
                printf("***                  项目名称       学院                 ***\n ");
                printf("*************************************************************\n");
                printf("%11s%7s\n", GAME[j].xmmc, GAME[j].xymc);
                break;
            }
        }

        if (flag == 0)
        {
            printf("该名次不存在!\n");
        }
        break;
    case 3:
        printf("请输入学院名称:");
        gets(search_xymc);

        for (j = 0; j<1000; j++)
        {
            flag = 0;
            //puts(GAME[i].xymc == 0);
            if (strcmp(search_xymc, GAME[j].xymc) == 0)
            {
                flag = 1;
                printf("******                 按学院名称查询有以下结果        ******\n");
                printf("***                  项目名称       名次                 ***\n ");
                printf("*************************************************************\n");

                printf("%11s%7d\n", GAME[j].xmmc, GAME[j].mc);
                break;
            }
        }

        if (flag == 0)
        {
            printf("该学院不存在!\n");
        }
        break;
    case 4: break;
    }
    system("pause");
}

//显示团体总分排序
void sort()
{
    int i, j;
    struct table_game t;
    system("cls");
    printf("******                   团体总分显示如下              *****\n");
    printf("******                  学院    总成绩     名次        *****\n");
    printf("************************************************************\n");
    for (i = 0; i <= 999; i++);
    {
        for (j = 0; j<999 - 1; j++)
        {
            if (GAME[j].mc<GAME[j + 1].mc)
            {
                t = GAME[j];
                GAME[j] = GAME[j + 1];
                GAME[j + 1] = t;
            }

        }

    }
    output();
}
//统计总分
void tongji()
{
    int i;
    char wrong[100];
    system("cls");
    printf("***         亲,欢迎来到总分统计栏目      ***\n");

    for (i = 0; i <= 19; i++)
    {
        if (GAME[i].mc == 1)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 10;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 10;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 10;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 10;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 10;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 10;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 10;
        }
        if (GAME[i].mc == 2)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 8;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 8;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 8;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 8;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 8;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 8;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 8;
        }
        if (GAME[i].mc == 3)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 6;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 6;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 6;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 6;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 6;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 6;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 6;
        }
        if (GAME[i].mc == 4)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 5;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 5;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 5;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 5;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 5;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 5;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 5;
        }
        if (GAME[i].mc == 5)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 4;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 4;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 4;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 4;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 4;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 4;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 4;
        }
        if (GAME[i].mc == 6)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 3;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 3;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 3;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 3;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 3;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 3;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 3;
        }
        if (GAME[i].mc == 7)
        {
            if (strcmp(GAME[i].xymc, "建管学院") == 0)
                ZF[1].fs += 1;
            if (strcmp(GAME[i].xymc, "土木学院") == 0)
                ZF[2].fs += 1;
            if (strcmp(GAME[i].xymc, "经管学院") == 0)
                ZF[3].fs += 1;
            if (strcmp(GAME[i].xymc, "人文学院") == 0)
                ZF[4].fs += 1;
            if (strcmp(GAME[i].xymc, "艺术学院") == 0)
                ZF[5].fs += 1;
            if (strcmp(GAME[i].xymc, "电气学院") == 0)
                ZF[6].fs += 1;
            if (strcmp(GAME[i].xymc, "建筑学院") == 0)
                ZF[7].fs += 1;
        }


    }

    system("pause");

}

//菜单函数
void menu()
{
    time_t t;
    struct tm *p;
    int n;

    t = time(NULL);
    p = (struct tm *)localtime(&t);

    system("cls");

    printf("                             运动会管理系统                \n");
    printf("          %d-%d-%d  %d:%d:%d\n", p->tm_year + 1990, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
    printf("***********************************************************\n");
    printf("---               1、录入比赛成绩功能                  ----\n");
    printf("---               2、查询各个比赛项目的成绩            ----\n");
    printf("---               3、显示团体总分报表                  ----\n");
    printf("---               4、统计总分                          ----\n");
    printf("---               5、保存数据                          ----\n");
    printf("---               6、读取数据                          ----\n");
    printf("---               7、退出系统                          ----\n");
    printf("***********************************************************\n");

    printf("请输入你的选择(1-7):");
    scanf("%d", &n);

    while (n<0 || n>7)
    {
        printf("亲,输错了,请重新输入(1-7)");
        scanf("%d", &n);
    }
    switch (n)
    {
    case 1: input(); menu(); break;
    case 2: search(); menu(); break;
    case 3: sort();  menu(); break;
    case 4: tongji(); menu(); break;
    case 5: save();  menu(); break;
    case 6: load();  menu(); break;
    case 7: exit(0); menu(); break;
    }
}
//主函数
void main()
{
    menu();//直接调用
    system("pause");

}
2016-06-22 10:12
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
收藏
得分:0 
回复 楼主 SR忘
统计总分就是总共有19个项目,每个项目有对应的一到七名,每个学院的总分统计就是在各项目得分之和
2016-06-22 19:43
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
收藏
得分:0 
回复 2楼 grmmylbs
提问如何在录入功能中,关于名次与学院处循环七次且不影响后面的功能?之前试过改动就造成后面查询读取都出现问题
2016-06-22 20:07
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
收藏
得分:0 
星期五还要交一份五千字的课程设计报告,求大神指点,关于统计分数的部分该怎么写,急求呀!
2016-06-22 23:02
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
收藏
得分:0 
为啥要循环7次
2016-06-23 08:57
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
收藏
得分:0 
回复 6楼 grmmylbs
因为一个项目有7个学院参加,在录入中项目名称录一次,学院名次则是7次
2016-06-23 09:48
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
收藏
得分:0 
之前和你讨论过啊,struct table_game GAME[1000];这个是按人来保存数据的,除非你改成struct table_game GAME[19];按项目来保存,那么结构体里面的参数都要改,代码很多地方也要改,几乎要重写。
2016-06-23 09:54
SR忘
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2016-6-22
收藏
得分:0 
回复 8楼 grmmylbs
哦哦,那算了,明天就要交作业了,来不及改了,求大神指导关于统计总分的部分怎么弄,急!
2016-06-23 10:54
tremere
Rank: 6Rank: 6
来 自:火星
等 级:侠之大者
帖 子:223
专家分:432
注 册:2013-3-11
收藏
得分:0 
看得眼都花完

极品菜鸟,来学习啦,啦啦啦啦啦啦啦。。。
2016-06-23 10:58
快速回复:[求助]关于读取函数与显示的问题
数据加载中...
 
   



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

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