Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. int suma1 = 0, suma2 = 0, sumaKolejnych1 = 0, sumaKolejnych2 = 0, liczbaElementow1 = 0, liczbaElementow2 = 0;
  2. double srednia1, srednia2, sredniaKolejnych1, sredniaKolejnych2;
  3.  
  4. Console.Write("Podaj liczbę do tablicy 1: ");
  5. int podanaLiczba1 = Convert.ToInt32(Console.ReadLine());
  6. for (int i = 0; i < 5; i ++)
  7. {
  8. tab1[i] = podanaLiczba1;
  9. Console.Write(tab1[i].ToString()+" ");
  10. }
  11. for (int i = 0; i < 5; i++)
  12. {
  13. suma1 += tab1[i];
  14. liczbaElementow1 += 1;
  15. }
  16. srednia1 = suma1 / liczbaElementow1;
  17. Console.WriteLine();
  18. Console.WriteLine("Suma 1: "+suma1.ToString()+"\nSrednia 1: "+srednia1.ToString());
  19.  
  20. Console.Write("Podaj liczbę do tablicy 2: ");
  21. int podanaLiczba2 = Convert.ToInt32(Console.ReadLine());
  22. for (int i = 0; i < 5; i++)
  23. {
  24. for (int j = 0; j < 5; j++)
  25. {
  26. tab2[i, j] = podanaLiczba2;
  27. Console.Write(tab2[i, j].ToString() + " ");
  28. }
  29. Console.WriteLine();
  30. }
  31. for (int i = 0; i < 5; i++)
  32. {
  33. for (int j = 0; j < 5; j++)
  34. {
  35. suma2 += tab2[i, j];
  36. liczbaElementow2 += 1;
  37. }
  38. }
  39. srednia2 = suma2 / liczbaElementow2;
  40. Console.WriteLine();
  41. Console.WriteLine("Suma 2: " + suma2.ToString() + "\nSrednia 2: " + srednia2.ToString());
  42.  
  43. Console.Write("Podaj liczbę do tablicy 1: ");
  44. int kolejneLiczby1 = Convert.ToInt32(Console.ReadLine());
  45. for (int i = 0; i < 5; i++, kolejneLiczby1++)
  46. {
  47. tab1[i] = kolejneLiczby1;
  48. Console.Write(tab1[i].ToString() + " ");
  49. }
  50. liczbaElementow1 = 0;
  51. for (int i = 0; i < 5; i++)
  52. {
  53. sumaKolejnych1 += tab1[i];
  54. liczbaElementow1 += 1;
  55. }
  56. sredniaKolejnych1 = sumaKolejnych1 / liczbaElementow1;
  57. Console.WriteLine();
  58. Console.WriteLine("Suma 1: " + sumaKolejnych1.ToString() + "\nSrednia 1: " + sredniaKolejnych1.ToString());
  59.  
  60. Console.Write("Podaj liczbę do tablicy 2: ");
  61. int kolejneLiczby2 = Convert.ToInt32(Console.ReadLine());
  62. for (int i = 0; i < 5; i++)
  63. {
  64. for (int j = 0; j < 5; j++, kolejneLiczby2++)
  65. {
  66. tab2[i, j] = kolejneLiczby2;
  67. Console.Write(tab2[i, j].ToString() + " ");
  68. }
  69. Console.WriteLine();
  70. }
  71. liczbaElementow2 = 0;
  72. for (int i = 0; i < 5; i++)
  73. {
  74. for (int j = 0; j < 5; j++)
  75. {
  76. sumaKolejnych2 += tab2[i, j];
  77. liczbaElementow2 += 1;
  78. }
  79. }
  80. sredniaKolejnych2 = sumaKolejnych2 / liczbaElementow2;
  81. Console.WriteLine();
  82. Console.WriteLine("Suma 2: " + sumaKolejnych2.ToString() + "\nSrednia 2: " + sredniaKolejnych2.ToString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement