Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <ctime>
  6. using namespace std;
  7. vector <int> tab;
  8. map <int> wyst;
  9. int A,B,N;
  10. void search(int);
  11. int main()
  12. {
  13. srand(time(NULL));
  14. cout<<"Wpisz A"<<endl;
  15. cin>>A;
  16. cout<<"Wpisz B"<<endl;
  17. cin>>B;
  18. cout<<"Wpisz N"<<endl;
  19. cin>>N;
  20. cout<<endl;
  21. for(int i=0; i<N; ++i){
  22. tab.push_back(rand()%(B-A)+A);
  23. cout<<tab[i]<<endl;
  24. }
  25. search(6);
  26. for(int i=0;i<N;++i)
  27. {
  28. wyst.push_back(i);
  29. }
  30. return 0;
  31. }
  32. void search(int a)
  33. {
  34. int i=0;
  35. while(i<N)
  36. { if(tab[i]==a)
  37. cout<<"Znaleziono szukany element, ma on indeks: "<<i<<endl;
  38. ++i;
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement