Skip to content

Instantly share code, notes, and snippets.

@Qub3k
Last active August 29, 2015 14:02
Show Gist options
  • Save Qub3k/6a530cd9ca410abb7fde to your computer and use it in GitHub Desktop.
Save Qub3k/6a530cd9ca410abb7fde to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
bool compare (string a, string b) // funkcja porównująca stringi
{
return (a < b);
}
int main()
{
vector <string> vStringArray; // tablica typu vector przechowująca obiekty typu vector
string sUserInput;
for(int i = 0; i < 5; i++)
{
cout << "Wpisz linijke tekstu" << endl;
cout << ">";
getline(cin, sUserInput); // zczytanie linijki ze standardowego wejscia [klawiatury] i umieszczenie ja w stringu
vStringArray.push_back(sUserInput); // umieszczanie linijki w tablicy vector
}
sort(vStringArray.begin(), vStringArray.end(), compare);
for(int i = 0; i < 5; i++)
cout << vStringArray[i] << ' ';
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment