Question: #include #include int main ( int argc, char * argv [ ] ) { if ( argc ! = 4 ) { printf (

#include
#include
int main(int argc, char *argv[]){
if (argc !=4){
printf("Please provide the correct number of arguments (columns, rows, # of sheets).
");
return 1;
}
int columns = atoi(argv[1]);
int rows = atoi(argv[2]);
int sheets = atoi(argv[3]);
if (columns <=0|| rows <=0|| sheets <=0){
printf("Please provide positive values for columns, rows, and # of sheets.
");
return 1;
}
for (int sheet =1; sheet <= sheets; sheet++){
for (int row =0; row < rows; row++){
for (int col =0; col < columns; col++){
if (col == columns -1){
if (row ==0|| row == rows -1){
printf("%d ", sheet);
} else {
printf("");
}
} else {
if (row ==0|| row == rows -1){
printf("%d ", sheet);
} else {
printf("");
}
}
}
printf("
");
}
}
return 0;
}
Make this code show the output below:
./a.out 334
Output:
111000
122100
123210
012321
001221
000111
Example 2
Input:
./a.out 243
Output:
1100
1210
1221
1221
0121
0011
Input:
./a.out 101010
Output:
1111111111000000000
1222222222100000000
1233333333210000000
1234444444321000000
1234555555432100000
1234566666543210000
1234567777654321000
1234567888765432100
1234567899876543210
12345678910987654321
0123456789987654321
0012345678887654321
0001234567777654321
0000123456666654321
0000012345555554321
0000001234444444321
0000000123333333321
0000000012222222221
0000000001111111111
In the output whwerevr you see zeros replace them with space in each of the row

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!