Help me learn how to program. - page 12

 
Oh yes, the topic is moving into a very serious direction, have begun to address questions of extreme importance and value - whether to scratch your nose with your left hand or your right.
 

Woke up, read it, wept.

Eleven pages of nothing, about nothing. What for?

I recommend a long-established and very effective way of responding to boorish people and other inadequates.

Press "reply", do not type anything. Mentally compose text in response, you can not be embarrassedin expressions.

Then mentally, very emotionally and with expression, send your opponent to * fuck.

Close the page.


On the subject of PositionsTotal(), I've read the whole reference and got the same construction everywhere.

  int total=PositionsTotal(); // количество открытых позиций   
//--- перебор всех открытых позиций
   for(int i=total-1; i>=0; i--)

I've never paid attention to it before this thread. And I have used it everywhere.

for(int i = PositionsTotal() - 1; i >= 0; i--)

Imho, it's the same thing but one less variable.

Tell me I'm right, because after 11 pages of this thread, I'm starting to have doubts.

 
Aleksandr Slavskii:

Woke up, read it, wept.

Eleven pages of nothing, about nothing. What for?

I recommend a long-established and very effective way of responding to boorish people and other inadequates.

Press "reply", do not type anything. Mentally compose text in response, you can not be embarrassedin expressions.

Then mentally, very emotionally and with expression, send your opponent to * fuck.

Close the page.


On the subject of PositionsTotal(), I've read the whole reference and got the same construction everywhere.

I've never paid attention to it before this thread. And I have used it everywhere.

Imho, it's the same thing but one less variable.

Tell me I'm right, because after 11 pages of this thread, I'm starting to have doubts.

One and the same. But, be careful. As you may have noticed in this thread, some people get very sick at the sight of such an entry.

 
Igor Makanu:

about loops

Why don't you want to use what C gives you out of the box?


about variables in the body of the loop, the same Microsoft recommends using local variables as much as possible, I read somewhere that it is convenient that they will be destroyed when they leave the scope, but we are talking about simple types that have no constructors and creation is free


@Dmitry Fedoseev, no

Because if you close several positions in such a loop, some positions will be missed, not closed.

 
Alexey Viktorov:

Because if you close several positions in such a cycle, some positions will be missed, not closed.

Yes, I agree

I think this is a bad example, it's not about much else, then this example is more correct:

for(int i = 0, n = ArraySize(arr); i<n ; i++)
{
....
}


SZU: you need to stop.... or with participants who think in categories of grandpa's Turbo-Pascal or real-time execution in DOS... Or with those who just fought with slide rule at recess, alas they are incorrigible and right in their own way )))

 
Igor Makanu:

Yes, I agree.

I gave the wrong example, it's not about much else, then this example is more correct:


S.S.: you need to stop.... arguments with participants who think in terms of grandpa's Turbo-Pascal or real-time execution in DOS... or those who just fought at break with logarithmic rulers, alas they are incorrigible and right )))

Try explaining that to the coolest programmer on this forum...

And logarithmic rulers were studied in high school... when they weren't fighting anymore, but trying to snuggle up to girls.

And as for the example, how is this different from that

int n = ArraySize(arr);
for(int i = 0; i < n ; i++)
{
....
}
especially if this loop is wrapped in a user-defined function. The n variable is local anyway and is killed when the function exits.
 
Aleksandr Slavskii:

I recommend a method of replying to boorish people and other inadequates, which I have long tried and which is very effective.

Press the "reply" button, don't type anything.

A great way!

This is how I sometimes open trades: I put a line where there is a spontaneous desire to open and do not open :)

 

I don't think loops are necessary at all - in critical applications they are avoided by explicitly writing out the command sequence. And in ordinary programming one should only use recursion.


Just kidding, of course) I just came across another thread and decided to share my weighty opinion too)

 
Aleksey Nikolayev:

I just stumbled across another flubbin' board.

I think it's all over the place. Except for the newbie help thread, I guess. People come here when the tester's optimizer makes another iteration, put in their five cents, and go back to the tester :)

The brain does not tolerate emptiness.
 

From the countryside, but it even made me want to ramble)

Writing a combed code at once, or learning to write code, especially when the problem-setter and algorithmist are in one person is impossible for me)))

Proper task setting, writing algorithms is a separate topic, which is quite complicated, it is necessary to learn it and there are not many good professionals). Coding is implementation, and of course you can implement it in different ways)))). Better not bad coding right away, but we must keep in mind that the problem has not yet fully studied and understood, correctly convince the algorithm is also a task for tasks with incomplete or unstable data, and immediately beautiful and combed to build ... logic does not add up)))