| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 874 人关注过本帖
标题:帮忙看一看有没有出错的地方,总是wa
取消只看楼主 加入收藏
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
结帖率:73.91%
收藏
已结贴  问题点数:20 回复次数:7 
帮忙看一看有没有出错的地方,总是wa
Delete Number

Time Limit:1000MS  Memory Limit:65536K
Total Submit:694 Accepted:129

Description

Given 2 integer number n and m. You can delete m digits from the number n, then number n changes to a new number n1. Tell me how to delete the number, you can get the smallest one.
For example,


 m: 1        n: 1456

 n1 may be 145, 156, 146, 456

 the smallest one is 145. Then n1 should be 145.

Input

The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case consists of one single line containing two integer number m(1 <= m <= 1000), and n(1 <= n < 101000).

Output

Your program must output a single line for each test case. The line should contain the number n1.

Sample Input


1
1 1456
Sample Output


145
Hint

if the number is 000345 you should output 345

Source

yhr






#include<stdio.h>
main()
{
    char n,j;
    int z;
    long m,i,k,g,f,c;
    long str[10];
    while(scanf("%d",&z)!=EOF)
      {
          for(c=1;c<=z;c++)
      {
         f=0;
         for(i=1;i<=9;i++)
         {
             str[i]=0;
         }
         scanf("%d",&m);
         while((n=getchar())!='\n')  /*输入的是字符*/
        {
          for(i=1;i<=9;i++)
          {
            j=i+48;
            if(n==j)
            {
                str[i]++;  /*计数每个字符的个数*/
                break;
            }
          }
          f++;
         }
         g=1;
         for(i=1;i<=9&&g<f-m;i++)
        {
          if(str[i]!=0)
          {
             for(k=1;k<=str[i]&&g<f-m;k++)
             {
                printf("%d",i);/*从1开始输出,直到刚好删除m个数为止*/
                g++;
              }
           }
         }
         printf("\n");
      }
      }
}



帮忙看一看那里漏了?
搜索更多相关主题的帖子: test 
2011-05-08 20:52
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 2楼 ppfly
恩?什么地址?不明白唉
2011-05-08 21:13
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 5楼 ppfly
还是runerror
2011-05-08 21:48
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
恩。http://acm.zstu.
2011-05-08 22:03
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 7楼 ppfly
第2511题
2011-05-08 22:04
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 13楼 fane
好像不明白,你这个不能输出删除k位后是n-k位中是最小的
2011-05-09 09:45
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 16楼 fane
错了,按你的例子,最小应该是124,而不是127
2011-05-09 12:03
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 19楼 fane
但是主要要换位,求最小值的
2011-05-09 12:34
快速回复:帮忙看一看有没有出错的地方,总是wa
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012211 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved