I´m trying to make a spiral pattern (just starting with C programming). I try to do it manually for the start from n=1 to n=15 but when the n=12 or more it starts to get messy. Maybe someone could give me a hint. Yes I know this is not a website for beginners/students/noobs but I couldn´t find help elsewhere.
For now I have this:
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
fflush(stdin);
for(int i = 0;i<n;i++){
for(int j = 0;j<n;j++){
if(i==0||i==n-1||j==n-1)
printf("#");
else if(j==0&&i>1&&i<n-1)
printf("#");
else if(i==2&&j<n-2)
printf("#");
else if(j==n-3&&i>2&&i<n-2)
printf("#");
else if(i==n-3&&j<n-3&&j>1)
printf("#");
else if(j==2&&i>3&&i<n-2)
printf("#");
else if(i==4&&j>2&&j<n-4)
printf("#");
else if(j==6&&i>4&&i<n-4)
printf("#");
else if(i==6&&j>3&&j<n-5)
printf("#");
else printf(".");
}
printf("\n");
}
getchar();
return 0;
}
Those are the examples of the outputs:
For n=7
#######
......#
#####.#
#...#.#
#.###.#
#.....#
#######
For n=9
#########
........#
#######.#
#.....#.#
#.###.#.#
#.#...#.#
#.#####.#
#.......#
#########
But now when n=13
#############
............#
###########.#
#.........#.#
#.#######.#.#
#.#...#...#.#
#.#.####..#.#
#.#...#...#.#
#.#...#...#.#
#.#.......#.#
#.#########.#
#...........#
#############
It becomes a mess.