Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不用2维数组直接输出的小代码

Posted by Eov_Second at 2016-12-06 17:10:06 on Problem 2039
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator