现在在上机考试啊,你可以帮我调试一下然后把代码发过来吗?如果可以那就太感谢了。帮帮忙吧
追答你的是winform还是控制台的
追问控制台的
追答string str = Console.ReadLine();
string[] strarray = str.Split(' ');
for (int i = 0; i < strarray.Length;i++ )
{
for (int j =1;j<strarray.Length;j++ )
{
if (strarray[j - 1].Length < strarray[j].Length)
{
string temp = strarray[j - 1];
strarray[j - 1] = strarray[j];
strarray[j] = temp;
}
}
}
Console.WriteLine(strarray[0]);
这个是我把分割后的字符串做了个长度的排序,然后最长的放在第一位,最后输出的,分割条件是空格,没有考虑相同长度的单词
控制台的
追答上面函数的调用:
Console.WriteLine("请输入一个句子:");
Console.Write(MaxLengthWord(Console.ReadLine()));
Console.ReadKey();
请问那个函数的调用是插在哪里的呀?调试不出来呢
追答放在 main 里面