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.IO;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] roz = { '\n', ' ', '\r' };
- String[] p1 = System.IO.File.ReadAllText(@"A1.TXT").Split(roz, System.StringSplitOptions.RemoveEmptyEntries);
- String[] p2 = System.IO.File.ReadAllText(@"A2.TXT").Split(roz, System.StringSplitOptions.RemoveEmptyEntries);
- StreamWriter sw = new StreamWriter(@"B.TXT");
- int pozice1 = 0;
- int pozice2 = 0;
- while(true)
- {
- if (pozice2 == p2.Length)
- {
- for (int i = pozice1; i < p1.Length; i++)
- {
- sw.Write((Convert.ToInt32(p1[i]) + " "));
- }
- break;
- }
- if (pozice1 == p1.Length)
- {
- for (int i = pozice2; i < p2.Length; i++)
- {
- sw.Write((Convert.ToInt32(p2[i]) + " "));
- }
- break;
- }
- if (Convert.ToInt32(p1[pozice1]) <= Convert.ToInt32(p2[pozice2]))
- {
- sw.Write((Convert.ToInt32(p1[pozice1]) + " "));
- pozice1++;
- }else
- if (Convert.ToInt32(p1[pozice1]) >= Convert.ToInt32(p2[pozice2]))
- {
- sw.Write(Convert.ToInt32(p2[pozice2]) + " ");
- pozice2++;
- }
- }
- sw.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment