Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class tomb {
- private int n;
- int[] x = new int[10];
- public tomb(int n1, int[] a1) {
- int i;
- n = n1;
- for (i = 0; i < n; i++) x[i] = a1[i];
- }
- public void szet(int n, ref int[] a, ref int[] b, ref int j, ref int k) {
- int i;
- for (i = 0; i < n; i++) {
- if (x[i] > 0) a[j++] = x[i];
- else if (x[i] < 0) b[k++] = x[i];
- }
- }
- }
- class Program {
- static void Main() {
- int n,i,p=0,r=0;
- int[] x = new int[10];
- int[] po = new int[10];
- int[] ne = new int[10];
- Console.Write("n = ");
- n = Convert.ToInt32(Console.ReadLine());
- for (i = 0; i < n; i++) x[i] = Convert.ToInt32(Console.ReadLine());
- tomb a = new tomb(n,x);
- a.szet(n, ref po, ref ne, ref p, ref r);
- Console.Write("\n\nA tomb: ");
- for (i = 0; i < n; i++) Console.Write("{0} ", x[i]);
- Console.Write("\n\nPozitiv szamos tomb: ");
- for (i = 0; i < p; i++) Console.Write("{0} ", po[i]);
- Console.Write("\nNegativ szamos tomb: ");
- for (i = 0; i < r; i++) Console.Write("{0} ", ne[i]);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement