Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago