Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- int[] tab1 = new int[6];
- int[,] tab2 = new int[6, 6];
- //int[][] tab3 = new int[][];
- int suma1 = 0, suma2 = 0, sumaKolejnych1 = 0, sumaKolejnych2 = 0, liczbaElementow1 = 0, liczbaElementow2 = 0;
- double srednia1, srednia2, sredniaKolejnych1, sredniaKolejnych2;
- // 1 tablica :
- //liczba:
- Console.Write("Podaj liczbę do 1 tablicy: ");
- int podanaLiczba = Convert.ToInt32(Console.ReadLine());
- for (int i=0; i < 6; i++)
- {
- tab1[i] = podanaLiczba;
- Console.Write(tab1[i].ToString() + " ");
- }
- for (int i = 0; i < 5; i++)
- {
- suma1 += tab1[i];
- liczbaElementow1 += 1;
- }
- srednia1 = suma1 / liczbaElementow1;
- Console.WriteLine();
- Console.WriteLine("Suma 1: " + suma1.ToString() + "\nSrednia 1: " + srednia1.ToString());
- //kolejne liczby:
- Console.Write("Podaj liczbę do tablicy 1 ( kolejne liczby) : ");
- int kolejneLiczby1 = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < 5; i++, kolejneLiczby1++)
- {
- tab1[i] = kolejneLiczby1;
- Console.Write(tab1[i].ToString() + " ");
- }
- liczbaElementow1 = 0;
- for (int i = 0; i < 5; i++)
- {
- sumaKolejnych1 += tab1[i];
- liczbaElementow1 += 1;
- }
- sredniaKolejnych1 = sumaKolejnych1 / liczbaElementow1;
- Console.WriteLine();
- Console.WriteLine("Suma 1: " + sumaKolejnych1.ToString() + "\nSrednia 1: " + sredniaKolejnych1.ToString());
- // 2 tablica :
- //takie same liczby:
- Console.Write("Podaj liczbę do 2 tablicy: ");
- int podanaLiczba2 = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < 6; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- tab2[i, j] = podanaLiczba2;
- Console.Write(tab2[i, j].ToString() + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- suma2 += tab2[i, j];
- liczbaElementow2 += 1;
- }
- }
- srednia2 = suma2 / liczbaElementow2;
- Console.WriteLine();
- Console.WriteLine("Suma 2: " + suma2.ToString() + "\nSrednia 2: " + srednia2.ToString());
- // kolejne liczby:
- Console.Write("Podaj liczbę do tablicy 2 ( kolejne liczby) : ");
- int kolejneLiczby2 = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++, kolejneLiczby2++)
- {
- tab2[i, j] = kolejneLiczby2;
- Console.Write(tab2[i, j].ToString() + " ");
- }
- Console.WriteLine();
- }
- liczbaElementow2 = 0;
- for (int i = 0; i < 5; i++)
- {
- for (int j = 0; j < 5; j++)
- {
- sumaKolejnych2 += tab2[i, j];
- liczbaElementow2 += 1;
- }
- }
- sredniaKolejnych2 = sumaKolejnych2 / liczbaElementow2;
- Console.WriteLine();
- Console.WriteLine("Suma 2: " + sumaKolejnych2.ToString() + "\nSrednia 2: " + sredniaKolejnych2.ToString());
- // 3 tablica :
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement