Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int v[100],i,n,poz,x,gasit=0;
- int main()
- {
- cout<<"Numarul care vreti sa fie gasit este:";cin>>x;
- cout<<"Numarul de elemente al sirului este:";cin>>n;
- for(i=1;i<=n;i++)
- cin>>v[i];
- for(i=1;i<=n&&gasit==0;i++)
- if(x==v[i])
- {
- poz=i;
- gasit=1;
- }
- if(gasit==0)
- cout<<x<<" nu se gaseste in sir."
- cout<<"Prima pozitie a numarului "<<x<<" in sir este "<<poz<<".";;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement