Hmmm ... good friends now we're going to learn a little about the multiplication of two sets. Of all my friends have been learning about the set.,, Hehehhe. . . But at this time we learn something else: how to make C + + program for multiplying two sets. Friends can see the algorithms and programs below. Check it out ... .. Lets try ..!
Algoritma :
{Mengalikan himpunan A dan B}
Deklarasi
n,m : integer
a,b : string of array
Deskripsi
read(n)
for x <= 0 to n do
write(a[x])
endfor
read(m)
for y <= 0 to m do
write(b[y])
endfor
for x <= 0 to n do
for y <= 0 to m do
write({(a[x])(b[y])})
endfor
endfor
Berikut kode programnya :
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string a[10];
string b[10];
int n,m;
cout<<"Masukan Data A:";
cin>>n;
for(int x=0;x<n;x++)
{
cout<<"Data["<<x+1<<"]:";
cin>>a[x];
}
cout<<endl;
cout<<"Masukan Data B:";
cin>>m;
for(int y=0;y<m;y++)
{
cout<<"Data["<<y+1<<"]:";
cin>>b[y];
}
cout<<endl;
cout<<"AxB=";
for(int x=0;x<n;x++)
for(int y=0;y<m;y++)
{
cout<<"{("<<a[x]<<")("<<b[y]<<")}";
cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
explanation:
The above program is a program used to multiply the two sets which, if we have two sets of set A and set B then the program will multiply the members of the set A and set B. With the notation: A x B. In the above program using arrays and have inputted the data types integer and string.
0 komentar:
Posting Komentar