zoukankan      html  css  js  c++  java
  • 学生运动会分数记录系统

    今天拉了一天肚子,快虚脱了,还要忙着复习最后两科,(明天考完就解放了,O(∩_∩)O哈哈~)。只写了分数记录系统输入函数,明天考完试后再添加输出和注释。

    代码如下:

      1 #include"iostream"
      2 using namespace std;
      3 #include<string>
      4 #include<fstream>
      5 #include<iomanip>
      6 
      7 struct school
      8 {
      9     string name;
     10     int number;
     11     int sores;
     12     int male;
     13     int female;
     14 }sch[25];
     15 
     16 struct 
     17 {
     18     string name[5];
     19     int xuhao[5];
     20 }stu[25];
     21 
     22 struct
     23 {
     24     int pre[5];
     25 }pro[25];
     26 
     27 int fen1[5]={7,5,3,2,1},fen2[3]={5,3,1};
     28 
     29 int n,m,w,x,i,j;
     30 
     31 void input()
     32 {
     33     
     34     cout<<"请输入参与学校个数"<<endl;
     35     cin>>n;
     36     cout<<"请输入学校的名字"<<endl;
     37     for(i=1;i<=n;i++)
     38     {
     39         cin>>sch[i].name;
     40         sch[i].number=i;
     41         sch[i].sores=0;
     42         sch[i].male=0;
     43         sch[i].female=0;
     44     }
     45     cout<<"请分别输入男子项目个数和女子项目个数"<<endl;
     46     cin>>m>>w;
     47     for(i=1;i<=m+w;i++)
     48     {
     49     if(i%2)
     50     {
     51         cout<<"请输入第"<<i<<"个项目前五名学校的序号"<<endl;
     52         for(j=1;j<=5;j++)
     53         {
     54             cin>>x;
     55             pro[i].pre[j]=x;
     56             sch[x].sores+=fen1[j-1];
     57             if(i<=m)
     58                 sch[x].male+=fen1[j-1];
     59             else
     60                 sch[x].female+=fen1[j-1];
     61         }
     62         
     63     }
     64     else
     65     {
     66         cout<<"请输入第"<<i<<"个项目前三名学校的序号"<<endl;
     67         for(j=1;j<=3;j++)
     68         {
     69             cin>>x;
     70             pro[i].pre[j]=x;
     71             sch[x].sores+=fen2[j-1];
     72             if(i<m)
     73                 sch[x].male+=fen2[j-1];
     74             else
     75                 sch[x].female+=fen2[j-1];
     76         }
     77     
     78     }
     79    }
     80 }
     81 void print(int i)
     82 {
     83     cout<<sch[i].number<<setw(10)<<sch[i].name<<setw(10)<<sch[i].sores<<setw(10)<<sch[i].male<<setw(10)<<sch[i].female<<endl;
     84 }
     85 
     86 void sore()// 按总成绩排名输出
     87 {
     88     cout<<"按总成绩排名输出"<<endl;
     89     school temp;
     90     for(i=1;i<=n;i++)
     91     {
     92         int flag=1;
     93         for(j=1;j<=n-i;j++)
     94         {
     95             if(sch[j].sores<sch[j+1].sores)
     96             {
     97                 temp=sch[j];
     98                 sch[j]=sch[j+1];
     99                 sch[j+1]=temp;
    100                 flag=0;
    101             }
    102         }
    103         if(1==flag)
    104            break;
    105     }
    106     for(i=1;i<=n;i++)
    107         print(i);
    108 
    109 }
    110 
    111 void malesore()
    112 {
    113     cout<<"按男子总成绩排名输出"<<endl;
    114     school temp;
    115     for(i=1;i<=n;i++)
    116     {
    117         int flag=1;
    118         for(j=1;j<=n-i;j++)
    119         {
    120             if(sch[j].male<sch[j+1].male)
    121             {
    122                 temp=sch[j];
    123                 sch[j]=sch[j+1];
    124                 sch[j+1]=temp;
    125                 flag=0;
    126             }
    127         }
    128         if(flag==1)
    129             break;
    130     }
    131     for(i=1;i<=n;i++)
    132         print(i);
    133 }
    134 
    135 void femalesore()
    136 {
    137     cout<<"按女子总成绩排名输出"<<endl;
    138     school temp;
    139     for(i=1;i<=n;i++)
    140     {
    141         int flag=1;
    142         for(j=1;j<=n-i;j++)
    143         {
    144             if(sch[j].female<sch[j+1].female)
    145             {
    146                 temp=sch[j];
    147                 sch[j]=sch[j+1];
    148                 sch[j+1]=temp;
    149                 flag=0;
    150             }
    151         }
    152         if(flag==1)
    153             break;
    154     }
    155     for(i=1;i<=n;i++)
    156         print(i);
    157 }
    158 int main()
    159 {
    160     input();
    161     sore();
    162     malesore();
    163     femalesore();
    164     return 0;
    165 }

     2013-01-24   19:03:37

    2013-02-25  16:20:33

    放完寒假回来了,以后仍然会每天学一点。

  • 相关阅读:
    celery定时器
    基于Django的Rest Framework框架的视图组件
    Django的缓存机制
    Django中的跨域请求问题
    基于Django的Rest Framework框架的url控制器
    基于Django的Rest Framework框架的响应器
    基于Django的Rest Framework框架的分页组件
    基于Django的Rest Framework框架的解析器
    虚拟机下CentOS7开启SSH连接
    Vue中computed和watch的区别
  • 原文地址:https://www.cnblogs.com/paradises/p/2875535.html
Copyright © 2011-2022 走看看