TV
Part of the Fundamentals section of Coddy's C journey — lesson 63 of 63.
Challenge
EasyA TV is drawn using numbers like below:
1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 3
The ones represent the TV's border, the twos represent the actual screen. The three in the lower right corner are the power buttons.
You are given a sequence of numbers from input until a 3 is entered. Calculate the width and height of the TV and output it to the screen.
Input
1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 3
Output
5 9
Input
1 1 1
1 2 1
1 1 3
Output
3 3
Try it yourself
#include <stdio.h>
int main() {
// Write code here
return 0;
};All lessons in Fundamentals
3Operators
Arithmetic OperatorsModulo OperatorIncrement/DecrementAssignment OperatorsRelational OperatorsLogical Operators Part 1Logical Operators Part 2Logical Operators Part 3Recap Challenge