73 lines
1.5 KiB
C
73 lines
1.5 KiB
C
#define LINE_SIZE 100
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
struct pizza
|
|
{ float prize;
|
|
char name[LINE_SIZE];
|
|
};
|
|
|
|
char hacker_script(char c) {
|
|
|
|
|
|
if (isupper(c)) {
|
|
return (char) tolower(c);
|
|
}
|
|
|
|
|
|
const char numbers[] = "0123456789";
|
|
const char letters[] = "oizeasbtbq";
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
if (c == numbers[i]) {
|
|
return letters[i];
|
|
}
|
|
}
|
|
|
|
return c;
|
|
}
|
|
//int read_pizza(struct pizza* item){
|
|
//char line[LINE_SIZE];
|
|
//char line2[LINE_SIZE];
|
|
// memset(line,0,LINE_SIZE);
|
|
// memset(line2,0,LINE_SIZE);
|
|
//fgets(line, sizeof(line), item->name);
|
|
//float value = strtof(line2, item->prize);
|
|
// printf("%s ", line2);
|
|
|
|
//}
|
|
|
|
int search_string(const char* heap, const char* needle) {
|
|
|
|
int heap_len = strlen(heap);
|
|
int needle_len = strlen(needle);
|
|
|
|
for (int i = 0; i <= heap_len - needle_len; i++) {
|
|
int j;
|
|
for (j = 0; j < needle_len; j++) {
|
|
char perm_n = hacker_script(needle[j]);
|
|
char perm_h = hacker_script(heap[i + j]);
|
|
|
|
|
|
if ((perm_n == '6' && perm_h == '8') || (perm_n == '8' && perm_h == '6')) {
|
|
continue;
|
|
}
|
|
|
|
if (perm_n != perm_h) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (j == needle_len) {
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
int main(void) {
|
|
int res = search_string("8rynd20va P1zza", "pizza");
|
|
printf("%d", res);
|
|
} |