Iseng-iseng buka folder source code yang udh lumutan akhirnya nemuin ni program. sederhana sih cuman asik bwt latihan dasar buat control n looping c++. silahkan dibaca..(Lengkap gak cuma fungsi)
#include <iostream>
#include <conio>
void main()
{
int n;
cout<<"Masukkan banyak # pada sisi persegi: ";
cin>>n;
for (int i=0;i<n;i++)
{
cout<<"\n";
if(i==0||i==n-1)
{
for (int j=0;j<n;j++)
{
cout<<"#";
}
}
else
for (int k=0;k<n;k++)
{
if(k==0||k==n-1)
{cout<<"#";}
else
cout<<" ";
}
getch();
}
}
#include <iostream>
#include <conio>
void main()
{
int n;
cout<<"Masukkan banyak # pada sisi persegi: ";
cin>>n;
for (int i=0;i<n;i++)
{
cout<<"\n";
if(i==0||i==n-1)
{
for (int j=0;j<n;j++)
{
cout<<"#";
}
}
else
for (int k=0;k<n;k++)
{
if(k==0||k==n-1)
{cout<<"#";}
else
cout<<" ";
}
getch();
}
}
Comments
Post a Comment