马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
原理:
备注:
代码:
#include <stdio.h>
#include <stdlib.h>
#define MAX 4
typedef struct list
{
int datas;
struct list *next;
}list,*lists;
typedef struct like
{
char data[MAX];
list *temp;
}like;
void loop_list (list **nice);
void prin_list (list *nice);
void prin_list (list *nice)
{
while(nice != NULL)
{
printf("%d ", nice->datas);
nice = nice->next;
}
}
void loop_list (list **nice)
{
list *temp, *tail;
int number;
while(1)
{
scanf("%d", &number);
if(number >= 0 && number <= 9) //输入9以上的数字结束本函数
{
temp = (lists )malloc(sizeof(list ));
temp->datas = number;
temp->next = NULL;
if(*nice == NULL)
{
*nice = temp;
}
else
{
tail->next = temp;
}
tail = temp;
}
else
{
break;
}
}
}
int main()
{
like diss[MAX];
for(int i = 0; i < MAX; i++)
{
scanf("%s", &diss[i].data[0]);
diss[i].temp = NULL;
loop_list(&diss[i].temp);
}
for(int i = 0; i < MAX; i++)
{
printf("%s ", diss[i].data);
prin_list(diss[i].temp);
putchar('\n');
}
return 0;
}
执行框运行状态:
|