Previous Next
0 / 21
Module DEMO-32-109DEMO-C-32

Subtract Matrices

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program to subtract two matrices (A - B) of the same dimensions. Input format is dimensions R C, then Matrix A, then Matrix B.

Constraints

1 <= N, M <= 10. Integers within standard range.

Input Format

Input: Dimensions N M followed by the matrix elements.

Output Format

Output: The formatted result as specified.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
2 2
5 5
4 9
4 7
2 8
1 -2
2 1
Performed element-wise subtraction.
Sample #2
Public sample
3 3
7 7 9
1 9 4
8 7 0
3 0 0
1 4 3
4 7 0
4 7 9
0 5 1
4 0 0
Performed element-wise subtraction.
Sample #3
Public sample
3 4
7 1 7 0
3 2 2 7
5 2 3 4
6 6 3 1
6 0 2 5
6 7 6 2
1 -5 4 -1
-3 2 0 2
-1 -5 -3 2
Performed element-wise subtraction.
Sample #4
Public sample
4 3
0 3 3
0 5 8
2 7 8
0 9 8
8 5 0
8 4 8
6 4 2
7 4 4
-8 -2 3
-8 1 0
-4 3 6
-7 5 4
Performed element-wise subtraction.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings