grazie per la risposta.

non voglio leggere gli elementi del
vettore ogni 4, ma sommarli 4 alla volta.
Parte da 0 il vettore che leggo, infatti
se j=1, 4J-4=0.

Ecco tutto il programma:

/*
################################# PROGRAM F500 ##############################
Finds correlations in profit-revenue space
Mon Nov 3 14:48:36 CET 2008
Ver. 0.1
*/
//--------------------------------- HEADER -------------------------------------
#include "stat.h"
#include <stdlib.h>
#include <stdio.h>
#include "rng.h"
#include "math.h"
//#include "parse.h"
#include <iostream>
#include <fstream>
#include <sstream>
//#include <gsl/gsl_math.h>
//#include <gsl/gsl_eigen.h>
//#include <gsl/gsl_fit.h>
//#include <gsl/gsl_statistics.h>
using namespace std;

#define SPACE << "\n " <<
#define SP << " " <<
//--------------------------------- CONSTANTS -----------------------------------
const int F500_maxcomp=500;
//-------------------------------------------------------------------------------
//------------------------------- PROGRAMS TO RUN -------------------------------
#define MAIN 1;
//-------------------------------------------------------------------------------
//--------------------------------- FUNCTIONS -----------------------------------
//-------------------------------------------------------------------------------

//-------------------------------------------------------------------------------
//---------------------------------- MAIN ---------------------------------------

//-------------------------------- VARIABLES ------------------------------------

//-------------------------------------------------------------------------------
//int main(int argc, char* argv[]){
/* bool verbose=false,vverbose=false;
fstream outfile; //General File for output
CCmdLine commands;
commands.SplitLine(argc,argv);
StringType infile;
// If requested, print a short help
if (commands.HasSwitch("-h")){
cout <<
"Usage:" << endl <<
" stat.x -f <prof rev file>" << endl<<
" -v <verbose mode>"<<endl<<
" -vv <very verbose mode>"<<endl;
exit(1);};
try {
infile=commands.GetArgument("-f",0);

//lowbound=atoi(commands.GetSafeArgument("-b",0,"0").c_str());
if(commands.HasSwitch("-v")){ verbose=true;};
if(commands.HasSwitch("-vv")){ verbose=true;vverbose=true;};}
catch (...) {
cout << "You must supply compulsory flags: -f <prof rev file>" << endl;
cout << "Use -h for help..." << endl;
exit(1);};*/
//-------------------------------------------------------------------------------

int main(){
int a,i,m,j,k,s;
double sommar,sommap;

// Read File with epsilons and scaled revenues
//fstream indata(infile.c_str(),ios::in);
fstream indata("ge.dat",ios::in);
indata.seekp(0,ios::beg); //positioning at the beginning of the file
int Ntrim=0; // Number of trim
string line;
while(getline(indata,line)){ Ntrim++; }
// and read them
cout << "# Number of steps:" SP Ntrim << endl;

// Read data and put into matrix timeserie(i,j):
double (*revprof)[2] = new double[Ntrim][2];
double (*rev) = new double[Ntrim];
double (*prof) = new double[Ntrim];
indata.clear();
indata.seekp(0,ios::beg);
for (j=0;j<Ntrim;j++) //rows
{
for (i=0;i<2;i++) //columns
{ indata >> revprof[j][i];
};
rev[j]=revprof[j][0];
prof[j]=revprof[j][1];
}

// Calculate Means
cout << "Moments of Revenues: " << Mean (rev,Ntrim) SP Sigma(rev,Ntrim) SP Skew(rev,Ntrim) SP Kurtosis(rev,Ntrim)<<endl<<
"Mean Profit: " << Mean (prof,Ntrim)<<endl;

// profitti e revenue annuali
a=(Ntrim/4);

double revprofa[a][2];
double reva[a],profa[a];
sommar=0;
sommap=0;

for(j=1; j=a; j++)
{ printf("ciao\n");
for(k=(4*j-4); k=(4*j-1); k++)
{
sommar=sommar+rev[k];
sommap=sommap+prof[k];
};
reva[j]=sommar;
profa[j]=sommap;
sommar=0;
sommap=0;
};
printf("nnnn:%f, %f\n", reva[3],profa[3]); //controllo

fstream outdata("ge annuali.dat",ios:ut);
for (j=0;j<a;j++) //rows
{
for (i=0;i<2;i++) //columns
{
revprofa[j][0]=reva[j];
revprofa[j][1]=profa[j];
outdata << revprofa[j][i];
};
}
exit(0);
//-------------------------------------------------------------------------------
//SP Sigma(rev,Ntrim) SP Skew(rev,Ntrim) SP Kurtosis(rev,Ntrim)<<
//-------------------------------------------------------------------------------
// ################################################## ############################


//-------------------------------------------------------------------------------


}