Pagini recente » Cod sursa (job #3300763) | Cod sursa (job #1798457) | Cod sursa (job #2395622) | Cod sursa (job #701672) | Cod sursa (job #518910)
Cod sursa(job #518910)
#include<fstream>
#define dim 1001
using namespace std;
int main()
{
ifstream fin ("dame.in");
ofstream fout ("dame.out");
int a,n,i,k=0,l,st[dim],aux;
fin>>n;
if(n==1 || n==2)
fout<<"1"<<endl<<"1 1";
else if(n==3)
fout<<"2"<<endl<<"1 1"<<endl<<"2 3";
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[l]=st[l+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;
}
fout<<n<<endl;
for(i=1;i<=n;i++)
{
fout<<i<<" "<<st[i]<<endl;
}
}
return 0;
}