输入性别并记录男女个数还要算出男女平均年龄的c语言程序怎样写
答案:2 信息版本:手机版
解决时间 2019-10-05 17:37
已解决
2019-10-05 00:19
输入性别并记录男女个数还要算出男女平均年龄的c语言程序怎样写
最佳答案
2019-10-05 01:24
#include "stdio.h"
typedef struct person
{
int sex;
int age;
}person,*pperson;//人
typedef struct man
{
int num;
float avg;
struct man()
{
num = 0;
avg = 0;
}
}man;//男性
typedef struct woman
{
int num;
float avg;
struct woman()
{
num = 0;
avg = 0;
}
}woman; //女性
void main()
{
person ps;
man m;
woman wm;
char c;
while (scanf("%d %d",&(ps.sex),&(ps.age))&&((c