Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- char rijec[20][20];
- void SortiranjeRijeci(char rijec[20][20], int n)
- {
- char temp[20];
- bool switcher = true;
- for (int i = n - 1; i > 0 && switcher; i--)
- {
- switcher = false;
- for (int j = 0; j < i; j++)
- {
- if (strcmp(rijec[j], rijec[j + 1]) == 1)
- {
- strcpy(temp, rijec[j]);
- strcpy(rijec[j], rijec[j + 1]);
- strcpy(rijec[j + 1], temp);
- switcher = true;
- }
- }
- }
- }
- int main()
- {
- int n;
- cin >> n;
- cin.ignore();
- for (int i = 0; i < n; i++)
- {
- cin.getline(rijec[i], 20);
- }
- SortiranjeRijeci(rijec, n);
- for (int i = 0; i < n; i++)
- {
- cout << rijec[i] << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement