Last active
August 29, 2015 14:02
-
-
Save Qub3k/6a530cd9ca410abb7fde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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