Advertisement
rootuss

zadkolejne

Dec 15th, 2017
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float srednia (float *tab, int ile)
  6. {
  7.     float suma=0;
  8.  
  9.     for(int i=0;i<ile;i++)
  10.     {
  11.         suma+=*tab;
  12.         *tab=999;
  13.         tab++;
  14.     }
  15.  
  16.     return suma/ile;
  17. }
  18.  
  19. int main()
  20. {
  21.     //cout << "Hello world!" << endl;
  22.  
  23.     float tablica[3];
  24.  
  25.     tablica [0] = 1.5;
  26.     tablica [1] = 2.3;
  27.     tablica [2] = 0.75;
  28.  
  29.     cout<<"srednia wynosi: "<<srednia(tablica,3)<<endl<<endl;
  30.  
  31.  
  32.     cout<<tablica [0]<<endl;
  33.     cout<<tablica [1]<<endl;
  34.     cout<<tablica [2] <<endl;
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement