i see.. maybe it's better to use while instead than for, isn't it?
At the moment I have no clues of how to do it anymore =(
This is a piece of the new code.
It seems to be working.
And my input is like this:
21
1 2 1 0 0 0 2 2 3 1
0 0 1 1 1 1 1 2 1 0
1
H 0
so that After I write it down and I declare H 3 my output should be
11210 and 10000 because of the Array[0][0][z] and [1][0][z]
but I only want to write in the output 11210 and 1, but not the empty one. How do I do that?
I also want if I declare in input example :
15
1 2 1 0 0 0 2 2 3 1
0 0 1 1 1
H 3
i want in output "the array is empty" because X[0][3][z] and X[1][][] have no values..
I have no clues of how to write it down..
But I have a question. How do I write if the array
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
|
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char ch;
int p;
int n_el=0;
int i=0;
int k=0;
int j=0;
int z=0;
int A[2][4][5];
ifstream IN("input");
ofstream OUT("output");
IN>>n_el;
while(i<n_el)
{
IN>>A[k][j][z];
cout<<A[k][j][z]<<" ";
z++;
if(z==5)
{
z=0;
j++;
cout<<"\n";
}
if(j==4)
{
j=0;
k++;
}
i++;
}
|