wxh1986715 发表于 2008-4-5 19:41

unexpected end of file found 出现这个错误 忘高手指点

#include <iostream.h>
#include "OnelinkNode.h"
class Onelink
{
bool Onelink::insert(int i,int k)
{               
OnelinkNode *q=new OnelinkNode(k);
OnelinkNode *p=this->head;
int j=1;
if (i<=1)
{
q->next=p;
head=q;
return true;
}
else
if(i>this->length())
{
while(p->next!=NULL)
p=p->next;
p->next=q;
q->next=NULL;
return true;
}
else
{
while(p->next!=NULL&&j<i-1)
{
p=p->next;
j++;
}
q->next=p->next;
p->next=q;
return true;
}
}
程序如上 编译出现题目中的错误 麻烦高手找下 谢谢

succubus 发表于 2008-4-6 01:57

[code]
#include <iostream.h>
#include "OnelinkNode.h"
class Onelink
{
    bool Onelink::insert(int i,int k)
    {               
        OnelinkNode *q=new OnelinkNode(k);
        OnelinkNode *p=this->head;
        int j=1;
        if (i<=1)
        {
            q->next=p;
            head=q;
            return true;
        }
        else if(i>this->length())
        {
            while(p->next!=NULL)
                p=p->next;
            p->next=q;
            q->next=NULL;
            return true;
        }
        else
        {
            while(p->next!=NULL&&j<i-1)
            {
                p=p->next;
                j++;
            }
            q->next=p->next;
            p->next=q;
            return true;
        }
    }
[/code]

把你的代码格式改了改,现在知道哪出问题了吧

页: [1]

编程论坛