| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
LS正解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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator