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

交换的时候多了一个“=”!!!

Posted by raymond8023 at 2007-11-14 21:42:13 on Problem 2039
In Reply To:请教:两份算法完全相同的代码,区别在哪里?? Posted by:qiqilrq at 2007-01-25 23:51:29
> //  by qiqilrq, wrong answer
> 
> #include <iostream>
> #include <string.h>
> using namespace std;
> 
> char t[210];
> int main()
> {
> 	int i,j,row,col;
> 	while (cin>>col && col>0)
> 	{
> 		cin>>t;
> 		row=strlen(t)/col;
> 		for(i=0;i<row;i++)
> 		{
> 			if(i%2==1)	//row is odd
> 			{
> 				for(j=0;j<=col/2;j++)
> 				{
>                 	char tmp=t[j+i*col];
>                     t[j+i*col] = t[col-j-1+i*col];
>                     t[col-j-1+i*col] = tmp;
>                 }
> 			}
> 		}
> //		cout<<t<<endl;
> 		for(i=0;i<col;i++)
> 			for(j=0;j<row;j++)
> 				cout<<t[i+j*col];
> 		cout<<endl;
> 	}
> 	return 0;
> }
> /*
> // by coffeeandtea, accepted
> #include <iostream.h>
> #include <string.h>
> 
> int main() 
> {
> 	int col;
> 	int i,j;
> 	while(cin>>col&&col)
> 	{
> 		char a[207];
> 		cin>>a;//gets(a) get a wa but cin>>a gets AC Why??
> 	    int len=strlen(a);
> 		int row=len/col;
> 		for(i=0;i<row;i++)
> 			for(j=0;j<col/2;j++)
> 			{
> 				if(i%2==1)
> 				{
> 					int temp=a[i*col+j];
> 					a[i*col+j]=a[i*col+col-j-1];
> 					a[i*col+col-j-1]=temp;
> 				}
> 			}
> 			
> 			for(i=0;i<col;i++)
>     			for(j=0;j<row;j++)
>     			{
>     				cout<<a[i+j*col];
>     			}
> 			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