Advertisement
rotti321

Dif Max-Min + Nr aparitii

Mar 10th, 2022
58
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,M=0,m=99999,a[1000],cont=0,n,dif;
  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.  
  20. for(int i=1;i<=n;i++){
  21. if(a[i]<m){
  22. m=a[i];
  23. }
  24. }
  25. dif=M-m;
  26. for(int i=1;i<=n;i++){
  27. if(a[i]==dif){
  28. cont++;
  29. }
  30. }
  31. cout << dif << " " << cont;
  32. return 0;
  33.  
  34.  
  35.  
  36. }
  37.  
Advertisement
RAW Paste Data Copied
Advertisement