Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _2D_array_class
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("enter the numbers of students");
- int students = int.Parse(Console.ReadLine());
- Console.WriteLine("enter the number of subjects");
- int subjects = int.Parse(Console.ReadLine());
- int[,] arr = new int[students, subjects];
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j <arr.GetLength(1); j++)
- {
- Console.WriteLine("enter subject {0} for student {1}",j+1,i+1);
- arr[i, j] = int.Parse(Console.ReadLine());
- }
- }
- /// 1 print the grade and the avarage for each subject
- /// colum sabt el row bytgyr
- Console.ForegroundColor = ConsoleColor.Green;
- for (int i = 0; i < subjects; i++)
- {
- int total = 0;
- double avarge = 0.0;
- Console.WriteLine("for subject {0}",(i+1));
- for (int j = 0; j < students; j++)
- {
- Console.Write(arr[i,j]+" ");
- total += arr[i, j];
- }
- Console.WriteLine("the avarage is {0}",(total/(double)students));
- }
- //print the max and min
- int max = arr[0,0];
- int min = arr[0, 0];
- for (int i = 0; i < students; i++)
- {
- for (int j = 0; j < subjects; j++)
- {
- if (arr[i, j] > max) max = arr[i, j];
- if (arr[i, j]< min) min = arr[i, j];
- }
- }
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("\n the max is {0} and the min is {1} \n \n ",max,min);
- Console.WriteLine("______________________");
- Console.ForegroundColor = ConsoleColor.Yellow;
- //over all zft حسبى الله و نعم الوكيل
- for (int k = 0; k < 100; k+=10)
- {
- int count = 0;
- for (int i = 0; i < students; i++)
- {
- for (int j = 0; j < subjects; j++)
- {
- if (arr[i,j]<=k+9&&arr[i,j]>=k)
- {
- count++;
- }
- }
- }
- Console.Write("{0}-{1} : ",k,(k+9));
- for (int i = 0; i < count; i++)
- {
- Console.Write("*");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement