Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- void zadanie1(){
- int tab[5][7];
- int sumaParzystych[5] = {0,0,0,0,0};
- int suma = 100;
- int nieparzyste = 0;
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 7; j++){
- tab[i][j] = suma;
- suma += 7;
- }
- }
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 7; j++){
- cout << tab[i][j] << " ";
- if(tab[i][j]%2 == 1){
- nieparzyste++;
- sumaParzystych[i]++;
- }
- }
- cout << endl;
- }
- cout << "wszystkich nieparzystych jest: " << nieparzyste << endl;
- for(int i = 0; i < 5; i++){
- cout << sumaParzystych[i] << " ";
- }
- }
- float oblicz(float m, float w){
- return m/(w*w) * 10000;
- }
- void zadanie2(){
- int m,w;
- cout << "aby przerwac program napisz -1" << endl << endl;
- while(true){
- cout << endl << "podaj wzrost: ";
- cin >> w;
- if(w == -1){
- return;
- }
- cout << "podaj mase: ";
- cin >> m;
- cout << "Twoje BMI to: " << setprecision(3) << oblicz(m,w) << endl;
- }
- }
- void randTab(int tab[5][5]){
- int wiersz;
- int sumaWiersz = 0;
- int kolumna1, kolumna2;
- int temp;
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 5; j++){
- tab[i][j] = rand() % 16;
- cout << tab[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl << "ktory wiersz chcesz zsumowac? " << endl;
- cin >> wiersz;
- cout << endl;
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 5; j++){
- if(i == wiersz-1){
- sumaWiersz += tab[i][j];
- }
- }
- }
- cout << "suma liczb w wierszu " << wiersz << " to " << sumaWiersz << endl;
- cout << "podaj dwie kolumny ktore chcesz zamienic miejscami: " << endl;
- cin >> kolumna1;
- cout << endl;
- cin >> kolumna2;
- cout << endl;
- cout << endl;
- cout << "oto tablica z zamienionymi kolumnami! " << endl;
- for(int i = 0; i < 5; i++){
- for(int j = 0; j < 5; j++){
- if(j == kolumna1){
- temp = tab[i][kolumna1];
- tab[i][kolumna1] = tab[i][kolumna2];
- tab[i][kolumna2] = temp;
- }
- cout << tab[i][j] << " ";
- }
- cout << endl;
- }
- }
- void zadanie3(){
- srand (time(NULL));
- int tablica[5][5];
- randTab(tablica);
- }
- int main()
- {
- //zadanie1();
- //zadanie2();
- zadanie3();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement