Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void reversePrint(int tab[], int howMany);
  6. void average(int tab[], int howMany);
  7. void maxFromArray(int tab[], int howMany);
  8.  
  9.  
  10. int main()
  11. {
  12.     int howMany;
  13.     cin>>howMany;
  14.     int* tab= new int[howMany];
  15.  
  16.     for(int i=0; i<howMany; i++){
  17.         cin>>tab[i];
  18.     }
  19.  
  20.     reversePrint(tab,howMany);
  21.     average(tab,howMany);
  22.     delete tab;
  23.     return 0;
  24. }
  25.  
  26.  
  27. void reversePrint(int tab[], int howMany){
  28.  
  29. for(int i=howMany-1; i>=0; --i){
  30.     cout<<tab[i]<<' ';
  31. }
  32. cout<<endl;
  33. }
  34.  
  35.  
  36. void average(int tab[], int howMany){
  37. int sum=0;
  38. double avr;
  39.  
  40. for(int i=0; i<howMany; i++){
  41.     sum+=tab[i];
  42. }
  43. avr=(double)sum/howMany;
  44. cout<<avr<<endl;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement