#include <stdio.h>#include <stdlib.h>#include <stdbool.h>int group[10];bool connected(int,int);void reunion(int,int)int main(){?? ?int i,check1,check2;?? ??? ?for(i=0;i<=9;i++){?? ??? ?group[i]=rand()%10;??? }??? for(;;){?? ??? ?scanf("%d %d",check1,check2);?? ??? ?if(!(connected(group[check1],group[check2]))){?? ??? ???? reunion();?? ??? ??? ?}?? ??? ??? ?}?? ?}bool connected(i,j){?? ?return i==j;}void reunion(i,j){?? ?group[i]=group[j];?? ?printf("succeed union");}
1 回答
已采納

onemoo
TA貢獻883條經驗 獲得超454個贊
scanf 后面參數是要接受輸入的變量的地址。所以不能直接傳入變量,而是要取地址后傳入:
scanf("%d %d", &check1, &check2);
- 1 回答
- 0 關注
- 1996 瀏覽
添加回答
舉報
0/150
提交
取消