Help and solutions to improve the program؟؟ | Sololearn: Learn to code for FREE!


Help and solutions to improve the program؟؟

In Group B of the World Cup, the teams of Iran, Portugal, Spain and Morocco are present. Write a program that, after receiving the results of the games, prints the name of the team, the number of wins and losses, the difference in goals and points, in a single line, respectively. Each team is printed on a line in order of points. (If the score was equal, the number of wins should be considered. If both the number of wins and the score were equal, they should be printed in alphabetical order.) Read the results of the games in the following order: (In the sample input, the number on the left corresponds to the team on the right.) Iran - Spain Iran - Portugal Iran - Morocco Spain - Portugal Spain - Morocco Portugal - Morocco

11/21/2021 8:22:08 PM

Khosro Mohammadi

7 Answers

New Answer


Maybe you want to have a look at this. But it's only one of many possible solutions.


Excellent, But what if the input of the teams games is different, i.e. get input from the user? I don't think it's going to work this way.


Khosro Mohammadi for sure it's possible. All we need is a nice input routine. I'll try to build one after work. 😉


Try this with input like: 2-2 [ENTER] 2-1 [ENTER] 1-1 [ENTER] 2-2 [ENTER] 3-1 [ENTER] 2-1 [SUBMIT]


I think this code is cleaner Thank you for helping me


Yes, that's also good 👍. I didn't spend much time to build the input. But if you use a range (1, 7) it works only for 4 teams. Or you have to change the code for differend number of teams/matches. And if you run my version on another interpreter than SoloLearn, you will get displayed, for witch match you have to input the result (teamA - teamB). But this are only small differences. Beside of this you are right, it is the better way to get the input.


Yes, Sure Everything is possible Thank you and good luck