Guest User

Untitled

a guest
Feb 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <vcl>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int PL1(int a[], int k,int l,int y);
  6. int main()
  7. {
  8. int k,x,l,y,a[100];
  9. cout<<"podaj liczbe elementow ";
  10. cin>>l;
  11. cout<<endl;
  12. for(int i=1;i<=l;i++)
  13. {
  14. cout<<"podaj liczbe ";
  15. cin>>a[i];
  16. }
  17. cout<<endl;
  18. k=1;
  19. cout<<"podaj szukana liczbe ";
  20. cin>>y;
  21. cout<<endl;
  22. x=PL1(a,k,l,y);
  23. if(x==-1) cout<<"brak szukanej liczby"<<endl<<endl;
  24. else cout<<x<<endl<<endl;
  25. system("PAUSE");
  26. return 0;
  27. }
  28. int PL1(int a[], int k,int l,int y)
  29. {
  30. int s;
  31. a[l+1]=y;
  32. s=k;
  33. while (y!=a[s])
  34. {
  35. s=s+1;
  36. if (s<=y) return s;
  37. else return -1;
  38. }
  39. }
Add Comment
Please, Sign In to add comment