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

gets,cin的区别

Posted by bushiniao at 2006-11-13 21:52:55 on Problem 2039
#include <iostream.h>
#include <stdio.h>
#include <string.h>

int main() 
{
	int col;
	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(int i=0;i<row;i++)
			for(int 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(int 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