I'm stuck on the very last part of a problem.

You've bought a square plot of land on ebay and you now want to plan how to develop this land. The trouble is, you've never been there. All you have is the engineer's terrain report which is an NxN matrix where each value indicates the height of that 1m2 cell. The format of the file provided to you is as follows:

10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 12 12 12

1 2 3 4 5 6 7 12 12 12

1 2 3 4 5 6 7 12 12 12

This matrix reflects a piece of land that slopes evenly from East to West, with a flat, elevated area in the south-easterly corner. The first value in the file is N, which tells you the size of the matrix (NxN).

Your program should output the following:

* the coordinates of the highest point in the site;

* the mean (average) height across the terrain;

* the standard deviation across the heights (the square root of [the difference between the mean of the squares of the heights and the square of the mean of the heights]).

And the following is my code:

```
#include "Plot.h"
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
Plot::Plot() {
}
void Plot::loadFromfile(){
ifstream inputfile;
inputfile.open("terrain200.dat");
inputfile>>area;
for(int i=0; i<area; i++){
for(int j=0;j<area; j++){
inputfile>>array[i][j];
}
}
inputfile.close();
}
void Plot::print(ostream &x){
int height=array[0][0];
int a,b;
double m,sum=0,ms,hs,diff,standDev; //ms = mean squared, hs = heights squared
for(int i=0; i<area; i++){
for(int j=0;j<area; j++){
sum+=array[i][j];
if(array[i][j]>height){
height=array[i][j];
a=i;
b=j;
}
}
}
hs=(sum*sum);
m=sum/(area*area);
ms=(m*m);
//diff=
standDev=sqrt(diff);
x << "Highest point is " << height << " at the coordinates (" << a << "," << b << "). \n" ;
x << "The total sum of heights is " << sum << ". \n";
x << "The mean of the heights is " << m << ". \n";
x << "the square of the mean of the heights is " << ms << ". \n";
x << "The mean of the squares of the heights is " << << ". \n";
x << "The standard deviation across the heights is " << standDev << ". \n";
}
```

I think I'm really close to getting it but I'm just at the stage where I can't think anymore!

*Edited 7 Years Ago by Daithi*: n/a