c# 求提供思路,我str1“i want to eat an apple” str2"i want eat apple"用什么方法可以识别出str2少了
to 和an两个单词
人气:278 ℃ 时间: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两个缺失的单词在控制台输出了。你拿去用吧。
推荐
猜你喜欢
- 一群小朋友乘船过河.如果每条船坐14,那么余12人;如果每条船多做3人,那么正好全部过河.一共又多少个小朋友过河?一共有多少条船?
- They could not find any strange things when they came into the room.同义句转换
- 两个蟹将和四个虾兵能打扫龙宫的十分之三,八个蟹将和十个虾兵在同样的时间里能打扫完龙宫.如果但让蟹将去打扫与让虾兵去打扫,各要多少个蟹将与虾兵?
- 计算下列各题,注意使用简便算法.
- 暗香是什么意思
- He has been in power ten years since he came to power.
- 一串数按规律排列如下:1,2,3,2,3,4,3,4,5,4,5,6,5,6,7.从第一个数算起,前2009个数的和是多少?
- x的平方+nx+3与 x的平方-3x+m的乘积中不含x的平方和x的立方的项求m和n的值