【发布时间】:2012-02-27 08:47:11
【问题描述】:
我目前正在尝试编写一个按字母顺序排列字符串的程序。我有一个错误。就是 minLocation 不接受 2 个参数。我对编程很陌生,谁能给我一个提示,为什么我的这部分代码是错误的?
int minLocation(string list[], int first, int last)
{
int mIndex=first;
int loc = 0;
for (loc = first+1; loc <= last; loc++)
if (list[loc] < list [mIndex])
mIndex = loc;
return mIndex;
void Sort(string slist[],int length)
{
int mIndex;
for (int loc = 0; loc < length-1; loc++)
{
mIndex = minLocation (loc,length-1);
swap (loc, minIndex);
}
}
【问题讨论】:
-
这看起来像 Java - 你能用语言标记,并告诉我们
minLocation是什么?您自己编写的方法,还是库的一部分?无论哪种方式,错误都是说您不正确地调用minLocation- 检查函数签名以了解它应该如何正确调用。
标签: c++ string visual-c++ sorting