您的工作是整理出现在字符串中的单词列表。单词之间用一个或多个空格隔开。删除所有一个或两个字母长的单词,并确保每个单词之间有一个空格。字符串将只由字母和空格组成。空格不应该出现在输出字符串的开头或结尾。
例子:
inStr = 'our is not to reason why';outStr = 'our not reason why';
这个问题很棘手!最好添加更多的测试用例并重新内核。例如,“aaa bb”
好一个
测试套件
测试状态代码的输入和输出
1失败
inStr = 'our is not to reason why';
outStr_correct = 'our not reason why';
断言(isequal (remove_small_words (inStr) outStr_correct))
outStr =
"我们没有理由"
断言失败。
2失败
生存还是毁灭,这是个问题;
outStr_correct = 'not That the question';
断言(isequal (remove_small_words (inStr) outStr_correct))
outStr =
"不是这个问题"
断言失败。
3失败
他是个肮脏的某某人;
outStr_correct = 'dirty and';
断言(isequal (remove_small_words (inStr) outStr_correct))
outStr =
“脏和“
断言失败。
4通过
inStr = 'oh me oh my';
outStr_correct = ";
断言(isequal (remove_small_words (inStr) outStr_correct))
outStr =
0 * 0空字符数组
这里的断言有什么问题?
不确定,为什么这个失败,传递我的本地MATLAB(版本8.3.0.532 (R2014a))
这对“aaa”不起作用