Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int trazeni_broj = 30;
- int rezultat = -1;
- int duljina = 50;
- int polje[duljina];
- for (int i = 0; i < duljina; i++)
- {
- polje[i] = i+10;
- cout << "Index: " << i << " Vrijednost: " << polje[i] << endl;
- }
- for (int i = 0; i < duljina; i++)
- {
- if (polje[i] == trazeni_broj)
- {
- rezultat = i;
- break;
- }
- }
- if (rezultat == -1)
- {
- cout << "Broj " << trazeni_broj << " nije pronađen." << endl;
- }
- else
- {
- cout << "Broj " << trazeni_broj << " je na indeksu " << rezultat << "." << endl;
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement