作业帮 > 英语 > 作业

一道acm题,Delete NumberTime Limit:1000MS Memory Limit:65536KTot

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/04/28 22:10:56
一道acm题,
Delete Number
Time Limit:1000MS Memory Limit:65536K
Total Submit:701 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
1
2 178023
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
}
……
if (*(p-1)>*p&&n>0)
{
del (p-1);
n--;
p=str+1;
}
不知道题目在那~没有测试~
再问: 地址:http://acmpj.zstu.edu.cn/JudgeOnline
题目是:2511
还是wa诶,不过178023已经可以了,麻烦再看一下,谢谢。
再答: 1 4 5789123456 #include #include void del (char *p) { while (*p!='\0') { *p=*(p+1); p++; } } int main() { int T;char c; scanf ("%d",&T); while (T--) { char str[1000]; int n; char *p; scanf ("%d",&n); scanf ("%s",str); p=str+1; while (*p!='\0') { if (*(p-1)>*p&&n>0) { del (p-1); n--; p=str+1; continue; } p++; } while (n) { p--; del(p); n--; } while (str[0]=='0') { strcpy(str,str+1); } if(str[0]=='\0')printf("0"); printf ("%s\n",str); } return 0; }