Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("bac.txt");
  5. int v[1001];
  6. int main()
  7. {int x,ok=1,r=-1,i,p;
  8. while(fin>>x)
  9. v[x]=1;
  10. i=0;
  11. while(v[i]==0)
  12. i++;
  13. p=i;
  14. for(i=i+1;i<=1000;i++)
  15. {if(v[i]==1)
  16. {
  17. if(r<0)
  18. r=i-p;
  19. else
  20. if(i-p!=r)
  21. ok=0;
  22. p=i;}
  23. }
  24. if(ok)
  25. cout<<"Ratie= "<<r;
  26. else
  27. cout<<"NU";
  28.  
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement