#include <iostream>
#include <stdio.h>
#include <string.h>
#include <conio.h>
using namespace std;
typedef struct student
{
int data;
struct student *next;
}node;
node *creat()
{
node *head, *p, *s;
int x, cycle = 1;
head = (node*)malloc(sizeof(node));
p = head;
while( cycle )
{
printf("\nplease input the data:");
scanf("%d", &x);
if( x != 0 )
{
s = (node*)malloc(sizeof(node));
s->data = x;
printf("\n%d", s->data);
p->next = s;
p = s;
}
else
cycle = 0;
}
//......
}
int length( node *head )
{
node *p;
int n = 0;
p = head;
while( p != NULL )
{
p = p->next;
n++;
}
return n;
}
void print( node *head )
{
node *p;
int n;
n = length( head );
p = head;
if( head != NULL )
{
while(p != NULL)
{
printf("\n uuu %d ", p->data);
p = p->next;
}
}
}
#include <stdio.h>
#include <string.h>
#include <conio.h>
using namespace std;
typedef struct student
{
int data;
struct student *next;
}node;
node *creat()
{
node *head, *p, *s;
int x, cycle = 1;
head = (node*)malloc(sizeof(node));
p = head;
while( cycle )
{
printf("\nplease input the data:");
scanf("%d", &x);
if( x != 0 )
{
s = (node*)malloc(sizeof(node));
s->data = x;
printf("\n%d", s->data);
p->next = s;
p = s;
}
else
cycle = 0;
}
//......
}
int length( node *head )
{
node *p;
int n = 0;
p = head;
while( p != NULL )
{
p = p->next;
n++;
}
return n;
}
void print( node *head )
{
node *p;
int n;
n = length( head );
p = head;
if( head != NULL )
{
while(p != NULL)
{
printf("\n uuu %d ", p->data);
p = p->next;
}
}
}