#include <stdio.h>
void main() {
int i,n,column,m,show,full_rows,k,b,flag=0,flag_b=0;
do {
printf("please enter frame size and width<frame size > 2*width>:");
scanf("%d",&n);
scanf("%d",&m);
}
while (n<=2*m||m<0); /*gives the conditions for the input of the program*/
for (i=0,k=0;k<23;i++,k++) {
for (column=0,b=0;b<79;column++,b++){
if (column==n){
column=0; /*restarts the building of the square*/
flag+=1;
}
if (i==n)
if ((n+1)%2)
flag_b+=1;
else
flag_b=0;
show=m>column;
show=show||m+column>=n; /*this are the conditions to create a squre with the thicknes(m) in the columns that is needed*/
if(show)
printf("*");
else {
full_rows=m>i;
full_rows=full_rows||m+i>=n;
if (full_rows) /*the condition to create thickness(m) in the rows that is needed*/
printf("*");
else
printf(" "); /*creates a blank in the spots that do not fullfill the conditions */
}
if(b==78)
printf("\n");
i=i%n;
}
}
}
void main() {
int i,n,column,m,show,full_rows,k,b,flag=0,flag_b=0;
do {
printf("please enter frame size and width<frame size > 2*width>:");
scanf("%d",&n);
scanf("%d",&m);
}
while (n<=2*m||m<0); /*gives the conditions for the input of the program*/
for (i=0,k=0;k<23;i++,k++) {
for (column=0,b=0;b<79;column++,b++){
if (column==n){
column=0; /*restarts the building of the square*/
flag+=1;
}
if (i==n)
if ((n+1)%2)
flag_b+=1;
else
flag_b=0;
show=m>column;
show=show||m+column>=n; /*this are the conditions to create a squre with the thicknes(m) in the columns that is needed*/
if(show)
printf("*");
else {
full_rows=m>i;
full_rows=full_rows||m+i>=n;
if (full_rows) /*the condition to create thickness(m) in the rows that is needed*/
printf("*");
else
printf(" "); /*creates a blank in the spots that do not fullfill the conditions */
}
if(b==78)
printf("\n");
i=i%n;
}
}
}
No comments:
Post a Comment