1. Deklarasi
jumlahA, jumlahB : Int
A , B : string
i, j : int
Deksripsi
read jumlahA, jumlahB;
for i ß 0 to jumlahA do
read A[i]
end for
for j ß 0 to jumlahB do
read B[j]
end for
for i ß 0 to jumlahA do
for j ß 0 to jumlahB do
write A[i], B[j]
end for
end for
Source Codenya:
#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;
int main(){
int jumlahA, jumlahB;
string A[10],B[10];
cout<<"===================================================="<<endl;
cout<<"+ LukmanReza 10018148 +"<<endl;
cout<<"===================================================="<<endl;
cout<<endl;
cout<<"Masukkan banyak himpunan Pertama : ";
cin>>jumlahA;
cout<<"Masukkan banyak himpunan Kedua : ";
cin>>jumlahB;
cout<<endl;
cout<<"Himpunan Pertama\n";
for(int i=0; i<jumlahA; i++){
cout<<"himpunan ke-"<<i+1<<" : ";
cin>>A[i];
}
cout<<endl;
cout<<"Himpunan Kedua\n";
for(int j=0; j<jumlahB; j++){
cout<<"himpunan ke-"<<j+1<<" : ";
cin>>B[j];
}
cout<<endl;
cout<<"Himpunan Pertama = { ";
for(int i=0; i<jumlahA; i++){
cout<<A[i]<<" , ";
}
cout<<"}\n";
cout<<endl;
cout<<"Himpunan Kedua = { ";
for(int j=0; j<jumlahB; j++){
cout<<B[j]<<" , ";
}
cout<<"}\n";
cout<<endl;
cout<<"Himpunan Pertama x Himpunan Kedua = {";
for(int i=0; i<jumlahA; i++){
for(int j=0; j<jumlahB; j++){
cout<<"("<<A[i]<<" , ";
cout<<B[j]<<"), ";
}
}
cout<<"}";
getch();
return 0;
}
0 Komentar