Advertisement
a53

minmaxk9

a53
Jan 1st, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int c;
  9. int x,Max,Min,maxpoz,minpoz,poz;
  10. cin>>c;
  11. Max=INT_MIN;
  12. Min=INT_MAX;
  13. poz=1;
  14. while((cin>>x)&&(x!=0))
  15. {
  16. if(x%10==c)
  17. {
  18. if(x<Min)
  19. Min=x,minpoz=poz;
  20. if(x>Max)
  21. Max=x,maxpoz=poz;
  22. }
  23. ++poz;
  24. }
  25. if(Max==INT_MIN)
  26. cout<<"NU EXISTA";
  27. else
  28. cout<<abs(maxpoz-minpoz)+1;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement