|
Fanidan tayyorlagan mustaqil ishi
|
bet | 5/5 | Sana | 18.05.2024 | Hajmi | 0,49 Mb. | | #240920 |
Bog'liq Dasturlash#include
#include
#include
struct Player {
std::string name;
int score;
};
class Game {
private:
std::map playerScores;
public:
void addPlayer(const Player& player) {
playerScores[player.name] = player.score;
}
void showPlayers() {
std::cout << "O'yinchilar:\n";
for (const auto& pair : playerScores) {
std::cout << pair.first << ": " << pair.second << std::endl;
}
}
};
int main() {
Player player1 = {"Ali", 100};
Player player2 = {"Vali", 80};
Game game;
game.addPlayer(player1);
game.addPlayer(player2);
game.showPlayers();
return 0;
}
|
| |