Advertisement
RusSimona

pg 157 ex 29

Jun 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. //ifstream fin("bac.in");
  9. //ofstream fout("bac.out");
  10.  
  11. int maxim (int v[100], int &n)
  12. {
  13.  
  14. int nrmax=INT_MIN, i,j;
  15.  
  16. for(i=1; i<=n; i++)
  17. if(nrmax<v[i])
  18. nrmax=v[i];
  19. for(i=n; i>=1; i--)
  20. {
  21. if(v[i]==nrmax)
  22. {
  23. for(j=i; j<n; j++)
  24. v[j]=v[j+1];
  25. n--;
  26. }
  27. }
  28. return nrmax;
  29.  
  30. }
  31.  
  32. int v[100];
  33.  
  34. int main ()
  35.  
  36. {
  37. int n=0,i, j,x, aux;
  38.  
  39. while (cin>>x)
  40. {
  41. v[++n]=x;
  42. }
  43.  
  44. while (n>0)
  45.  
  46. {
  47. cout<<maxim(v,n)<<" ";
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement