#include <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list
{ int data;
struct list *next;
} SLIST;
SLIST *creatlist(char *);
void outlist(SLIST *);
int fun( SLIST *h, char ch)
{ SLIST *p; int n=0;
p=h->next;
/**********found**********/
while(p!=___1___)
{ n++;
/**********found**********/
if (p->data==ch) return ___2___;
else p=p->next;
}
return 0;
}
main()
{ SLIST *head; int k; char ch;
char a[N]={'m','p','g','a','w','x','r','d'};
head=creatlist(a);
outlist(head);
printf("Enter a letter:");
scanf("%c",&ch);
/**********found**********/
k=fun(___3___);
if (k==0) printf("\nNot found!\n");
else printf("The sequence number is : %d\n",k);
}
SLIST *creatlist(char *a)
{ SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=0; i<N; i++)
{ q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
}
p->next=0;
return h;
}
void outlist(SLIST *h)
{ SLIST *p;
p=h->next;
if (p==NULL) printf("\nThe list is NULL!\n");
else
{ printf("\nHead");
do
{ printf("->%c",p->data); p=p->next; }
while(p!=NULL);
printf("->End\n");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
C程序课件(四川大学-夏欣)
共17个文件
ppt:11个
c:6个
需积分: 9 15 下载量 104 浏览量
2009-10-07
16:08:44
上传
评论
收藏 617KB RAR 举报
温馨提示
C程序课件(四川大学-夏欣),很不错的C语言学习资料,适合于非计算机专业的同学.
资源推荐
资源详情
资源评论
收起资源包目录
C程序课件.rar (17个子文件)
C程序课件
链表例题
blank2.c 1KB
blank1.c 1KB
链表.ppt 175KB
blank4.c 1KB
modi1.c 1KB
blank3.c 1KB
modi2.c 733B
chap8.ppt 251KB
chap4.ppt 175KB
chap5.ppt 269KB
chap12.ppt 143KB
chap3.ppt 326KB
chap10.ppt 217KB
chap1.ppt 110KB
chap7.ppt 401KB
chap11.ppt 190KB
chap6.ppt 279KB
共 17 条
- 1
资源评论
jianyangzjw
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功