-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMateri-05-Praktikum-5-compositeFunction.cpp
63 lines (48 loc) · 1.22 KB
/
Materi-05-Praktikum-5-compositeFunction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Matematika Diskrit Praktikum 5 Materi compositeFunction
By hafizhhasyhari
*/
#include <iostream>
#include <string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop*/
int main(int argc, char *argv[]) {
int jumlah;
string f[100][100];
string g[100][100];
cout<<"Masukkan jumlah f(x) :";
cin>>jumlah;
cout<<"Masukkan fungsi f->x"<<endl;
for(int i=1;i<=jumlah;i++){
cout<<"f(x):";
cin>>f[0][i];
cout<<"x:";
cin>>f[i][0];
}
cout<<"Masukkan fungsi g->x"<<endl;
for(int i=1;i<=jumlah;i++){
cout<<"g(x):";
cin>>g[0][i];
cout<<"x:";
cin>>g[i][0];
}
cout<<"f(x) = {";
for(int i=1;i<=jumlah;i++){
cout<<"("<<f[0][i]<<")"<<"("<<f[i][0]<<"),";
}
cout<<"}"<<endl;
cout<<"g(x) = {";
for(int i=1;i<=jumlah;i++){
cout<<"("<<g[0][i]<<")"<<"("<<g[i][0]<<"),";
}
cout<<"}"<<endl<<"fog(x)={";
for(int i=1;i<=jumlah;i++){
for(int j=1;j<=jumlah;j++){
if(f[i][0]==g[0][j]){
cout<<"("<<f[0][i]<<","<<g[j][0]<<"),";
}
}
}
cout<<"}"<<endl;
return 0;
}