?? array.cpp
字號:
// array.cpp: implementation of the array class.
//
//////////////////////////////////////////////////////////////////////
#include "array.h"
//#define debug
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
array::array(int x)
{
n=x;
head=new int[n*n];
e=false;
for(x=0;x<n*n;x++)head[x]=0;
init();
}
array::array(array &x)
{
n=x.n;
head=new int[n*n];
for(int i=0;i<n*n;i++)
{
*(head+i)=x[i];
}
e=x.e;
}
bool array::xright()
{
int i,j,temp;
j=0,temp=0;
for(i=0;i<n;i++)
{
temp+=head[j];
j+=n+1;
}
if(temp!=(n*n+1)*n/2)return false;
j=n-1,temp=0;
for(i=0;i<n;i++)
{
temp+=head[j];
j+=n-1;
}
return temp==(n*n+1)*n/2;
}
void array::show()
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<setw(4)<<head[i*n+j];
}
cout<<endl;
}
}
bool array::aright()
{
int i,j,temp,temp1;
for(i=0;i<n;i++)
{
temp=temp1=0;
for(j=0;j<n;j++)
{
temp+=head[i+j*n];
temp1+=head[j+i*n];
}
if(temp!=temp1||temp!=(n*n+1)*n/2)return false;
}
return true;
}
void array::update(array&a)
{
for(int i=0;i<n*n;i++)
{
*(head+i)=a[i];
}
}
void lbiao::add(addrs *x)
{
if(head==NULL)
{
head=end=x;
}
else
{
end->next=x;
end=end->next;
}
}
void lbiao::add(addrs &x)
{
if(head==NULL)
{
head=end=new addrs(x);
}
else
{
end->next=new addrs(x);
end=end->next;
}
}
lbiao::~lbiao()
{
while(head!=NULL)
{
end=head;
head=head->next;
delete end;
}
}
bool operator !=(addrs &x,addrs &y)
{
if(x.fir==y.fir)return false;
if(x.fir==y.sec)return false;
if(x.sec==y.fir)return false;
if(x.sec==y.sec)return false;
return true;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -