#include <iostream>
#include<cstring>
using namespace std;
struct student
{
long id;
char gender;
int age;
int money;
};
void judge(long, char, int, int);
void averageage(int, int, int, int, int);
void allmoney(int, int, int, int, int);
void main()
{
student a = { 9413599, 'M', 25, 10001 };
student b = { 9513622, 'M', 22, 500 };
student c = { 9613812, 'F', 20, 30 };
student d = { 9713964, 'F', 18, 66000 };
int id;
char gender;
int age;
int money;
cout << " Please enter your student id :" << endl;
cin >> id;
cout << "Gender (M/F):" << endl;
cin >> gender;
cout << "Age:" << endl;
cin >> age;
cout << " The amount of money in your own :" << endl;
cin >> money;
judge(a.id, a.gender, a.age, a.money);
judge(b.id, b.gender, b.age, b.money);
judge(c.id, c.gender, c.age, c.money);
judge(d.id, d.gender, d.age, d.money);
judge(id, gender, age, money);
averageage(a.age, b.age, c.age, d.age, age);
allmoney(a.money, b.money, c.money, d.money, money);
system("pause");
}
void judge(long id, char gender, int age, int money)
{
char a[20],m[5],g[20];
if (age < 21)
strcpy_s(a, "young");
else
strcpy_s(a, "adult");
if (gender == 'M')
strcpy_s(g, "man");
else if (gender = 'F')
strcpy_s(g, "woman");
else
strcpy_s(g, "unknown gender");
if (money >= 10000)
strcpy_s(m, "rich");
else
strcpy_s(m, "poor");
cout << "id\t" << id << " is a "<<a<<" & "<< m << " " << g << endl;
}
void averageage(int a, int b, int c, int d, int e)
{
double avg;
avg = (a + b + c + d + e) / 5;
cout << "This group is " << avg << " years old in average." << endl;
}
void allmoney(int a, int b, int c, int d, int e)
{
int all;
all = a + b + c + d + e;
cout << "This group has $" << all << " now" << endl;
}