-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.cpp
172 lines (169 loc) · 2.4 KB
/
function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
Nama Mahasiswa : Bramanto
Pokok Bahasan : Procedure & Function
Date Modified : Saturday, 27 May 2014 04.11 PM
*/
#include "conio.h"
#include "iostream.h"
void line(int g)
{
if(g>0)
{
cout <<"-";
line(g-1);
}
}
void starleft()
{
int i, j, star;
clrscr();
cout <<"Masukkan Nilai : ";
cin >> star;
cout<<endl;
for(i=1;i<=star;i++)
{
for(j=0;j<i;j++)
{
cout<<"*";
}
cout<<endl;
}
for(i=star;i>0;i--)
{
for(j=(i-1);j>0;j--)
{
cout<<"*";
}
cout<<endl;
}
cout<<"\nRasi Bintang Segitiga Dengan Function Rata Kiri.";
getch();
}
void starright()
{
int star,x,y,z;
clrscr();
cout << "Masukkan Nilai : ";
cin >> star;
cout << endl;
for(z=star;z>0;z--)
{
for(x=z-1;x>0;x--)
{
cout<<" ";
}
for(y=(star-(z-1));y>0;y--)
{
cout<<"*";
}
cout<<endl;
}
for(z=0;z<star;z++)
{
for(x=0;x<(z+1);x++)
{
cout<<" ";
}
for(y=0;y<(star-(z+1));y++)
{
cout<<"*";
}
cout<<endl;
}
cout<<"\nRasi Bintang Segitiga Dengan Function Rata Kanan.";
getch();
}
void starbottom()
{
int s,t,star;
clrscr();
cout <<"Masukkan Nilai : ";
cin >> star;
for(s=0;s<star;s++)
{
for(t=(star-1);t>s;t--)
{
cout <<" ";
}
for(t=0;t<=s;t++)
{
cout <<"*";
}
for(t=0;t<s;t++)
{
cout <<"*";
}
cout << endl;
}
cout<<"\nRasi Bintang Segitiga Dengan Function Rata Bawah.";
getch();
}
void startop()
{
int i,j,star;
clrscr();
cout <<"Masukkan Nilai : ";
cin >> star;
cout<<endl;
for(i=0;i<star;i++)
{
for(j=0;j<i;j++)
{
cout<<" ";
}
for(j=(star-1);j>=i;j--)
{
cout<<"*";
}
for(j=(star-1);j>i;j--)
{
cout<<"*";
}
cout<<endl;
}
cout<<"\nRasi Bintang Segitiga Dengan Function Rata Atas.";
getch();
}
void main()
{
char menu;
menu:
clrscr();
line(41);
cout <<"\n PROGRAM DINAMIS RASI BINTANG SEGITIGA \n";
line(41);
cout <<"\n\n MENU PILIHAN\n";
line(14);
cout <<"\n[1] Rasi Bintang Rata Kiri";
cout <<"\n[2] Rasi Bintang Rata Kanan";
cout <<"\n[3] Rasi Bintang Rata Bawah";
cout <<"\n[4] Rasi Bintang Rata Atas";
cout <<"\n[5] Keluar Program";
cout <<"\n\nMasukkan Pilihan Anda [1..5] : ";
cin >> menu;
if(menu=='1')
{
starleft();
goto menu;
}
else if(menu=='2')
{
starright();
goto menu;
}
else if(menu=='3')
{
starbottom();
goto menu;
}
else if(menu=='4')
{
startop();
goto menu;
}else if(menu=='5')
{
clrscr();
cout<<"\t\t Terima Kasih, Anda Telah Keluar Program.";
getch();
}else{goto menu;}
}