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;
- namespace _04EncryptedMatrix
- {
- class Program
- {
- static void Main()
- {
- string input = Console.ReadLine();
- char[] inputChar = input.ToCharArray();
- char[] concat = new char[inputChar.Length];
- char[] concat2 = new char[concat.Length];
- char[] newNumber = new char[concat2.Length];
- // char[] newnewNumber = new char[newNumber.Length];
- string slash = Console.ReadLine();
- for (int i = 0; i < inputChar.Length; i++)
- {
- char lastDigit = Convert.ToChar(inputChar[i] % 10);
- concat[i]=Convert.ToChar(lastDigit);
- }
- for (int i = 0; i < concat.Length; i++)
- {
- if ((int)concat[i] % 2 == 0)
- {
- newNumber[i] = (char)(concat[i] * concat[i]);
- }
- else if ((int)concat[i] % 2 != 0 && (i==0))
- {
- newNumber[i] = (char)(Convert.ToInt32(concat[i + 1])+ Convert.ToInt32(concat[i]));
- }
- else if ((int)concat[i] % 2 != 0 && (i == concat.Length - 1))
- {
- newNumber[i] = (char)(Convert.ToInt32((concat[i - 1])+Convert.ToInt32(concat[i]) ));
- }
- else if (((int)concat[i] % 2 != 0) && (i!=0) && (i!=concat.Length-1))
- {
- newNumber[i] = (char)(Convert.ToInt32(concat[i - 1]) + Convert.ToInt32(concat[i + 1]) + Convert.ToInt32(concat[i]));
- }
- }
- char[,] matrix = new char[newNumber.Length, newNumber.Length];
- if (slash == "\\")
- {
- for (int i = 0; i < newNumber.Length; i++)
- {
- matrix[i, i] = newNumber[i];
- }
- }
- else
- {
- for (int i = 0; i < newNumber.Length; i++)
- {
- matrix[newNumber.Length - i - 1, i] = newNumber[i];
- }
- }
- char[] characters = newNumber.ToString().ToCharArray();
- for (int i = 0; i < newNumber.Length; i++)
- {
- for (int j = 0; j < newNumber.Length; j++)
- {
- Console.Write((int)matrix[i,j]+ " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment