Advertisement
ajreuri23

שאלה 20

Dec 3rd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. int[] a = new int[10];
  4. int[] b = new int[a.Length];
  5. int[] c = new int[a.Length];
  6. int i, j, Placement = 0, x, f, y, car, bar, aar;
  7. for (i = 0; i < a.Length; i++)
  8. {
  9. a[i] = int.Parse(Console.ReadLine());
  10. }
  11. for (j = 0; j < a.Length; j++)
  12. {
  13. if (a[j] < 0)
  14. {
  15. b[Placement] = a[j];
  16. Placement++;
  17. }
  18. }
  19. for (x = 0; x < a.Length; x++)
  20. {
  21. if (a[x] > 0)
  22. {
  23. b[Placement] = a[x];
  24. Placement++;
  25. }
  26. }
  27. for (f = 0; f < a.Length; f++)
  28. Console.Write(b[f] + " ");
  29. for (y = 0; y < a.Length; y++)
  30. {
  31. if (a[y] > b[y])
  32. {
  33. c[y] = a[y];
  34. }
  35. else if (b[y] > a[y])
  36. {
  37. c[y] = b[y];
  38. }
  39. else
  40. {
  41. c[y] = 0;
  42. }
  43. }
  44. Console.WriteLine("");
  45. for (car = 0; car < a.Length; car++)
  46. Console.Write(a[car] + " ");
  47. Console.WriteLine("");
  48. for (bar = 0; bar < a.Length; bar++)
  49. Console.Write(b[bar] + " ");
  50. Console.WriteLine("");
  51. for (aar = 0; aar < a.Length; aar++)
  52. Console.Write(c[aar] + " ");
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement