Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<time.h>
- using namespace std;
- int main()
- {
- int liczba;
- int indeks = 0;
- int ilosc = 0;
- srand(time(NULL));
- int tablica[50];
- for(int i=0;i<50;i++)
- {
- tablica[i] = (rand()%41)-20;
- }
- cout<<"Podaj liczbe: ";
- cin>>liczba;
- while(indeks < 50)
- {
- if(tablica[indeks]==liczba)
- {
- cout<<"Liczba "<<liczba<<" znajduje sie na pozycji: "<<indeks<<endl;
- ilosc++;
- }
- indeks++;
- }
- if(ilosc == 0)
- cout<<"Nie znaleziono podanej liczby!"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement