预览加载中,请您耐心等待几秒...
1/5
2/5
3/5
4/5
5/5

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

#include<iostream> #include<time.h> usingnamespacestd; voidJudge(); //================================== voidprint() { intA[4][4],A1[4][4];//定義一個矩陣 inti,j,k; inttemp; i=j=4; //隨機生成這個矩陣 srand((unsigned)time(NULL)); cout<<"================================\n" <<"\n~~~~隨機生成一個4乘4的矩陣。~~~~\n"; for(i=0;i<4;i++) { for(j=0;j<4;j++) { A[i][j]=rand()%2; cout<<A[i][j]<<''; } cout<<"\n"; } //判斷自反性 if(A[i][j]==1&&(i=j)) cout<<"\n~~~~~關係矩陣滿足自反性。請輸入:1。~~~\n"; else cout<<"\n~~~~~關係矩陣不滿足自反性。輸入:0。~~~\n" <<endl; //判斷對稱性 if(A[i][j]==1&&A[j][i]==1) cout<<"\n~~~~~關係矩陣滿足對稱性。請輸入:2。~~~\n"; else cout<<"\n~~~~~關係矩陣不滿足對稱性。輸入:0。~~~\n" <<endl; //判斷傳遞性 temp=0; for(k=0;k<4;k++) { temp=temp+A[i][k]*A[k][j]; if(temp>0) { temp=1; A1[i][j]=temp; cout<<"\n~~~~~該關係矩陣滿足傳遞性。請輸入:3。~~~\n" <<endl; break; } else { cout<<"\n~~~~~該關係矩陣不滿足傳遞性。輸入:0。~~~\n" <<endl; break; } } } //==================================== voidmain() { inta,b,c; print();//調用print函數 cout<<"\n請輸入該輸入的數字:\n" <<endl; cin>>a>>b>>c; if(a==1) { if(b==2) if(c==3) cout<<"\n~~~關係矩陣滿足等價關係。~~~\n" <<endl; } else { cout<<"\n~~~關係矩陣不滿足等價關係。~~~\n" <<endl; } }