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;
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string word = Console.ReadLine().ToUpper();
- char[,] charMatrix = new char[n,n];
- int x = 0, y = 0, size = n, currentChar=0;
- while (size > 0)
- {
- for (int i = y; i <= y + size - 1; i++)
- {
- charMatrix[x, i] = word[currentChar % word.Length];
- currentChar++;
- }
- for (int j = x + 1; j <= x + size - 1; j++)
- {
- charMatrix[j, y + size - 1] = word[currentChar % word.Length];
- currentChar++;
- }
- for (int i = y + size - 2; i >= y; i--)
- {
- charMatrix[x + size - 1, i] = word[currentChar % word.Length];
- currentChar++;
- }
- for (int i = x + size - 2; i >= x + 1; i--)
- {
- charMatrix[i, y] = word[currentChar % word.Length];
- currentChar++;
- }
- x = x + 1;
- y = y + 1;
- size = size - 2;
- }
- int maxWeight = 0, rowNumber=0;
- for (int i = 0; i < charMatrix.GetLength(0); i++)
- {
- int currentWeight = 0;
- for (int j = 0; j < charMatrix.GetLength(1); j++)
- {
- currentWeight += (charMatrix[i, j] - 64);
- }
- if ( currentWeight > maxWeight)
- {
- maxWeight = currentWeight ;
- rowNumber = i;
- }
- }
- Console.WriteLine(rowNumber + " - " + maxWeight * 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement