#include<stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=5;j++)
{
if(i%2==0)
{
if(j==1)
{
printf(" %d",i+1);
}
else
printf(" %d",i);
}
else
{
if(j==5)
{
printf(" %d",i+1);
break;
}
else
{
printf(" %d",i);
}
}
}
printf("\n");
}
return 0;
}
input 10
output
1 1 1 1 2
3 2 2 2 2
3 3 3 3 4
5 4 4 4 4
5 5 5 5 6
7 6 6 6 6
7 7 7 7 8
9 8 8 8 8
9 9 9 9 10
11 10 10 10 10
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=5;j++)
{
if(i%2==0)
{
if(j==1)
{
printf(" %d",i+1);
}
else
printf(" %d",i);
}
else
{
if(j==5)
{
printf(" %d",i+1);
break;
}
else
{
printf(" %d",i);
}
}
}
printf("\n");
}
return 0;
}
input 10
output
1 1 1 1 2
3 2 2 2 2
3 3 3 3 4
5 4 4 4 4
5 5 5 5 6
7 6 6 6 6
7 7 7 7 8
9 8 8 8 8
9 9 9 9 10
11 10 10 10 10
No comments:
Post a Comment