Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vcl>
- #include <iostream>
- using namespace std;
- int PL1(int a[], int k,int l,int y);
- int main()
- {
- int k,x,l,y,a[100];
- cout<<"podaj liczbe elementow ";
- cin>>l;
- cout<<endl;
- for(int i=1;i<=l;i++)
- {
- cout<<"podaj liczbe ";
- cin>>a[i];
- }
- cout<<endl;
- k=1;
- cout<<"podaj szukana liczbe ";
- cin>>y;
- cout<<endl;
- x=PL1(a,k,l,y);
- if(x==-1) cout<<"brak szukanej liczby"<<endl<<endl;
- else cout<<x<<endl<<endl;
- system("PAUSE");
- return 0;
- }
- int PL1(int a[], int k,int l,int y)
- {
- int s;
- a[l+1]=y;
- s=k;
- while (y!=a[s])
- {
- s=s+1;
- if (s<=y) return s;
- else return -1;
- }
- }
Add Comment
Please, Sign In to add comment