Добавил:
Upload
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:16_II / адрес
.cpp#include <iostream>
using namespace std;
struct List { int data;
List *next;};
void create_List (List *&nach, int n){
List *p;
nach=0;
for(int i=0; i<n;i++){
p=new List;
cin>>p->data;
p->next=nach;
nach=p;}
}
void pokaz_List(List *nach){
List *p;
p=nach;
while (p!=0){
cout<<p->data<<" ";
p=p->next;}
}
List *adress_x_List(List *nach,int x){
List *p;
p=nach;
while((p!=0)&&(p->data!=x))
p=p->next;
return p;
}
void main(){
int n,x;
List *q;
List *nach1;
cout<<"n= ";
cin>>n;
create_List(nach1,n);
pokaz_List(nach1);
cout<<endl;
cout<<"x= ";
cin>>x;
q=adress_x_List(nach1,x);
cout<<q<<endl;
}
Соседние файлы в папке 16_II