Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<stdlib.h>
#include<stdio.h>
int get_frequency(int *, int, int);
void display_results(int param1);
int main(int argc, char *argv[]){
int total_size=1000;
int search_size=1000;
int target=5;
// allocation
int * input_data = (int *) malloc(total_size * sizeof(int));
// initialization
for(int i=0;i<total_size;i++)
input_data[i]=1;
// usage 1
printf("Search for target %d\n",5);
int res=get_frequency(input_data, 10, 5);
display_results(res); // could not find target
// usage 2
printf("Search for target %d\n",1);
res=get_frequency(input_data, 1000, 1);
display_results(res); // target has been found 1000
free(input_data);
return 0;
}
int get_frequency(int * in, int size, int target){
// TODO implement get_get_frequency here
}
void display_results(int param1){
switch(param1){
case -1:
printf("could not find target\n");
break;
default:
printf("target has been found %d\n", param1);
}
}