Find Two Numbers with Target Sum


Submit solution

Points: 45 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem type

題目說明

請設計一個程式,讓使用者輸入一組整數陣列和一個目標數字。程式應檢查陣列中的任意兩個數字是否相加等於目標數字,並輸出找到的兩個數字;若沒有找到,輸出No

輸入

第一個整數為陣列大小 n ,接著為 n 個整數,最後一個整數為目標數字。

輸出

如果找到符合條件的數字,輸出兩數。若沒有找到,輸出No

範例輸入 #1

6 2 7 11 15 4 8 12

範例輸出 #1

4 8

範例輸入 #2

5 1 2 5 7 10 10

範例輸出 #2

No

Comments

There are no comments at the moment.