11-12-2019 10:45 AM
Yes he didn't mention that correctly but logically that's what he meant.
And the ranges are not the point.
Mistakes happen.
11-12-2019 10:48 AM - edited 11-12-2019 10:51 AM
He is a wonderful teacher.
And these common mistakes happen all the time.
i suggest that you don't lose your hope in your teacher for a small mistake.
He is actually a inventer btw.
11-12-2019 10:55 AM
wiebe@CARYA wrote:
@Yamaeda wrote:My C++ teacher lost my respect when she claimed you need a 3rd variable to swap two variables.
Why do you say that? In a text based language, you do need a 3rd variable. Unless there is some other function built into that language that does the swap. I would bet that even then, the underlying machine code probably uses a 3rd register to transfer the values. Please tell me your example of why you claim you would be wrong.
11-12-2019 10:59 AM
@RavensFan wrote:
wiebe@CARYA wrote:
@Yamaeda wrote:My C++ teacher lost my respect when she claimed you need a 3rd variable to swap two variables.
Why do you say that? In a text based language, you do need a 3rd variable. Unless there is some other function built into that language that does the swap. I would bet that even then, the underlying machine code probably uses a 3rd register to transfer the values. Please tell me your example of why you claim you would be wrong.
You can do it with pointers. It has been way too long since I cared about the specifics, but it was essentially just swapping the addresses in a very weird way.
11-12-2019 11:37 AM
We where not talking about compiler internals.
Just about user declared variables, and how you need a 3rd.
It's fair to say we didn't get along in the first place.
@RavensFan wrote:
wiebe@CARYA wrote:
@Yamaeda wrote:My C++ teacher lost my respect when she claimed you need a 3rd variable to swap two variables.
Why do you say that? In a text based language, you do need a 3rd variable.
You don't need one, it's comfortable to use one. There's a difference.
Of course there was some conversation first about exactly how utterly impossible it was.
Challenge excepted!
int a = something;
int b = something;
a = a xor b;
b = a xor b;
a = a xor b;
swapped integer values! No 3rd variable!
That proves to me you can most definitely swap to variables without a 3rd.
Reluctantly, see said "but that only works for integers"...
float a = something;
float b = something;
a = a / b;
b = a * b;
a = b / a;
Swapped floats!
She still refused my solution as a possibility, still claiming it was not possible.
There's a difference between "not possible" and "not feasible". Refusing to acknowledge the difference invalidates someone as my programming teacher.
11-12-2019 02:41 PM
Slick.
I was visualizing the classic early programming class example of sorting strings like in a bubble sort and swapping them when needed.
11-13-2019 03:44 AM
@Arash_kh wrote:
He is a wonderful teacher.
And these common mistakes happen all the time.
i suggest that you don't lose your hope in your teacher for a small mistake.
He is actually a inventer btw.
Making a mistake is perfectly ok. It's how he'd react to it.
If you point out why the test is confusing (or incomplete), he should say something like: "ah, you're right. I'll fix it for next year". If he responses with: "Bugger off, you're the only one complaining so you must be wrong, stop bugging me", it's a hole other story.
11-13-2019 07:32 AM
wiebe@CARYA wrote:If you point out why the test is confusing (or incomplete), he should say something like: "ah, you're right. I'll fix it for next year". If he responses with: "Bugger off, you're the only one complaining so you must be wrong, stop bugging me", it's a hole other story.
"hole other story." LOL
11-13-2019 07:42 AM
@johntrich1971 wrote:
wiebe@CARYA wrote:If you point out why the test is confusing (or incomplete), he should say something like: "ah, you're right. I'll fix it for next year". If he responses with: "Bugger off, you're the only one complaining so you must be wrong, stop bugging me", it's a hole other story.
"hole other story." LOL
That one wasn't intentional 😊.