Created
May 30, 2018 09:09
-
-
Save wirajayaabadi/fd4dc356640d7d123ef4c5b7916d7adf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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