[問題] 陣列出現跟前面相同值則重新輸入

看板C_and_CPP (C/C++)作者 (假斯汀)時間16年前 (2009/05/21 03:26), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串1/1
也就是像樂透的程式碼 其中一小部份 printf("Input the number of set you will choose is :"); scanf("%d",&chz_set); for(k=1;k<=chz_set;k++) { for(n_th=1;n_th<=6;n_th++) { printf("the %d-th number of %d-th set you choose is :",n_th,k); scanf("%d",&chz_num[5]); } } 我一開始可以輸入要手選幾組號碼 假設輸入2組 就會開始出現 the 1-th number of 1-th set you choose is 11(鍵入數字) the 2-th number of 1-th set you choose is 22 . . . the 6-th number of 2-th set you choose is 44 以上這些我都順利跑出來了 現在想要加上一些條件:數字相同、大於0、小於50時重選 假設第1組的第1個數字是11 如果在第1組的第3個數字也輸入11 程式就會再重run一次 the 3-th number of 1-th set you choose is 需要再輸入一次 並要考慮多組時的判斷(不同組不影響) 不知這個條件式需要加在哪個地方,才能在每次輸入時都判斷符合條件時 就要重新輸入一次 麻煩大家幫解答,感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.64.84.225 ※ 編輯: SiriusJinn 來自: 61.64.84.225 (05/21 03:30)

05/21 05:29, , 1F
一輸入完馬上判斷是否有>0 & <50 若有,則把該數字存起
05/21 05:29, 1F

05/21 05:29, , 2F
來,每當輸入完一個條件成立的數字,就比對一下已經存好
05/21 05:29, 2F

05/21 05:29, , 3F
數字
05/21 05:29, 3F
文章代碼(AID): #1A55bJ41 (C_and_CPP)
文章代碼(AID): #1A55bJ41 (C_and_CPP)