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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
int max(int n, int w);
int min(int n, int w);
int predictingValue(int n, int w, int nw);
int main()
{
int rows, columns, y, a = 0, b = 0;
int projectArray[400][400];
fstream fin;
ofstream fout;
fin.open("input2.txt");
fout.open("output2.txt");
if(!fin)
{
cerr << "File did not open." << endl;
exit(1);
}
fin >> columns >> rows;
for(int i=0; i < columns; i++)
{
for(int j=0; j < rows; j++)
{
fin >> projectArray[i][j];
//projectArray[i][j] = predictingValue(projectArray[i][j+1], projectArray[i+1][j], projectArray[i][j]); //this is the call, it does nothing! this is one of the places it is being tried.
}
}
//if I try the call here, it also does nothing.
/*
for(int i=0; i < columns; i++)
{
for(int j=0; j < rows; j++)
{
projectArray[i][j] = predictingValue(projectArray[i][j+1], projectArray[i+1][j], projectArray[i][j]); // thought maybe a loop would do it, and it does nothing.
}
}
*/
for(int i=0; i < columns; i++)
{
for(int j=0; j < rows; j++)
{
fout << projectArray[i][j] << " ";
}
fout << endl;
}
fin.close();
fout.close();
char response;
cin >> response;
return 0;
}
int max(int n, int w)
{
if(n > w)
{
return n;
}
else
{
return w;
}
}
int min(int n, int w)
{
if(n < w)
{
return n;
}
else
{
return w;
}
}
int predictingValue(int n, int w, int nw)
{
int y;
if(nw>=max(n,w))
{
y=max(n,w);
}
else if(nw<=min(n,w))
{
y=min(n,w);
}
else
{
y = w + n - nw;
}
return y;
}
|