Update 'cv1/program.c'
This commit is contained in:
		
							parent
							
								
									594d3cd491
								
							
						
					
					
						commit
						7a37447541
					
				@ -30,26 +30,31 @@ int read_pizza(struct pizza* item){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int search_string(const char* heap, const char* needle){
 | 
					int search_string(const char* heap, const char* needle){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int H = strlen(heap);
 | 
					    int H = strlen(heap);
 | 
				
			||||||
    int N = strlen(needle);
 | 
					    int N = strlen(needle);
 | 
				
			||||||
    int i;
 | 
					    int i = 0;
 | 
				
			||||||
    for(i = 0; i <= H - N; i++){
 | 
					    for(i = 0; i <= H - N; i++){
 | 
				
			||||||
        int j;
 | 
					        int j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for(j = 0; j < N; j++){
 | 
					        for(j = 0; j < N; j++){
 | 
				
			||||||
            if(heap[i+j] != needle[j]){
 | 
					            if(heap[i+j] != needle[j]){
 | 
				
			||||||
                return -1;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if(j = N){
 | 
					 | 
				
			||||||
                return i;    
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } 
 | 
					        if(j == N){
 | 
				
			||||||
 | 
					            return i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char hacker_script(char c){
 | 
					char hacker_script(char c){
 | 
				
			||||||
    if(isupper(c)){
 | 
					    if(isupper(c)){
 | 
				
			||||||
        c = tolower(c);    
 | 
					        c = tolower(c);
 | 
				
			||||||
    }       
 | 
					    }
 | 
				
			||||||
    char numbers[] = "0123456789";
 | 
					    char numbers[] = "0123456789";
 | 
				
			||||||
    char letters[] = "oizeasbtbq";
 | 
					    char letters[] = "oizeasbtbq";
 | 
				
			||||||
    int i;
 | 
					    int i;
 | 
				
			||||||
@ -59,48 +64,56 @@ char hacker_script(char c){
 | 
				
			|||||||
            return c;
 | 
					            return c;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return c;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(){
 | 
					int main(){
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    printf("Zadaj hladanu surovinu:");
 | 
					    printf("Zadaj hladanu surovinu:");
 | 
				
			||||||
    char key[LINESIZE];
 | 
					    char key[LINESIZE];
 | 
				
			||||||
    memset(key,0,LINESIZE);
 | 
					    memset(key,0,LINESIZE);
 | 
				
			||||||
    char* r = fgets(key,LINESIZE,stdin);  
 | 
					    char* r = fgets(key,LINESIZE,stdin);
 | 
				
			||||||
    
 | 
					    key[strlen(key)-1] = '\0';
 | 
				
			||||||
 | 
					    int k = 0;
 | 
				
			||||||
 | 
					    for(k = 0; k < strlen(key); k++){
 | 
				
			||||||
 | 
					        key[k] = hacker_script(key[k]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    printf("Zadaj jedalny listok:");
 | 
					    printf("Zadaj jedalny listok:");
 | 
				
			||||||
    struct pizza jedalny_listok[100];
 | 
					    struct pizza jedalny_listok[100];
 | 
				
			||||||
    struct pizza pomocny[100];
 | 
					    struct pizza pomocny[100];
 | 
				
			||||||
    memset(pomocny, 0, sizeof(struct pizza)*100);
 | 
					    memset(pomocny, 0, sizeof(struct pizza)*100);
 | 
				
			||||||
    memset(jedalny_listok, 0,sizeof(struct pizza)*100);    
 | 
					    memset(jedalny_listok, 0,sizeof(struct pizza)*100);
 | 
				
			||||||
    struct pizza item;
 | 
					    struct pizza item;
 | 
				
			||||||
    int counter = 0;
 | 
					    int counter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   
 | 
					   
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    while(read_pizza(&item)){
 | 
					    while(stdin,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;
 | 
				
			||||||
        counter++;
 | 
					        counter++;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int i, j, f;
 | 
					    int i, j, f;
 | 
				
			||||||
 | 
					    int i, j;
 | 
				
			||||||
    for(i = 0; i < counter; i++){
 | 
					    for(i = 0; i < counter; i++){
 | 
				
			||||||
        for(j = 0; j < strlen(jedalny_listok[i].name); j++){
 | 
					        for(j = 0; j < strlen(jedalny_listok[i].name); j++){
 | 
				
			||||||
            pomocny[i].name[j] = hacker_script(jedalny_listok[i].name[j]);
 | 
					            pomocny[i].name[j] = hacker_script(jedalny_listok[i].name[j]);
 | 
				
			||||||
            //printf("%c", pomocny[i].name[j]);
 | 
					
 | 
				
			||||||
                 
 | 
					        }
 | 
				
			||||||
        } 
 | 
					        int result = search_string(pomocny[i].name, key);
 | 
				
			||||||
        search_string(pomocny[i].name, key); 
 | 
					        if(result != -1){
 | 
				
			||||||
        if(search_string(pomocny[i].name, key) != -1){
 | 
					 | 
				
			||||||
            printf("%s", jedalny_listok[i].name);
 | 
					            printf("%s", jedalny_listok[i].name);
 | 
				
			||||||
            printf("%.2f\n", jedalny_listok[i].prize);
 | 
					            printf("%.2f\n", jedalny_listok[i].prize);
 | 
				
			||||||
            printf("Nacitano %d poloziek.\n", counter);
 | 
					        }
 | 
				
			||||||
            return 1;        
 | 
					
 | 
				
			||||||
        }       
 | 
					 | 
				
			||||||
     
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    printf("Nacitano %d poloziek\n", counter);
 | 
					    printf("Nacitanych %d poloziek.\n", counter);
 | 
				
			||||||
    return 1;    
 | 
					    return 0;
 | 
				
			||||||
   
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user