函数题:链表-遍历链表
本题要求实现一个函数,从链表的头指针开始遍历整个链表,输出每个节点字符数据。
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
答案:若无答案欢迎评论
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
答案:若无答案欢迎评论