| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 600 人关注过本帖
标题:帮忙改改 谢谢先
只看楼主 加入收藏
bcomer
Rank: 1
等 级:新手上路
帖 子:113
专家分:0
注 册:2004-9-13
收藏
 问题点数:0 回复次数:1 
帮忙改改 谢谢先

题目:运动会5个School参加 统计他们的Totalscore

帮忙改改,谢谢先

#include <stdio.h> #include <stdlib.h> #define TRUE 1 #define FALSE 0 #define MAXNUM 100 typedef enum{A,B,C,D,E} SchoolName; typedef enum{MALE,FEMALE} SexType; struct Component{ SchoolName school; SexType sex; char event; int score; }Component; struct Sum{ int malesum; int femalesum; int totalsum; }; typedef struct Component *PComponent; typedef struct Sum *PSum; PComponent Initialize(); PSum Stat(PComponent p); void Showscore(PSum pl); main() { Component a[10]; Sum b[5]; PComponent p; PSum pl; p=a; pl=b; p=Initialize(); pl=Stat(p); Showscore(pl); getch(); } PComponent Initialize() { int i; PComponent p; for (i=0;i<10;i++) { int a4; char a1,a2,a3; printf("\nPlease input schoolname"); scanf("%c ",&a1); /*printf("\nPlease input sextype"); scanf("%s ",&a2)*/; printf("\nPlease input event name"); scanf("%s ",&a3); printf("\nPlease input score"); scanf("%d ",&a4); (p+i)->school=a1; (p+i)->sex=a2; (p+i)->event=a3; (p+i)->score=a4; } return p; } PSum Stat(PComponent p) { int i; PSum pl; (pl+0)->totalsum=0; (pl+1)->totalsum=0; (pl+2)->totalsum=0; (pl+3)->totalsum=0; (pl+4)->totalsum=0; for (i=0;i<10;i++) { if((p+i)->school=='A') (pl+0)->totalsum+=(p+i)->score; if((p+i)->school=='B') (pl+1)->totalsum+=(p+i)->score; if((p+i)->school=='C') (pl+2)->totalsum+=(p+i)->score; if((p+i)->school=='D') (pl+3)->totalsum+=(p+i)->score; if((p+i)->school=='E') (pl+4)->totalsum+=(p+i)->score; /*else printf("error");*/ } return pl; } void Showscore(PSum pl) { int i; char a[5]={A,B,C,D,E}; for (i=0;i<5;i++) { printf("%c score is %d",a[i],(pl+i)->totalsum); } }

搜索更多相关主题的帖子: 改改 
2004-10-12 10:32
chen__han1
Rank: 1
等 级:新手上路
帖 子:256
专家分:0
注 册:2004-9-16
收藏
得分:0 

知道得人来......


路漫漫其修远兮 吾将上下而求索!
2004-10-13 08:05
快速回复:帮忙改改 谢谢先
数据加载中...
 
   



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

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