Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int nowa=0;
- int nowa1=0;
- void wypelnij(float tab[4][3])
- {
- for (int i=0; i<4; i++)
- {
- for (int j=0; j<3; j++)
- {
- cout << "Element " << i << j << " wynosi: ";
- tab[i][j] = rand() % 50 + 5;
- cout << tab[i][j];
- cout << endl;
- }
- }
- }
- void wypisz(float tab[4][3])
- {
- for (unsigned int i=0; i<=0; i++)
- for (unsigned int j=0; j<3; j++)
- {
- cout << setw(10) << tab[i][j] << setw(10);
- }
- cout << endl;
- for (unsigned int i=1; i<=1; i++)
- for (unsigned int j=0; j<3; j++)
- {
- cout << setw(10) << tab[i][j] << setw(10);
- }
- cout << endl;
- for (unsigned int i=2; i<=2; i++)
- for (unsigned int j=0; j<3; j++)
- {
- cout << setw(10) << tab[i][j] << setw(10);
- }
- cout << endl;
- for (unsigned int i=3; i<=3; i++)
- for (unsigned int j=0; j<3; j++)
- {
- cout << setw(10) << tab[i][j] << setw(10);
- }
- cout << endl;
- }
- void suma(float tab[4][3])
- {
- for (int i=0; i<4; i++)
- {
- for (int j=0; j<3; j++)
- {
- nowa=nowa + tab[i][j];
- }
- }
- cout << "Suma wszystkich elementow tablicy wynosi: " << nowa;
- }
- void max(float tab[4][3])
- {
- for (int i=0; i<4; i++)
- {
- for (int j=0; j<3; j++)
- {
- if (tab[i][j]>nowa1)
- nowa1 = tab[i][j];
- }
- }
- cout << "Max wartosc wynosi: "<< nowa1;
- }
- void zamiana(float tab[4][3])
- {
- for (unsigned int i=0; i<=0; i++)
- for (unsigned int j=0; j<4; j++)
- {
- cout << setw(10) << tab[j][i] << setw(10);
- }
- cout << endl;
- for (unsigned int i=1; i<=1; i++)
- for (unsigned int j=0; j<4; j++)
- {
- cout << setw(10) << tab[j][i] << setw(10);
- }
- cout << endl;
- for (unsigned int i=2; i<=2; i++)
- for (unsigned int j=0; j<4; j++)
- {
- cout << setw(10) << tab[j][i] << setw(10);
- }
- cout << endl;
- }
- int main()
- {
- float tab1[4][3];
- wypelnij(tab1);
- cout << endl;
- zamiana (tab1);
- cout << endl;
- wypisz (tab1);
- cout << endl;
- suma (tab1);
- cout << endl;
- max (tab1);
- getch ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement