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

Re:先把input的字符串存入一个二维数组,然后再输出~~晕,可是怎么会错了呢?请大侠指点一下啊(附代码)

Posted by bushiniao at 2006-11-13 21:53:19 on Problem 2039
In Reply To:先把input的字符串存入一个二维数组,然后再输出~~晕,可是怎么会错了呢?请大侠指点一下啊(附代码) Posted by:304988557 at 2006-09-13 23:41:37
> #include<iostream.h>
> #include<string.h>
> #include <stdio.h>
> #include<math.h>
> int main()
> {
> 	int i,j,k,n,row,col;
> 	char s1[201];
> 	char s2[21][21];
> 	while(cin>>col)
> 	{
> 		if(col==0) break;
> 		gets(s1);
> 		n=strlen(s1);
> 		row=n/col;
> 		for(i=0;i<row;i++)
> 		{
> 			if(i%2==0)
> 			{
> 				j=0;
> 				while(j<col)
> 				{
> 					for(k=i*col;k<(i+1)*col;k++) { s2[i][j]=s1[k]; j++; }
> 				}				
> 			}	
> 		    else
> 			{
> 				j=0;
> 				while(j<col)
> 				{
> 					for( k=((i+1)*col-1) ; k>=i*col; k--) { s2[i][j]=s1[k]; j++; }
> 				}			
> 			}
> 			
> 		}
> 		for(j=0;j<col;j++)
> 		{
> 			for(i=0;i<row;i++)
> 			{
> 				cout<<s2[i][j];
> 
> 			}
> 		}
> 		cout<<endl;
> 
> 
> 	}
> 
>     return 0;
> }

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