I started to test your program and realized I have no idea what is in the "dan.txt" file.
It is better if I use what you are using, so that we get the same outcome.
FYI line 44 is calling a function with uninitialized variabes and these variables have yt to receive a value yet. This will have undetermined results, but make no difference because "z" is never used.
I strongly recommend stepping through your code with a debugger, so that you can examine what's happening at each step, and see what's causing your crash.
EDIT: Is there a reason your sk method is ignoring the first element of the mas array?
Right,
dan.txt is a file with the initial data (in this case
5 // it shows how many elements in array, it's mas[0] and that's why it is ignored
13 3 4 -1 16 // mas[1]...mas[5]
By the way, I've found what causes RTE - it's because of 'mas' and 'mass'.
Even in fixed code test server gives WA2 - wrong answer.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int read(int mas[],int n)
{
ifstream f("dan.txt");
if(f)
{
int i=0;
for( ; (f>>mas[i])&& i<n ; i++)
;
f.close();
return i;
}
return 0;
}
int sk(int mas[],int n,int& max, int& min, double& sum)
{
sum=0;
max=min=0;
int z=read(mas,n);
if (z>0)
{
max=mas[1];
min=mas[1];
for (int i=1; i<z; i++)
{
sum += mas[i];
if (mas[i]<min)
min=mas[i];
if (mas[i]>max)
max=mas[i];
}
}
return z;
}
int main()
{
int max, min;
double sum=0;
const int N=10;
int mas[N];
int z=sk(mas,N,max,min,sum);
if (mas[0]==0) {
ofstream out ("rez.txt");
out<<"0"<<" ";
out<<"0"<<" ";
out<<"0.00";}
else {
ofstream out ("rez.txt");
out<<min<<" ";
out<<max<<" ";
out<<setprecision(2)<<fixed<<sum/mas[0];}
return 0;
}