Advertisement
wrench786

Lab task - (array - 2)

Sep 29th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define ull unsigned long long
  5. #define uom unordered_map
  6. #define pb push_back
  7. #define yes cout<<"YES\n"
  8. #define no cout<<"NO\n"
  9.  
  10. #define dot(x) fixed<<setprecision(x)
  11. #define wrench786 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  12.  
  13. #define PI (acos(-1.0))
  14. #define eps 0.00001
  15. const int LIMIT = 10000*10;
  16. using namespace std;
  17.  
  18. int main(){
  19. int tc,n,i;
  20. cin>>tc;
  21. cin>>n;
  22. int arr[n];
  23.  
  24. for(i=0;i<n;i++){
  25. cin>>arr[i];
  26. }
  27.  
  28. while(tc--){
  29. int x,flag=0,index;
  30. cin>>x;
  31.  
  32. for(i=0;i<n;i++){
  33. if(arr[i]==x){
  34. flag = 1;
  35. index = i;
  36. }
  37. }
  38.  
  39. if(flag) cout<<x<<" is found at Index "<<index<<endl;
  40. else cout<<x<<" is not found in the Array"<<endl;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement