import java.io.*;
import javax.swing.*;
public class relasi
{
public static void main(String[] args) throws Exception
{
int i,j;
int [] k = new int[10];
int [] l = new int[10];
BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
System.out.print("Banyak Anggota Himpunan X Maksimal 10 :");
int x=Integer.parseInt(input.readLine());
System.out.println("\n");
for(i=1;i<=x;i++)
{
System.out.print("Elemen himpunan X ke-"+i+" : ");
int m=Integer.parseInt(input.readLine());
k[i]=m;
}
System.out.print("X={");
for(i=1;i<=x;i++)
{
System.out.print(k[i]);
if(i!=x)
System.out.print(",");
}
System.out.print("}");
System.out.println("\n\n");
System.out.print("Banyak Anggota Himpunan Y Maksimal 10 :");
int y=Integer.parseInt(input.readLine());
System.out.println("\n");
for(j=1;j<=y;j++)
{
System.out.print("Elemen himpunan Y ke-"+j+" : ");
int n=Integer.parseInt(input.readLine());
l[j]=n;
}
System.out.print("Y={");
for(j=1;j<=y;j++)
{
System.out.print(l[j]);
if(j!=y)
System.out.print(",");
}
System.out.print("}");
System.out.println("\n\n");
System.out.println("Relasi Yang Mungkin :");
for(i=1;i<=x;i++)
{
for(j=1;j<=y;j++)
{
System.out.println("{"+k[i]+","+l[j]+"}");
}
}
}
}
Tidak ada komentar:
Posting Komentar