代码1

来源:互联网 发布:手机淘宝晒图怎么删除 编辑:程序博客网 时间:2024/05/24 02:26

1.机房位置(二):

#include<iostream>
using namespace std;
int main(){
int T,N,n;
cin>>T;
while(T--){
cin>>N;
if(N%3==0){
n=N/3;
}
else { n=N/3+1;
}
cout<<n<<endl;
}
return 0;
}


2.判断恒等关系:

#include<iostream>
using namespace std;
#define N 6
bool IS_E(int A[N][N])
{
int n,m=0;
for(n=0; n<N; n++)
{
if(A[n][n]==1)//判断矩阵中位于(0,0)(1,1)(2,2)(3,3)(4,4)(5,5) 的赋值是否为1 
m++; 
}
if(m==N)// 矩阵中位于(0,0)(1,1)(2,2)(3,3)(4,4)(5,5) 的赋值都为1时为恒等关系 
return true;
else 
return false;//bool型返回值只能为1或0 

}
int main()
{
int a[N][N];
int i,j;
for(i=0; i<N; i++)
{
for(j=0; j<N; j++)
{
   cin>>a[i][j];
    }
}
cout<<IS_E(a);
return 0;
}


原创粉丝点击