2 条题解
-
-1
//定义列表 #include using namespace std; struct Node{ int data; Node *next; }; Node *head,*p,*r;//生成一个头指针 int x;//元素 void zhao (int a) { p=head->next; while((p->data!=a)&&(p->next!=NULL) ) { p=p->next; } if(p->data==a) { cout<<"找到了"<<a; } else { cout<<"不存在"<<a; } } int main(){ cin>>x; head=new Node; r=head; while(x!=-1) { p=new Node; p->data=x; p->next=NULL; r->next=p; r=p; cin>>x; } p=head->next; while(p->next!=NULL) { cout<data<<" "; p=p->next; } cout<data<<endl; return 0; }
-
-1
//定义列表 #include using namespace std; struct Node{ int data; Node *next; }; Node *head,*p,*r;//生成一个头指针 int x;//元素 int main() { cin>>x; head=new Node; r=head; while(x!=-1) { p=new Node; p->data=x; p->next=NULL; r->next=p; r=p; cin>>x; } p=head->next; while(p->next!=NULL) { cout<data<<" "; p=p-<next; } cout<data<<endl; return 0; }
- 1
信息
- ID
- 264
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者