帮忙看一看有没有出错的地方,总是wa
Delete NumberTime 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");
}
}
}
帮忙看一看那里漏了?