作业帮 > 英语 > 作业

c# 求提供思路,我str1“i want to eat an apple” str2"i want eat apple

来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:英语作业 时间:2024/06/25 19:12:28
c# 求提供思路,我str1“i want to eat an apple” str2"i want eat apple"用什么方法可以识别出str2少了
to 和an两个单词
c# 求提供思路,我str1“i want to eat an apple” str2
string str1="i want to eat an apple";
string str2="i want eat apple";
Console.WriteLine(str1.Length);
Console.Write(str2.Length);
Console.ReadKey();
第一个长度是22
第二个是16.
str2不就少了吗?
再问: 谢谢,那我怎么知道少了什么呢。。。
再答: string[] aa; string[] bb; string str1="i want to eat an apple"; string str2="i want eat apple"; aa = str1.Split(' '); bb = str2.Split(' '); int count=0; foreach(string c in aa) { count = 0; for (int i = 0; i < bb.Length; i++) { if (c != bb[i]) { count++; } if (count == bb.Length) { Console.Write(c+' '); } } } Console.ReadKey(); 已经把to和an两个缺失的单词在控制台输出了。你拿去用吧。