Advertisement
rotti321

Max + nr aparitii in sir

Mar 10th, 2022
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int x,p,M=0,a[1000000],cont=0,n;
  6.  
  7. int main()
  8. {
  9. ifstream cin("puteri6.in");
  10. ofstream cout("puteri6.out");
  11.  
  12. cin>>n;
  13. for(int i=1;i<=n;i++){
  14. cin>>a[i];
  15. if(a[i]>M){
  16. M=a[i];
  17. }
  18. }
  19. for(int i=1;i<=n;i++){
  20. if(a[i]==M){
  21. cont++;
  22. }
  23.  
  24. }
  25. cout << M << " " << cont;
  26. return 0;
  27.  
  28.  
  29.  
  30. }
  31.  
Advertisement
RAW Paste Data Copied
Advertisement