help me

hello, i worte this code but i want to reverse the elemnts after show up in screen but i stuck and i dont know where is the error can any one please help me with it

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
#include<iostream>
#include<algorithm>
using namespace std;

void reverseDiagonal(int s[][5]){
int size;
int reverse=0;
cout<<"enter plaese the size of array \n";
cin>>size;
for(int i=0;i<5;++i){
	for(int j=0;j<size;++j){
		cout<<"{"<<j<<"}"<<"{"<<i<<"}";
		cin>>s[j][i];
		int temp=s[j][i];

       reverse = reverse * 10;
      reverse = reverse +temp%10;
     temp= temp/10;
	

cout<<"the reverse after is \n"<<reverse;


		cout<<endl;
}
}

int main(){
int s[100][5];
cout<<"the array before inverse them is ";
reverseDiagonal(s);




system("pause");
}
You should really better indent your code :-(. It's missing the closing '}' of function reverseDiagonal().

What does reverse the elements mean exactly?

Please describe the error. After fixing the closing '}' bug your program is compiling well and running. What is the intention of your program? What should be its output on what kind of input? Is its output erroneous?
no it is work with me as well, but my problem here when i try to reverse what the user put of elements .
for example out put:
enter plaese the size of array
2//user put it as example
{0}{0} 12//ueser put it
{0}{1} 5
.
.
.etc
the array after reserve is :
5
12

i dont know how to put it as sepreat i mean not in loop to run with me
Does this fit your intention?

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
using std::ostream;
using std::cout;
using std::endl;

/* ========================================================================== */
class Mx
{
    static const size_t mx_size = 4;

private:
    unsigned int _mx[mx_size][mx_size];

public:
    Mx();

    Mx reverseDiagonal();

    ostream &print(ostream &out) const;

} /* Mx */;

/* -------------------------------------------------------------------------- */
Mx::Mx()
{
    unsigned int val(0);

    for (size_t i = 0; i < mx_size; i++)
    {
        for (size_t j = 0; j < mx_size; j++)
        {
            _mx[i][j] = ++val;
        }
    }

} /* Mx::Mx() */

/* -------------------------------------------------------------------------- */
Mx Mx::reverseDiagonal()
{
    Mx rmx;

    for (size_t i = 0; i < mx_size; i++)
    {
        for (size_t j = 0; j < mx_size; j++)
        {
            rmx._mx[j][i] = _mx[i][j];
        }
    }

    return rmx;

} /* Mx &Mx::reverseDiagonal() */

/* -------------------------------------------------------------------------- */

ostream &Mx::print(ostream &out) const
{
    for (size_t i = 0; i < mx_size; i++)
    {
        for (size_t j = 0; j < mx_size; j++)
        {
            out << _mx[i][j];
            if (j < ARRAYSIZE(*_mx) - 1)
                out << " ";
        }
        if (i < ARRAYSIZE(_mx) - 1)
            out << endl;
    }

    return out;

} /* ostream &Mx::print(ostream &) */

/* ========================================================================== */
static ostream &operator<<(ostream &out, const Mx &mx)
{
    return mx.print(out);

} /* ostream &operator<<(ostream &, const Mx &) */

/* ========================================================================== */
/*
 *  m a i n
 */
int main()
{
    Mx mx;

    cout << mx << endl;
    cout << endl << "  reverted:" << endl << endl;
    cout << mx.reverseDiagonal() << endl;

    return 0;

} /* main() */

/* ========================================================================== */

Topic archived. No new replies allowed.