Knowee
Questions
Features
Study Tools

Question10Max. score: 40.00PatternInput format :two integersOutput format :Print patternconstraints :1<=N<=100Sample input5 4Sample outputX X X X X 0 0 X X 0 0 X X 0 0 X X X X XNote:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC

Question

Question10Max. score: 40.00PatternInput format :two integersOutput format :Print patternconstraints :1<=N<=100Sample input5 4Sample outputX X X X X 0 0 X X 0 0 X X 0 0 X X X X XNote:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

To solve this problem, you need to write a code that takes two integers as input and prints a pattern based on those integers.

Here are the steps to solve the problem:

  1. Read the input values for N and M (the two integers).
  2. Create a loop to iterate N times (for each row of the pattern).
  3. Inside the loop, create another loop to iterate M times (for each column of the pattern).
  4. Check if the current row or column is the first or last row/column (i.e., if it is the border of the pattern).
  5. If it is the border, print "X" (as specified in the output format).
  6. If it is not the border, print "0" (as specified in the output format).
  7. After printing each row, move to the next line.
  8. Repeat steps 3-7 until all rows and columns are printed.
  9. End the program.

Here is an example code in C that implements the above steps:

#include <stdio.h>

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (i == 0 || i == N - 1 || j == 0 || j == M - 1) {
                printf("X ");
            } else {
                printf("0 ");
            }
        }
        printf("\n");
    }

    return 0;
}

This code reads the input values for N and M using scanf, and then uses nested loops to print the pattern based on the given constraints. The inner loop checks if the current row or column is the border and prints "X" accordingly, otherwise it prints "0". Finally, the code moves to the next line after printing each row.

Note that this code is just an example and there may be other valid solutions to this problem.

This problem has been solved

Similar Questions

PatternInput format :two integersOutput format :Print patternconstraints :1<=N<=100Sample input5 4Sample outputX X X X X 0 0 X X 0 0 X X 0 0 X X X X XNote:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC

Question9Max. score: 30.00Nth Fibonacci NumberInput  format :An integerOutput format :An integerConstraints :1<=N<=1000000Sample input10Sample output89Note:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC

Question9Max. score: 30.00Nth Fibonacci NumberInput  format :An integerOutput format :An integerConstraints :1<=N<=1000000Sample input10Sample output89

Question8Max. score: 40.00Reverse first half and second half of the array.Input format :Size of the arrayArray elementsOutput format :Reversed arrayConstraints :1<=N<=100000Sample input1 2 3 4 7 8 6 5 4Sample output4 3 2 1 7 4 5 6 8ExplanationInput :71 2 3 4 5 6 7Output :3 2 1 7 6 5 4Note:Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.LimitsTime Limit: 5.0 sec(s) for each input fileMemory Limit: 256 MBSource Limit: 1024 KBScoringScore is assigned if any testcase passesAllowed LanguagesC

Even SplitMax Score: 50Given a number N, check if you can split the number into 2 non-zero even parts.Input FormatFirst line of input contains T - number of test cases. Its followed by T lines, each line contains a single integer N.Output FormatFor each test case, print "Yes" if you can split the number into 2 non-zero even parts, "No" otherwise, separated by new line.Constraints1 <= T <= 1050 <= N <= 1018ExampleInput285OutputYesNoExplanationExample 1:You can split 8 as 4,4 or 6,2.Example 2:You cannot split 5 into 2 even parts.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.