1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】15.结构体1/6-1 选队长.md

61 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6-1 选队长
小明最近喜欢玩一款新游戏。在该游戏中,需要组建队伍去完成任务以获取奖励。小明挑出了所有的队员(每个人能力不同),需要一个函数挑出队长(能力最强的队员)。
### 函数接口定义:
```c
void showCaptain(TeamMember team[], int n);
```
参数说明team中从下标0开始存放n个TeamMembern>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
```