-
help
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
const int size_x = 25;
const int size_y = 2;
int field[size_x][size_y];
void location(int& size_x, int& size_y);
int main ()
{
srand((unsigned) time(NULL));
cout << fixed << showpoint << setprecision(5);
for ( int i = 0; i < size_x; ++i )
{
for (int i = 0; i <size_y; ++i)
{
cout << size_y <<" " << rand() % 10;
cout << size_x <<" " << rand() % 2 << endl;
}
}
return 0;
}
//location function
void location(int& size_x, int& size_y)
{
}
can any one help. the output supose to be only two lines with both size_x and size_y being randome numbers.
-
Can you show an example of the output you're looking for?
-
somthing like:
1 2
2 10
1 15
1 18
2 2
-
Well, what you're doing now is printing size_y (2), then a random number, then size_x (25) and then another random number. It seems like you only need to avoid printing size_y and size_x:
Code:
#include <cstdlib>
#include <ctime>
using namespace std;
const int size_x = 25;
const int size_y = 2;
int field[size_x][size_y];
int main ()
{
srand((unsigned)time(NULL));
for (int i = 0; i < size_x; ++i)
{
for (int i = 0; i <size_y; ++i)
{
cout<< rand() % 10 <<" "<< rand() % 2 <<endl;
}
}
return 0;
}
Though I'm still slightly confused as to the purpose of this, so I could be wrong in my assumption.
-
thanks alot man now i have to do is get it to loop 25 times
and maybe try to use a fucntion to check if the numbers hae been plooted twice and print those numbers.
-
>now i have to do is get it to loop 25 times
It does already. The loop goes from 0 to size_x - 1. Because size_x is 25, there are 25 iterations of the outer loop.