#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;
int main(){
int banyakA, banyakB;
string A[10],B[10];
cout<<"Masukkan banyaknya himpunan a : ";
cin>>banyakA;
cout<<"Masukkan banyaknya himpunan b : ";
cin>>banyakB;
cout<<endl;
cout<<"Himpunan A = ";
for(int i=0; i<banyakA; i++){
cin>>A[i];
}
cout<<endl;
cout<<"Himpunan B = ";
for(int j=0; j<banyakB; j++){
cin>>B[j];
}
cout<<endl;
cout<<"Himpunan A = {";
for(int i=0; i<banyakA; i++){
cout<<A[i]<<",";
}
cout<<"}";
cout<<endl;
cout<<"Himpunan B = {";
for(int j=0; j<banyakB; j++){
cout<<B[j]<<",";
}
cout<<"}";
cout<<endl;
cout<<"Himpunan A x Himpunan B = {";
for(int i=0; i<banyakA; i++){
for(int j=0; j<banyakB; j++){
cout<<"("<<A[i]<<",";
cout<<B[j]<<"),";
}
}
cout<<"}";
getch();
return 0;
}
Hasil running nya :
#include <conio.h>
#include <string.h>
using namespace std;
int main(){
int banyakA, banyakB;
string A[10],B[10];
cout<<"Masukkan banyaknya himpunan a : ";
cin>>banyakA;
cout<<"Masukkan banyaknya himpunan b : ";
cin>>banyakB;
cout<<endl;
cout<<"Himpunan A = ";
for(int i=0; i<banyakA; i++){
cin>>A[i];
}
cout<<endl;
cout<<"Himpunan B = ";
for(int j=0; j<banyakB; j++){
cin>>B[j];
}
cout<<endl;
cout<<"Himpunan A = {";
for(int i=0; i<banyakA; i++){
cout<<A[i]<<",";
}
cout<<"}";
cout<<endl;
cout<<"Himpunan B = {";
for(int j=0; j<banyakB; j++){
cout<<B[j]<<",";
}
cout<<"}";
cout<<endl;
cout<<"Himpunan A x Himpunan B = {";
for(int i=0; i<banyakA; i++){
for(int j=0; j<banyakB; j++){
cout<<"("<<A[i]<<",";
cout<<B[j]<<"),";
}
}
cout<<"}";
getch();
return 0;
}
Hasil running nya :
0 komentar:
Posting Komentar