mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
61 lines
1.3 KiB
Markdown
61 lines
1.3 KiB
Markdown
|
# 6-1 选队长
|
|||
|
|
|||
|
小明最近喜欢玩一款新游戏。在该游戏中,需要组建队伍去完成任务以获取奖励。小明挑出了所有的队员(每个人能力不同),需要一个函数挑出队长(能力最强的队员)。
|
|||
|
|
|||
|
### 函数接口定义:
|
|||
|
```c
|
|||
|
void showCaptain(TeamMember team[], int n);
|
|||
|
```
|
|||
|
|
|||
|
参数说明:team中从下标0开始存放n个TeamMember,n>0。
|
|||
|
函数功能:找出队长并输出其各项信息
|
|||
|
|
|||
|
### 裁判测试程序样例:
|
|||
|
```c
|
|||
|
#include<stdio.h>
|
|||
|
#include<stdlib.h>
|
|||
|
#define NAME_LEN 100
|
|||
|
#define SEX_LEN 6
|
|||
|
typedef struct {
|
|||
|
int id;//身份证号码
|
|||
|
char lastname[NAME_LEN+1];//姓
|
|||
|
char firstname[NAME_LEN+1];//名
|
|||
|
char sex[SEX_LEN];//性别
|
|||
|
double ability;
|
|||
|
} TeamMember;
|
|||
|
|
|||
|
void showCaptain(TeamMember team[], int n);
|
|||
|
int main()
|
|||
|
{
|
|||
|
TeamMember *team;
|
|||
|
int n;
|
|||
|
int i;
|
|||
|
|
|||
|
scanf("%d",&n);
|
|||
|
team = (TeamMember *)malloc(n*sizeof(TeamMember));
|
|||
|
for(i=0;i<n;i++)
|
|||
|
{
|
|||
|
scanf("%d %s %s %s %lf",&team[i].id,team[i].lastname, team[i].firstname, team[i].sex, &team[i]. ability);
|
|||
|
}
|
|||
|
|
|||
|
showCaptain(team, n);
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
/* 您提交的代码将放置在这里 */
|
|||
|
```
|
|||
|
|
|||
|
### 输入样例:
|
|||
|
```in
|
|||
|
3
|
|||
|
123456 zhang san male 100
|
|||
|
123457 li si female 200.5
|
|||
|
123458 wang ming male 159.1
|
|||
|
```
|
|||
|
|
|||
|
### 输出样例:
|
|||
|
```out
|
|||
|
123457 li si female 200.50
|
|||
|
```
|