Last active
October 19, 2018 08:33
-
-
Save carmel4a/de86fac1be53782b2e1566cf8536289b 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 <vector> | |
int main() | |
{ | |
std::vector< std::string> names; | |
std::vector< int> scores; | |
std::string name; | |
int score; | |
do | |
{ | |
std::cout << "Podaj imie i swoj wiek:" << std::endl; | |
std::cin >> name >> score; | |
names.push_back( name ); | |
scores.push_back( score ); | |
for( int i = 0; i < names.size(); ++i ) | |
if( names[i-1] == names [i] ) // ! | |
{ | |
std::cout << "Poprzednie imie był takie samo". | |
return 1; | |
} | |
} | |
while ( name != "ToKoniec" && score != 0 ); | |
names.pop_back(); | |
scores.pop_back(); | |
for( int i = 0; i < names.size(); ++i) | |
cout << names[i] << " " << scores[i] << endl; | |
/////////////////////////////////////////////////// | |
std::string temp; | |
bool fund { false }; | |
std::cout << "Podaj imie do wyszukania:" << std::endl; | |
std::cin >> temp; | |
for( int i = 0; i < names.size(); ++i ) | |
if( names[i] == temp ) | |
{ | |
std::cout << names[i] << " " << score[i] << std::endl; | |
fund = true; | |
break; | |
} | |
if( !fund ) std::cout << "Nie ma takiego imienia na liście." << std::endl; | |
/////////////////////////////////////////////////// | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment