我创建了一组算法,它接受字符串向量的输入,检查是否有任何字符串出现不止一次:如果是,则从向量中删除所有额外出现的字符串,然后输出新的“较轻”数组裁员。
它很好用,除了现在我要让它不区分大小写;我试图简单地将toupper()
std 函数添加到==
比较语句中,但它似乎不起作用。
我对 Java 有更熟悉的背景,并且正在尝试学习 C++。
有人可以告诉我如何更正我的语法吗?
// Output old list.
cout << endl << "==========\nOld list:\n==========";
for (int i = 0; i < count; i++) {
cout << endl << list[i];
}
cout << endl << endl;
// Check uniqueness.
for (int i = 0; i < count; i++)
for (int j = i+1; j < count; j++) {
if (toupper(list[i]) == toupper(list[j])) {
list[j] = "";
count--;
}
}
// Output new list.
cout << endl << "==========\nNew list:\n==========";
for (int i = 0; i < count; i++) {
cout << endl << list[i];
}
cout << endl << endl;