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;
- using System.IO;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main(string[] args)
- {
- StreamWriter Sw_out = File.CreateText("out.txt");
- string[] line = System.IO.File.ReadAllLines("in.txt");
- string[] s = line[0].Split(' ');
- int n = int.Parse(s[0]);
- int m1 = int.Parse(s[1]);
- int[] liczby = new int[n];
- int[] liczby1 = new int[n];
- for (int i = 0; i < n; i++)
- {
- liczby[i] = int.Parse(line[i + 1]);
- }
- Array.Sort(liczby);
- int[] pomocnicza1 = new int[n];
- int[] pomocnicza2 = new int[n];
- int tablicowa = 0;
- int pomocnicza = 0;
- int[] liczby_pom = new int[n];
- int[] liczby1_pom = new int[n];
- for (int i = 0; i < n; i++)
- {
- liczby_pom[i] = liczby[i];
- }
- for (int x = 0; x < n; x++)
- {
- pomocnicza = liczby[x] + liczby[n - 1];
- if ((pomocnicza <= 140) && (x != n))
- {
- if (liczby[x] != liczby[n - 1])
- {
- pomocnicza1[tablicowa] = liczby[x];
- pomocnicza2[tablicowa] = liczby[n - 1];
- n--;
- }
- }
- if ((pomocnicza > 140) && (x != n))
- {
- pomocnicza = Math.Max(liczby[x], liczby[n - 1]);
- pomocnicza1[tablicowa] = pomocnicza;
- x--;
- n--;
- }
- if (liczby[x] == liczby[n - 1])
- {
- pomocnicza = liczby[x];
- pomocnicza1[tablicowa] = liczby[x];
- }
- tablicowa++;
- pomocnicza = 0;
- }
- int zlicz = 5;
- for (int x = 0; x < zlicz; x++)
- {
- if ((pomocnicza1[x] != 0) && (pomocnicza2[x] != 0))
- {
- if (pomocnicza2[x] != pomocnicza1[x])
- { Sw_out.Write(pomocnicza1[x] + " " + pomocnicza2[x] + " " + Environment.NewLine); }
- }
- else
- {
- Sw_out.Write(pomocnicza1[x] + Environment.NewLine);
- }
- }
- Console.WriteLine("Koniec!");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement