В void TComputer::Perevirka() должно сортировать страни в алфавитному порядку
я не знаю как сделать.
Код: Выделить всё
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <locale.h>
using namespace std;
class TComputer
{
char country[20];
float area;
int people;
char neighboring_countries[60];
int life;
public:
TComputer();
TComputer(char*,float,int,char*,int);
~TComputer();
void Show();
void Set();
void Perevirka();
};
TComputer::TComputer()
{
cout <<"Створили обєкт\n";
}
TComputer::TComputer(char* country,float area,int people,char* neighboring_countries,int life)
{
strcpy(this->country,country);
this->area=area;
this->people=people;
strcpy(this->neighboring_countries,neighboring_countries);
this->life=life;
cout <<"Створили обєкт\n";
}
TComputer::~TComputer()
{
cout <<"Видалили обєкт\n";
}
void TComputer::Show()
{
cout<<"Назва країни - "<<country<<endl;
cout<<"Площа - "<<area<<endl;
cout<<"Кiлькiсть населення - "<<people<<endl;
cout<<"Сусідні країни - "<<neighboring_countries<<endl;
cout<<"Середня тривалість життя - "<<life<<endl;
cout<<endl;
}
void TComputer::Set()
{
cout<<"Назва країни - ";
cin>>country;
cout<<"Площа - ";
cin>>area;
cout<<"Кiлькiсть населення - ";
cin>>people;
cout<<"Сусідні країни - ";
cin>>neighboring_countries;
cout<<"Середня тривалість життя - ";
cin>>life;
cout<<endl;
}
void TComputer::Perevirka()
{
this->Show();
}
int main()
{
setlocale(LC_ALL, "Ukrainian");
system("color F1");
TComputer o("Австрія",8768,38,"Угорщина, Чехія, Швейцарія, Німечинна",60);
o.Show();
TComputer comp[6];
for (int i=0;i<6;i++){
comp[i].Set();}
int hdd,ram;
cout<<"Сортування в алфавітному порядку \n";
cout<<endl;
for (int i=0;i<6;i++)
comp[i].Perevirka();
o.Perevirka();
system("pause");
return 0;
}