I learned how to sort array elements, how to search for array elements, and how to find and sort array elements in the C ++ library.
Program:
// Lab10_2.cpp
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Void displayarray (int A [], int N)
{Cout <Endl <"your input array is :";
For (INT I = 0; I <n; I ++) cout <A [I] <"";
Cout <Endl ;}
Int main ()
{Int N, J;
Cout <"Enter the number of values you want to enter :";
Cin> N;
Int * P;
P = new int [N];
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
For (INT I = 0; I <n; I ++)
{Cout <"input number" <I + 1 <"value:" <Endl;
Cin> J;
P [I] = J ;}
Displayarray (p, N );
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Int L = 1;
While (l)
{Int K;
Int * q;
Cout <Endl <"Enter the value you want to search :";
Cin> K;
Q = find (p, p + n-1, k );
If (Q! = P + N-1)
Cout <"the value you searched for" <k <"is in the" <q-p + 1 <"bit! "<Endl;
Else
Cout <"the value you searched for" <k <"does not exist! "<Endl;
Cout <"continue searching? "<Endl <" by 1/No by 0 "<Endl;
Cin> L;
} Return 0 ;}