IPetrov007

Piramid

Apr 4th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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.  
  7. namespace _03_Piramidic
  8. {
  9. public class Piramidic
  10. {
  11. public static void Main()
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. var stringArray = new string[n];
  15. for (int i = 0; i < n; i++)
  16. {
  17. var input = Console.ReadLine();
  18. stringArray[i] = input;
  19. }
  20. var maxCounter = int.MinValue;
  21. var maxChar = '0';
  22.  
  23. var counter = 1;
  24.  
  25. for (int i = 0; i < stringArray.Length; i++)
  26. {
  27. var currentWord = stringArray[i];
  28. for (int j = 0; j < currentWord.Length; j++)
  29. {
  30. var currentChar = currentWord[j];
  31.  
  32. var nextRowCharLenght = 3;
  33.  
  34.  
  35. for (int k = i + 1; k < stringArray.Length; k++)
  36. {
  37. var nextRowChar = new string(currentChar, nextRowCharLenght);
  38.  
  39. if (stringArray[k].Contains(nextRowChar))
  40. {
  41. counter++;
  42. nextRowCharLenght += 2;
  43. }
  44. else
  45. {
  46. nextRowCharLenght = 3;
  47. break;
  48. }
  49. }
  50. if (counter > maxCounter)
  51. {
  52. maxCounter = counter;
  53. maxChar = currentChar;
  54. }
  55. counter = 1;
  56. }
  57. }
  58. var widht = 1;
  59. for (int i = 1; i <= maxCounter; i++)
  60. {
  61. Console.WriteLine(new string(maxChar, widht));
  62. widht += 2;
  63. }
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment