C# İki Boyutlu Dizide Satır ve Sütun Toplamını Bulma

Rooster

only business
Legend Member
Joined
Aug 10, 2019
Topics
727
Messages
3,205
Solutions
314
Reaction score
4,997
Location
Milano
RC Point
0
C# ile iki 10×10 luk iki boyutlu bir dizi oluşturarak, oluşturulan bu çok boyutlu dizi içine rastgele sayılar atan ve daha sonra bu dizideki her bir satır ve sütunun toplamını hesaplayarak ekranda gösteren örneği oluşturalım.


Örneğimize ait C# kodlar aşağıdaki gibidir.

Code:
static void Main(string[] args)
        {
            int[,] dizi = new int[10,10];
            Random rnd = new Random();
 
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    dizi[i, j] = rnd.Next(10);
                    Console.Write(dizi[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine("=====================realitycheats.com============================");
            Console.WriteLine();
            for (int m = 0; m < 10; m++) 
            {
                int sutun_toplam=0;
                int satır_toplam = 0;
                for (int n = 0; n < 10; n++)
                {
                    satır_toplam += dizi[m, n];
                    sutun_toplam+=dizi[n,m];
                }
                Console.WriteLine("{0}. Satırın Toplamı\t: {1}\t\t{2}. SütununToplamı\t: {3}",(m+1),satır_toplam,(m+1),sutun_toplam);
            }
 
            Console.ReadKey();
        }
 
Top