更新时间:2018-11-22 16:18作者:王新老师
输入:“4 - 7” 输出:“-3”
输入:“9 ++ 7” 输出:“0” 注:格式错误
为第一题 19:19-19:36 17分钟
#include
#include
using namespace std;
bool g_flag[26];
void stringFilter(const char *pInputStr, long lInputLen, char *pOutputStr)
{
assert(pInputStr != NULL);
int i = 0;
if (pInputStr == NULL || lInputLen <= 1)
{
return;
}
const char *p = pInputStr;
while(*p != '\0')
{
if (g_flag[(*p - 'a')])
{
p++;
}else{
pOutputStr[i++] = *p;
g_flag[*p - 'a'] = 1;
p++;
}
}
pOutputStr[i] = '\0';
}
int main()
{
memset(g_flag,0,sizeof(g_flag));
char input[] = "abacacde";
char *output = new char[strlen(input) + 1];
stringFilter(input,strlen(input),output);
cout<
delete output;
return 0;
}