Deklarasi
n,i,j: integer
Algoritma
read (n)
for (i=1to i<=n) do
{ for (j=1 to j<=i) do
write('*')
endfor }
for (i=n-1downto i>=1) do
{ for (j=i downto j>=1)
write('*')
endfor }
endfor
endfor
CODING
#include <iostream>
using namespace std;
int main() {
int n,i,j;
cout<<"Masukan jumlah N=";cin>>n;
cout<<" "<<endl;
for (i=1;i<=n;i++)
{ for (j=1;j<=i;j++)
{cout<<"*"; }
cout<<endl;
}
for (i=n-1;i>=1;i--)
{ for (j=i;j>=1;j--)
{cout<<"*"; }
cout<<endl;
}
system("PAUSE");
}
KELUARAN
Download program disini https://drive.google.com/open?id=1eogdi5-7UEuUxX_YE_2GX-T-rQfNocCQ
No comments:
Post a Comment