create a file and fill an 6x6 array with random +ev integers

guys ..

help !!

i`m really sucking @this:`c

i need the help and really fast please...>.<"

this is my code!!

but it`s not working @ all ~(OoO)~


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <fstream>
#include <cstdlib>

#include <ctime>

using namespace std;

int main () 
{

	ofstream fout("datain.txt",ios::out);

	int array[6][6];
	int i, j;
	int random;
unsigned seed = time(0);
	srand(seed);

	random=0+rand()%100;
	
	while(random%2==0)
	{
		for (i=0;i<6;i++)
			for(j=0;j<6;j++){
				cout<<(array[i][j]=random)<<" ";
			cout<<endl;
			}

			random++;
}
fout.close();
  return 0;
}
But what's going wrong? It would be nice to have some more details.
... and really fast - please :-)
tcs
im so so sorry,, i know im late .. i actually solved did ,, but its just now tat i have time to post the solution..

so here is my code!!:)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

#include <ctime>

using namespace std;

int main () 
{

	ofstream fout("datain.txt",ios::out);

	if ( !fout) 
	{  // overloaded ! operator
		cerr << "File could not be opened" << endl;

		exit( 1 );
	}


	int array[6][6];
	int i, j;
	int random;
unsigned seed =( time(0));
	srand(seed);

	random=0+rand()%100;
 
  for(i=0;i<6;++i)
	  for(j=0;j<6;++j)
	  {
	  array[i][j]=random=0+rand()%100;
	  }

	  for(i=0;i<6;++i)
	  {
		  for(j=0;j<6;++j)
		  {
			  cout<<setw(4)<<array[i][j];
			  fout<<setw(4)<<array[i][j];

		  }
		  cout<<endl;

	  }
		  

fout.close();

  return 0;
}

/*
  12  63  25  84  70   8
  31  16  60  78  65  32
  71  80  14  34   2  46
  16  94  28  54  66  65
  65  48   2  85  90   7
  71  47  55  33  97   4
Press any key to continue
*/


so yeay
Concratulation!!
\( ^.^")/thank yew~~~ it`s good for a beginner like me.. but can you please help me with my second question i`m stuck with >>? i just have posted it
tcs
Last edited on
Topic archived. No new replies allowed.