شرح مثال عن المصفوفات ثنائية الابعاد في سي شارب
برمجة سي شارب | c# programming
- 2024-03-09
شرح مثال عن two dimension arrays في لغة سي شارب
Using two dimension array,to print the following numbers as shown in the output and find the sum of Array numbers.
Output:
3 5 6 12
9 8 2 1
using System;
class HelloWorld {
public static void Main()
{
int[,]a = new int [2,4];
Console.WriteLine("Enter elements into array:");
dir="ltr">
for(int i=0;i
for(int j=0;j
a[i,j]=int.Parse(Console.ReadLine());
Console.WriteLine("The array is :"+ "\n");
for(int i=0;i
{
for(int j=0;j
{
Console.Write(a[i,j]+ "\t");
}
Console.WriteLine("\n");
}
int sum=0;
for(int i=0;i
for(int j=0;j
{
sum=sum+a[i,j];
}
Console.WriteLine("The sum of the elements in the array is: " +sum);
}
}
هل كان الشرح مفيد؟