a
This commit is contained in:
		
							parent
							
								
									bcd0e38ddf
								
							
						
					
					
						commit
						44522e6917
					
				
							
								
								
									
										0
									
								
								a3/program.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								a3/program.exe
									
									
									
									
									
										Normal file
									
								
							@ -41,6 +41,10 @@ struct tree* read_tree(){
 | 
				
			|||||||
    return node;
 | 
					    return node;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
int main(){
 | 
					int main(){
 | 
				
			||||||
 | 
					    printf("Expert z bufetu to vie.\n");
 | 
				
			||||||
 | 
					    printf("Pozna 2 druhov ovocia a zeleniny.\n");
 | 
				
			||||||
 | 
					    printf("Odpovedajte␣'a'␣pre␣prvu␣moznost␣alebo␣'n'␣pre␣druhu␣moznost.\n");
 | 
				
			||||||
 | 
					    printf("Je to ovocie alebo zelenina ?\n");
 | 
				
			||||||
/*int counter = 0;
 | 
					/*int counter = 0;
 | 
				
			||||||
int si = 0;
 | 
					int si = 0;
 | 
				
			||||||
struct tree* stack[SIZE];
 | 
					struct tree* stack[SIZE];
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								cv8/program.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								cv8/program.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										47
									
								
								sk4/program.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								sk4/program.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned char tape[30000] = {0};
 | 
				
			||||||
 | 
					unsigned char* ptr = tape;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void interpret(char* input) {
 | 
				
			||||||
 | 
					    char current_char;
 | 
				
			||||||
 | 
					    size_t i;
 | 
				
			||||||
 | 
					    size_t loop;
 | 
				
			||||||
 | 
					    size a;
 | 
				
			||||||
 | 
					    for (i = 0; input[i] != 0; i++) {
 | 
				
			||||||
 | 
					        current_char = input[i];
 | 
				
			||||||
 | 
					        if (current_char == 'TUK') {//
 | 
				
			||||||
 | 
					            ++ptr;
 | 
				
			||||||
 | 
					        } else if (current_char == 'FUK') {//
 | 
				
			||||||
 | 
					            --ptr;
 | 
				
			||||||
 | 
					        } else if (current_char == 'INK') {//+
 | 
				
			||||||
 | 
					            ++*ptr;
 | 
				
			||||||
 | 
					        } else if (current_char == 'DEK') {//-
 | 
				
			||||||
 | 
					            --*ptr;
 | 
				
			||||||
 | 
					        } else if (current_char == 'PUK' ) {//.
 | 
				
			||||||
 | 
					            putchar(*ptr);
 | 
				
			||||||
 | 
					        } else if (current_char == 'KUK') {//,
 | 
				
			||||||
 | 
					            *ptr = getchar();
 | 
				
			||||||
 | 
					        } else if (current_char == '[') {//
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        } else if (current_char == ']' && *ptr) {//
 | 
				
			||||||
 | 
					            loop = 1;
 | 
				
			||||||
 | 
					            while (loop > 0) {
 | 
				
			||||||
 | 
					                current_char = input[--i];
 | 
				
			||||||
 | 
					                if (current_char == '[') {
 | 
				
			||||||
 | 
					                    loop--;
 | 
				
			||||||
 | 
					                } else if (current_char == ']') {
 | 
				
			||||||
 | 
					                    loop++;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main() {
 | 
				
			||||||
 | 
					    interpret(",[.[-],]");  // outputs input
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								sk4/program.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								sk4/program.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2
									
								
								sk4/readme.MD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								sk4/readme.MD
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					Riesenie inspirovane https://gist.github.com/maxcountryman/1699708
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user