Recent

Author Topic: Swap variables  (Read 5980 times)

MacWomble

  • Jr. Member
  • **
  • Posts: 79
Re: Swap variables
« Reply #15 on: October 16, 2019, 11:44:32 pm »
I understand your point not to give useful or easy understandable  answers for such homework questions.
But I think its false to give complicated answers.
Instead you should try to help - this is the sense of the forum. Must not be a solution but some hints should always be useful.
Such like:
"You have to  use a third variable to change the content of two variables"

Your answers (not Thaddys) are not useful for a beginner. Help them to get them with Lazarus !!!  ;D
You all had a time where you began coding !  :o

All other answers are coming from (maybe genious) apes I think.... ;D
« Last Edit: October 16, 2019, 11:48:47 pm by MacWomble »
Mint 19.3 Cinnamon, FPC/ Lazarus Trunk 64Bit

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Swap variables
« Reply #16 on: October 17, 2019, 08:39:35 am »
I agreed to Macwomble, but the person, who started the topic, can still show some code to he what he has done. And also an example is usefull to see what the person wants.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Thaddy

  • Hero Member
  • *****
  • Posts: 19624
  • Glad to be alive.
Re: Swap variables
« Reply #17 on: October 17, 2019, 09:21:23 am »
Anyway, I suggest to just remove the thread?
Why? I think my answers are for the most part well written and explanatory.
Non-computable thingies do not come around too often... :D and this is a prime example explaining the necessity of input fields.
It is part of the fun!

(Note prefix covers "de" sort order is on name, not prefix, but you know that)
« Last Edit: October 17, 2019, 09:23:38 am by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

neuro

  • Jr. Member
  • **
  • Posts: 95
Re: Swap variables
« Reply #18 on: March 19, 2022, 11:30:55 am »
Kaslauskaite (daughter of Kaslauskas) (I can complicate that even much further: *ciute instead if *Kaite depending on name)

Surnames are incorrectly written. The same sentence with corrected surnames:
Kazlauskaitė (daughter of Kazlauskas) (I can complicate that even much further: *čiūtė instead if *kaitė depending on name)

By the way, official information from Lithuanian authorities (State Enterprise Centre of Registers):
The most popular surname in the country is Kazlauskaitė - there are almost 5.2 thousand of them in Lithuania.

Quote
https://www.registrucentras.lt/naujienos/index.php?mod=news&act=view&id=42565
Pati populiariausia pavardė šalyje yra Kazlauskaitė - jų visoje Lietuvoje galima sutikti beveik 5,2 tūkstančio.

https://www.registrucentras.lt/en/
State Enterprise Centre of Registers (SECR) is a public entity of limited civil liability incorporated by the Government of the Republic of Lithuania on the basis of the State-owned property on 8 July 1997.
« Last Edit: March 19, 2022, 11:32:37 am by neuro »

dbannon

  • Hero Member
  • *****
  • Posts: 3882
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Swap variables
« Reply #19 on: March 19, 2022, 12:51:39 pm »
Is your son really called "drop table"? ;)

Just in case someone missed Thaddy's reference, https://xkcd.com/327/
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 19624
  • Glad to be alive.
Re: Swap variables
« Reply #20 on: March 19, 2022, 01:38:30 pm »
Surnames are incorrectly written.
No. I wrote them correctly, (except for the hyphens ) my wife checked it,  Kaslauskiene, meaning: is married to, my mother in law, was the wife of Count Kaslauskas - the last one - . Kaslauskaite means daughter of Kaslauskas like my wife and her sister. It can be even more complex: my stepdaughter is called Benediktaviciute, the daughter of Benediktus... Lithuanian is beautiful. Really fun to learn, but it helps if you have an old school background like Latin. It is nice to see Lithuanian on this forum... :)

To the point:
Code: Pascal  [Select][+][-]
  1. program swapme;
  2. { swap without temp variable }
  3. {$mode objfpc}{$H+}
  4. var
  5.   a:integer = 10;
  6.   b:integer = 3;
  7. begin
  8.   writeln(a:4,b:4);
  9.   a:=a+b;
  10.   b:=a-b;
  11.   a:=a-b;
  12.   writeln(a:4,b:4);
  13. end.
« Last Edit: March 19, 2022, 02:14:29 pm by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

 

TinyPortal © 2005-2018