int main() { int choice; void switch_case(int); do { system("cls"); printf("Data encryption and decryption program.\n"); printf("\nMenu:-"); printf("\nPress 1 for data encryption."); printf("\nPress 2 for data decryption."); printf("\nPress 3 to read data from a file."); printf("\nEnter your choice: "); scanf("%d",&choice); switch_case(choice); printf("\n\nDo you wish to continue ?"); printf("\nPress 1 for Yes."); printf("\nPress 2 for No."); printf("\nEnter your choice: "); scanf("%d",&choice); }while(choice == 1); return 0; }
int main() { int i; for(i = 0; i < 15; i ++) { nemu_assert(switch_case(i - 1) == ans[i]); } return 0; }
int main() { int i; for(i = 0; i < 15; i ++) { memu_assert(switch_case(i - 1) == ans[i]); } HIT_GOOD_TRAP; return 0; }
static uint32_t get_argument_on_stack(t_buffer *dst, char *fmt, va_list ap) { uint32_t len; t_flags flag; len = 1; ft_memset(&flag, 0, sizeof(flag)); while (fmt[len]) { if (!flag_get_main(fmt, &len, &flag)) break ; len += 1; } if ('A' <= fmt[len] && fmt[len] <= 'Z' && fmt[len] != 'X') { flag.l = 1; fmt[len] += 40; } if (!switch_case(dst, fmt[len], ap, &flag)) return (0); flag_apply_main(dst, &flag); return (len + 1); }
struct Value execute (struct Tree * ast, struct Tree_map * defined, struct Map * let_map){ struct Value result; // first check for special kinds of execution if(ast->type == 'k' && string_matches(&ast->content.data.str, &if_const)){ return if_block(ast, defined, let_map); } else if(ast->type == 'k' && string_matches(&let_const, &ast->content.data.str)){ store_let_binding(ast, defined, let_map); result.type = 'u'; } else if(ast->type == 'k' && string_matches(&each_const, &ast->content.data.str)){ for_each(ast, defined, let_map); result.type = 'u'; } else if(ast->type == 'k' && string_matches(&map_const, &ast->content.data.str)){ return map_array(ast, defined, let_map); } else if(ast->type == 'k' && string_matches(&reduce_const, &ast->content.data.str)){ return reduce_array(ast, defined, let_map); } else if(ast->type == 'k' && string_matches(&set_const, &ast->content.data.str)){ struct Value index = execute(ast->children[0], defined, let_map); struct Value item = execute(ast->children[1], defined, let_map); struct Value array = execute(ast->children[2], defined, let_map); result = array_set(index, item, array); return result; } else if(ast->type == 'k' && string_matches(&for_const, &ast->content.data.str)){ for_loop(ast, defined, let_map); result.type = 'u'; //return undefined } else if(ast->type == 'k' && string_matches(&do_const, &ast->content.data.str)){ for(int i = 0; i < ast->size; i++){ if(i == ast->size-1){ result = execute(ast->children[i], defined, let_map); } else { execute(ast->children[i], defined, let_map); } } } else if(ast->type == 'k' && string_matches(&read_const, &ast->content.data.str)){ return read_file(ast->children[0]->content.data.str); } else if(ast->type == 'k' && string_matches(&substring_const, &ast->content.data.str)){ struct Value string = execute(ast->children[2], defined, let_map); struct Value start = execute(ast->children[0], defined, let_map); struct Value end = execute(ast->children[1], defined, let_map); if(string.type != 's'){ ERROR("Non-string value passed into substring: %c.", string.type); result.type = 'u'; return result; } else { return substring(start.data.ln, end.data.ln, string); } } else if(ast->type == 'k' && string_matches(&switch_const, &ast->content.data.str)){ return switch_case(ast, defined, let_map); } else if(ast->type == 'k' && string_matches(¶llel_const, &ast->content.data.str)){ parallel_execution(ast, defined, let_map); result.type = 'u'; } else { // no special execution types found, check for more basic conditions int idx; if(!ast->size){ // ast with no children is either a value or a variable if(ast->type == 'k'){ for(int i = 0; i < let_map->size; i++){ if(string_matches(&let_map->members[i]->key->data.str, &ast->content.data.str)){ return *let_map->members[i]->val; } } ERROR("Undefined variable: %s", ast->content.data.str.body); } else { return ast->content; } } else if(ast->type == 'k' && (idx = is_defined_func(defined, ast->content.data.str)) > -1){ return execute_defined_func(ast, defined, let_map, idx); } else if(ast->size == 1){ struct Value a = execute(ast->children[0], defined, let_map); if(ast->type == 'k'){ if(string_matches(&ast->content.data.str, &print_const)){ print(a); printf("\n"); result.type = 'u'; } else if(string_matches(&ast->content.data.str, &length_const)){ return length(a); } else if(string_matches(&ast->content.data.str, &return_const)){ return execute(ast->children[0], defined, let_map); } } } else if(ast->size == 2) { struct Value a = execute(ast->children[0], defined, let_map); struct Value b = execute(ast->children[1], defined, let_map); result = apply_core_function(ast, a, b); } else { result = reduce_ast(ast, defined, let_map); } } return result; }