What's wrong with this? (Related to string output)

Asked 2 years ago, Updated 2 years ago, 24 views

int main(int agrc, char const *argv[]) {

    while (1) {

        int idx;
        string sel1, sel2;
        double W, L, M, D, K, C; // Victory, defeat, total number of plates, damage, gold volume per minute, damage per minute, KDA, CS per minute
        double wra, wrb, winrate;

        TeamA TA;
        TeamB TB;

        color(deepwhite);

        cout << "Enter the target team among LCK 9 teams and the team to compare. (It will be terminated by entering X.) ex) SKT HLE: ";
        cin >> sel1;

        if (sel1 == "X" || sel1 == "x") {

            color(lightmagenta);

            cout << "End of program." << endl;

            color(defaultcol);

            return EXIT_SUCCESS;
        }

        cin >> sel2;

        cout << endl;

        for (idx = 0; idx < 2; idx++) {

            switch (idx) {

                case 0:
                    cout << sel1;

                case 1:
                    cout << sel2;
            }

            cout << "Please enter the number of wins, number of losses, amount of gold per minute, damage per minute, and CS per minute." <<<<endl;
            cin >> W >> L >> M >> D >> K >> C;

            switch (idx) {

                case 0:
                    wra = TA.Wp(W, L, M, D, K, C);

                case 1:
                    wrb = TB.Wp(W, L, M, D, K, C);
            }
        }

        winrate = wr(wra, wrb);

        if (winrate > 50) {

            color(lightturq);
            cout << "Team A's winning probability is ""<< win rate <<%"" <<< endl;
        }

        else if (winrate < 50) {

            color(lightred);
            cout << "Team A's winning probability is ""<< win rate <<%"" <<< endl;
        }

        else if (winrate == 50) {

            color(lightyellow);
            cout << "Team A's winning probability is ""<< win rate <<%"" <<< endl;
        }
    }
}

If you make it like this...

 Enter the target team among LCK 9 teams and the team you want to compare. (If you enter X, it will end.) ex) SKT HLE: AB

Enter the number of wins, the number of losses, the amount of gold per minute, damage per minute, and CS per minute for Team AB.

1 2 3 4 5 6
Enter the number of wins, the number of losses, the amount of gold per minute, damage per minute, and CS per minute for Team B.

It floats like this.

c++

2022-09-22 16:55

1 Answers

Break is missing in the switch door


2022-09-22 16:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.