[問題] 陣列出現跟前面相同值則重新輸入
也就是像樂透的程式碼
其中一小部份
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
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
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章