答题时间: 2015-04-11 11:44:28
判题时间: 2015-04-11 11:44:31
运行时间: 32MS
运行内存: 1204.0KB
答题结果: 正确
测试用例结果:
测试用例数量 5
失败数量 0
异常数量 0
编译信息: OJ.c
E:\Project\\\solution\p3719\s1660670\source\OJ.c(49) : warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
e:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(295) : see declaration of 'scanf'
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/stack:16777216
/out:E:\Project\\\solution\p3719\s1660670\source\OJ.exe
E:\Project\\\solution\p3719\s1660670\source\OJ.obj
SourceMonitor结果:
方法名称 圈复杂度 语句数 最大嵌套深度 调用次数
del_min() 8 18 3 2
main() 2 11 2 2
PC-Lint信息: 工具未运行
CPP-Check信息: 工具未运行
SIM检测结果:
solution\p3719\s1660670\source\OJ.c consists for 17 % of target\p3719\s1424160\zpSZ6584SA_OJ.c material
Infusion信息: 工具未运行
//=======================以下是被检查代码:
功能:删除字符串中出现次数最少的字符
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
char* del_min(char* str, int str_len)
{
int hash[256] = {0};
int min = 0x7fffffff;
int i = 0;
int j = 0;
char *str_new = NULL;
str_new = (char*)malloc((str_len+1)*sizeof(char));
if(NULL == str_new)
return NULL;
memset(str_new,0,(str_len+1)*sizeof(char));
for(i = 0; i < str_len; i++)
{
hash[str[i]]++;
}
for(i = 0; i < 256; i++)
{
if(hash[i] < min && hash[i] != 0)
min = hash[i];
}
for(i = 0,j = 0; i < str_len; i++)
{
if(hash[str[i]] != min)
{
str_new[j++] = str[i];
}
}
return str_new;
}
int main(void)
{
char str[1000];
char *str_new = NULL;
char *s = str;
memset(str,0,sizeof(str));
scanf("%s", s);
str_new = del_min(s,strlen(s));
if(NULL == str_new)
return -1;
printf("%s\n", str_new);
free(str_new);
return 0;
}
8634



被折叠的 条评论
为什么被折叠?



