| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 买学问 - 大牛一对一辅导，有问必答 买学问 - 专业的付费知识问答平台

问题点数：0  回复次数：1

得分:0

```#if 1

#include <stdio.h>

typedef struct worker
{
float score;
}WK;

WK wks[100];

void getMes(int &wkNum)
{
int wkCount = 0;
printf("职工考核成绩录入：\n");
do
{
printf("num %d score : ",wkCount+1);
scanf("%f", &(wks[wkCount].score));
while (!getchar());
if (wks[wkCount].score > 100.0)
{
printf("请输入有效成绩（0-100）\n");
continue;
}
else if (wks[wkCount].score < 0.0)
{
wkNum = wkCount;
printf("共计录入%d人\t", wkNum);
break;
}
else
{
++wkCount;
}
} while (1);
}

void get_ave_max(int wknum)
{
float max = wks[0].score;
float ave = 0.0;
float total = 0.0;
for (int i = 0; i < wknum;++i)
{
total += wks[i].score;
if (max < wks[i].score)
{
max = wks[i].score;
}
}
ave = total / wknum;
printf("ave score : %.3f\tmax score : %.3f\n", ave, max);
}

int main()
{
int wkNum;
getMes(wkNum);
get_ave_max(wkNum);

getchar();
}
#endif
```

-------------------------------若有不当之处，敬请谅解-------------------------------
• 2
• 1/1页
• 1