⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 复件 1.c

📁 运动会分数统计,我的课程设计,用c语言编写的,
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <conio.h>
#include <stdio.h>   
  


#define MAX 20

typedef struct node1{
      int school;  /*学校编号*/
      int record;  /*项目成绩*/
      struct node1 *next;  /*链域*/ 
     }Schools;

typedef struct {
      int item;  /*项目编号*/
      Schools *firstschool; /*链域指向链表中第一个结点*/ 
     }ITEM;
typedef struct
     {
      int item;  /*项目编号*/
      int j;
      int m;
      int w;
      int n;
      int School[MAX];

     }ITEMSAVE;

typedef struct ALLitems1{ 
        int z; /* 项目总数 */
        ITEM a[MAX];
     }ALLitems;

typedef struct node2 {
       int item;  /*该学校获奖的项目*/
       int record;  /*项目成绩*/
       struct node2 *next;  /*链域*/ 
    }Items;

typedef struct { 
      int school;  /*学校编号*/
      int score;  /*学校总分*/
      int boys;  /*男团体总分*/
      int girls;  /*女团体总分*/
      Items *firstitem; /*链域指向链表中第一个获奖项目的结点*/ 
    }SCHNode;

typedef struct ALLNode1{
       int n; /* 学校总数 */
       SCHNode b[MAX];
    }ALLNode;

ALLitems *g1;
ALLNode *g2;
ITEMSAVE s[MAX];

void funct1(ALLitems *g1,ALLNode *g2)                    /* 输入各个项目成绩 */
{ 

  Schools *p1;
  Items *p2;
  int i,j,k,m,w,h,x,y;
    printf("\n");
    printf("\n");
    printf("\n");
    printf("\t\t************************************************\n");
    printf("\t\t*           运动会分数统计系统                 *\n");
    printf("\t\t************************************************\n");
    printf("\t\t\t                                             \n");
    printf("\t\t************************************************\n");
    printf("\t\t*            输入各个项目信息                  *\n");
    printf("\t\t************************************************\n");

  printf("\t\t\t     输入男子项目总数m:");
  scanf("%d",&m);
  s[1].m=m;
  if(m<0||m>20) 
   { printf("\t\t\t     输入有误,m是20以内的整数,请重新输入:");
     scanf("%d",&m);
   }
  printf("\t\t\t     输入女子项目总数w:");
  scanf("%d",&w);
  s[1].w=w;
  if(w<0||w>20) 
   { printf("\t\t\t     输入有误,w是20以内的整数,请重新输入:");
     scanf("%d",&w);
   }
  printf("\t\t\t     输入参加运动会的学校总数n:");

  scanf("%d",&y);
 g2->n=y;
 s[1].n=y;

  if(g2->n<0||g2->n>20) 
   { printf("\t\t\t     输入有误,n是20以内的整数,请重新输入:");
     scanf("%d",&g2->n);
   }
  g1->z=m+w;
  printf("\t\t\t     则项目编号为男子1-%d,女子%d-%d",m,m+1,g1->z);
      printf("\n\t\t************************************************\n");
  printf("\t\t*     \t        记录运动会成绩 \t\t       *\n\t\t*\t        (输入0标志结束)                *");
      printf("\n\t\t************************************************");

  for(k=1;k<=g1->z;k++)
   { g1->a[k].item=k;
     g1->a[k].firstschool=NULL;
   }

  for(k=1;k<=g2->n;k++)
   { g2->b[k].school=k;
     g2->b[k].firstitem=NULL; 
     g2->b[k].score=g2->b[k].boys=g2->b[k].girls=0;
   }
     g2->b[0].score=g2->b[0].boys=g2->b[0].girls=0;
  while(i!=0)
   { 
   
   printf("\n\t\t\t     项目:");
     scanf("%d",&i);
     s[i].item=i;
     if(i!=0)
     
     { printf("\t\t\t     1.前三名   2.前五名\n");
       printf("\t\t\t     请选择:"); 
       scanf("%d",&j);
         fflush(stdin);
       if(j!=1&&j!=2)
        { printf("\t\t\t     输入有误,请重新选择:");
          scanf("%d",&j);
            fflush(stdin);
        }
        s[i].j=j;
      if(j==1)               /* 该项目只有前三名时执行此语句 */
       { 
          h=3; 
         do{ printf("\t\t\t     第%d名:学校(学校编号为数字)",h);
              fflush(stdin);
             scanf("%d",&x);
              fflush(stdin);
             s[i].School[h]=x;
             p1=(Schools *)malloc(sizeof(Schools));
             p1->school=x;
             p2=(Items *)malloc(sizeof(Items));
             p2->item=i;
             if(h==3) p2->record=p1->record=2;
             if(h==2) p2->record=p1->record=3;
             if(h==1) p2->record=p1->record=5;
             p1->next=g1->a[i].firstschool;
             g1->a[i].firstschool=p1;
             p2->next=g2->b[x].firstitem;
             g2->b[x].firstitem=p2;
             g2->b[x].score=g2->b[x].score+p2->record;        /* 累计总分 */
             if(i<=m) g2->b[x].boys=g2->b[x].boys+p2->record;  /* 累计男团体总分 */
             else  g2->b[x].girls=g2->b[x].girls+p2->record;   /* 累计女团体总分 */ 
             h--;
           }while(x!=0&&h!=0);
       }
      if(j==2)              /* 该项目有前五名时执行此语句 */
       {   
          h=5; 
         do{ printf("\t\t\t     第%d名:学校(学校编号为数字)",h);
             scanf("%d",&x);
             s[i].School[h]=x;
             p1=(Schools *)malloc(sizeof(Schools));
             p1->school=x;
             p2=(Items *)malloc(sizeof(Items));
             p2->item=i;
             if(h==5) p2->record=p1->record=1;
             if(h==4) p2->record=p1->record=2;
             if(h==3) p2->record=p1->record=3;
             if(h==2) p2->record=p1->record=5;
             if(h==1) p2->record=p1->record=7;
             p1->next=g1->a[i].firstschool;
             g1->a[i].firstschool=p1;
             p2->next=g2->b[x].firstitem;
             g2->b[x].firstitem=p2;
             g2->b[x].score=g2->b[x].score+p2->record;        /* 累计总分 */
             if(i<=m) g2->b[x].boys=g2->b[x].boys+p2->record;  /* 累计男团体总分 */
             else  g2->b[x].girls=g2->b[x].girls+p2->record;   /* 累计女团体总分 */ 
             h--;
           }while(x!=0&&h!=0);
           
             
}    
       }
     }  

   }




void funct2(ALLNode *g2)                                 /* 输出各学校总分 */
{ int k;
    printf("\n");
    printf("\n");
    printf("\n");
    printf("\t\t************************************************\n");
    printf("\t\t*           运动会分数统计系统                 *\n");
    printf("\t\t************************************************\n");
    printf("\t\t\t                                             \n");
    printf("\t\t************************************************\n");
    printf("\t\t*            输出各学校总分                    *\n");
    printf("\t\t************************************************\n");
    printf("\t\t*        学校编号\t     总分              *\n");

  for(k=1;k<=g2->n;k++)
  printf("\t\t*          %2d\t\t      %2d               *\n",k,g2->b[k].score);
    
  printf("\n");
  printf("\t\t************************************************\n");
  printf("\t\t            按任意键返回主菜单......");

    getch(); 
  
}

void funct3(ALLNode *g2)                                /* 按学校编号排序输出 */
{ int k;
  Items *p2;
    printf("\n");
    printf("\n");
    printf("\n");
    printf("\t\t************************************************\n");
    printf("\t\t*           运动会分数统计系统                 *\n");
    printf("\t\t************************************************\n");
    printf("\t\t\t                                             \n");
    printf("\t\t************************************************\n");
    printf("\t\t*          按学校编号排序输出                  *\n");
    printf("\t\t************************************************\n");
    printf("\t\t*      学校编号\t\t   获奖情况            *\n");
  for(k=1;k<=g2->n;k++)
  { printf("\t\t*         %2d\t \t\t              *\n",k);
    p2=g2->b[k].firstitem;
    while(p2!=NULL)
    { printf("\t\t*                  项目%2d:得%2d分               *\n",p2->item,p2->record);
      p2=p2->next;
    }
    printf("\t\t*                                              *\n");
  }
    printf("\t\t************************************************\n");
  printf("\n");
  printf("                  按任意键返回主菜单......");
      getch(); 
  
}

void funct4(ALLNode *g2)                               /* 按学校总分排序输出 */
{ int i,j,k;
    printf("\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -