| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 359 人关注过本帖
标题:求助帖,谁能告诉我运行过程中晚上会崩溃呀,求大版主,求神仙!!
只看楼主 加入收藏
xiaoshalong
Rank: 2
等 级:论坛游民
帖 子:20
专家分:16
注 册:2013-1-10
结帖率:0
收藏
 问题点数:0 回复次数:0 
求助帖,谁能告诉我运行过程中晚上会崩溃呀,求大版主,求神仙!!
程序代码:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "tree.h"

enum allchoices {addone,deleteone,itemcount,search,showall,cleanall};
const char * choices[]={"addone","deleteone","itemcount","search","showall","cleanall"};

#define LEN 15
void menu(void);
void AddOne (Tree *ptree);
void DeleteOne(Tree *ptree);
unsigned int ItemCount(const Tree *ptree);
void FindOne(const Tree *ptree);
void ShowAll(const Tree *ptree);
void CleanAll(Tree *ptree);
void PrintItem(Item item);

int main(void)
{
    Tree classmates;
    char yourchoice[LEN];
    enum allchoices  choice;
    bool the_order_iseffective=false;

     menu();
    while(strcmp(gets(yourchoice),"quit")!=0&&yourchoice[0]!='\0')
    {
        for(choice=addone;choice<=cleanall;choice++)
        {
            if(strcmp(yourchoice,choices[choice])==0)
            {
                the_order_iseffective=true;
                break;
            }
        }
        if(the_order_iseffective)
            switch (choice)
        {
            case (addone): AddOne(&classmates);
            break;
            case (deleteone):DeleteOne(&classmates);
            break;
            case(itemcount):ItemCount(&classmates);
            break;
            case(search):FindOne(&classmates);
            break;
            case(showall):ShowAll(&classmates);
            break;
            case(cleanall):CleanAll(&classmates);
            break;

        }
        else
            printf("i don\'t know what the order mean!\n");
        the_order_iseffective=false;
        puts("next order\n");
         menu();

    }
    puts("good job\n");
    return 0;
}

void menu(void)
{
     puts("please chioce what do you want to to?\n");
     puts("enter \"addone\" to add a classmate.\n");
     puts("enter \"deleteone\" to delete a classmate\n");
     puts("enter \"itemcount\" to konw the number of your classmatas\n");
     puts("enter \"search\" to find your classmate\n");
     puts("enter\"showall\"to printf all of your classmates.\n");
     puts("enter \"cleanall\"to chean all items. \n");
     puts("enter \"quit\" to quit\n");
     return 0;
}

void AddOne (Tree *ptree)
{
    Item temp;
    if(TreeIsFull(ptree))
        puts("no room to accept a new one!\n");
    else
        {
        puts("please enter your classmate\'s name:\n");
        gets(temp.name);
        puts("please enter sex of your classmate:\n");
        gets(temp.sex);
        puts("please enter age of your classmate:\n");
        scanf("%d",&temp.age);
        AddItem(&temp,ptree);
        }

    printf("just like this.\n");
}

void DeleteOne(Tree *ptree)
{
   Item temp;

   if(TreeIsEmpty(ptree))
   {
       puts("no members to put out!\n");
       return;
    }

    puts("please enter name of classmate you want to delete:\n");
    gets(temp.name);
    if(DeleteItem(&temp,ptree))
        printf("sccessfully\n");
    else
        puts("is not a members\n");
    printf("just like\n");
}

unsigned int ItemCount(const Tree *ptree)
{
    unsigned int count;
    count=TreeItemCount(ptree);
    printf("just like2\n");
      return count;
}
void FindOne(const Tree *ptree)
{
    Item temp;

    if(TreeIsEmpty(ptree))
    {
        puts("no information in the tree!");
        return;
    }
    puts("please enter name of classmate you want to find:\n");
    gets(temp.name);
    if(InTree(&temp,ptree))
        puts("is a member in the class!");
        else
        puts("is not a member");
    printf("just like 3\n");
}

void ShowAll(const Tree *ptree)
{
    if(TreeIsEmpty(ptree))
    {
        puts("no information in the tree!");
        return;
    }
    else
        Traverse(ptree,PrintItem);
    printf("just like 4\n");
}

void CleanAll(Tree *ptree)
{
    DeleteAll(ptree);
    printf("just clean all\n");
}

void PrintItem(Item item)
{
   printf("name:%s,\tsex:%s,\tage:%d",item.name,item.sex,item.age);
}
搜索更多相关主题的帖子: search color 
2013-06-11 16:08
快速回复:求助帖,谁能告诉我运行过程中晚上会崩溃呀,求大版主,求神仙!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025471 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved