Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ///cin: n, n nr nat cout: d - dif max dintre 2 nr, nrp - nr de aparitii ale ecestei dif
  8. int n,x,y,maxx,nrp,i;
  9. cin>>n;
  10. cin>>x>>y;
  11. maxx=abs(x-y);
  12. nrp=1;
  13. for(i=3;i<=n;i++)
  14. {
  15. x=y;
  16. cin>>y;
  17. if(abs(x-y)==maxx)
  18. nrp=nrp+1;
  19. if(abs(x-y)>maxx)
  20. {
  21. maxx=abs(x-y);
  22. nrp=1;
  23. }
  24. }
  25. cout<<maxx<<' '<<nrp;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement