0

Hi Guys,
sorry for asking many questions, but i'm a newby to C++.

I generated 2 dimensional array with number of rows defined by a user and number of columns set to 5. But I can't figure out how to substitute duplicating values with new unique ones.
I can't use binary search, because it will then be used for comparison with other corresponding numbers.
I'm also not quite well familiar with the shaffling. Is there a way to make it with linear search?

I would appreciate any advice.
Thanks

#include <iostream>
#include <cstdlib>
#include<iomanip>
#include<fstream>
#include <ctime>

using namespace std;

int main{

int random[7][5];
int choice;
int temp;
int results=0;

cout <<"Enter you choice\n"<<endl;
cin>> choice;
cout<<endl;

srand((unsigned)time(0)); 
int t=0;
for (;t<choice;)
{    
for(int i=0; i<1; i++)
{ 
temp = (rand()%46)+1; 
         
results = searchList(random [i],t,temp);
	if(results == -1)
	{
		temp=random[t][i];
		cout << random[t][i] << endl;
                i++;
	}
	else {
	i--;	
	}

}
t++;
}
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by phorce
0

Hello, I dunno if this helps but noticed a few things in your code:

int main{

-- Does this even compile?

for (;t<choice;)

-- What are you trying to do here?

results = searchList(random [i],t,temp);

-- I think you're trying to store "results" from a function, but, where is the function "searchList"?

:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.