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

Re:为啥这份代码C++WA G++AC 谁能解释一下呢

Posted by liyaonan at 2009-07-23 10:27:46 on Problem 3438
In Reply To:为啥这份代码C++WA G++AC 谁能解释一下呢 Posted by:yizer at 2009-03-28 09:08:12
> /*
> PKU 3438
> Author : Yizer
> */
> #include <iostream>
> #include <algorithm>
> #include <functional>
> #include <vector>
> #include <queue>
> #include <stack>
> #include <map>
> #include <set>
> #include <string>
> #include <cmath>
> using namespace std;
> 
> int main()
> {
> 	#ifndef ONLINE_JUDGE
> 	freopen("data.in","r",stdin);
> //	freopen("data.out","w",stdout);
> 	#endif
> 	char line[1000];
> 	gets(line);
> 	int nCase;
> 	sscanf(line,"%d",&nCase);
> 	while (nCase--)
> 	{
> 		gets(line);
> 		int pre = line[0] , cnt = 1 , len = strlen(line);
> 		for (int i=1;i<len;i++)
> 			if (line[i]==pre)
> 				cnt++;
> 			else
> 			{
> 				printf("%d%c",cnt,(char)pre);
> 				pre = line[i];
> 				cnt = 1;
> 			}
> 			printf("%d%c\n",cnt,(char)pre);
> 	}
> 	#ifndef ONLINE_JUDGE
> //	system("pause");
> 	while(1);
> 	#endif
> 	return	0;
> }
> 
> 常遇到这种问题
> 有的是涉及实数精度的
> 但是这个全是整数运算的为什么还错
char line[1000];
是不是数组开小了?

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