Skip to content

Instantly share code, notes, and snippets.

@carmel4a
Last active October 19, 2018 08:33
Show Gist options
  • Save carmel4a/de86fac1be53782b2e1566cf8536289b to your computer and use it in GitHub Desktop.
Save carmel4a/de86fac1be53782b2e1566cf8536289b to your computer and use it in GitHub Desktop.
#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