//help please, i just want the program to tell me
// if there is a repeated # on the string
// is always true or false
#include <iostream>
using namespace std;

const int ARRAY_SIZE = 5;

bool valid2(const int list1[]);
void fillArray(int list1[], int ARRAY_SIZE);
void printArray(const int list1[], int ARRAY_SIZE );

int main()
{   
int list1[ARRAY_SIZE];
  bool found;


cout << "enter a number" << endl;

     fillArray(list1, ARRAY_SIZE);

    printArray(list1, ARRAY_SIZE);
     cout << endl;

      valid2(list1);

  if (!found)
  cout << "repeat number" <<endl;
  else 
  cout << " " <<endl;
  system("pause");
} 

bool valid2(const int list1[])
{
     int tmp;
     for(int i=0;i<ARRAY_SIZE;i++)
     {
             tmp=list1[i];
             for(int j=0;j<ARRAY_SIZE;j++)
             {
                if(list1[j]==tmp && (j>i))
                  {
                  return false;
                  }
             }
     }
     return true;

}

void fillArray(int list1[], int ARRAY_SIZE )
{
     int index;
     for (index = 1; index < ARRAY_SIZE; index++)
         cin >> list1[index];
}

void printArray(const int list1[], int ARRAY_SIZE )
{
     int index;
     for (index = 1; index < ARRAY_SIZE; index++)
         cout << list1[index];
}

Edited 3 Years Ago by Dani: Formatting fixed

Comments
posts >= 10 && !usesCodeTags => -ve rep
This article has been dead for over six months. Start a new discussion instead.