Konteks Menara Hanoi di sini adalah bukan menunjukkan nama suatu tempat, melainkan menunjukkan nama sebuah game puzzle yang sudah sering terdengar dalam telinga para gamers dan programmers. Kenapa Saya masukkan kata “programmers” ? Memang ini adalah sebuah games, tetapi penerapannya sering digunakan sebagai sebuah problem dalam bahasa pemrogaman.
Pada kali ini, Saya akan membagi ilmu kepada para pembaca sekalian tentang bagaimana problem ini dapat dipecahkan dengan bahasa pemrogaman. Bahasa pemrogaman yang akan Saya pakai adalah bahasa C. Pada pembahasan kali ini, kita akan memakai aplikasi fungsi rekursif yaitu fungsi yang memanggil dirinya sendiri.
Berikut adalah listing SC-nya.
#include <stdio.h>
#include <stdlib.h> //Header ini digunakan untuk mengambil fungsi atoi
#include <string.h> //Header ini digunakan untuk mengambil fungsi strlen
void tulisLangkah(int jmlCakram,char pasakAwal,char pasakAkhir,char pasakBantu)
// pindahkan piringan ke jmlPasak dari pasakAwal menuju pasakAkhir melalui pasakBantu
{
static int langkah=0; //Digunakan untuk penomoran setiap langkah
if (jmlCakram == 0) return;
/*1*/ tulisLangkah(jmlCakram-1,pasakAwal,pasakBantu,pasakAkhir);
//pindahkan piringan ke jmlPasak-1 dari pasakAwal menuju pasakBantu melalui pasakAkhir
/*2*/ printf("%4d. Pindahkan cakram ke %d dari pasak %c ke pasak %c\n",++langkah,jmlCakram,pasakAwal,pasakBantu);
/*3*/ tulisLangkah(jmlCakram-1,pasakAkhir,pasakAwal,pasakBantu);
//pindahkan piringan ke jmlPasak - 1 dari pasakAkhir menuju pasakAwal melalui pasakBantu
}
int main(int argc,char *argv[]) //Perintah untuk menuliskan argument pada Command Line
{
int jmlCakram,i;
if(argc==1)
{
printf("Maaf Anda harus menuliskan argumen pada command line !!!");
return 0;
}
jmlCakram = atoi(argv[1]);
//fungsi atoi didapat dari standar libarary stdlib yang fungsinya untuk mengconvert data string menjadi data integer
for(i=0;i
if(argv[1][i]-48<=0||argv[1][i]-48>9)
jmlCakram=0;
//Jika argumen yang dimasukkan mengandung integer dan string, maka akan ada informasi berupa peringatan
if(jmlCakram==0)
//jika argumen yang dimasukkan berupa string, maka fungsi atoi otomatis akan mengkonversi string menjadi 0
//sehingga apabila data yang dimasukkan berupa string, maka akan ada informasi yang akan muncul
{
printf("Argumen yang Anda masukkan salah !!!");
return 0;
}
if(jmlCakram>10)
{
printf("Argumen yang Anda masukkan terlalu besar !!!");
return 0;
}
printf("\n\n ***Menara Hanoi***\n\n");
printf("Untuk memindahkan %d cakram dari\npasak 1 ke 2, lakukan langkah-langkah ini:\n\n",jmlCakram);
tulisLangkah(jmlCakram,'1','3','2');
printf("\n\n ***Selesai***");
return 0;
}
31 October 2008
Solusi Puzzle Menara Hanoi Dengan Pemrogaman C
18 October 2007
MAKING 3D TEXT MODEL IN DAZ BRYCE 5.5 ( English Version )
DAZ Bryce 5.5 is one of 3D programs that have application like other 3D programs, but it more focus to landscape modeling.
Although it focused to landscape modeling, it can produce text object too.
DAZ Bryce 5.5 doesn’t supply application text model directly, but with helpful object in this program, we can make text object indirectly.
The principle we must prepare text in picture or 2D form. Therefore we must need picture applications to make the text in 2D form like Photoshop, CorelDraw, Paint, etc.
Mentioned below is interface of DAZ Bryce 5.5.

These are the steps:
1.Prepare 2D text from the other picture applications like Photoshop, CorelDraw, Paint, etc.
Note:
Afford 2D text that we prepare colored white and the background colored black. In order to clear, please look picture example in below:

2.We save the text
3.Let us open DAZ Bryce 5.5
4.After appears its interface, we choose Tool Palettes “Create” on upper part interface.

5.The next, we choose “Symmetrical Lattice” on the palette.

6.If appear object in work area, we can double click that object.
7.After that, we can look a terrain editor. In here we can edit The Lattice object to become text object.
Mentioned below is interface of terrain editor:

8.The next, we choose New on the tab Elevation in the Editing Tools sub menu.
9.We can look screens in the Terrain Canvas be blank. The Next, We choose tab Pictures in the Editing Tools sub menu.
10.We can look screens like this picture:

After that we can choose Load on the most left part, and then we can choose Copy on the most left part and we can choose again Paste on the most right part, and then we can choose Apply on the bottom right.
11.On 3D Preview, we can look Lattice object change to be text object, but the form is not good and thicker. Therefore, we must focus to our work in the Terrain Canvas and we can move Slider on the most right part of Terrain Canvas like this picture.

12.After that, we can choose arrow on the upper part of Terrain Canvas, and then we can choose Solid. Look this picture.

13. The next, we can choose sign
on the corner bottom right.
14. After that we can back to work area on the beginning interface and we can look the Lattice object change to be text object. The next, we can give good position with Edit on Tool Palettes and Camera Controls on the left part of the interface. The purpose is in order that the object good looked when rendered. If the point has done, we could look interface like this picture.

15. After the model that we make considered in the right size and good looked, we can render the object by using Render Controls. After that, we can look the object like this picture.

If we brave trying this program with using material on the text object and add to the other object such as Water Plane, Terrain, Stone, and others, we can look the result like this picture.
Although it focused to landscape modeling, it can produce text object too.
DAZ Bryce 5.5 doesn’t supply application text model directly, but with helpful object in this program, we can make text object indirectly.
The principle we must prepare text in picture or 2D form. Therefore we must need picture applications to make the text in 2D form like Photoshop, CorelDraw, Paint, etc.
Mentioned below is interface of DAZ Bryce 5.5.
These are the steps:
1.Prepare 2D text from the other picture applications like Photoshop, CorelDraw, Paint, etc.
Note:
Afford 2D text that we prepare colored white and the background colored black. In order to clear, please look picture example in below:

2.We save the text
3.Let us open DAZ Bryce 5.5
4.After appears its interface, we choose Tool Palettes “Create” on upper part interface.

5.The next, we choose “Symmetrical Lattice” on the palette.

6.If appear object in work area, we can double click that object.
7.After that, we can look a terrain editor. In here we can edit The Lattice object to become text object.
Mentioned below is interface of terrain editor:
8.The next, we choose New on the tab Elevation in the Editing Tools sub menu.
9.We can look screens in the Terrain Canvas be blank. The Next, We choose tab Pictures in the Editing Tools sub menu.
10.We can look screens like this picture:
After that we can choose Load on the most left part, and then we can choose Copy on the most left part and we can choose again Paste on the most right part, and then we can choose Apply on the bottom right.
11.On 3D Preview, we can look Lattice object change to be text object, but the form is not good and thicker. Therefore, we must focus to our work in the Terrain Canvas and we can move Slider on the most right part of Terrain Canvas like this picture.

12.After that, we can choose arrow on the upper part of Terrain Canvas, and then we can choose Solid. Look this picture.
13. The next, we can choose sign

14. After that we can back to work area on the beginning interface and we can look the Lattice object change to be text object. The next, we can give good position with Edit on Tool Palettes and Camera Controls on the left part of the interface. The purpose is in order that the object good looked when rendered. If the point has done, we could look interface like this picture.

15. After the model that we make considered in the right size and good looked, we can render the object by using Render Controls. After that, we can look the object like this picture.
If we brave trying this program with using material on the text object and add to the other object such as Water Plane, Terrain, Stone, and others, we can look the result like this picture.
Subscribe to:
Posts (Atom)