aaaa
This commit is contained in:
parent
9975be5199
commit
a8868ff748
@ -10,11 +10,11 @@ struct pizza {
|
|||||||
float prize;
|
float prize;
|
||||||
char name[LINESIZE];
|
char name[LINESIZE];
|
||||||
};
|
};
|
||||||
|
void trim(char* str);
|
||||||
int search_string(const char* heap, const char* needle);
|
int search_string(const char* heap, const char* needle);
|
||||||
int read_pizza(struct pizza* item);
|
int read_pizza(struct pizza* item);
|
||||||
char hacker_script(char c);
|
char hacker_script(char c);
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
struct pizza jedalny_listok[POCET_JEDAL];
|
struct pizza jedalny_listok[POCET_JEDAL];
|
||||||
memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL);
|
memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL);
|
||||||
int counter;
|
int counter;
|
||||||
@ -22,34 +22,49 @@ int main(){
|
|||||||
memset(line,0,LINE_SIZE);
|
memset(line,0,LINE_SIZE);
|
||||||
printf("Zadaj hladanu surovinu:\n");
|
printf("Zadaj hladanu surovinu:\n");
|
||||||
char* r = fgets(line,LINE_SIZE,stdin);
|
char* r = fgets(line,LINE_SIZE,stdin);
|
||||||
|
trim(line);
|
||||||
if(r != NULL && line[1] != 0){
|
if(r != NULL && line[1] != 0){
|
||||||
printf("Zadaj jedalny listok\n");
|
printf("Zadaj jedalny listok\n");
|
||||||
struct pizza item;
|
struct pizza item;
|
||||||
counter = 1;
|
counter=0;
|
||||||
while(read_pizza(&item)){
|
while(read_pizza(&item)){
|
||||||
strcpy(jedalny_listok[counter-1].name, item.name);
|
strcpy(jedalny_listok[counter].name, item.name);
|
||||||
jedalny_listok[counter-1].prize=item.prize;
|
jedalny_listok[counter].prize=item.prize;
|
||||||
|
//printf("%s",jedalny_listok[counter].name);
|
||||||
|
//printf("%s",item.name);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//printf("%d\n",counter);
|
||||||
for(int i=0;i<counter;i++){
|
for(int i=0;i<counter;i++){
|
||||||
if(search_string(jedalny_listok[i].name,line)!=-1){
|
if(search_string(jedalny_listok[i].name,line)!=-1){
|
||||||
printf("%s\n",jedalny_listok[i].name);
|
printf("%s\n",jedalny_listok[i].name);
|
||||||
printf("%.2f\n",jedalny_listok[i].prize);
|
printf("%.2f\n",jedalny_listok[i].prize);
|
||||||
|
//printf("daco\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//printf("%s",line);
|
||||||
printf("Nacitanych %d poloziek",counter);
|
printf("Nacitanych %d poloziek",counter);
|
||||||
}
|
}
|
||||||
|
void trim(char* str){
|
||||||
|
int i=0;
|
||||||
|
while(str[i]!='\n'&&str[i]!=0){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
str[i]=0;
|
||||||
|
}
|
||||||
int search_string(const char* heap, const char* needle){
|
int search_string(const char* heap, const char* needle){
|
||||||
int M=strlen(needle);
|
int M=strlen(needle);
|
||||||
int N=strlen(heap);
|
int N=strlen(heap);
|
||||||
for(int i=0;i<=N-M;i++){
|
for(int i=0;i<=N-M;i++){
|
||||||
int j;
|
int j;
|
||||||
for(j=0;j<M;j++){
|
for(j=0;j<M;j++){
|
||||||
|
//printf("heap:%c\n",hacker_script(heap[i+j]));
|
||||||
|
//printf("needle:%c\n",hacker_script(needle[j]));
|
||||||
if(hacker_script(heap[i+j])!=hacker_script(needle[j])){
|
if(hacker_script(heap[i+j])!=hacker_script(needle[j])){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(j==M){
|
if(j==M){
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -57,13 +72,12 @@ int search_string(const char* heap, const char* needle){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int read_pizza(struct pizza* item){
|
int read_pizza(struct pizza* item){
|
||||||
char line[LINE_SIZE];
|
char line[LINE_SIZE];
|
||||||
memset(line,0,LINE_SIZE);
|
memset(line,0,LINE_SIZE);
|
||||||
char* r = fgets(line,LINE_SIZE,stdin);
|
char* r = fgets(line,LINE_SIZE,stdin);
|
||||||
|
trim(line);
|
||||||
if(r != NULL && line[1] != 0){
|
if(r != NULL && line[1] != 0){
|
||||||
char line2[LINE_SIZE];
|
char line2[LINE_SIZE];
|
||||||
memset(line2,0,LINE_SIZE);
|
memset(line2,0,LINE_SIZE);
|
||||||
@ -77,6 +91,7 @@ int read_pizza(struct pizza* item){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char hacker_script(char c){
|
char hacker_script(char c){
|
||||||
char numbers[] = "0123456789";
|
char numbers[] = "0123456789";
|
||||||
char letters[] = "oizeasbtbq";
|
char letters[] = "oizeasbtbq";
|
||||||
|
BIN
cv1/program.exe
BIN
cv1/program.exe
Binary file not shown.
Loading…
Reference in New Issue
Block a user