Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int v[100],i,n,poz,x,gasit=0;
  5. int main()
  6. {
  7. cout<<"Numarul care vreti sa fie gasit este:";cin>>x;
  8. cout<<"Numarul de elemente al sirului este:";cin>>n;
  9. for(i=1;i<=n;i++)
  10. cin>>v[i];
  11. for(i=1;i<=n&&gasit==0;i++)
  12. if(x==v[i])
  13. {
  14. poz=i;
  15. gasit=1;
  16. }
  17. if(gasit==0)
  18. cout<<x<<" nu se gaseste in sir."
  19. cout<<"Prima pozitie a numarului "<<x<<" in sir este "<<poz<<".";;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement