Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // HOmeWork-18.cpp :
- //
- #include <iostream>
- #include <string>
- using namespace std;
- void FamSort(string* Fam, int num)
- {
- for (int i = 0; i < num; i++)
- {
- for (int j = 0; j < num; j++)
- {
- if (Fam[i] < Fam[j])
- {
- string tmp = Fam[i];
- Fam[i] = Fam[j];
- Fam[j] = tmp;
- }
- }
- }
- cout << endl;
- }
- int main()
- {
- const int num = 5;
- string Familia;
- string* Fam = new string[num];
- for (int i = 0; i < num; i++) {
- cout << "Enter the Familia -> ";
- getline(cin, Familia);
- Fam[i] = Familia;
- }
- FamSort(Fam, num);
- for (int i = 0; i < num; i++) {
- cout << Fam[i] << endl;
- }
- cout << endl << endl;
- delete[] Fam;
- return 0;
- }
Add Comment
Please, Sign In to add comment