Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- //You should make a league table only for one of the leagues.
- //It consists of 8 teams: Arsenal, Chelsea, Manchester City,
- //Manchester United, Liverpool, Everton, Southampton and Tottenham.
- //You are given a string in the format ″team1 outcome team2″ separated by one or more whitespaces.
- //The outcome of the match will be one of the characters [1, X, 2].
- //The character ′1′ represents a win for team1,
- //the character ′2′ represents a win for team2 and ′X′ represents draw.
- //When one of the teams wins, it receives 3 points. The other team receives 0 points.
- //In case of a draw the both teams receive 1 point.
- //Mr. Vulchan will pay you N euros for every match.
- //You should evaluate how much money you will obtain for this job and print it on the console in leva.
- //Assume that 1 euro is 1.94lv.
- //Input
- //The input data should be read from the console.
- //On the first line you will receive the payment for every match.
- //On the next N lines you are given several input lines holding the match and its result.
- //When you receive the command “End of the league.” the program should stop.
- //The input data will always be valid and in the format described. There is no need to check it explicitly.
- //Output
- //The output data should be printed on the console.
- //On the first line you should print the evaluated price for all matches in the league in leva
- //rounded to two digits after the decimal point.
- //On the next 8 lines you should print all the teams in alphabetical order,
- //each on a separate line, together with the points, they have gained.
- //Constraints
- //The payment will be a floating point number in the range (-7.9 x 1028 to 7.9 x 1028) / (100 to 1028)
- //Allowed working time for your program: 0.1 seconds.
- //Allowed memory: 16 MB.
- //Hint: The teams with more than one word are represented without spacing in Pascal case.
- class TheFootballStatistician
- {
- static void Main()
- {
- decimal everyMatchPayment = decimal.Parse(Console.ReadLine());
- int counterMatch = 0;
- string teamOne;
- string teamTwo;
- string outcome;
- Dictionary<string, int> teamsResult = new Dictionary<string, int>();
- while (true)
- {
- string inputMatch = Console.ReadLine();
- if (inputMatch == "End of the league.")
- {
- break;
- }
- counterMatch++;
- string[] matchResult = inputMatch.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- teamOne = matchResult[0];
- teamTwo = matchResult[2];
- outcome = matchResult[1];
- if (outcome == "1")
- {
- if (teamsResult.ContainsKey(teamOne))
- {
- teamsResult[teamOne] += 3;
- }
- else
- {
- teamsResult.Add(teamOne, 3);
- }
- if (teamsResult.ContainsKey(teamTwo))
- {
- teamsResult[teamTwo] += 0;
- }
- else
- {
- teamsResult.Add(teamTwo, 0);
- }
- }
- if (outcome == "2")
- {
- if (teamsResult.ContainsKey(teamTwo))
- {
- teamsResult[teamTwo] += 3;
- }
- else
- {
- teamsResult.Add(teamTwo, 3);
- }
- if (teamsResult.ContainsKey(teamOne))
- {
- teamsResult[teamOne] += 0;
- }
- else
- {
- teamsResult.Add(teamOne, 0);
- }
- }
- if (outcome == "X")
- {
- if (teamsResult.ContainsKey(teamOne))
- {
- teamsResult[teamOne] += 1;
- }
- else
- {
- teamsResult.Add(teamOne, 1);
- }
- if (teamsResult.ContainsKey(teamTwo))
- {
- teamsResult[teamTwo] += 1;
- }
- else
- {
- teamsResult.Add(teamTwo, 1);
- }
- }
- }
- Console.WriteLine("{0:F2}lv.",counterMatch*(everyMatchPayment*1.94m));
- foreach (var team in teamsResult.OrderBy(i => i.Key))
- {
- Console.WriteLine("{0} - {1} points.",team.Key,team.Value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement