Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Вывести на экран все числа, попадающий в отрезок [a, b], отсортировав их в порядке возрастания.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- using (StreamReader input = new StreamReader("e:/practice/input.txt", Encoding.GetEncoding(1251)))
- {
- int n = int.Parse(input.ReadLine());
- int [] array = new int[n];
- string[] text = input.ReadLine().Split(' ');
- int a = int.Parse(text[0]);
- int b = int.Parse(text[1]);
- string[] tmp = input.ReadLine().Split(' ');
- for (int i = 0; i < n; i++)
- array[i] = int.Parse(tmp[i]);
- var Nums =
- from x in array
- where x >= a && x <= b
- orderby x
- select x;
- using (StreamWriter output = new StreamWriter("e:/practice/output.txt", false))
- {
- foreach (var x in Nums)
- output.WriteLine("{0} ", x);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement