Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6. int n;
  7. int v[10001];
  8.  
  9. cin >> n;
  10. for(int i = 0; i < n; i++){
  11. cin >> v[i];
  12.  
  13. if(v[i]==0)
  14. cout << "0\n";
  15. else{
  16. int j = -n;
  17. while(j < n){
  18.  
  19. if(v[i]== -1 && i+j >= 0 && i+j <= n){
  20. v[i]=v[i+j];
  21. }
  22. if(v[i] != 0 ){
  23. j++;
  24. continue;
  25. }else{
  26. cout << j << "\n";
  27. }
  28.  
  29. j++;
  30.  
  31. }
  32. }
  33.  
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement