CSE102 – C程式設計實習 雙周測驗 (Solution)

$ 30.00
Category:

Description

2023.11.09
1. (50%) Let the user to input two integers, N and M, representing an N * M two-dimensional matrix. Next, generate two two-dimensional matrices (, and ,). The elements in these matrices are random 0s and 1s, and then multiply these two matrices.
Finally, output the result of the operation.

Noted:

a. Please use continuous input.
b. The constraints are that 1 < N, M < 10.
c. if N and M exceed this range, print “Invalid Input: N and M must be between 2 and 9.”.
e. Terminate the program when the input is 0 0.

2. (50%) Read a sorted array of integers from standard input, where the values are input in ascending order until End-of-file is reached. The array’s length will not exceed 1024 integers. Use binary search to find the value in the sorted array that is closest to 10,000. If there are two values equally close to 10,000, output the larger one. Noted:
a. This problem must be solved using binary search.
b. Read signed integers from standard input until End-of-file.
c. Output the value closest to 10000, followed by a newline. If there are two equally close values, output the larger one.
d. When only input one ‘0’,you should output “Finish! ” and shut down.
Hint:Maybe you will need to use memset(Array, 1024, ”)

The print format must be like the picture above.

Test Data
1. Input:100 200 300 400 500 600 700 800 900
10000
Output:10000
2. Input:9000 9500 9800 9900 10000 10001 Output:10000
3. Input:8000 8500 9000 9500 10000 10500 Output:10000
4. Input:1 2 3 4 5 6 7 8 9 10 Output:10
5. Input:9998 9999 10001 Output:10001
6. Input:9990 10240 Output:9990
7. Input:0 Output:Finish!
8. Input:100 500 900 1400 1900 2400 2900 3400
3900 4400 4900 5400 5900 6400 6900 7400
7900 8400 8900 9400 9900 10400 10900 11400
11900 12400 12900 13400 13900 14400 14900
15400 15900 16400 16900 17400 17900 18400
18900 19400 19900 20400 20900 21400 21900 22400 22900 23400 23900 24400 24900 25400 25900 26400 26900 27400 27900 28400 28900
29400 29900 30400 30900 31400 31900 32400
32900 33400 33900 34400 34900 35400 35900
36400 36900 37400 37900 38400 38900 39400
39900 40400 40900 41400 41900 42400 42900 43400 43900 44400 44900 45400 45900 46400 46900 47400 47900 48400 48900 49400 49900
50400 50900 51400 51900 52400 52900 53400
53900 54400 54900 55400 55900 56400 56900
57400 57900 58400 58900 59400 59900 60400
60900 61400 61900 62400 62900 63400 63900 64400 64900 65400 65900 66400 66900 67400 67900 68400 68900 69400 69900 70400 70900 71400 71900 72400 72900 73400 73900 74400
74900 75400 75900 76400 76900 77400 77900
78400 78900 79400 79900 80400 80900 81400
81900 82400 82900 83400 83900 84400 84900
85400 85900 86400 86900 87400 87900 88400
88900 89400 89900 90400 90900 91400 91900 92400 92900 93400 93900 94400 94900 95400 95900 96400 96900 97400 97900 98400 98900 99400 99900 100400 100900 101400 101900
102400 102900 103400 103900 104400 104900
105400 105900 106400 106900 107400 107900
108400 108900 109400 109900 110400 110900 111400 111900 112400 112900 113400 113900 114400 114900 115400 115900 116400 116900
117400 117900 118400 118900 119400 119900
120400 120900 121400 121900 122400 122900
123400 123900 124400 124900 125400 125900
126400 126900 127400 127900 128400 128900 129400 129900 130400 130900 131400 131900 132400 132900 133400 133900 134400 134900
135400 135900 136400 136900 137400 137900
138400 138900 139400 139900 140400 140900
141400 141900 142400 142900 143400 143900
144400 144900 145400 145900 146400 146900 147400 147900 148400 148900 149400 149900 150400 150900 151400 151900 152400 152900
153400 153900 154400 154900 155400 155900
156400 156900 157400 157900 158400 158900
159400 159900 160400 160900 161400 161900
162400 162900 163400 163900 164400 164900 165400 165900 166400 166900 167400 167900 168400 168900 169400 169900 170400 170900
171400 171900 172400 172900 173400 173900
174400 174900 175400 175900 176400 176900
177400 177900 178400 178900 179400 179900
180400 180900 181400 181900 182400 182900 183400 183900 184400 184900 185400 185900 186400 186900 187400 187900 188400 188900
189400 189900 190400 190900 191400 191900
192400 192900 193400 193900 194400 194900
195400 195900 196400 196900 197400 197900
198400 198900 199400 199900 200400 200900
201400 201900 202400 202900 203400 203900 204400 204900 205400 205900 206400 206900 207400 207900 208400 208900 209400 209900
210400 210900 211400 211900 212400 212900
213400 213900 214400 214900 215400 215900
216400 216900 217400 217900 218400 218900
219400
Output:9990

Reviews

There are no reviews yet.

Be the first to review “CSE102 – C程式設計實習 雙周測驗 (Solution)”

Your email address will not be published. Required fields are marked *