Forum: C++ Mar 28th, 2008 |
| Replies: 21 Views: 1,318 Thanks for everyones help. I went through it last night and started from scratch. A few points:
I had designated the counter in a for loop, which I didn't want to do. It was there by error. So... |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 #include <fstream.h>
#include <stdlib.h>
#include <assert.h>
int i, j;
int matrix[10000][5] = {0}; //Define a matrix with a maximum of 100 rows and 6 columns
int... |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 yeah i tried changing that part to different combinations of code that mean the same thing... no change though :( |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 That asseret didnt work either... just doubles 10 and 11, leaving 00 as zero.
Yeah the counters are there... they're just not working :( |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 Oh, and I tried the above suggestion, but that didn't work either. Still weird numbers. |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 Hate to do this vernon but...
counters array??? |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 Hi. I tried that but it still didn't work. An example of the output:
Desired number of repeats = 3
1 0 0 0 1
2 0 0 1 1
3 0 0 0 1
4 1 2 1 1
5 1 2 1 1 |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 Ok, well forgetting that comment (I have to excess comment to submit it to my markers, they're really strict on it)...
I'm not missing the 1-0 count. It is there if you look again.
The counting... |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 ok guys... i attempted a counter of my own accord. Code as follows:
#include <fstream.h>
#include <stdlib.h>
int i, j;
int matrix[10000][5] = {0}; //Define a... |
Forum: C++ Mar 27th, 2008 |
| Replies: 21 Views: 1,318 Hi guys,
I have an input file as below (it is a family tree):
1 0 0
2 0 0
3 0 0
4 1 2
5 1 2
6 0 0 |
Forum: C++ Mar 3rd, 2008 |
| Replies: 14 Views: 1,059 my program REALLY doesnt like that += thing you did...
it runs the program but crashes? It gives an error to that line. |
Forum: C++ Mar 3rd, 2008 |
| Replies: 14 Views: 1,059 I'm sorry but that made absolutely no sense to me whatsoever...
I'm all for working things out myself, but I can't get my head around this one I'm afraid... |
Forum: C++ Mar 3rd, 2008 |
| Replies: 14 Views: 1,059 ...and if you could show me using my previous example that would be fantastic :) |
Forum: C++ Mar 3rd, 2008 |
| Replies: 14 Views: 1,059 No I don't have to store each individual number as I will not be using it again, all I need is the average.
So could you possibly explain to me a bit better how to go about getting the average... |
Forum: C++ Mar 3rd, 2008 |
| Replies: 14 Views: 1,059 I have an equation within a while loop like this:
while(repeats != 1000000){
x = rand1;
y = rand2;
result = x + y;
cout << result; |
Forum: Legacy and Other Languages Mar 3rd, 2008 |
| Replies: 3 Views: 1,123 ok, instead i did a while loop like this:
while(repeats != 1000000){
Equation = x + y;
Cout << Equation;
repeats++;
}
So basically, it prints the above 1000000 times. Instead, what I want... |
Forum: Legacy and Other Languages Mar 3rd, 2008 |
| Replies: 3 Views: 1,123 Hi guys,
I'm sure this is pretty simple really, but I can't get my head around it.
I have a long equation that I'm using c++ to work out. It involves a random number generator, so each time the... |
Forum: C++ Feb 8th, 2008 |
| Replies: 4 Views: 1,465 Yeah, basically x1, x2, and x3 change every time it is run, but it changes a little bit less each time. For example:
x1: 0.56778
x2: 0.12234
x3: 0.32214
x1: 0.56877
x2: 0.12945
x3: 0.32715 |
Forum: C++ Feb 8th, 2008 |
| Replies: 4 Views: 1,465 My program initially asks the user to input 3 values, x1, x2 and x3.
These get fed into a mathematical equation and come out of it the other side slightly altered.
The program then prints to... |
Forum: C++ Feb 6th, 2008 |
| Replies: 6 Views: 2,002 hmm, still aborts for some reason? |
Forum: C++ Feb 6th, 2008 |
| Replies: 6 Views: 2,002 Like this...?
for (i=0; i < 3; i++){
printf("\n%f\t%f\t%f", matrix[i][j]);
for (j = 0; j < 3; j++)
{
inFile >> matrix[i][j]; |
Forum: C++ Feb 5th, 2008 |
| Replies: 6 Views: 2,002 input file:
1 0 0
2 1 0
0 2 1
I would like to produce this in a 3x3 array on screen. My code:
#include <fstream.h> |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Sorry, I posted it, did you get it? I don't want to leave it up as I don't want it to get seen.
For the first option, use 0.4.
For the second, Use a repeat from 1 - 9, it doesnt work properly... |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Ahh, I had to put this:
indIndex1 = ind1 - 1;
indIndex2 = ind2 - 1;
After I declared what ind1 and 2 was. That compiled.
However, when I come to print the results, when I run it once, it... |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Thanks for that. I did completely forget though, I wanted to track 2 individuals and record the numbers of 00's 01's and 11's too.
So I set up a very similar counter as the one I did before. It... |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Haha, yes we did.
I did post one last question though :) |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 My last question I think :)
I need to print all of my work to an output file called 'output.txt'
Could anybody show me how to do this please?
Thank you :) |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Don't worry guys I solved it. I just did this:
else
if (matrix[i][3]==0 && matrix[i][4] ==1 || matrix[i][3]==1 && matrix[i][4] ==0)
{
counters[0][1]++;
} |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Yeah thats right it works fine without adding them together, but just doesnt when i do.
The correct scores are not added up.
I've tried dumping them in variables and then adding the variables... |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Great. Everythings running really well. Apart from this counter:
for(i = 0; i < numRows; i++)
{
if (matrix[i][3]==0 && matrix[i][4] ==0)
{
counters[0][0]++;
} |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 Also, you told me to fix that while loop to a for loop. At the moment it looks like this:
while (inFile >> matrix[numRows][0])
{
printf ("%d\t", matrix[numRows][0]);
for (j = 1; j < numCols;... |
Forum: C++ Feb 3rd, 2008 |
| Replies: 48 Views: 5,462 I have placed the counter just after the program closes the infile. I'm pretty sure this will work. I placed int counters[2][2] = {0}; as a global variable, and the code looks like this:
... |
Forum: C++ Feb 2nd, 2008 |
| Replies: 48 Views: 5,462 Brilliant!
Ok, I'm on the right track then. Where exactly in my code would you place the if statements? After the array has run obviously, but where exactly? Also, where would I place the
int... |
Forum: C++ Feb 2nd, 2008 |
| Replies: 48 Views: 5,462 Also, I'm wanting my program to track 2 individuals out of the family tree.
So when the program starts, I want it to say, which 2 individuals are you interested in?
e.g.
>5
>9
Can I get... |
Forum: C++ Feb 2nd, 2008 |
| Replies: 48 Views: 5,462 ... so it would be:
if (matix[i][3]==0 && mattrix[i][4] ==0)
{
counters[00]++;
}
if (matix[i][3]==0 && mattrix[i][4] ==1) |
Forum: C++ Feb 2nd, 2008 |
| Replies: 48 Views: 5,462 Right, well the if statements it is then!
You say use...
if (matrix[i][3] == 0)
counters[0]++;
else
counters[1]++; |
Forum: C++ Feb 2nd, 2008 |
| Replies: 48 Views: 5,462 Cheers guys, which do you think I should go for? Being a beginner as I am?? |
Forum: C++ Feb 1st, 2008 |
| Replies: 32 Views: 2,873 Sorry to be a pain, but could you put it in two separate posts, one on how to read the file in with the extra row, and what i have to change, and one with how to repeat the program 1000 times?
... |
Forum: C++ Feb 1st, 2008 |
| Replies: 48 Views: 5,462 sorry yes, I got rid of int counter;
Forget that!
I placed the code as follows:
else{
int dad = matrix[i][1]; // 1 is "dad" column
int mom = matrix[i][2]; // 2 is "mom" column |
Forum: C++ Feb 1st, 2008 |
| Replies: 32 Views: 2,873 Ok, well firstly I changed all the numRows to i's.
Then I changed:
while (inFile >> matrix[i][0])
{
printf ("%d\t", matrix[i][0]);
for (j = 1; j < numCols; j++)
{ |