Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- int main() {
- srand(time(nullptr));
- const int W{ 5 };
- const int K{ 6 };
- double tablica[W][K];
- // zapisanie wartości do tablicy
- for (auto i{ 0 }; i < W; ++i) {
- for (auto j{ 0 }; j < K; ++j) {
- tablica[i][j] = 10.0 * rand() / RAND_MAX;
- }
- }
- // wypisanie tablicy na ekran
- for (auto i{ 0 }; i < W; ++i) {
- for (auto j{ 0 }; j < K; ++j) {
- std::cout << tablica[i][j] << '\t';
- }
- std::cout << std::endl;
- }
- std::cout << std::endl;
- // policzenie średnich
- for (auto i{ 0 }; i < W; ++i) {
- double srednia{};
- for (auto j{ 0 }; j < K; ++j) {
- srednia += tablica[i][j];
- }
- std::cout << "Srednia wartosci z wiersza nr " << i + 1 << " wynosi " << srednia / K << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement