The title
Image filtering is to dye all the unimportant pixels in the image into the background color, so that the important parts are highlighted. Given a black and white image, you are asked to replace all pixel colors within a specified range of gray values with a specified color.
Input format: input gives the resolution of an image in the first line, that is, two positive integers M and N (0<M,N≤500), and the end points A and B of the gray value interval to be filtered (0≤A<B≤255), as well as the specified replacement gray value. Then M lines, each line gives the gray value of N pixels, separated by Spaces. All gray values are within the range [0, 255].
Output format: output filtered images as required. That is, output M lines, each line N pixel gray value, each gray value occupies 3 bits (for example, black to be displayed as 000), separated by a space. There must be no extra space at the beginning or end of a line.
Example: 3 5 100 150 0 3 189 254 101 119 150 233 151 99 100 88 123 149 0 255 No blank line is displayed at the end. 003 189 254 000 000 000 233 151 099 000 088 000 000 000 255 There is no blank line at the endCopy the code
Their thinking
M,N,A,B,H = map(int,input().split()) # M,N,A,B,H = map(int, "3 5 100 150 0".split(" ")) zongResList = [] for i in range(M): for j in input().split(): if A <= int(j) <= B: zongResList.append("%03d" % H) else: Zongreslist.append ("%03d" % j) # inputList = List (map(int, input().split())) # # inputList = list(map(int, "3 189 254 101 119".split())) # resList = [] # for j in inputList: # # res = None if A < = int (j) < = B: # # # # 0 escape res up = "{: 0 > 3 d}". The format (int) (H) # res = "% 3 d" % H # else: Format (int(j)) # res = "%03d" % j # # reslist.append (res) # zongresList.append (res) # # zongResList.append(resList) # # print(" ".join(resList)) for i in range(0, len(zongResList),N): print(' '.join(zongResList[i:i+N]))Copy the code