Advertisement
Guest User

f ugorjon egy kamion ala

a guest
Jan 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace vigenere
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Console.WriteLine("1.feladat");
  15.             Console.WriteLine("Adj meg egy szöveget ékezettel, írásjellel!");
  16.             string nyilt = Console.ReadLine();
  17.             nyilt = nyilt.ToUpper();
  18.             Console.WriteLine("eredeti upperelve " + nyilt);
  19.             string elegans = "";
  20.             for (int i = 0; i < nyilt.Length; i++)
  21.             {
  22.                 if (nyilt[i] == 'Á') { nyilt = nyilt.Replace(nyilt[i], 'A'); Console.WriteLine("Itt vagyok!" + nyilt); }
  23.                 else if (nyilt[i] == 'É') { nyilt = nyilt.Replace(nyilt[i], 'E'); }
  24.                 else if (nyilt[i] == 'Í') { nyilt = nyilt.Replace(nyilt[i], 'I'); }
  25.                 else if (nyilt[i] == 'Ó' || nyilt[i] == 'Ö' || nyilt[i] == 'Õ') { nyilt = nyilt.Replace(nyilt[i], 'O');}
  26.                 else if (nyilt[i] == 'Ú' || nyilt[i] == 'Ü' || nyilt[i] == 'Û') { nyilt = nyilt.Replace(nyilt[i], 'U');}
  27.                 else if(nyilt[i] != '!' && nyilt[i] != '.' && nyilt[i] != '?' && nyilt[i] != ',' && nyilt[i] != ' ' && nyilt[i] != ';') { elegans += nyilt[i];}
  28.             }
  29.             Console.WriteLine("  "+elegans);
  30.             StreamReader sr = new StreamReader("vtabla.dat");
  31.             char[,] betuk = new char[26, 26];
  32.             string sorr;
  33.             for (int i = 0; i < 26; i++)
  34.             {
  35.                 sorr = sr.ReadLine();
  36.                 for (int j = 0; j < 26; j++)
  37.                 {
  38.                     betuk[i, j] = sorr[j];
  39.                 }
  40.             }
  41.             for (int i = 0; i < 26; i++)
  42.             {
  43.                 for (int j = 0; j < 26; j++)
  44.                 {
  45.                     Console.Write(betuk[i, j]);
  46.                 }
  47.                 Console.WriteLine();
  48.             }
  49.             sr.Close();
  50.             Console.WriteLine(" Adj meg egy kulcsszót!");
  51.             string er_kulcs = Console.ReadLine();
  52.             er_kulcs.ToUpper();
  53.             int hossza_kulcsnak = er_kulcs.Count();
  54.             int sor_hossza = elegans.Count();
  55.             string autozok = "";
  56.             int hanyszor = sor_hossza / hossza_kulcsnak;
  57.             for (int i = 0; i < hanyszor; i++)
  58.             {
  59.                 autozok += er_kulcs;
  60.             }  
  61.             Console.WriteLine(autozok);
  62.             int sorindex = 0;
  63.             int oszlopindex = 0;
  64.             string kodolt = "";
  65.             for (int j = 0; j < 26; j++)
  66.             {
  67.                 for (int i = 0; i < 26; i++)
  68.                 {
  69.                     if (elegans[j] == betuk[i, 0]) { sorindex = i; }
  70.                     if (autozok[j] == betuk[0, i]){oszlopindex = i;}
  71.                    
  72.                 }
  73.                 kodolt += betuk[sorindex, oszlopindex];
  74.             }
  75.                // FileStream fs = new FileStream("kodolt.txt", FileMode.Create, Encoding.Default);
  76.                 StreamWriter sw = new StreamWriter("kodolt.txt");
  77.                 sw.WriteLine(kodolt);
  78.                 Console.WriteLine(kodolt);
  79.                 sw.Close();
  80.                // fs.Close();
  81.                 Console.ReadKey();
  82.            
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement