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两个缺失的单词在控制台输出了。你拿去用吧。
推荐
猜你喜欢
- 落叶阅读题答案
- 岳阳楼记的理解“不以物喜,不以己悲”、“先天下之忧而忧,后天下之乐而乐”和现在人们的观念的不同之处
- 直线y=2x=8与x轴叫于点P,平移直线y=3x,使其过点P,求平移后所得直线的表达式
- 放射与辐射的区别是什么?伦琴/小时又是什么单位,概念是什么?
- 若函数f(x)=f(x+2),x<2 2∧-3,x≥2,则f(-3)的值
- treat everyone or everything equally
- 有一个小物块,置于一个光滑的水平桌面上,一条绳的一端连接此物体,另一端穿过桌面中心的小孔,该物体原以角速度w在距孔为R的圆周上转动,今将绳从小孔缓慢往下拉,则物体
- 氯铂酸盐如何检验铵根,钾离子,钠离子和铯离子,铅离子?