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
|
#include <iostream>
#include <fstream>
using namespace std;
void riga(ofstream &put,int &val2, int n_el, int X[], int pr, int sec, int ter,int j)
{
for(int k=0;k<sec &&val2<n_el;k++)
{ put<<"r"<<k<<":"<<"";
for(int l=0; l<ter &&val2<n_el;l++)
{
X[j][k][l]=X[sec*j + ter*k + l];
put<<X[j][k][l]<<" ";
val2++;
}
put<<"\n";
}
}
void funzione(ofstream &out, int n_el, int X[], int pr, int sec, int ter )
{ int Z[pr][sec][ter];
int val=0;
for(int j=0;j<pr &&val<n_el; j++)
{
out<<"\n"<<"strato"<<" "<<j<<endl;
riga(out,val, n_el, X, pr, sec, ter,j);
}
}
int main()
{
ifstream IN("input");
ofstream OUT("output");
if (IN && OUT)
{
int n_el; //Leggo array A[400]
int X[400];
IN>>n_el;
for(int i=0; i<n_el; i++)
{
IN>>X[i];
} // finisco di leggere l'array dichiarato
int a, b, c;
IN>>a>>b>>c;
funzione(OUT, n_el, X, a,b,c);
}
else
cout<<"errore con i files";
IN.close(); OUT.close();
}
| |