一旦上课开始,我就已经在数组上刷新了自己。所以为此我得到了代码,我需要能够在用户输入中找到重复项。任何解决方案?
例: 怎么样: 相反的数字是:5 2 7 6 5 3 9
它应该如何: 相反的数字是:2 7 6 5 3 9
注意:数字相反。
#include <iostream>
using namespace std;
const int ARRAY_SIZE = 1000;
int main()
{
int count;
int number;
int numItems;
int list[ARRAY_SIZE];
count = 0;
cout << "Enter a number (negative number to quit): ";
cin >> number;
while (number >= 0){
list[count] = number;
count++;
cout << "Enter a number (negative number to quit): ";
cin >> number;
}
numItems = count;
cout << "The numbers in reverse order is: ";
for (count = numItems - 1; count >= 0; count--){
cout << list[count] << " ";
}
}