Pagini recente » Cod sursa (job #2631732) | Cod sursa (job #2303325) | Cod sursa (job #1712727) | Cod sursa (job #681849) | Cod sursa (job #490972)
Cod sursa(job #490972)
#include<fstream>
#define NMax 1001
using namespace std;
int main()
{
ifstream f ("dame.in");
ofstream g ("dame.out");
int a,n,i,k=0,l,st[NMax],aux;
f>>n;
if(n==1 || n==2)
g<<"1"<<endl<<"1 1";
else if(n==3)
g<<"2"<<endl<<"1 1"<<endl<<"3 2";
else
{
for(i=2;i<=n;i+=2)
st[++k]=i;
if(n%12==3 || n%12==9)
{
for(l=1;l<k;l++)
st[i]=st[i+1];
st[k]=2;
}
a=k+1;
for(i=1;i<=n;i+=2)
st[++k]=i;
if(n%12==3 || n%12==9)
{
for(i=a;i<k-1;i++)
st[i]=st[i+2];
st[k-1]=1;
st[k]=3;
}
else if(n%12==2)
{
st[a]=3;
st[a+1]=1;
for(i=a+2;i<k;i++)
st[i]=st[i+1];
st[k]=5;
}
else if(n%12==8)
for(i=a;i<=k;i+=2)
{
aux=st[i];
st[i]=st[i+1];
st[i+1]=aux;
}
g<<n<<endl;
for(i=1;i<=n;i++)
{
g<<i<<" "<<st[i]<<endl;
}
}
return 0;
}