| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1248 人关注过本帖
标题:本人是新手小白,刚入编程的门,有个链表问题请教大神
取消只看楼主 加入收藏
hanlen99
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-9-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
本人是新手小白,刚入编程的门,有个链表问题请教大神
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
void menu();
void choose();
char ch;
char a[100];
char b[30];
struct word *head;
struct word *creat(struct word *head);
struct word *delet(struct word *head,char a[100]);
void print(struct word *head);
struct word
{
    char a[100];
    struct word *next;
};
void main ()
{
    system("color 0b");
    menu();
    do
    {
        scanf("%c",&ch);
        system("cls");
        choose();
    }while(ch!='4');
}
void choose()
{
    switch(ch)
    {
    case '1':creat(head);
        break;
    case '2':print(head);
        break;
    case '3':delet(head,a);
        break;
    case '4':printf("\n\n\t感谢您的使用!\n");
        break;
        getch();
    default:menu();
        printf("\n\t\t请重新选择:");
    }
}
void menu()
{
    char *s[5]={"1-输入单词","2-查看单词","3-删除单词","4-退出词汇表","请选择:"};
    int i;
    printf("\t\t----------英语单词学习系统----------");
    printf("\n");
    printf("\t++++++++++++++++++++++++++++++++++++++++++++");
    printf("\n");
    for(i=0;i<5;i++)
    {
        printf("\t\t----------");
        printf("%s",s[i]);
        printf("----------");
        printf("\n");
    }
}
struct word *creat(struct word *head)
{
    struct word *p1,*p2;
    head=p1=p2=NULL;
   
    while(p1->a>0)
    {
        p1=(struct word*)malloc(sizeof(struct word));
        printf("请输入单词,输入0时结束\n");
        scanf("%c",&p1->a);
        if(head==NULL)
            head=p1;
        else
            p2->next=p1;
        p2=p1;
    }
    free(p1);
    p1=NULL;
    p2->next=NULL;
    printf("单词本输入结束");
    return head;
}
void print(struct word *head)
{
    struct word *temp;
    temp=head;
    printf("单词表为:\n");
    while(temp!=NULL)
    {
        printf("%c\n",*temp->a);
        temp=temp->next;
        getch();
    }
}
struct word *delet(struct word *head,char a)
{
    struct word *temp,*p;
    temp=head;
    if (head==NULL)
        printf("\nListis null!\n");
    else
    {
        temp=head;
        while (*temp->a!=a&&temp->next!=NULL)
        {
            p = temp;
            temp = temp->next;
        }
        if(*temp->a==a)
        {
        if(temp==head)
        {
            printf("delete string :%d\n",temp->a);
            head=head->next;
            free(temp);
        }
        else
        {
            p->next=temp->next;
            printf("delete string :%d\n",temp->a);
            free(temp);
        }
    }
    else
    printf("\nno find string!\n");
    }
    return(head);
}




void choose 那对链表的调用有问题吧,但是我不知道怎么改!!!!
搜索更多相关主题的帖子: include system color 
2016-09-08 10:19
hanlen99
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-9-8
收藏
得分:0 
回复 4楼 ehszt
谢谢你,我尝试一下。。。看PPT学的,感觉老师都没怎么教
2016-09-08 10:36
hanlen99
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2016-9-8
收藏
得分:0 
回复 3楼 grmmylbs
能具体指一下吗?我才开始学,不是很理解
2016-09-08 10:37
快速回复:本人是新手小白,刚入编程的门,有个链表问题请教大神
数据加载中...
 
   



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

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