Rabu, 06 April 2016
kasus 5.8 menghitung gcd dari dua bilangan bulat positif.
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int gcd(int m, int n){
int r;
while(n>0){
r=m%n;
m=n;
n=r;
}
return(m);
}
using namespace std;
int main(int argc, char** argv) {
int a, b;
cout<<"masukkan nilai 1 = "; cin>>a;
cout<<"masukkan nilai 2 = "; cin>>b;
cout<<"\nFPB("<<a<<","<<b<<") = "<<gcd(a,b);
return 0;
}
kasus 5.2 dan 5.3 dapat dilihat di : http://hiwilmacleta.blogspot.co.id/search/label/TugasKe4
kasus 5.4 dan 5.5 dapat dilihat di : http://ghaidaazzahra771.blogspot.co.id/search/label/TugasK4
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar