Last active
August 28, 2015 17:31
-
-
Save anugrahbsoe/75e25cea8b569988ef4c to your computer and use it in GitHub Desktop.
Susun program untuk mencetak berapa jumlah pohon semula yang ada di kebun besar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sebuah kebun besar ditanami pohon bibit sebanyak n baris. Setiap baris | |
terdiri dari n pohon, sehingga kebun besar ini dapat kita sebut ukurannya = n | |
x n. Pohon-pohon tersebut kemudian dicabut dan ditanam ulang menjadi 13 | |
buah kebun dengan ukuran lebih kecil yaitu setiap kebun kecil terdiri dari m | |
baris dan setiap baris terdiri dari m pohon, sehingga kebun kecil ini kita sebut | |
berukuran m x m. | |
Setelah terbentuk 13 kebun kecil ukuran m x m, ternyata pada kebun besar | |
masih tersisa 1 pohon. | |
Susun program untuk mencetak berapa jumlah pohon semula yang ada di | |
kebun besar. | |
#include <iostream> | |
#include <math.h> | |
#include <conio.h> | |
using namespace std; | |
main() | |
{ | |
cout<<"Program Soal No.2"<<endl; | |
cout<<"========================"<<endl<<endl; | |
cout<<"NIM \t: 1011530480"<<endl; | |
cout<<"Nama \t: bagus"<<endl; | |
cout<<"Kelas \t: XA"<<endl<<endl; | |
cout<<"========================"<<endl<<endl; | |
int x=100; | |
int b1,b2 ; | |
float a1,a2; | |
bool cukup; | |
do | |
{ | |
x++; | |
if(x%13 == 1) | |
{ | |
a1= sqrt(x); | |
b1= sqrt(x); | |
a2= sqrt((x-1)/13); | |
b2= sqrt((x-1)/13); | |
if(a1-b1==0 && a2-b2==0) | |
cukup=true; | |
} | |
} | |
while(cukup==false); | |
cout<<"Jumlah Pohon Pada Kebun besar dengan ukuran | |
["<<b1<<" X "<<b1<<"] \t: "<<x<<" batang"<<endl; | |
cout<<"Jumlah Pohon Pada 13 Kebun kecil dengan ukuran | |
["<<b2<<" X "<<b2<<"] \t: "<<(x-1)/13<<" batang"; | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment