데이터 구조 운동회 점수 통계 실습 보고서 소스 코드

2458 단어 데이터 구조
#include
#include
int n,m,w;
struct Student
{
    char name[20];
    int mingci;
    int score;
};
struct Xiangmu
{
    int bianhao;
    char xiangname[20];
    Student students[50];
    int xiangscore;
};
struct School
{
    char xiaoname[20];
    int renshu;
    int Sumnamtuan;
    int Sumnvtuan;
    int sumtuan;
    int sumnanscore;
    int sumnvscore;
    Xiangmu SuoyouXiangmu[50];
}xuexiao[50];
void shuruchengji(int i)
{
    int qumingcishu = ( (i&1)==1?5:3 );
    printf("     %d   
%d
",i,qumingcishu); printf(" , ( ), ,
"); char sss[20];int xiaohao,defen; int j=1; for(;j<=qumingcishu;j++){ scanf("%s%d%d",sss,&xiaohao,&defen); xuexiao[xiaohao].SuoyouXiangmu[i].students[j].mingci=j; strcpy(xuexiao[xiaohao].SuoyouXiangmu[i].students[j].name,sss); xuexiao[xiaohao].SuoyouXiangmu[i].students[j].score=defen; } } void shuchuxiangchengjidan(int k) { printf("%d
",k); for(int i=1;i<=m+w;i++){ printf(" %d
",i); for(int j=1;j<=5;j++){ if(xuexiao[k].SuoyouXiangmu[i].students[j].mingci!=0){ printf(" %d %s %d
", xuexiao[k].SuoyouXiangmu[i].students[j].mingci, xuexiao[k].SuoyouXiangmu[i].students[j].name, xuexiao[k].SuoyouXiangmu[i].students[j].score); if(i<=m){ xuexiao[k].Sumnamtuan+=xuexiao[k].SuoyouXiangmu[i].students[j].score; } else xuexiao[k].Sumnvtuan+=xuexiao[k].SuoyouXiangmu[i].students[j].score; } } } } void shuchutuantibiao(int k) { printf("

%d
",k); printf(" %d
",xuexiao[k].Sumnamtuan); printf(" %d
",xuexiao[k].Sumnvtuan); printf(" %d
",xuexiao[k].Sumnvtuan+xuexiao[k].Sumnamtuan); } int main() { int nanzirenshu,nvzirenshu; printf(" n
");scanf("%d",&n); printf(" m
");scanf("%d",&m); printf(" w
");scanf("%d",&w); for(int i=1;i<=m+w;i++) shuruchengji(i); for(int i=1;i<=n;i++) shuchuxiangchengjidan(i); for(int i=1;i<=n;i++) shuchutuantibiao(i); return 0; }

좋은 웹페이지 즐겨찾기