Advertisement
Ochkasty_Dino

Practicum9-II-5

Nov 18th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp1
  9. {
  10.  
  11.     class Program4
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             using (StreamReader fileIn = new StreamReader("C:/Users/belousaa/Documents/in1.txt", Encoding.GetEncoding(1251)))
  16.             {
  17.                 using (StreamReader fileIn2 = new StreamReader("C:/Users/belousaa/Documents/in2.txt", Encoding.GetEncoding(1251)))
  18.                 {
  19.                     using (StreamWriter fileOut = new StreamWriter("C:/Users/belousaa/Documents/out.txt", false))
  20.                     {
  21.                         while (!fileIn.EndOfStream)
  22.                         {
  23.                             string[] nums = fileIn.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  24.                             string[] nums2 = fileIn2.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  25.                             for (int i = 0; i < nums.Length; i++)
  26.                             {
  27.                                 if (int.Parse(nums[i]) > int.Parse(nums2[i]))
  28.                                 {
  29.                                     fileOut.Write(int.Parse(nums[i]) + " ");
  30.                                 }
  31.                                 else
  32.                                 {
  33.                                     fileOut.Write(int.Parse(nums2[i]) + " ");
  34.                                 }
  35.                             }
  36.                             fileOut.WriteLine();
  37.                         }
  38.  
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement