Swap | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Swap

Hola a todos me pueden indicar para que se utiliza swap

12th Sep 2018, 2:14 PM
Wilmer Torres
Wilmer Torres - avatar
1 ответ
+ 2
It exchanges the values between two storage locations such as variables or array elements. Normally, it is done with a third storage location in your code, but some languages support it without the extra storage. The most often usage in coding is during a sort to move things into order. Intercambia los valores entre dos ubicaciones de almacenamiento, como variables o elementos de matriz. Normalmente, se realiza con una tercera ubicación de almacenamiento en el código, pero algunos idiomas lo admiten sin el almacenamiento adicional. El uso más frecuente en la codificación es durante un movimiento para ordenar las cosas. int a = 10; int b = 5; // swap int c = a; a = b; b = c; // a = 5; b = 10;
12th Sep 2018, 6:49 PM
John Wells
John Wells - avatar