This commit is contained in:
Radovan Kofira 2020-10-13 17:02:34 +02:00
parent bb7b0457b9
commit ea244bb683
2 changed files with 26 additions and 32 deletions

View File

@ -19,19 +19,13 @@ 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=0; int counter=0;
char line[LINE_SIZE]; //char line[LINE_SIZE];
memset(line,0,LINE_SIZE); //memset(line,0,LINE_SIZE);
//printf("Zadaj hladanu surovinu:\n");
char* r = fgets(line,LINE_SIZE,stdin);
trim(line);
if(r != NULL && line[1] != 0){
//printf("Zadaj jedalny listok:\n");
struct pizza item; struct pizza item;
while(read_pizza(&item)){ while(read_pizza(&item)){
strcpy(jedalny_listok[counter].name, item.name); strcpy(jedalny_listok[counter].name, item.name);
jedalny_listok[counter].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); //printf("%d\n",counter);
if (counter>=POCET_JEDAL) if (counter>=POCET_JEDAL)
@ -39,18 +33,18 @@ int main(){
break; break;
} }
} }
}
//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("daco\n");
} //}
} }
//printf("%s",line); //printf("%s",line);
//printf("Nacitanych %d poloziek.\n",counter); //printf("Nacitanych %d poloziek.\n",counter);
} }
void trim(char* str){ void trim(char* str){
int i=0; int i=0;
while(str[i]!='\n'&&str[i]!=0){ while(str[i]!='\n'&&str[i]!=0){
@ -58,6 +52,7 @@ void trim(char* str){
} }
str[i]=0; 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);
@ -76,7 +71,7 @@ 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);
@ -97,8 +92,7 @@ int read_pizza(struct pizza* item){
} }
return 0; return 0;
} }
/*char hacker_script(char c){
char hacker_script(char c){
char numbers[] = "0123456789"; char numbers[] = "0123456789";
char letters[] = "oizeasbtbq"; char letters[] = "oizeasbtbq";
for (int i = 0; i < 10; i++){ for (int i = 0; i < 10; i++){
@ -107,19 +101,19 @@ int read_pizza(struct pizza* item){
} }
} }
return tolower(c); return tolower(c);
} }*/
//////////////////////// ////////////////////////
// ///////// /// /////////
// /////// ///////
// //////// ///////
// //////// ///////
// ////// ////////
// //// //////////
// ////// /////// // ////// ///////
// /////// /////// // /////// ///////
// /////// /////// // /////// ///////
// ////// //////// // ////// ////////
// //// ////////// // //// //////////
// ////////////
// /// /////////// // /// ///////////
// //// //////////
// ///// /////////
// ////// ////////
// //////// ///////
//////////////////////// ////////////////////////

Binary file not shown.