Ребят помогите найти пересечение. Желательно отдельной функцией.
ПС: Заранее спасибо
Код:
#include <stdio.h>
#include<conio.h>
#include <stdlib.h>
#include <time.h>
#include<iostream>
#include<cstdlib>
using namespace std;
struct Tlist{
int inf;
Tlist *next,*prev;};
int x,i;
class Clist{
Tlist *head,*end,*curr;
public:
Clist(){
head=end=curr=NULL;}
void add(int x);
void showl();
void showr();
~Clist();};
void Clist:: add(int x){
Tlist *temp;
temp=new Tlist;
temp->next=NULL;
temp->inf=x;
if(head==NULL){
temp->prev=NULL;
head=temp;
end=temp;}
else{
end->next=temp;
temp->prev=end;
end=temp;}}
void Clist:: showl(){
cout<<"vvuvod s leva\n";
Tlist *temp;
temp=head;
while(temp!=NULL){
cout<<temp->inf<<' ';
temp=temp->next;}
cout<<'\n';}
void Clist:: showr(){
cout<<"vvuvod s sprava \n";
Tlist *temp;
temp=end;
while(temp!=NULL){
cout<<temp->inf<<' ';
temp=temp->prev;}
cout<<'\n';}
Clist:: ~Clist(){
Tlist *temp;
while(end){
temp=end->prev;
delete end;
end=temp;}}
void main(){
Clist lst1,lst2;
int k,l;
l=400;
for(k=100;k<500;k++){
if((k%6)==0){
x=k;
lst1.add(x);}}
for(l=400;l>0;l--){
if(l%5==0){x=l;
lst2.add(x);} }
lst1.showl();
lst2.showl();
lst1.showr();
lst2.showr();
getch();
}