Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Problem 1. Fill the Matrix//////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int rowsAndColsSize = int.Parse(Console.ReadLine());
- char pattern = (char)Console.Read();
- int[,] matrix = new int[rowsAndColsSize, rowsAndColsSize];
- int currentNumber = 1;
- if (Char.ToUpper(pattern).Equals('A'))
- {
- for (int col = 0; col < rowsAndColsSize; col++)
- {
- for (int row = 0; row < rowsAndColsSize; row++)
- {
- matrix[row, col] = currentNumber;
- currentNumber++;
- }
- }
- }
- else if (Char.ToUpper(pattern).Equals('B'))
- {
- for (int col = 0; col < rowsAndColsSize; col++)
- {
- if (col % 2 == 0)
- {
- for (int row = 0; row < rowsAndColsSize; row++)
- {
- matrix[row, col] = currentNumber;
- currentNumber++;
- }
- }
- else
- {
- for (int row = rowsAndColsSize - 1; row >= 0; row--)
- {
- matrix[row, col] = currentNumber;
- currentNumber++;
- }
- }
- }
- }
- for (int row = 0; row < rowsAndColsSize; row++)
- {
- for (int col = 0; col < rowsAndColsSize; col++)
- {
- Console.Write("{0,2} ", matrix[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- }
- Problem 2. Maximal Sum /////////////////////////////////////////////////////////////////////////////////////////////////////////
- using System;
- class MaximalSum
- {
- static void Main()
- {
- string[] rowsAndColsInput = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- int rows = int.Parse(rowsAndColsInput[0]) + 1;
- int cols = int.Parse(rowsAndColsInput[1]) + 1;
- int[,] matrix = new int[rows, cols];
- for (int row = 0; row < rows; row++)
- {
- string[] currentRowNumbersAsStrings =
- Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int col = 0; col < cols; col++)
- {
- matrix[row, col] = int.Parse(currentRowNumbersAsStrings[col]);
- }
- }
- int bestSum = int.MinValue;
- int currentSum = 0;
- int[,] elementsWithMaxSum = new int[3, 3];
- for (int row = 0; row < rows - 2; row++)
- {
- for (int col = 0; col < cols - 2; col++)
- {
- currentSum = matrix[row, col] + matrix[row, col + 1] + matrix[row, col + 2] +
- matrix[row + 1, col] + matrix[row + 1, col + 1] + matrix[row + 1, col + 2] +
- matrix[row + 2, col] + matrix[row + 2, col + 1] + matrix[row + 2, col + 2];
- if (currentSum > bestSum)
- {
- bestSum = currentSum;
- for (int i = 0; i < elementsWithMaxSum.GetLength(0); i++)
- {
- for (int j = 0; j < elementsWithMaxSum.GetLength(1); j++)
- {
- elementsWithMaxSum[i, j] = matrix[row + i, col + j];
- }
- }
- }
- }
- }
- Console.WriteLine("Sum = {0}", bestSum);
- for (int row = 0; row < elementsWithMaxSum.GetLength(0); row++)
- {
- for (int col = 0; col < elementsWithMaxSum.GetLength(1); col++)
- {
- Console.Write("{0,2} ", elementsWithMaxSum[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- Problem 3. Matrix shuffling /////////////////////////////////////////////////////////////////////////////////
- using System;
- class MatrixShuffling
- {
- static void Main()
- {
- int rows = int.Parse(Console.ReadLine());
- int cols = int.Parse(Console.ReadLine());
- string[,] matrix = new string[rows, cols];
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- matrix[row, col] = Console.ReadLine();
- }
- }
- int x1 = 0;
- int y1 = 0;
- int x2 = 0;
- int y2 = 0;
- string temp = String.Empty;
- string command = Console.ReadLine();
- while (command != "END")
- {
- string[] commandTokens = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- if (commandTokens.Length == 5 && commandTokens[0] == "swap")
- {
- x1 = int.Parse(commandTokens[1]);
- y1 = int.Parse(commandTokens[2]);
- x2 = int.Parse(commandTokens[3]);
- y2 = int.Parse(commandTokens[4]);
- if ((x1 >= 0 && x1 < rows) && (y1 >= 0 && y1 < cols)
- && (x2 >= 0 && x2 < rows) && (y2 >= 0 && y2 < cols))
- {
- temp = matrix[x1, y1];
- matrix[x1, y1] = matrix[x2, y2];
- matrix[x2, y2] = temp;
- Console.WriteLine("(After swapping {0} and {1}): ", matrix[x2, y2], matrix[x1, y1]);
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- Console.Write("{0,2} ", matrix[row, col]);
- }
- Console.WriteLine();
- }
- }
- else
- {
- Console.WriteLine("Invalid input!");
- }
- }
- else
- {
- Console.WriteLine("Invalid input!");
- }
- command = Console.ReadLine();
- }
- }
- }
- Problem 4. Sequence in Matrix /////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class SequenceInMatrix
- {
- static void Main()
- {
- List<List<string>> matrix = new List<List<string>>();
- string currentRowContents = Console.ReadLine();
- string[] currentRowTokens;
- for (int row = 0; !String.IsNullOrEmpty(currentRowContents); row++)
- {
- matrix.Add(new List<string>());
- currentRowTokens = currentRowContents.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int col = 0; col < currentRowTokens.Length; col++)
- {
- matrix[row].Add(currentRowTokens[col]);
- }
- currentRowContents = Console.ReadLine();
- }
- int currentLength = 1;
- int bestLength = int.MinValue;
- string bestValue = String.Empty;
- for (int row = 0; row < matrix.Count; row++)
- {
- for (int col = 0; col < matrix[row].Count; col++)
- {
- currentLength = CheckVertical(matrix, row, col, matrix[row][col]);
- if (currentLength > bestLength)
- {
- bestLength = currentLength;
- bestValue = matrix[row][col];
- }
- currentLength = CheckHorizontal(matrix, row, col, matrix[row][col]);
- if (currentLength > bestLength)
- {
- bestLength = currentLength;
- bestValue = matrix[row][col];
- }
- currentLength = CheckDiagonal(matrix, row, col, matrix[row][col]);
- if (currentLength > bestLength)
- {
- bestLength = currentLength;
- bestValue = matrix[row][col];
- }
- }
- }
- Console.Write(bestValue);
- for (int i = 1; i < bestLength; i++)
- {
- Console.Write(", {0}", bestValue);
- }
- Console.WriteLine();
- }
- private static int CheckDiagonal(List<List<string>> matrix, int row, int col, string currentValue)
- {
- int currentLength = 1;
- for (int i = row, j = col; i < matrix.Count && j < matrix[row].Count; i++, j++)
- {
- if (i + 1 < matrix.Count && j + 1 < matrix[i + 1].Count && matrix[i + 1][j + 1].Equals(currentValue))
- {
- currentLength++;
- }
- else
- {
- break;
- }
- }
- return currentLength;
- }
- private static int CheckHorizontal(List<List<string>> matrix, int row, int col, string currentValue)
- {
- int currentLength = 1;
- for (int i = col; i < matrix[row].Count; i++)
- {
- if (i + 1 < matrix[row].Count && matrix[row][i + 1].Equals(currentValue))
- {
- currentLength++;
- }
- else
- {
- break;
- }
- }
- return currentLength;
- }
- private static int CheckVertical(List<List<string>> matrix, int row, int col, string currentValue)
- {
- int currentLength = 1;
- for (int i = row; i < matrix.Count; i++)
- {
- if (i + 1 < matrix.Count && matrix[i + 1][col].Equals(currentValue))
- {
- currentLength++;
- }
- else
- {
- break;
- }
- }
- return currentLength;
- }
- }
- Problem 5. Collect the Coins ///////////////////////////////////////////////////////////////////////////////
- using System;
- class CollectTheCoins
- {
- static void Main()
- {
- char[][] board = new char[4][];
- string boardLine = String.Empty;
- for (int row = 0; row < board.GetLength(0); row++)
- {
- boardLine = Console.ReadLine();
- board[row] = new char[boardLine.Length];
- for (int col = 0; col < board[row].Length; col++)
- {
- board[row][col] = boardLine[col];
- }
- }
- int currentRow = 0;
- int currentCol = 0;
- int coinsCount = 0;
- int wallHitsCount = 0;
- string movementCommands = Console.ReadLine();
- foreach (char currentDirection in movementCommands)
- {
- if (currentDirection == 'V')
- {
- currentRow++;
- if (currentRow >= board.GetLength(0))
- {
- currentRow--;
- wallHitsCount++;
- continue;
- }
- else if (currentCol >= board[currentRow].Length)
- {
- currentRow--;
- wallHitsCount++;
- continue;
- }
- }
- else if (currentDirection == '>')
- {
- currentCol++;
- if (currentCol >= board[currentRow].Length)
- {
- currentCol--;
- wallHitsCount++;
- continue;
- }
- }
- else if (currentDirection == '<')
- {
- currentCol--;
- if (currentCol < 0)
- {
- currentCol++;
- wallHitsCount++;
- continue;
- }
- }
- else if (currentDirection == '^')
- {
- currentRow--;
- if (currentRow < 0)
- {
- currentRow++;
- wallHitsCount++;
- continue;
- }
- else if (currentCol >= board[currentRow].Length)
- {
- currentRow++;
- wallHitsCount++;
- continue;
- }
- }
- if (board[currentRow][currentCol].Equals('$'))
- {
- coinsCount++;
- }
- }
- Console.WriteLine("Coins collected: {0}", coinsCount);
- Console.WriteLine("Walls hit: {0}", wallHitsCount);
- }
- }
- Problem 6. Count Symbols ////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class CountSymbols
- {
- static void Main()
- {
- string inputText = Console.ReadLine();
- SortedDictionary<char, int> occurrences = new SortedDictionary<char, int>();
- foreach (char symbol in inputText)
- {
- if (occurrences.ContainsKey(symbol))
- {
- occurrences[symbol]++;
- }
- else
- {
- occurrences.Add(symbol, 1);
- }
- }
- foreach (KeyValuePair<char, int> pair in occurrences)
- {
- Console.WriteLine("{0}: {1} time/s", pair.Key, pair.Value);
- }
- }
- }
- Problem 7. Phonebook ////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class Phonebook
- {
- static void Main()
- {
- Dictionary<string, List<string>> phonebook = new Dictionary<string, List<string>>();
- string contactInformation = Console.ReadLine();
- string[] contactTokens;
- string contactName = String.Empty;
- string contactNumber = String.Empty;
- while (contactInformation != "search")
- {
- contactTokens = contactInformation.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
- contactName = contactTokens[0];
- contactNumber = contactTokens[1];
- if (!phonebook.ContainsKey(contactName))
- {
- phonebook[contactName] = new List<string>();
- }
- phonebook[contactName].Add(contactNumber);
- contactInformation = Console.ReadLine();
- }
- string contactNameToSearch = Console.ReadLine();
- while (!String.IsNullOrEmpty(contactNameToSearch))
- {
- if (phonebook.ContainsKey(contactNameToSearch))
- {
- Console.Write("{0} -> {1}", contactNameToSearch, String.Join(", ", phonebook[contactNameToSearch]));
- }
- else
- {
- Console.WriteLine("Contact {0} does not exist.", contactNameToSearch);
- }
- contactNameToSearch = Console.ReadLine();
- }
- }
- }
- Problem 8. Night Life //////////////////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class NightLife
- {
- static void Main()
- {
- Dictionary<string, SortedDictionary<string, SortedSet<string>>> nightLifeDictionary =
- new Dictionary<string, SortedDictionary<string, SortedSet<string>>>();
- string[] eventTokens;
- string city = String.Empty;
- string venue = String.Empty;
- string performer = String.Empty;
- string eventInformation = Console.ReadLine();
- while (eventInformation != "END")
- {
- eventTokens = eventInformation.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
- city = eventTokens[0];
- venue = eventTokens[1];
- performer = eventTokens[2];
- if (!nightLifeDictionary.ContainsKey(city))
- {
- nightLifeDictionary[city] = new SortedDictionary<string, SortedSet<string>>();
- }
- if (!nightLifeDictionary[city].ContainsKey(venue))
- {
- nightLifeDictionary[city][venue] = new SortedSet<string>();
- }
- nightLifeDictionary[city][venue].Add(performer);
- eventInformation = Console.ReadLine();
- }
- foreach (var cityPair in nightLifeDictionary)
- {
- Console.WriteLine(cityPair.Key);
- foreach (var venuePair in cityPair.Value)
- {
- Console.WriteLine("->{0}: {1}", venuePair.Key, String.Join(", ", venuePair.Value));
- }
- }
- }
- }
- 9 problem Terrorists Win! /////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Text;
- class TerroristsWin
- {
- static void Main()
- {
- string inputText = Console.ReadLine();
- StringBuilder inputTextAsStringBuilder = new StringBuilder(inputText);
- int startIndex = inputText.IndexOf('|');
- int endIndex = 0;
- int unicodeSum = 0;
- int destroyedArea = 0;
- while (startIndex != -1)
- {
- unicodeSum = 0;
- endIndex = inputText.IndexOf('|', startIndex + 1);
- if (endIndex <= startIndex)
- {
- break;
- }
- for (int i = startIndex + 1; i <= endIndex - 1; i++)
- {
- unicodeSum += inputText[i];
- inputTextAsStringBuilder[i] = '.';
- }
- destroyedArea = unicodeSum % 10;
- for (int i = startIndex; i >= startIndex - destroyedArea && i >= 0; i--)
- {
- inputTextAsStringBuilder[i] = '.';
- }
- for (int i = endIndex; i <= endIndex + destroyedArea && i < inputTextAsStringBuilder.Length; i++)
- {
- inputTextAsStringBuilder[i] = '.';
- }
- startIndex = inputText.IndexOf('|', endIndex + 1);
- }
- Console.WriteLine(inputTextAsStringBuilder);
- }
- }
- Problem 10. * Plus-Remove ///////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class PlusRemove
- {
- static void Main()
- {
- List<List<char>> board = new List<List<char>>();
- string lineContents = Console.ReadLine();
- for (int row = 0; lineContents != "END"; row++)
- {
- board.Add(new List<char>(lineContents.Length));
- for (int col = 0; col < lineContents.Length; col++)
- {
- board[row].Add(lineContents[col]);
- }
- lineContents = Console.ReadLine();
- }
- char currentValue = '\0';
- HashSet<KeyValuePair<int, int>> coordinatesSet = new HashSet<KeyValuePair<int, int>>();
- for (int row = 1; row < board.Count - 1; row++)
- {
- for (int col = 1; col < board[row].Count - 1; col++)
- {
- currentValue = Char.ToLower(board[row][col]);
- if (col < board[row - 1].Count && currentValue.Equals(Char.ToLower(board[row - 1][col]))
- && currentValue.Equals(Char.ToLower(board[row][col - 1])) && currentValue.Equals(Char.ToLower(board[row][col + 1]))
- && col < board[row + 1].Count && currentValue.Equals(Char.ToLower(board[row + 1][col])))
- {
- coordinatesSet.Add(new KeyValuePair<int, int>(row, col));
- coordinatesSet.Add(new KeyValuePair<int, int>(row - 1, col));
- coordinatesSet.Add(new KeyValuePair<int, int>(row + 1, col));
- coordinatesSet.Add(new KeyValuePair<int, int>(row, col + 1));
- coordinatesSet.Add(new KeyValuePair<int, int>(row, col - 1));
- }
- }
- }
- for (int row = 0; row < board.Count; row++)
- {
- for (int col = 0; col < board[row].Count; col++)
- {
- KeyValuePair<int, int> curKeyValuePair = new KeyValuePair<int, int>(row, col);
- if (!coordinatesSet.Contains(curKeyValuePair))
- {
- Console.Write(board[row][col]);
- }
- }
- Console.WriteLine();
- }
- }
- }
- Problem 11. * String Matrix Rotation ////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class StringMatrixRotation
- {
- static void Main()
- {
- string[] inputTokens = Console.ReadLine().Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
- int degrees = int.Parse(inputTokens[1]) % 360;
- int bestLength = int.MinValue;
- Queue<string> elements = new Queue<string>();
- string currentElement = Console.ReadLine();
- while (!String.IsNullOrEmpty(currentElement))
- {
- elements.Enqueue(currentElement);
- if (currentElement.Length > bestLength)
- {
- bestLength = currentElement.Length;
- }
- currentElement = Console.ReadLine();
- }
- char[,] matrix = new char[elements.Count, bestLength];
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- currentElement = elements.Dequeue().PadRight(bestLength, ' ');
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- matrix[row, col] = currentElement[col];
- }
- }
- if (degrees == 90)
- {
- char[,] rotatedMatrix = new char[matrix.GetLength(1), matrix.GetLength(0)];
- for (int row = 0; row < rotatedMatrix.GetLength(0); row++)
- {
- for (int col = 0; col < rotatedMatrix.GetLength(1); col++)
- {
- rotatedMatrix[row, col] = matrix[matrix.GetLength(0) - col - 1, row];
- }
- }
- PrintMatrix(rotatedMatrix);
- }
- else if (degrees == 180)
- {
- char[,] rotatedMatrix = new char[matrix.GetLength(0), matrix.GetLength(1)];
- for (int row = 0; row < rotatedMatrix.GetLength(0); row++)
- {
- for (int col = 0; col < rotatedMatrix.GetLength(1); col++)
- {
- rotatedMatrix[row, col] = matrix[matrix.GetLength(0) - row - 1, matrix.GetLength(1) - col - 1];
- }
- }
- PrintMatrix(rotatedMatrix);
- }
- else if (degrees == 270)
- {
- char[,] rotatedMatrix = new char[matrix.GetLength(1), matrix.GetLength(0)];
- for (int col = 0; col < rotatedMatrix.GetLength(1); col++)
- {
- for (int row = 0; row < rotatedMatrix.GetLength(0); row++)
- {
- rotatedMatrix[row, col] = matrix[col, matrix.GetLength(1) - row - 1];
- }
- }
- PrintMatrix(rotatedMatrix);
- }
- else if (degrees == 0)
- {
- PrintMatrix(matrix);
- }
- }
- private static void PrintMatrix(char[,] matrix)
- {
- for (int row = 0; row < matrix.GetLength(0); row++)
- {
- for (int col = 0; col < matrix.GetLength(1); col++)
- {
- Console.Write(matrix[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- Problem 12. * To the Stars! /////////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class ToTheStars
- {
- static void Main()
- {
- Dictionary<string, Tuple<double, double>> starSystemsDictionary = new Dictionary<string, Tuple<double, double>>();
- string startSystemName = String.Empty;
- double starSystemCoordinateX = 0;
- double starSystemCoordinateY = 0;
- string[] starSystemsTokens;
- for (int i = 0; i < 3; i++)
- {
- starSystemsTokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- startSystemName = starSystemsTokens[0];
- starSystemCoordinateX = double.Parse(starSystemsTokens[1]);
- starSystemCoordinateY = double.Parse(starSystemsTokens[2]);
- starSystemsDictionary[startSystemName] = new Tuple<double, double>(starSystemCoordinateX, starSystemCoordinateY);
- }
- string[] spaceshipStartCordinates = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- int numberOfMoves = int.Parse(Console.ReadLine());
- double spaceshipX = double.Parse(spaceshipStartCordinates[0]);
- double spaceshipY = double.Parse(spaceshipStartCordinates[1]);
- bool isInStarSystem = false;
- while (numberOfMoves >= 0)
- {
- isInStarSystem = false;
- foreach (var pair in starSystemsDictionary)
- {
- if (IsInStarSystem(pair.Value.Item1, pair.Value.Item2, spaceshipX, spaceshipY))
- {
- Console.WriteLine(pair.Key.ToLower());
- isInStarSystem = true;
- break;
- }
- }
- if (!isInStarSystem)
- {
- Console.WriteLine("space");
- }
- spaceshipY++;
- numberOfMoves--;
- }
- }
- private static bool IsInStarSystem(double starX, double starY, double spaceshipX, double spaceshipY)
- {
- if ((spaceshipX >= starX - 1 && spaceshipX <= starX + 1) && (spaceshipY >= starY - 1 && spaceshipY <= starY + 1))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- Problem 13. * Activity Tracker ////////////////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- class ActivityTracker
- {
- static void Main()
- {
- SortedDictionary<int, SortedDictionary<string, int>> dataDictionary =
- new SortedDictionary<int, SortedDictionary<string, int>>();
- int dataLinesNumber = int.Parse(Console.ReadLine());
- string lineContents = String.Empty;
- string[] lineTokens;
- int month = 0;
- string user = String.Empty;
- int distance = 0;
- for (int i = 0; i < dataLinesNumber; i++)
- {
- lineContents = Console.ReadLine();
- lineTokens = lineContents.Split(new char[] { ' ', '/' }, StringSplitOptions.RemoveEmptyEntries);
- month = int.Parse(lineTokens[1]);
- user = lineTokens[3];
- distance = int.Parse(lineTokens[4]);
- if (!dataDictionary.ContainsKey(month))
- {
- dataDictionary[month] = new SortedDictionary<string, int>();
- }
- if (!dataDictionary[month].ContainsKey(user))
- {
- dataDictionary[month][user] = distance;
- }
- else
- {
- dataDictionary[month][user] += distance;
- }
- }
- bool isFirstPair = true;
- foreach (var dataPair in dataDictionary)
- {
- Console.Write("{0}: ", dataPair.Key);
- isFirstPair = true;
- foreach (var subPair in dataPair.Value)
- {
- if (isFirstPair)
- {
- Console.Write("{0}({1})", subPair.Key, subPair.Value);
- isFirstPair = false;
- }
- else
- {
- Console.Write(", {0}({1})", subPair.Key, subPair.Value);
- }
- }
- Console.WriteLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- class NightLife
- {
- static void Main()
- {
- Dictionary<string, SortedDictionary<string, List<int>>> nightLifeDictionary =
- new Dictionary<string, SortedDictionary<string, List<int>>>();
- string[] eventTokens;
- string city = String.Empty;
- string venue = String.Empty;
- int performer = 0;
- string eventInformation = Console.ReadLine();
- while (eventInformation != "END")
- {
- eventTokens = eventInformation.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- city = eventTokens[0];
- venue = eventTokens[1];
- performer = int.Parse(eventTokens[2]);
- if (!nightLifeDictionary.ContainsKey(city))
- {
- nightLifeDictionary[city] = new SortedDictionary<string, List<int>>();
- }
- if (!nightLifeDictionary[city].ContainsKey(venue))
- {
- nightLifeDictionary[city][venue] = new List<int>();
- }
- nightLifeDictionary[city][venue].Add(performer);
- eventInformation = Console.ReadLine();
- }
- string kondio = "";
- double sum = 0;
- double count = 0;
- double avg = 0;
- foreach (var cityPair in nightLifeDictionary)
- {
- Console.WriteLine();
- Console.Write(cityPair.Key + ":: ");
- // Console.WriteLine(": " + kondio);
- // Console.WriteLine(avg);
- foreach (var venuePair in cityPair.Value)
- {
- Console.Write(" ->{0}: ", venuePair.Key);
- count = 0;
- sum = 0;
- foreach (var item in venuePair.Value)
- {
- count++;
- // Console.WriteLine(item);
- sum += item;
- }
- venuePair.Value.ToString();
- avg = sum / count;
- // Console.WriteLine("->{0}: ", venuePair.Key);
- kondio = venuePair.Key.ToString();
- Console.Write(" >>" + avg);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement