Advertisement
Shtiler

Untitled

Dec 13th, 2019
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp41
  4. {
  5. internal class Program
  6. {
  7. private static void Main(string[] args)
  8. {
  9. string str = @"Dpxo, epxo, epxo. Tifsf xbt opuijoh fmtf up ep, tp Amjdf tppo cfhbo ubmljoh bhbjo. `Djobi'mm njtt nf wfsz nvdi up-ojhiu, I tipvme uijol!' (Djobi xbt uif dbu.) `I ipqf uifz'mm sfnfncfs ifs tbvdfs pg njml bu ufb-ujnf. Djobi nz efbs! I xjti zpv xfsf epxo ifsf xjui nf! Tifsf bsf op njdf jo uif bjs, I'n bgsbje, cvu zpv njhiu dbudi b cbu, boe uibu't wfsz mjlf b npvtf, zpv lopx. Bvu ep dbut fbu cbut, I xpoefs?' Aoe ifsf Amjdf cfhbo up hfu sbuifs tmffqz, boe xfou po tbzjoh up ifstfmg, jo b esfbnz tpsu pg xbz, `Dp dbut fbu cbut? Dp dbut fbu cbut?' boe tpnfujnft, `Dp cbut fbu dbut?' gps, zpv tff, bt tif dpvmeo'u botxfs fjuifs rvftujpo, ju ejeo'u nvdi nbuufs xijdi xbz tif qvu ju. Sif gfmu uibu tif xbt epajoh pgg, boe ibe kvtu cfhvo up esfbn uibu tif xbt xbmljoh iboe jo iboe xjui Djobi, boe tbzjoh up ifs wfsz fbsoftumz, `Npx, Djobi, ufmm nf uif usvui: eje zpv fwfs fbu b cbu?' xifo tveefomz, uivnq! uivnq! epxo tif dbnf vqpo b ifbq pg tujdlt boe esz mfbwft, boe uif gbmm xbt pwfs";
  10. string strfixed = @"Dpxoepxoepxo.Tifsfxbtopuijohfmtfupep,tpAmjdftppocfhboubmljohbhbjo.`Djobi'mmnjttnfwfsznvdiup-ojhiu,Itipvmeuijol!'(Djobixbtuifdbu.)`Iipqfuifz'mm sfnfncfsifstbvdfspgnjmlbuufb-ujnf.Djobinzefbs!Ixjtizpvxfsfepxoifsfxjuinf!Tifsfbsfopnjdfjouifbjs,I'nbgsbje,cvuzpvnjhiudbudibcbu,boeuibu'twfsz mjlfbnpvtf,zpvlopx.Bvuepdbutfbucbut,Ixpoefs?'AoeifsfAmjdfcfhbouphfusbuifstmffqz,boexfoupotbzjohupifstfmg,jobesfbnztpsupgxbz,`Dpdbutfbucbut?Dpdbutfbucbut?'boetpnfujnft,`Dpcbutfbudbut?gps,zpvtff,bttifdpvmeo'ubotxfsfjuifs rvftujpo, ju ejeo'u nvdi nbuufs xijdi xbz tif qvu ju. Sif gfmu uibu tif xbt epajoh pgg, boe ibe kvtu cfhvo up esfbn uibu tif xbt xbmljoh iboe jo iboe xjui Djobi, boe tbzjoh up ifs wfsz fbsoftumz, `Npx, Djobi, ufmm nf uif usvui: eje zpv fwfs fbu b cbu?' xifo tveefomz, uivnq! uivnq! epxo tif dbnf vqpo b ifbq pg tujdlt boe esz mfbwft, boe uif gbmm xbt pwfs";
  11. // had to delete the spaces so space wouldn't be the most used character
  12. int[] charCount = new int[256];
  13.  
  14. int length = strfixed.Length;
  15. for (int i = 0; i < length; i++)
  16. {
  17. charCount[strfixed[i]]++;
  18. }
  19. int maxCount = -1;
  20. char character = ' ';
  21. for (int i = 0; i < length; i++)
  22. {
  23. if (maxCount < charCount[strfixed[i]])
  24. {
  25. maxCount = charCount[strfixed[i]];
  26. character = strfixed[i];
  27. }
  28. }
  29. Console.WriteLine("The highest occurring character in the above string is: {0} and it occured {1} times ", character, maxCount);
  30. string abc = "abcdefghijklmnopqrstuvwxyz";
  31. int key = 0;
  32. for (int i = 0; i < 26; i++)
  33. {
  34. if (abc[((character - 'a') + key) % 26] != 'e')
  35. {
  36. key++;
  37. }
  38. }
  39. Console.WriteLine("The Key is!: {0}", key);
  40. for (int i = 0; i < str.Length; i++)
  41. {
  42. if ((str[i] >= 'a') && (str[i] <= 'z'))
  43. {
  44. Console.Write(abc[((str[i] - 'a') + key) % 26]);
  45. }
  46. else
  47. {
  48. Console.Write(str[i]);
  49. }
  50. }
  51. Console.WriteLine("\n");
  52. Console.ReadLine();
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement