0

## c語言提問

``````#include <stdio.h>
int main(void){
int num[6];
int i,k;
int again;
int out=0;
again=1;
while(again==1){
again=0;
printf("請輸入號碼\n");
for ( i = 0; i < 6; i++){num[i]=0;}
scanf("%d,%d,%d,%d,%d,%d",&num[0],&num[1],&num[2],&num[3],&num[4],&num[5]);
for ( i = 0; i < 6; i++){
for (k = 0; k<i ; k++){
if (num[i]==num[k]){
printf("輸入重複,重新輸出\n");
out=1;
again=1;
break;
}
}
if(out){break;}
}
if(again){continue;}
}

return 0;
}****
``````

EN iT邦研究生 2 級 ‧ 2021-07-10 00:11:14 檢舉

haward79 iT邦新手 3 級 ‧ 2021-07-10 00:59:54 檢舉

(1) 邏輯
(2) 變數
(3) 運算元、運算子（operand & opera）

### 3 個回答

0
uobik
iT邦新手 4 級 ‧ 2021-07-10 06:36:05

``````		for ( i = 0; i < 6; i++){
printf("i=%d，滿足條件i<6，執行第一個迴圈內容\n",i);
for (k = 0; k<i ; k++){
printf("i=%d，k=%d，滿足條件k<i，執行第二個迴圈內容\n",i,k);
if (num[i]==num[k]){
printf("輸入重複,重新輸出\n");
out=1;
again=1;
break;
}
}
if(out){break;}
}
``````

0

iT邦大師 1 級 ‧ 2021-07-10 08:19:47
``````for (k = 0; k<i ; k++)
``````

0

iT邦大神 1 級 ‧ 2021-07-11 23:04:03

1.N2 vs N1
2.N3 vs N2, N3 vs N1
3.N4 vs N3, N4 vs N2, N4 vs N1
4.N5 vs N4, N5 vs N3, N5 vs N2, N5 vs N1
5.N6 vs N5, N6 vs N4, N6 vs N3, N6 vs N2, N6 vs N1