woody1000

10*10 array (C# Shell App Paste)

Mar 10th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace HW
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int[,] array = new int[10,10];
  15.            
  16.             Random rnd = new Random();
  17.          
  18.            
  19.             int kj = 0;
  20.             int k =0;
  21.            
  22.             for(int i= 0; i < array.GetLength(0);i++)
  23.             {
  24.                 for(int j = 0 ; j < array.GetLength(1); j++)
  25.                 {
  26.                  int initNum = rnd.Next(5,500);
  27.            
  28.                    array [i,j] = initNum;
  29.                   kj=  array[i,j] ;
  30.                    Console.Write(" "+kj);
  31.        
  32.                 }
  33.                 Console.WriteLine();
  34.                
  35.        
  36.             }
  37.            
  38.             for(int i= 0; i < array.GetLength(0);i++)
  39.             {
  40.                
  41.                 for(int j = 0 ; j < array.GetLength(1); j++)
  42.                 {
  43.                     k = array[i,j];
  44.                   if (array[i,j]>array[i, j +1])
  45.                   {
  46.                     k= array[i,j];
  47.                    
  48.                   }
  49.                   else if(array[i,j]<array[i, j +1])
  50.                   {
  51.                     k  = array[i,j+1];
  52.                   }
  53.                  
  54.                  
  55.                  
  56.                  
  57.            
  58.                    
  59.                
  60.                    Console.Write(" " + array[i,j]);
  61.        
  62.                 }
  63.                 Console.WriteLine();
  64.                
  65.        
  66.             }
  67.                
  68.               Console.WriteLine(k) ;
  69.          
  70.  
  71.  
  72.         }
  73.     }
  74. }
Add Comment
Please, Sign In to add comment