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

LS正解

Posted by Belldandy at 2013-11-08 16:21:02 on Problem 3438
In Reply To:Re:gets( ) WA , cin AC 为什么呢?嚎 Posted by:kingsword at 2011-08-18 10:56:28
> 如果想用gets() 要把上次cin的回车用getchar()吸收掉 明白?
> #include <iostream>
> #include <cstdio>
> using namespace std;
> int main()
> {	
>     int n1,i,j;char c[1000],p;
> 	cin>>n1;
>         getchar();
> 	for(int k=0;k<n1;k++)
> 	{
> 		gets(c);
> 		j=1;
> 		for(i=1,p=c[0];i<strlen(c);i++)
> 			if(c[i]==p)
> 				j++;
> 			else
> 			{
> 				cout<<j<<(int)p-48;
> 			    j=1;
> 		     	p=c[i];
> 			}
>         cout<<j<<(int)p-48<<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