I want to create a hallow rectangle with a dynamic border, which means that if I input 3, then the border is going to be 3 columns thick. I've managed to do it with pre-given value, but I want the values to be inputted by the user.
#include <stdio.h>
int main()
{
int i, j, n, m;
printf("Rows: ");
scanf("%d", &n);
printf("Columns: ");
scanf("%d", &m);
for(i=1; i<=n; i++){
for(j=1; j<=m; j++){
if(i==1 || i==2 || i==3 || i==n-2 || i==n-1 || i==n || j==1 || j==2 || j== 3 || j==m-2 || j==m-1 || j==m){
printf("*");
}
else{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire