Я работаю над программой, которая удаляет дубликаты из массива. Здесь я использую три функции: одну для приема входных данных, таких как размер и число, вторую функцию для удаления дубликатов и возврата числа без дубликатов, а третью функцию просто в отчете показаны размер и новое число, но у меня возникла проблема. Я не знаю, на каком этапе я думаю в отчете, или Филипп допустил ошибку:
В функции 'int main()': недопустимое преобразование из 'int*' в 'int', инициализация аргумента 1 из 'void report(int, int)'
#include
using namespace std;
const int size = 100;
void phillip(int[], int & );
/* Preconditions: Array of base type in declared and int varuable declared
postconditions: the array is filled with values supllied by the user at
the keybord. the user is assked how many values they want - this value is
given to the second argument.
*/
int remdubs(int[], int noel);
/* Preconditions: An array of basetype int that has noel values.
postconditions: The number of unique elemts in the array is returned. The function removes all dubplicates inside the array.
*/
void report(int s, int d);
int main()
{
int ruby[size];
int numele, numuniq;
phillip(ruby, numele);
numuniq = remdubs(ruby, numele);
report(ruby, numuniq);
return 0;
}
void phillip(int[], int& )
{
int s;
cout > s;
cout > num;
}
}
int rembups(int sapphire[], int noel)
{
for (int i = 0; i < noel; i++)
{
for (int j = i + 1; j < noel; j++)
{
if (sapphire == sapphire[j])
{
for (int k = j; k < noel; k++)
sapphire[k] = sapphire[k + 1];
noel--;
j--;
}
}
}
return noel;
}
void report(int s, int d)
{
cout
Подробнее здесь: https://stackoverflow.com/questions/235 ... m-an-array
Написать программу для удаления дубликатов из массива ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение