标签:names scanf ++ else for stream clu strlen math
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
char a[1001];
int now=0;
char b[101][101];
int main()
{
int n,m;
cin>>n;
scanf("%s",&a);
int l=strlen(a);
int hang=l/n;
int i=1;
int j=1;
int fx=1;// 1右 2左
while(i*j!=hang*n)
{
if(fx==1)
{
b[i][j]=a[now];
now++;
j++;
}
else if(fx==2)
{
b[i][j]=a[now];
now++;
j--;
}
if(j==n+1)
{
i++;
fx=2;
}
if(j==1&&i!=1)
{
i++;
fx=1;
}
}
b[i][j]=a[now];
/*for(int i=1;i<=hang;i++)
{
for(int j=1;j<=n;j++)
{
b[i][j]=a[now];
now++;
}
}*/
i=1,j=1;
while(i*j!=hang*n)
{
if(i%2==1)
cout<<b[i][j];
else cout<<b[i][j+1];
i++;
if(i==hang)
{
if(i%2==1)
cout<<b[i][j+1];
i=1;
j++;
}
}
return 0;
}
标签:names scanf ++ else for stream clu strlen math
原文地址:http://www.cnblogs.com/zwfymqz/p/6517089.html