CristinaGeorgiu

5-lucrare vectori

Feb 5th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int v[1001];
  4. int main ()
  5. {
  6. int n,i,contor=0;
  7. cin>>n;
  8. for(i=1; i<=n; i++)
  9. {
  10. cin>>v[i];
  11. }
  12. for(i=1; i<=n; i++)
  13. {
  14. if(v[i-1]+v[i+1]==v[i])
  15. {
  16. contor++;
  17. }
  18. }
  19. cout<<contor<<" ";
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment