-->
当前位置:首页 > 题库 > 正文内容

函数题:链表-遍历链表

Luz3年前 (2022-04-13)题库963
本题要求实现一个函数,从链表的头指针开始遍历整个链表,输出每个节点字符数据。

head是链表的头指针,链表上节点的定义如下:

struct node
{char ch;
struct node * next;}
### 函数接口定义:
c++
void countnode(struct node *head);

head是链表头指针,函数显示链表中节点的ch成员中字符
### 裁判测试程序样例:

#include <stdio.h>
#include<stdlib.h>
struct node
{int ch;
struct node * next;}
struct node *setlink(int N);

void countnode( struct node * head);//在下面代码区定义此函数

int main()
{
int i,N;
struct node *head;
scanf("%d",&N);
head=setlink(N);
countnode(head);
return 0;
}

/* 请在这里填写答案 */




### 输入样例:



in
5


### 输出样例:



out
abcde







答案:若无答案欢迎评论

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。