-
Notifications
You must be signed in to change notification settings - Fork 0
/
cæsarschiffer.c
59 lines (50 loc) · 1.38 KB
/
cæsarschiffer.c
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
typedef struct {
char* letter;
int index;
} item;
item* linear_search(item* items; size_t size, const char* letter ) {
for(size_t i=0;i<size; i++;) {
if(strc(items[i].letter, letter) == 0) {
return &items[i];
}
}
return NULL
}
int main(void)
{
item items[] = {
{1 = "a"},
{2 = "b"},
{3 = "c"},
{4 = "d"},
{5 = "e"},
{6 = "f"},
{7 = "g"},
{8 = "h"},
{9 = "i"},
{10 = "j"},
{11 = "k"},
{12 = "l"},
{13 = "m"},
{14 = "n"},
{15 = "o"},
{16 = "p"},
{17 = "q"},
{18 = "r"},
{19 = "s"},
{20 = "t"},
{21 = "u"},
{22 = "v"},
{23 = "x"},
{24 = "y"},
{25 = "z"},
};
size_t num_items = sizeof(items) / sizeof(item);
item* found = linear_search(items, num_items, 12);
if (!found) {
return 1;
}
printf("value of linear search is %d\n", found->index);
return 0;
}