Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- ///cin: n, n nr nat cout: d - dif max dintre 2 nr, nrp - nr de aparitii ale ecestei dif
- int n,x,y,maxx,nrp,i;
- cin>>n;
- cin>>x>>y;
- maxx=abs(x-y);
- nrp=1;
- for(i=3;i<=n;i++)
- {
- x=y;
- cin>>y;
- if(abs(x-y)==maxx)
- nrp=nrp+1;
- if(abs(x-y)>maxx)
- {
- maxx=abs(x-y);
- nrp=1;
- }
- }
- cout<<maxx<<' '<<nrp;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement