# include<iostream>
#include<ctime>
#include<cstdlib>
#include"swap.h"
#include<string>
using namespace std;
struct hero {
string name;
int age;
string agend;
};
int main() {
struct hero heroarray[5];
void fuzhi(hero heroarray[], int len);
int len = sizeof(heroarray) / sizeof(heroarray[0]);
fuzhi(heroarray, len);
void print(hero heroarray[], int len);
print(heroarray, len);
system("pause");
return 0;
}
void fuzhi(hero heroarray[], int len) {
for (int i = 0; i < 5; i++) {
string nameseed[5] = { "刘备", "关羽","张飞","赵云","貂蝉" };
int ageseed[5] = {23,22,20,21,19 };
string agendseed[5] = { "男","男","男","男","女" };
heroarray[i].name += nameseed[i];
heroarray[i].age += ageseed[i];
heroarray[i].agend += agendseed[i];
}
}
void print(hero heroarray[], int len) {
for (int i = 0; i < 5; i++) {
cout << "英雄的名字是" << heroarray[i].name << "英雄的年龄是" << heroarray[i].age << "英雄的性别是" << heroarray[i].agend << endl;
}
}
请问大佬我哪里做错了,为什么年龄没办法正常赋值?