SHARE
TWEET

Untitled

a guest Feb 25th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int is[1000], elem = 0, m, x, aux:
  8. char cs[10];
  9. ifstream fin("coada1.in");
  10. ofstream fout("coada1.out");
  11. fin>>m;
  12. while(m>0)
  13. {
  14. m--; fin>>cs>>x;
  15. if(cs[0]=='p')
  16. {
  17. is[elem] = x; elem++;
  18. for(unsigned int i = 0; i < elem-1; i++)
  19. if(is[i] == x)
  20. {
  21. for(unsinged int j = 0; j < elem - i - 1; j++)
  22. is[j] = is[i+j];
  23. break;
  24. }
  25. }
  26. else
  27. {
  28. aux=-1;
  29. for(unsigned int i = 0; i < elem ; i++)
  30. if(is[i]==x)
  31. { aux = i+1; break; }
  32. fout<<aux<<endl;
  33. }
  34. }
  35. return 0;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top