Make a Nazi Symbol with C


How to make a Nazi symbol? It’s just a trick. And what a kind of trick is it? It’s a logical trick. So, you need your logic to finish this one.  Let’s see…….

Below this paragraph, I’ll show you  how to make it. I will use the C programming language as the code.

#include <stdio.h>

#include <stdlib.h>

int main()

{

int i,j,n,k;

printf(“input your number, it must be odd : “);scanf(“%d/n”,&n);

k=(n/2)+1;

for (i=1;i<=n;i++)

{

for (j=1;j<=n;j++)

{

if ((i==k) or (j==k) or ((i==1) && (j<=k)) or ((i==n)&&(j>=k)) or ((j==1)&&(i>=k)) or ((j==n)&&(i<=k)))

{

printf(“*”);

}

else

{

printf(” “);

}

}

printf(“\n”);

}

system(“pause”);

return 0;

}

Then try it by yourself. This is just an example of program. I use dev C++ to compile and run this program.

Iklan

Tinggalkan Komentar

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s