Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("palarii.in");
  5. int a[103],b[103],x,y,st=1,dr=101,i,salvati;
  6.  
  7. void choose(int x)
  8. {
  9. if(x==a[i])
  10. salvati++;
  11. }
  12. int main()
  13. {
  14. for(i=1;i<=100;i++)
  15. fin>>a[i],b[a[i]]=1;
  16.  
  17. x=89,y=57;
  18. for(i=1;i<=100;i++)
  19. {
  20. if(x>dr||x<st)
  21. {
  22. choose(x);
  23. x=a[i+1];
  24. }
  25. else if(y>dr||y<dr)
  26. {
  27. choose(y);
  28. y=a[i+1];
  29. }
  30. else if(i%2==1)
  31. {
  32. if(x>y)
  33. {
  34. choose(x);
  35. x=a[i+1];
  36. }
  37. else
  38. {
  39. choose(y);
  40. y=a[i+1];
  41. }
  42. }
  43. else
  44. {
  45. if(x>y)
  46. {
  47. choose(y);
  48. y=a[i+1];
  49. }
  50. else
  51. {
  52. choose(x);
  53. x=a[i+1];
  54. }
  55. }
  56.  
  57. }
  58. cout<<salvati;
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement