#include<stdio.h>
#include<conio.h>
struct node{
int x;int y;int z;
}p1[5],p2[5],p3[5];
int main()
{int i,p,a[5],b[5],c[5],d[5];
printf("enter number of events");
scanf("%d",&p);
for(i=0;i<p;i++)
{
printf(" %d event is from e ",i+1);
scanf("%d %d",&a[0],&b[0]);
printf(" to e");
scanf("%d %d",&c[0],&d[0]);
}
for(i=0;i<5;i++)
{
p1[i].x=i+1;
p2[i].y=i+1;
p3[i].z=i+1;
}
for(i=0;i<5;i++)
{
if(c[i]==2)
{if(a[i]==1)
{
p2[d[i]].x=p1[b[i]].x;
p2[d[i]].y=p1[b[i]].y>p2[d[i]].y?p1[b[i]].y:p2[d[i]].y;
}
if(a[i]==3)
{p2[d[i]].z=p3[b[i]].z;
p2[d[i]].y=p3[b[i]].y>p2[d[i]].y?p3[b[i]].y:p2[d[i]].y;
}
}
if(c[i]==1)
{
if(a[i]==2)
{
p1[d[i]].y=p2[b[i]].y;
p1[d[i]].x=p2[b[i]].x>p1[d[i]].x?p2[b[i]].x:p1[d[i]].x;
}
if(a[i]==3)
{
p1[d[i]].z=p3[b[i]].z;
p1[d[i]].x=p3[b[i]].x>p1[d[i]].x?p3[b[i]].x:p1[d[i]].x;
}
}
if(c[i]==3)
{
if(a[i]==2)
{
p3[d[i]].y=p2[b[i]].y;
p3[d[i]].z=p2[b[i]].z>p3[d[i]].z?p2[b[i]].z:p3[d[i]].z;
}
if(a[i]==1)
{p3[d[i]].x=p1[b[i]].x;
p3[d[i]].z=p1[b[i]].z>p3[d[i]].z?p1[b[i]].z:p3[d[i]].z;
}
}
}
for(i=0;i<5;i++)
{
printf("%d ",p1[i].x);
printf("%d ",p1[i].y);
printf("%d ",p1[i].z);
printf("\n");
printf("%d ",p2[i].x);
printf("%d ",p2[i].y);
printf("%d ",p2[i].z);
printf("\n");
printf("%d ",p3[i].x);
printf("%d ",p3[i].y);
printf("%d ",p3[i].z);
printf("\n");
}
}
#include<conio.h>
struct node{
int x;int y;int z;
}p1[5],p2[5],p3[5];
int main()
{int i,p,a[5],b[5],c[5],d[5];
printf("enter number of events");
scanf("%d",&p);
for(i=0;i<p;i++)
{
printf(" %d event is from e ",i+1);
scanf("%d %d",&a[0],&b[0]);
printf(" to e");
scanf("%d %d",&c[0],&d[0]);
}
for(i=0;i<5;i++)
{
p1[i].x=i+1;
p2[i].y=i+1;
p3[i].z=i+1;
}
for(i=0;i<5;i++)
{
if(c[i]==2)
{if(a[i]==1)
{
p2[d[i]].x=p1[b[i]].x;
p2[d[i]].y=p1[b[i]].y>p2[d[i]].y?p1[b[i]].y:p2[d[i]].y;
}
if(a[i]==3)
{p2[d[i]].z=p3[b[i]].z;
p2[d[i]].y=p3[b[i]].y>p2[d[i]].y?p3[b[i]].y:p2[d[i]].y;
}
}
if(c[i]==1)
{
if(a[i]==2)
{
p1[d[i]].y=p2[b[i]].y;
p1[d[i]].x=p2[b[i]].x>p1[d[i]].x?p2[b[i]].x:p1[d[i]].x;
}
if(a[i]==3)
{
p1[d[i]].z=p3[b[i]].z;
p1[d[i]].x=p3[b[i]].x>p1[d[i]].x?p3[b[i]].x:p1[d[i]].x;
}
}
if(c[i]==3)
{
if(a[i]==2)
{
p3[d[i]].y=p2[b[i]].y;
p3[d[i]].z=p2[b[i]].z>p3[d[i]].z?p2[b[i]].z:p3[d[i]].z;
}
if(a[i]==1)
{p3[d[i]].x=p1[b[i]].x;
p3[d[i]].z=p1[b[i]].z>p3[d[i]].z?p1[b[i]].z:p3[d[i]].z;
}
}
}
for(i=0;i<5;i++)
{
printf("%d ",p1[i].x);
printf("%d ",p1[i].y);
printf("%d ",p1[i].z);
printf("\n");
printf("%d ",p2[i].x);
printf("%d ",p2[i].y);
printf("%d ",p2[i].z);
printf("\n");
printf("%d ",p3[i].x);
printf("%d ",p3[i].y);
printf("%d ",p3[i].z);
printf("\n");
}
}