• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Heading 1 Here:Enter the heading 1 description here.Go to blogger edit html,find these words and replace it with your own description ...
  • Heading 2 Here:Enter the heading 2 description here.Go to blogger edit html,find these words and replace it with your own description ...
  • Heading 3 Here:Enter the heading 3 description here.Go to blogger edit html,find these words and replace it with your own description ...
  • Heading 4 Here:Enter the heading 4 description here.Go to blogger edit html,find these words and replace it with your own description ...
  • Heading 5 Here:Enter the heading 5 description here.Go to blogger edit html,find these words and replace it with your own description ...
  • SLIDE-1-TITLE-HERE

    Welcome to Blogger.Go to Blogger edit html and find these sentences.Now replace these text/sentences with your own descriptions.This theme is convert to Blogger by Premiumbloggertemplates.com.Download this template and more Premium Blogger Templates From PremiumBloggerTemplates.com...

  • SLIDE-2-TITLE-HERE

    Welcome to Blogger.Go to Blogger edit html and find these sentences.Now replace these text/sentences with your own descriptions.This theme is convert to Blogger by Premiumbloggertemplates.com.Download this template and more Premium Blogger Templates From PremiumBloggerTemplates.com...

  • SLIDE-3-TITLE-HERE

    Welcome to Blogger.Go to Blogger edit html and find these sentences.Now replace these text/sentences with your own descriptions.This theme is convert to Blogger by Premiumbloggertemplates.com.Download this template and more Premium Blogger Templates From PremiumBloggerTemplates.com...

  • SLIDE-4-TITLE-HERE

    Welcome to Blogger.Go to Blogger edit html and find these sentences.Now replace these text/sentences with your own descriptions.This theme is convert to Blogger by Premiumbloggertemplates.com.Download this template and more Premium Blogger Templates From PremiumBloggerTemplates.com...

Kamis, 07 April 2011

program sederhana mencari KPK

Posted by Cipto Tri Raharjo On 20.18 No comments

Algoritma KPK
{membaca masukan n dan i kemudian diperiksa melalui perulangan for, jika i samadengan 1 , i kurangdari n maka i++ , jika n mod i samadengan 0 maka menuliskan hasil i}

#include <iostream.h>
#include <conio.h>
class kpk {
friend istream& operator>>(istream&, kpk&);
public :
kpk ();
private:
int a,b,nilai;
};
kpk::kpk() { cout<<”Menghitung KPK”<<endl; }
istream& operator>>(istream& in, kpk& masuk) {
masuk.nilai=0;
cout<<”Masukkan A: “; in>>masuk.a;
cout<<”Masukkan B: “; in>>masuk.b;
for (int z=1; z<=masuk.b; z++) {
masuk.nilai=masuk.nilai+masuk.a;
if (masuk.nilai%masuk.b==0) {
cout<<”KPK dari “<< masuk.a << ” dan “<< masuk.b <<” adalah “<< masuk.nilai <<endl;
return in;
}
}
}
int main () {
kpk X;
cin >> X;
getch ();
}

0 komentar:

Posting Komentar