Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- vector <int> tab;
- map <int> wyst;
- int A,B,N;
- void search(int);
- int main()
- {
- srand(time(NULL));
- cout<<"Wpisz A"<<endl;
- cin>>A;
- cout<<"Wpisz B"<<endl;
- cin>>B;
- cout<<"Wpisz N"<<endl;
- cin>>N;
- cout<<endl;
- for(int i=0; i<N; ++i){
- tab.push_back(rand()%(B-A)+A);
- cout<<tab[i]<<endl;
- }
- search(6);
- for(int i=0;i<N;++i)
- {
- wyst.push_back(i);
- }
- return 0;
- }
- void search(int a)
- {
- int i=0;
- while(i<N)
- { if(tab[i]==a)
- cout<<"Znaleziono szukany element, ma on indeks: "<<i<<endl;
- ++i;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement