Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float srednia (int n, int *tab)
- {
- int l=n;
- float sr=0;
- while(n--)
- sr+=*tab++;
- return (sr/l);
- }
- void wypelnij(int tab[4][5])
- {
- for (int i=0; i<4; ++i)
- {
- for(int j=0;j<5;++j)
- {
- cout<<"Wpisz ocene uczniowi "<<i<<": ";
- cin>>tab[i][j];
- }
- }
- }
- int sred(int tab[4][5])
- {
- float sred=0;
- int isred;
- for(int i=0;i<4;++i){
- float s=srednia(5,tab[i]);
- if(s>sred){
- sred=s;
- isred=i;
- }
- }
- cout<<"Najwieksza srednia ma uczen "<<isred<<". Wynosi ona: "<<sred<<endl;
- return sred;
- }
- int main()
- {
- int tab[4][5];
- wypelnij(tab);
- sred(tab);
- return 0;
- }
Add Comment
Please, Sign In to add comment