hdu 1106 排序 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1106

      这个题目一开始以为是水题,就想着用来轻松轻松,谁知道改得我想吐!!

      除了discuss 中的数据外,还加上这两组,一般就能过了:001568970056   5551235555789

     

 1 #include <iostream>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 const int maxn = 1000 + 10;
 7 char s[maxn], t[maxn];
 8 int a[maxn];
 9 
10 int main()
11 {
12     int i, l, f, tl, tmp, len;
13     while (gets(s))
14     {
15         len = strlen(s);
16         tmp = tl = l = 0;
17         for (i = 0; i < len; i++)
18         {
19             f = 0;
20             while (s[i] == '5' && i < len)  // 过滤5
21             {
22                 i++;
23                 f = 1;
24             }
25             if (f)
26                 i--;
27             while (s[i] != '5' && i < len)
28                 t[tl++] = s[i++];
29             if (i == len)  // 最后无5结束
30             {
31                 t[tl] = '