Advertisement
a53

Progresie3

a53
Jan 7th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <fstream>
  2. #define N 1001
  3. using namespace std;
  4. ifstream f("progresie3.in");
  5. ofstream g("progresie3.out");
  6. int F[N];
  7.  
  8. int main()
  9. {
  10. int a;
  11. while(f>>a)
  12. F[a]=1;
  13. int r=0,ultim=-1;
  14. bool ok=true;
  15. for(int i=0;i<N&&ok;++i)
  16. if(F[i])
  17. {
  18. if(ultim!=-1)
  19. {
  20. if(r==0)
  21. r=i-ultim;
  22. else
  23. if(i-ultim!=r)
  24. ok=false;
  25. }
  26. ultim=i;
  27. }
  28. if(ok)
  29. g<<r;
  30. else
  31. g<<"NU";
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement