Skip to content

Instantly share code, notes, and snippets.

@wirajayaabadi
Created May 30, 2018 09:09
Show Gist options
  • Select an option

  • Save wirajayaabadi/fd4dc356640d7d123ef4c5b7916d7adf to your computer and use it in GitHub Desktop.

Select an option

Save wirajayaabadi/fd4dc356640d7d123ef4c5b7916d7adf to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int loop (int n){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if ((i==j)||(i==n)||(j==(n/2)+1)||(j==(n-i)+1)||(i==1)){
cout<<"*";
}else{
cout<<" ";
}
}
cout<<endl;
}
}
int main(){
int n;
cout<<"Inputkan bilangan ganjil : ";
cin>>n;
cout<<"Hasil : \n";
if(n%2==1){
loop(n);
}
else{
cout<<"Silahkan ulangi kembali dan inputkan dengan bilangan ganjil.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment