Seal_of_approval

Pr6R4ex3

Sep 25th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace test
  4. {
  5.     class Program
  6.     {
  7.         static void Change (ref int[,] ar, ref int n, ref int[] x)
  8.         {
  9.             for (int j = 0; j < n; j++)
  10.                 if ((j + 1) % 2 == 0)
  11.                     for (int i = 0; i < n; i++)
  12.                         ar [i,j] = x[i];
  13.                
  14.         }
  15.  
  16.         static void Main()
  17.         {
  18.             int[,] array;
  19.             Console.Write ("n = ");
  20.             int n = int.Parse (Console.ReadLine ());
  21.             array = new int[n, n];
  22.  
  23.             for (int i = 0; i < n; i++) {
  24.                 string[] s = Console.ReadLine ().Split (' ');
  25.                 for (int j = 0; j < n; j++)
  26.                     array [i, j] = Int32.Parse (s [j]);
  27.             }
  28.  
  29.             Console.Write ("Enter X = ");
  30.             string[] a = Console.ReadLine ().Split(' ');
  31.             int [] x;
  32.             x = new int[n];
  33.             for (int i = 0; i < n; i++)
  34.                 x [i] = Int32.Parse (a [i]);
  35.  
  36.             Change (ref array, ref n, ref x);
  37.             for (int i = 0; i < n; i++) {
  38.                 for (int j = 0; j < n; j++)
  39.                     Console.Write ("{0} ", array [i, j]);
  40.                 Console.WriteLine ();
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment