#include <iostream>
#include <vector>
using namespace std;
class Player
{
string name;
public :
Player( string name)
{
this- > name = name;
}
string get_name( )
{
return this- > name;
}
} ;
bool add_player( vector< Player> & player_vector)
{
string name;
string comp_name;
//getline(cin, name);
//system("CLS");
cout << "Podaj login gracza: " ;
getline( cin , name) ;
for ( int i = 0 ; i < player_vector.size ( ) ; i++ )
{
comp_name = player_vector[ i] .get_name ( ) ;
if ( name == comp_name)
{
cout << endl;
cout << "Wybrany login jest zajety." ;
cout << flush;
//Sleep(2000);
return false ;
}
}
player_vector.push_back ( Player( name) ) ;
cout << "Gracz " << name << " pomyslnie dodany do ligi." ;
//Sleep(2000);
return true ;
}
int main( ) {
vector< Player> list;
cout << ( add_player( list) ) ? "TAK" : "NIE" ;
cout << endl;
cout << ( add_player( list) ) ? "TAK" : "NIE" ;
cout << endl;
cout << ( add_player( list) ) ? "TAK" : "NIE" ;
cout << endl;
cout << ( add_player( list) ) ? "TAK" : "NIE" ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgUGxheWVyCnsKCXN0cmluZyBuYW1lOwogcHVibGljOgogCVBsYXllcihzdHJpbmcgbmFtZSkKIAl7CiAJCXRoaXMtPm5hbWUgPSBuYW1lOwogCX0KIAkKIAlzdHJpbmcgZ2V0X25hbWUoKQogCXsKIAkJcmV0dXJuIHRoaXMtPm5hbWU7CiAJfQp9OwoKYm9vbCBhZGRfcGxheWVyKHZlY3RvcjxQbGF5ZXI+ICZwbGF5ZXJfdmVjdG9yKQp7CiAgICBzdHJpbmcgbmFtZTsKICAgIHN0cmluZyBjb21wX25hbWU7CiAgICAvL2dldGxpbmUoY2luLCBuYW1lKTsKICAgIC8vc3lzdGVtKCJDTFMiKTsKICAgIGNvdXQgPDwgIlBvZGFqIGxvZ2luIGdyYWN6YTogIjsKICAgIGdldGxpbmUoY2luLCBuYW1lKTsKICAgIGZvci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