Problem1:數字刪除(12%)
Solomon
posted @ 2010年8月14日 03:13
in 98程式設計模擬試題
, 1191 阅读
Problem1:數字刪除(12%)
給 n 個數字,請你在這 n 個數字中,找出所有重覆出現的數字,並把它刪除。最後計算刪除後剩餘的數字個數。輸入說明:第一行的數字,表示有幾組測試資料,第二行開始即為第一筆測試資料,每行不會超過100 個數字,每個數字之間用一個空白做為區隔,數字的範圍為[0, 10000]間的整數。輸出說明:對輸入的每筆測試資料,分別輸出刪除完後剩下的數字個數。輸入範例:21 2 3 4 5 6 7 8 9 2 12 4 6 8 10輸出範例:75
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim fileContents As String fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Test1.txt") Dim row() = Split(fileContents, vbNewLine) Dim str1 = "" For i As Integer = 1 To Val(row(0)) Dim aList = New ArrayList If row(i) = "" Then Exit For Dim d() = Split(row(i), " ") For j As Integer = 0 To d.Length - 1 If alist.Contains(d(j)) = False Then '若不存在則加入 alist.Add(d(j)) Else '否則從aList中刪除 aList.Remove(d(j)) End If Next str1 = str1 & alist.Count & vbNewLine Next My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\result1.txt", str1, False) End End Sub End Class
2022年12月01日 20:21
If you are given n numbers, you can find all the repeated numbers among them and delete them. To do this, you can use a gout icd 10 standard for loop to check each number against all the other numbers. If you find a match, you can delete that number.
2022年12月24日 15:43
Programming mock exam questions can be found online or in textbooks. They can be difficult, so it is best to have a solid Safe Global Payment Processing Solution understanding of the material before taking the exam.