编程介的小学生 2017-03-08 06:15 采纳率: 20.5%
浏览 825
已采纳

LED Test

Many electronic devices have digital read-outs that are made using light-emitting diode (LED) arrays. A common digital display element uses seven, bar-shaped LED's, with the seven LED bars (segments) arranged and identified as:

Digits are displayed by illuminating various combinations of the seven segments in accordance with the following table:

For example, the digit three (3) would be displayed as the illumination of the segments {a,b,c,d,g} as:

The problem below is abstracted from one occurring in the incoming-parts inspection department, in a microwave-oven manufacturing facility. The incoming seven-segment LED's are checked for their proper functioning by automated equipment running under programmable control.

Note: The solution to the problem below will not be a complete nor necessarily useful test for the actual inspections that would be conducted.

You are to create a program that will observe successive sets of illumination conditions of the seven segments of a single-digit display, and decide whether the sequence of illuminations could have been a valid ``count down" sequence.

Unfortunately, for the LED your program is to observe, some of the segments may be burned out at the start of your test, and additional segments may burn out during the test. No segments will everfail into the ON mode; no burned out segments will recover. Nevertheless, you are expected to be able to ``read" through the ambiguities this malfunctioning display presents, by watching the display count down through one or more values.

Input

The input consists of a series of data sets having the following format:

First line -
A single unsigned integer, N, with value greater than zero (0) and less than eleven (11). The integer is left-justified on the input line.

Next N lines -
Each line has a string of seven (7) contiguous Y/N characters showing the light condition of the segments of the LED display. These successive lines supposedly represent a count down" sequence. The first of these seven characters, the illumination reading for thea" segment, will be the first character on a line.

The end of data is signaled by a null data set having a zero on the first line and no further data.

There is no information about where the ``count down" sequence begins for a given data set. There is no information that carries over from one data set to the next; each data set represents a different LED being tested.

Output

Foreach supposed ``count down" sequence you receive as a data set, you are to reply either:

MATCH

-or-

MISMATCH

depending on whether this sequence could possibly be a valid ``count down" sequence somewhere within the sequence { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } if an unknown number of burned-out segments were present at the beginning of the test, and, with possible burn-outs occurring during the test. Your output must be at the beginning of the line.

Sample Input

1
YYYYNYY
2
NNNNNNN
NNNNNNN
2
YYYYYYY
YYYYYYY
3
YNYYYYY
YNYYNYY
NYYNNYY
3
YNYYYYN
YNYYNYN
NYYNNYN
3
YNYYYYN
YNYYNYN
NYYNYYN
4
YYYYYYY
NYYNNNN
NNYYYYN
NNNYNNN
3
NNNNNNN
YNNNNNN
NNNNYNN
0

Sample Output

MATCH
MATCH
MISMATCH
MATCH
MATCH
MISMATCH
MATCH
MATCH

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-13 14:32
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统