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

哪个大神指下,为什么都是 WA 蛋都碎咯!!! 或者给组BT的数据吧

Posted by smzzw at 2013-02-19 17:06:11 on Problem 1782
#include <iostream>
#include <cstring>
using namespace std;

int main() 
{ 
	char ch[1500]; 
	int i,j; 
	char tmp[1500]; 
	while(cin >> ch) 
	{ 
		int len = strlen(ch); 

		for(i = 0; i < len; i++) 
		{ 
			if(i + 1 < len && ch[i] == ch[i+1]) 
			{ 
				j = 0; 
				tmp[j] = ch[i]; 
				j++; 
				i++; 

				while(j < 9 && i < len && ch[i] == ch[i-1]) 
				{ 
					tmp[j++] = ch[i]; 
					i++; 
				} 
				cout << j << tmp[0]; 
				i--; 
			} 

			else
			{ 
				cout << "1"; 
				while(i < len) 
				{ 
					if(i + 1 < len && ch[i] == ch[i+1])
						break; 
					cout << ch[i];
					if(ch[i] == '1')
						cout << "1"; 
					i++; 
				} 
				i--; 
				cout << "1"; 
			} 
		}
		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