Diamond Hole with Modular C++

diamondhole

diamondhole

Program ini dibuat untuk membuat diamond hole(lubang berlian) dengan code C++ meggunakan fungsi modular disini fungsi modular dipecah dalam 3 file. Yang pertama atas.h kemudian bawah.h dan rumus.h yang mana nantinya dipanggil di program utama.

rumus.h


#include <iostream>
void header(){
int a;
for(a=0;a< =11;a++){
cout<<"*";
}
cout << endl;
}



atas.h


#include <iostream>
#include <conio.h>

// bagian atas!
void atas(){
for (int count = 0; count = count; atas--)
cout < = (4 - count); bintangatas--)
cout < = (4 - count); spasikanan--)
cout < = count; bintangkanan--)
cout < < "*";

cout << endl;
}
}


bawah.h


#include <iostream>
#include <conio.h>


void bawah(){
for (int count2 = 0; count2 < =4; count2++)
{

for (int spasibawah = 0; spasibawah <= count2; spasibawah++)
cout << "*";
for (int bintangbawah = 0; bintangbawah <= (4 - count2); bintangbawah++)
cout << " ";

for (int spasibkanan = 0; spasibkanan <= (4 - count2); spasibkanan++)
cout << " ";
for(int bintangbkanan = 0; bintangbkanan <= count2; bintangbkanan++)
cout << "*";

cout << endl;
}
}


tugasku.cpp


#include <iostream>
#include <conio.h>
#include "rumus.h";
#include "atas.h";
#include "bawah.h";
int main()
{
cout< <"  HASIL UJIAN AKHIR SEMESTER GENAP"<< endl<< endl;
cout<<"----------------------------------"<< endl;
cout<<"Praktik Pemrograman Terstruktur"<< endl<< endl;
cout<<" Oleh :"<< endl;
cout<<" Nama : Anton elyas priyambodo "<< endl;
cout<<" NIM  : 3095113017"<< endl<< endl<< endl;

header();
atas();
bawah();
header();
getch();
return 0;

}

[button link=”http://antzone.web.id/wp-content/uploads/2011/05/diamond-hole.zip type=”icon”]Source code[/button]

This entry was posted in Kuliahan and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s