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;
- namespace bsk1
- {
- class Program
- {
- public static String deszyfrowanie(int n = 3, String word = "CRYPTOGRAPHY")
- {
- List<List<Char>> list = new List<List<char>>();
- for(int i=0;i<n; i++)
- {
- list.Add(new List<char>());
- }
- int iterator =
- String result = "";
- //gorna linia
- for(int i=0; 2*(n-1)*i < word.Length ; i++)
- {
- int twojastara = 2 * (n - 1) * i;
- list[0].Add(word[twojastara]);
- //srodki
- for(int j=1; j<n-1; j++)
- {
- if(twojastara-j > 0)
- list[j].Add(word[twojastara - j]);
- if (twojastara+j < word.Length)
- list[j].Add(word[twojastara + j]);
- }
- }
- // dolna linia
- for (int i = 0; 2 * (n - 1) * i + n -1 < word.Length; i++)
- {
- result += word[2 * (n - 1) * i + n -1];
- }
- Console.WriteLine(result);
- return result;
- }
- static void Main(string[] args)
- {
- deszyfrowanie();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement