Beispiel #1
0
int main(int argc, char ** argv)
{
	Tree pets;
	char choice;

	InitializeTree(&pets);
	while ((choice = menu()) != 'q')
	{
		switch (choice)
		{
		case 'a': addPet(&pets);							//添加一个宠物
			break;
		case 'l': showPets(&pets);							//输出所有宠物的信息
			break;
		case 'f': findPet(&pets);							//查找宠物
			break;
		case 'n': printf("%d pets in club\n",				//计算宠物的个数
			TreeItemCount(&pets));
			break;
		case 'd': dropPet(&pets);							//删除某个宠物
			break;
		default: fputs("Switching error\n", stdout);
			break;
		}
	}
	DeleteAll(&pets);
	fputs("Bye!\n", stdout);

	_CrtDumpMemoryLeaks();
	return EXIT_SUCCESS;
}
Beispiel #2
0
int main(void)
{
    Tree pets;
    char choice;

    InitializeTree(&pets);
    while ((choice = menu()) != 'q')
    {
        switch (choice)
        {
            case 'a' :  addpet(&pets);
                        break;
            case 'l' :  showpets(&pets);
                        break;
            case 'f' :  findpet(&pets);
                        break;
            case 'n' :  printf("%d pets in club\n",
                                TreeItemCount(&pets));
                        break;
            case 'd' :  droppet(&pets);
                        break;
            default  :  puts("Switching error");
        }
    }
    DeleteAll(&pets);
    puts("Bye.");
   
    return 0;
}
int main(void) {
	Tree pets;
	char choice;
	InitializeTree(&pets);

	while ((choice = menu()) != 'q') {
		puts("");
		if (choice == 'a') {
			addpet(&pets);
		} else if (choice == 'l') {
			showpets(&pets);
		} else if (choice == 'f') {
			findpet(&pets);
		} else if (choice == 'n') {
			printf("%d pets in club\n", TreeItemCount(pets));
		} else if (choice == 'd') {
			droppet(&pets);
		} else {
			printf("Not a valid option.\n");
		}
		puts("");
	}
	DeleteAll(&pets);
	puts("Bye.");

	return 0;
}