Advertisement
Guest User

Untitled

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