Do you know: How to swap two variables values without using a third variable?
just do some math:
Code:
Uses "Console"
Double a = 1.234
Double b = 5.678
console_writeLine("A = " + str$(a) )
console_writeLine("B = " + str$(b) )
a += b
b = a - b
a = a - b
console_writeLine("A = " + str$(a) )
console_writeLine("B = " + str$(b) )
console_waitKey()
How about Strings?
Code:
Uses "Console"
String A = "World !"
String B = "Hello "
Console_WriteLine(A + B)
A += B
B = Left$( A, Len(A) - Len(B) )
A = Right$(A, Len(A) - Len(B) )
console_writeLine(A + B)
console_waitKey()
or in thinBasic:
Swap two Number using Bitwise operator
We can also swap two Numbers using Bitwise operator :bom:
var arg1 = int.Parse(Console.ReadLine());
var arg2 = int.Parse(Console.ReadLine());
Console.WriteLine("\n Before swapping arg1= {0} and arg2 = {1}", arg1, arg2);
arg1 = arg1 ^ arg2;
arg2 = arg1 ^ arg2;
arg1 = arg1 ^ arg2;
Here is full sample code
https://corevoila.in/coding-problems...wise-operator/
And what about compute time
Hello,
Little question
Which method is less or more time consuming.:zzz:
The time may be an important parameter, example bubble sorting.
Regards