一直提示syntax error : ';',我实在是找不到错误,求大神看看程序.#include "stdio.h"#include "stdlib.h"typedef struct node{ int data; struct node*next;}numberlist; struct node*creatlink() {numberlist*h=NULL; int n,i; numberlist*p,*s

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/12 08:41:12

一直提示syntax error : ';',我实在是找不到错误,求大神看看程序.#include "stdio.h"#include "stdlib.h"typedef struct node{ int data; struct node*next;}numberlist; struct node*creatlink() {numberlist*h=NULL; int n,i; numberlist*p,*s
一直提示syntax error : ';',我实在是找不到错误,求大神看看程序.
#include "stdio.h"
#include "stdlib.h"
typedef struct node{
int data;
struct node*next;}numberlist;
struct node*creatlink()
{numberlist*h=NULL;
int n,i;
numberlist*p,*s;
for(i=1;idata=n;
numberlist*s=(numberlist*)malloc(sizeof(numberlist));
if(!h) p=h=s;
else{ p->next=s;
p=p->next;}
}
return h;
}

一直提示syntax error : ';',我实在是找不到错误,求大神看看程序.#include "stdio.h"#include "stdlib.h"typedef struct node{ int data; struct node*next;}numberlist; struct node*creatlink() {numberlist*h=NULL; int n,i; numberlist*p,*s
看下面说明,两个地方:
#include "stdio.h"
#include "stdlib.h"
typedef struct node{
    int data;
    struct node*next;
}numberlist;
struct node*creatlink()
{
    numberlist*h=NULL;
    int n,i;
    numberlist*p,*s;
    for(i=1;i<=10;i++)//这里多了个分号
    {printf("请输入一个整数:\n");
    scanf("%d",&n);
    s->data=n;
    s=(numberlist*)malloc(sizeof(numberlist));//去掉前面的numberlist*
    if(!h) p=h=s;
    else{ p->next=s;
    p=p->next;}
    }
    return h;
}