Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. class tomb {
  3.     private int n;
  4.     int[] x = new int[10];
  5.     public tomb(int n1, int[] a1) {
  6.         int i;
  7.         n = n1;
  8.         for (i = 0; i < n; i++) x[i] = a1[i];
  9.     }
  10.     public void szet(int n, ref int[] a, ref int[] b, ref int j, ref int k) {
  11.         int i;
  12.         for (i = 0; i < n; i++) {
  13.             if (x[i] > 0) a[j++] = x[i];
  14.             else if (x[i] < 0) b[k++] = x[i];
  15.         }
  16.     }
  17. }
  18. class Program {
  19.     static void Main() {
  20.         int n,i,p=0,r=0;
  21.         int[] x = new int[10];
  22.         int[] po = new int[10];
  23.         int[] ne = new int[10];
  24.         Console.Write("n = ");
  25.         n = Convert.ToInt32(Console.ReadLine());
  26.         for (i = 0; i < n; i++) x[i] = Convert.ToInt32(Console.ReadLine());
  27.         tomb a = new tomb(n,x);
  28.         a.szet(n, ref po, ref ne, ref p, ref r);
  29.         Console.Write("\n\nA tomb: ");
  30.         for (i = 0; i < n; i++) Console.Write("{0} ", x[i]);
  31.         Console.Write("\n\nPozitiv szamos tomb: ");
  32.         for (i = 0; i < p; i++) Console.Write("{0} ", po[i]);
  33.         Console.Write("\nNegativ szamos tomb: ");
  34.         for (i = 0; i < r; i++) Console.Write("{0} ", ne[i]);
  35.         Console.ReadKey();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement