0
Print this ....1,-4,7,-10....using for loop
for loop
5 Réponses
+ 12
for (int i = 1, j = 3; i < n; i = -i, j = -j, i += j)
{
std::cout << i << " ";
}
+ 9
for(int i = 0; i < n; ++i)
cout << (i&1 ? -3*i - 1 : 3*i + 1) <<endl;
Edited with swim correction
+ 6
for(int i = 1; i < 11; i = i > 0 ? -(i+3) : -i+3) {
cout << i << endl;
}
+ 3
for(int x=1,j=1;j<=4;j++){
(j%2==0)?(x=x*-1):(x=x);
cout << x << " ";
(j%2==0)?(x=x*-1):(x=x);
x+=3;
}
I decided to do them the long way :)



