Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 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.  
  9. namespace ConsoleApp8
  10. {
  11. class Program
  12. {
  13.  
  14. static void Main(string[] args)
  15. {
  16. StreamWriter Sw_out = File.CreateText("out.txt");
  17.  
  18. string[] line = System.IO.File.ReadAllLines("in.txt");
  19.  
  20. string[] s = line[0].Split(' ');
  21.  
  22. int n = int.Parse(s[0]);
  23. int m1 = int.Parse(s[1]);
  24.  
  25.  
  26. int[] liczby = new int[n];
  27. int[] liczby1 = new int[n];
  28. for (int i = 0; i < n; i++)
  29. {
  30. liczby[i] = int.Parse(line[i + 1]);
  31. }
  32.  
  33. Array.Sort(liczby);
  34.  
  35. int[] pomocnicza1 = new int[n];
  36. int[] pomocnicza2 = new int[n];
  37. int tablicowa = 0;
  38. int pomocnicza = 0;
  39. int[] liczby_pom = new int[n];
  40. int[] liczby1_pom = new int[n];
  41. for (int i = 0; i < n; i++)
  42. {
  43. liczby_pom[i] = liczby[i];
  44. }
  45.  
  46. for (int x = 0; x < n; x++)
  47. {
  48.  
  49. pomocnicza = liczby[x] + liczby[n - 1];
  50.  
  51. if ((pomocnicza <= 140) && (x != n))
  52. {
  53.  
  54. if (liczby[x] != liczby[n - 1])
  55. {
  56. pomocnicza1[tablicowa] = liczby[x];
  57. pomocnicza2[tablicowa] = liczby[n - 1];
  58.  
  59. n--;
  60. }
  61.  
  62. }
  63. if ((pomocnicza > 140) && (x != n))
  64. {
  65. pomocnicza = Math.Max(liczby[x], liczby[n - 1]);
  66. pomocnicza1[tablicowa] = pomocnicza;
  67.  
  68. x--;
  69. n--;
  70. }
  71.  
  72. if (liczby[x] == liczby[n - 1])
  73. {
  74. pomocnicza = liczby[x];
  75. pomocnicza1[tablicowa] = liczby[x];
  76.  
  77. }
  78.  
  79.  
  80. tablicowa++;
  81.  
  82.  
  83. pomocnicza = 0;
  84. }
  85. int zlicz = 5;
  86. for (int x = 0; x < zlicz; x++)
  87. {
  88.  
  89. if ((pomocnicza1[x] != 0) && (pomocnicza2[x] != 0))
  90. {
  91.  
  92. if (pomocnicza2[x] != pomocnicza1[x])
  93. { Sw_out.Write(pomocnicza1[x] + " " + pomocnicza2[x] + " " + Environment.NewLine); }
  94. }
  95. else
  96. {
  97. Sw_out.Write(pomocnicza1[x] + Environment.NewLine);
  98. }
  99.  
  100. }
  101.  
  102. Console.WriteLine("Koniec!");
  103.  
  104. Console.ReadLine();
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement