Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- template <class Data>
- int Search(Data *x, Data target, int n){
- int i;
- for(i = 0; i < n; i++){
- if(x[i] == target){
- return i;
- }
- }
- return -1;
- }
- int main(){
- int age[5] = {5, 9 , 4, 7, 3};
- double cgpa[5] = {3.5, 1.9, 2.9, 3.9, 2.5};
- int ans;
- ans = Search(cgpa, 2.5, 5);
- cout << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment