| ||||||||||
| 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 | |||||||||
为啥这份代码C++WA G++AC 谁能解释一下呢/*
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;
}
常遇到这种问题
有的是涉及实数精度的
但是这个全是整数运算的为什么还错
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator