> 英语 >
c# 求提供思路,我str1“i want to eat an apple” str2"i want eat apple"用什么方法可以识别出str2少了
to 和an两个单词
人气:330 ℃ 时间:2020-03-24 23:12:38
解答
string str1="i want to eat an apple"; string str2="i want eat apple"; Console.WriteLine(str1.Length); Console.Write(str2.Length); Console.ReadKey();第一个长度是...谢谢,那我怎么知道少了什么呢。。。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两个缺失的单词在控制台输出了。你拿去用吧。
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版