-
Notifications
You must be signed in to change notification settings - Fork 3
/
experiment6.c
98 lines (98 loc) · 1.63 KB
/
experiment6.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<stdio.h>
void main()
{
int i,j,m1,n1,m2,n2,c,k;
float R[50][50],S[50][50],T[50][50],U[50][50],a[50];
printf("Enter the number of rows and columns of matrix R: ");
scanf("%d %d",&m1,&n1);
printf("Enter the Elements:\n");
for(i=0;i<m1;i++)
{
for(j=0;j<n1;j++)
{
scanf("%f", &R[i][j]);
}
}
printf("\nEnter the number of rows and columns of matrix S: ");
scanf("%d %d",&m2,&n2);
printf("Enter the Elements:\n");
for(i=0;i<m2;i++)
{
for(j=0;j<n2;j++)
{
scanf("%f", &S[i][j]);
}
}
if(n1!=m2)
{
printf("Cartesian product can't be determined.");
}
printf("\nCartesian Product on Fuzzy Relation using:\n\n1. Max-Min Composition\n2. Max-Product Composition\n Enter your choice:");
scanf("%d",&c);
switch(c)
{
case 1:
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
for(k=0;k<m2;k++)
{
if(R[i][k]>=S[k][j])
{
a[k]=S[k][j];
}
else if(R[i][k]<=S[k][j])
{
a[k]=R[i][k];
}
}
for(k=1;k<m2;k++)
{
if(a[0]<a[k])
a[0]=a[k];
}
T[i][j]=a[0];
}
}
printf("\nThe Max-Min of R and S is T:\n");
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
printf(" %f",T[i][j]);
}
printf("\n");
}
break;
case 2:
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
for(k=0;k<m2;k++)
{
a[k]=R[i][k]*S[k][j];
}
for(k=1;k<m2;k++)
{
if(a[0]<a[k])
a[0]=a[k];
}
U[i][j]=a[0];
}
}
printf("\nThe Max-Product of R and S is U:\n");
for(i=0;i<m1;i++)
{
for(j=0;j<n2;j++)
{
printf(" %f",U[i][j]);
}
printf("\n");
}
break;
default:
printf("Please choose correct option.");
}
}