1.
This is illegal. The length of an array can't depend on the value of a variable at run time. You're probably using GCC, which lets you get away with it, but you still shouldn't do it.
2.
1 2 3 4
|
for (int i=0; i<=n; i++)
{
mas [i]=i;
}
|
This is a buffer overflow. i can reach n, but mas only goes from 0 to n-1.
3. What's the point of mas, if all it does is give you back the same number you put in, and you never modify it?
4.
1 2 3
|
for (int i=0; i<=n;i++){
//...
for(int z=0; z<=n;z++){
|
You're not respecting the conditions of the problem. z can at times be higher than i.
5.
I'm not too clear on the precedence of the comma operator, but this means either (cout << a),b,c or cout << (a,b,c). Probably the former.
The former prints a and then evaluates b and c to no effect, and the latter evaluates a and b to no effect, then prints c.
To print a, then b, then c, do
|
std::cout <<a<<" "<<b<<" "<<c<<std::endl;
|
6. Just an algorithmic note: You're going to get a lot of useless output if you start your loops at zero, since 0^2 + a^2 = a^2 is true for all a.