Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int n_players;
- cout << "Enter amount of players" << endl;
- cin >> n_players;
- int scores[n_players];
- int bids[n_players];
- int achieved[n_players];
- string names[n_players];
- // Denumirea jucatorilor
- for(int i = 0; i < n_players; i++){
- cout << "Enter name of player " << i + 1;
- if(i == 0){
- cout << " (Starting player)" << endl;
- }else{
- cout << endl;
- }
- cin >> names[i];
- }
- int round = 1;
- int roundamount = 0;
- int turn = 0;
- int bidsum = 0;
- int ach = 0;
- for(int i = 0; i < n_players; i++){
- scores[i] = 0;
- }
- while(round <= 3 * n_players + 12){
- if(1 <= round && round <= n_players){
- roundamount = 1;
- }else if(round > n_players && round <= n_players + 6){
- roundamount = round - n_players + 1;
- }else if(round > n_players + 6 && round <= 2 * n_players + 6){
- roundamount = 8;
- }else if(round > 2 * n_players + 6 && round <= 2 * n_players + 12){
- roundamount = 2 * n_players + 14 - round;
- }else{
- roundamount = 1;
- }
- cout << "-----------------------------------------------------" << endl << "Round " << round << "/" << 3 * n_players + 12;
- if(roundamount == 1){
- cout << " (" << roundamount << " card per person)" << endl;
- }else{
- cout << " (" << roundamount << " cards per person)" << endl;
- }
- turn = (round + 3) % 4;
- bidsum = 0;
- for(int i = 0; i < n_players; i++){
- achieved[i] = 0;
- bids[i] = 0;
- }
- for(int i = 0; i < n_players; i++){
- cout << "How many will " << names[turn] << " bid? ";
- if(i == n_players - 1 && bidsum <= roundamount){
- cout << "You are not allowed to bid " << roundamount - bidsum << "! ";
- }
- if(i == n_players - 1 && bidsum > roundamount){
- cout << "You can bid any amount! ";
- }
- cin >> bids[turn];
- bidsum = bidsum + bids[turn];
- if(i == n_players - 1){
- while(bidsum == roundamount){
- cout << "Bid a different amount! ";
- bidsum = bidsum - bids[turn];
- cin >> bids[turn];
- bidsum = bidsum + bids[turn];
- }
- }
- turn++;
- if(turn == n_players)
- turn = 0;
- }
- while(roundamount > 0){
- cout << endl << endl << endl << "Who took that hand?" << endl;
- for(int i = 0; i < n_players; i++){
- cout << i + 1 << " - " << names[i] << endl;
- }
- cin >> ach;
- achieved[ach - 1]++;
- roundamount--;
- }
- for(int i = 0; i < n_players; i++){
- if(bids[i] == achieved[i]){
- scores[i] = achieved[i] * 10 + 50 + scores[i];
- }else{
- scores[i] = 0 - abs(bids[i] - achieved[i]) * 10 + scores[i];
- }
- }
- cout << endl << endl << "-----------------------------------------------------" << endl << "Scores: " << endl;
- for(int i = 0; i < n_players; i++){
- cout << names[i] << " -> " << scores[i] << endl;
- }
- round++;
- }
- int zero = 0;
- int maxplayer = -1;
- int maxamount = 0;
- int equals = 0;
- cout << endl << endl << "-----------------------------------------------------" << endl << "Final Scores:" << endl;
- for(int i = 0; i < n_players; i++){
- cout << names[i] << " -> " << scores[i] << endl;
- }
- cout << "-----------------------------------------------------" << endl;
- for(int i = 0; i < n_players; i++){
- if(scores[i] == 0){
- zero++;
- cout << names[i] << " won the game by getting 0 points!";
- }
- }
- if(zero == 0){
- for(int i = 0; i < n_players; i++){
- if(scores[i] > maxamount){
- maxamount = scores[i];
- maxplayer = i;
- }
- }
- for(int i = 0; i < n_players; i++){
- if(scores[i] == maxamount){
- if(equals >= 1){
- cout << " and " << names[i];
- }else{
- cout << names[i];
- }
- equals++;
- }
- }
- cout << " won the game!";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement