Perkalian 2 Himpunan dengan C++

Code :

#include <iostream>
#include <conio.h>
#include <string.h>

using namespace std;

int main(){
    int banyakA, banyakB;
    string A[10],B[10];
    
    cout<<"PERKALIAN 2 HIMPUNAN"<<endl;
    cout<<"--------------------------------"<<endl;
    
    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;   
}

Posted on Mei 15, 2011, in Algoritma & Pemrograman. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: