Re: [問題] 掃描陣列的問題

看板C_Sharp (C#)作者 (信)時間11年前 (2014/04/01 03:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
※ 引述《APE36 (PT鄉民)》之銘言: : int main() : { : int array_a[5]={11,22,33,22,44}; : int array_b[5]={11,22,33,22,44}; : int array_c[5]; : int i,j; : for(i=0;i<5;i++) : { : for(j=0;j<5;j++) : { : if(array_a[i]!=array_b[j]) : { : printf("%d\n",array_a[i]); : break; : } : } : } : return 0; : } : 假如題目我判斷相同的才輸出,但是重複過的不輸出 : 這程式哪裡有需要做判斷呢? : 覺得因該判斷式都已經做完了 : 只不過重複的值 沒做出正確的判斷 List<int> arrA = new List<int>{3,3,4,5,6}; List<int> arrB = new List<int>{3,3,4,5,6}; for(int i=0;i<arrA.Count;i++) { bool find = false; int idx = 0; while(idx<arrB.Count) { if(arrA[i] == arrB[idx]) { if(!find) { find = true; Console.WriteLine(arrB[idx]); } arrB.RemoveAt(idx); } else idx++; } } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.240.239.100 ※ 文章網址: http://www.ptt.cc/bbs/C_Sharp/M.1396294876.A.BA0.html
文章代碼(AID): #1JESJSkW (C_Sharp)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
文章代碼(AID): #1JESJSkW (C_Sharp)