Guest User

Untitled

a guest
Apr 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. char[] roz = { '\n', ' ', '\r' };
  14. String[] p1 = System.IO.File.ReadAllText(@"A1.TXT").Split(roz, System.StringSplitOptions.RemoveEmptyEntries);
  15. String[] p2 = System.IO.File.ReadAllText(@"A2.TXT").Split(roz, System.StringSplitOptions.RemoveEmptyEntries);
  16.  
  17. StreamWriter sw = new StreamWriter(@"B.TXT");
  18.  
  19. int pozice1 = 0;
  20. int pozice2 = 0;
  21. while(true)
  22. {
  23. if (pozice2 == p2.Length)
  24. {
  25. for (int i = pozice1; i < p1.Length; i++)
  26. {
  27. sw.Write((Convert.ToInt32(p1[i]) + " "));
  28. }
  29. break;
  30. }
  31. if (pozice1 == p1.Length)
  32. {
  33. for (int i = pozice2; i < p2.Length; i++)
  34. {
  35. sw.Write((Convert.ToInt32(p2[i]) + " "));
  36. }
  37. break;
  38. }
  39. if (Convert.ToInt32(p1[pozice1]) <= Convert.ToInt32(p2[pozice2]))
  40. {
  41. sw.Write((Convert.ToInt32(p1[pozice1]) + " "));
  42. pozice1++;
  43. }else
  44. if (Convert.ToInt32(p1[pozice1]) >= Convert.ToInt32(p2[pozice2]))
  45. {
  46. sw.Write(Convert.ToInt32(p2[pozice2]) + " ");
  47. pozice2++;
  48. }
  49. }
  50. sw.Close();
  51. }
  52. }
  53. }
Add Comment
Please, Sign In to add comment