데이터 구조 - 단일 체인 테이블 찾기 값 찾기
804 단어 데이터 구조
#include
#include
#define ERROR -40000
using namespace std;
typedef struct LNODE
{
int data;
struct LNODE *next;
}Lnode;
Lnode *Input(int n)
{
Lnode *head,*p,*q;
head=p=(Lnode*)malloc(sizeof(Lnode));
p->next=NULL;
for(int i=0;i>data;
q=(Lnode*)malloc(sizeof(Lnode));
q->data=data;
q->next=p->next;
p->next=q;
p=q;
}
return head;
}
int FindData(Lnode *L,int num)
{
Lnode *p;
p=L->next;
int id=1;
while(p!=NULL)
{
if(p->data==num) return id;
id++;
p=p->next;
}
if(p==NULL) return ERROR;
}
int main()
{
int n;
while(cin>>n)
{
Lnode *p=Input(n);
cout<>num;
int find_data=FindData(p,num);
if(find_data!=ERROR)
{
cout<