Как отсортировать объекты из структуры С++?
Вывести на екран всех людей старше 25лет.
Cod_C++:
#include
using namespace std;
struct Human{
char name[30];
char sex;
int year;
int height;
int weight;
};
int main(){
//The reading part START//
Human human[2];
for (int i = 0; i < 2; i++) {
cout << "Please enter the name for: " << i << "_id person."<< '\n';
cin >> human[ i ].name;
cout << "Please enter the gender for " << human[ i ].name << '\n';
cin >> human[ i ].sex;
cout << "Please enter the age for " << human[ i ].name << '\n';
cin >> human[ i ].year;
cout << "Please enter the heigt for " << human[ i ].name << '\n';
cin >> human[ i ].height;
cout << "Please enter the weight for " << human[ i ].name << '\n';
cin >> human[ i ].weight;
}
//The reading part END//
//Show all persons to the display START//
cout<<"|||||||||||||||||||||||||||||||||||||||||||||||||"<
cout<<"|||||||||Show all persons to the display|||||||||"<
cout<<"|||||||||||||||||||||||||||||||||||||||||||||||||"<
for (int i = 0; i < 2; ++i) {
cout <<"Numele:"<< human[i].name <<'\n';
cout<<"Genul: " << human[i].sex <<'\n';
cout <<"Virsta:"<< human[i].year <<" ani"<<'\n';
cout <<"Inaltimea:"<< human[i].height <<" cm"<<'\n';
cout <<"Greutatea:"<< human[i].weight <<" kg"<<'\n';
cout<<"-------------------------------"<
}
//Show all persons to the display END//
system("pause > nul");
return 0;
}