Example #1
0
int process_choice(tree *pTree, int choice)
{
	char *words = (char *)Malloc(64*sizeof(char));
	node *temp = NULL;
	char ch = 'A';

	switch(choice)
		{
			case ADD_NODE:				
				printf("Input the adding node content:\n");
				while(scanf("%s", words) > 0)
					{
						
						//scanf("%s", words);
						ch = getchar();
						insert_node(pTree, words);
						if(ch == '\n')
							{
								break;
							}
						words = (char *)Malloc(64*sizeof(char));
					}
				break;
				
			case DELETE_NODE:
				printf("Input the destroy node content\n");
				while(scanf("%s", words) > 0)
					{
					
						//scanf("%s", words);
						destroy_node(pTree, words);
						ch = getchar();
						if(ch == '\n')
							{
								break;
							}
						words = (char *)Malloc(64*sizeof(char));
					}
				break;
					
			case FIND_NODE:
				printf("Input the search node content\n");
				scanf("%s", words);
				temp = search_node_by_content( pTree, words);
				break;
				
			case SHOW_TREE:
				print_tree(pTree);
				break;
				
			case QUIT:
				print_tree(pTree);
				printf("Nodes num:%d, row:%d\n", pTree->nodeNum, DEPTH);
				exit(1);
				break;
		}
			
	print_choice();	
	return 1;
}
Example #2
0
int main(void)
{
    int choice;
    if(file2mem() == FAIL){
        printf("信息文件读取出错\n");
        return 1;
    }
    while(1){
        print_choice();
        scanf("%d",&choice);
        switch(choice){
            case ADD:
                add_student();break;
            case DEL:
                delete_student();break;
            case CGE:
                change_student();break;
            case F_NAME:
                find_name();break;
            case F_NUM:
                find_number();break;
            case SORT:
                sort_score();break;
            case PRT:
                print_student();break;
            case EXIT:
                return 0;
        }
        getchar();
        printf("请按任意继续\n");
        getchar();
    }
    
}
Example #3
0
int main()
{
	int type = 1;

	print_choice();
	while(type != 0){
		printf(">");
		scanf("%d", &type);
		switch(type) {
			case STRCPY:
				call_strcpy();
				break;
			case STRCMP:
				call_strcmp();
				break;
			case STRNCMP:
				call_strncmp();
				break;
			case STRSTR:
				call_strstr();
				break;
			case STRLEN:
				call_strlen();
				break;
			case ATOI:
				call_atoi();
				break;
			case INT2STR:
				call_int2str();
				break;
			case PERMUTATION:
				call_permutation();
				break;
			case COMBINATION:
				call_combination();
				break;
			case REVERTSTR:
				call_revert_string();
				break;
			case REVERTWORD:
				call_revert_word();
				break;
			default:
				break;
		}
	}
	return 0;
}
Example #4
0
int mouse_doing(void)
{
    int fd = 0;
    int mx = 512;
    int my = 384;
    char victory = -1;
    mouse_info_t mouse_info;
    fd = open("/dev/input/mice",O_RDWR|O_NONBLOCK);
    if(fd < 0 )
    {
        perror("open");
        exit(1);
    }
    draw_cursor(mx,my);
    print_choice();

    while(1)
    {
        if(get_mouse_info(fd,&mouse_info) > 0)
        {
            repair_shape(mx,my);
            mx += mouse_info.dx;
            my += mouse_info.dy;

            mx = (mx >= 0) ? mx:0;
            my = (my >= 0) ? my:0;
            
            if(mx >= (fb_info.w - C_WIDTH))
            {
                mx = fb_info.w - C_WIDTH;
            }

            if(my >= (fb_info.h - C_HEIGHT))
            {
                my = fb_info.h - C_HEIGHT;
            }
             draw_cursor(mx,my);

            switch(mouse_info.button)
            {
                case 1:
//printf("%d\n", event.button);                
                    repair_shape(mx, my);
                    if((draw_one_chess(mx,my)) == 0)
                    {
                        check_count(mx,my);
                        victory = check_all();
                    }
                    draw_cursor(mx, my);
                    break;
                case 2:
                    break;
                case 4:
                    break;
                default :
                    break;
            }
            if(victory == 1)
            {
                printf("Player %d won!\n",who);
                printf("Continue ? y/n \n");
                if(getchar() == '\n')
                {
                    break;
                }
                else
                {
					memset((u8_t *)fb_info.fb_mem, 0, fb_info.w*fb_info.h*fb_info.bpp/8);
					memset(board, 0, H_NUM*V_NUM);
					draw_board();
					print_choice();
					color_choice = 0x000000ff;
					who = 1;
					victory = -1;
					mx = 512;
					my = 384;
					draw_cursor(mx, my);
                }
                getchar();
            }
         }
        usleep(100);
    }
    return 0;
}