Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不用2维数组直接输出的小代码int main() { char s[210]; int n,i,j,m,k,q,w[2]; while(scanf("%d",&n)&&n){ scanf("%s",s); m=strlen(s)/n; for(i=0;i<n;i++){ k=i;q=0; // 每次循环下标步进值,就是w[0],w[1]这两个交替 w[0]=2*(n-i)-1; w[1]=2*i+1; for(j=0;j<m;j++){ putchar(s[k]); k+=w[q]; q^=1;//让q01交替 } } putchar(10); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator