Exchanging
Moderators:Labib, bristy1588
It's a nice problem. If u want to exchange the value of two variable a & b, u may go like this:
int a,b,c;
c=a;
a=b;
b=c;
but, i asked to do it without having an another variable.
int a,b,c;
c=a;
a=b;
b=c;
but, i asked to do it without having an another variable.
A man is not finished when he's defeated, he's finished when he quits.
-
- Posts:125
- Joined:Mon Dec 13, 2010 12:05 pm
- Location:চট্রগ্রাম,Chittagong
- Contact:
Re: Exchanging
এইটা কি লেখলা আপু??? চট্টগ্রামে কি গনিত কর্মশালা হচ্ছে??? আমি আর রাফিদ একজনো কর্মশালার খবর জানিনাHandaramTheGreat wrote:a^=b^=a^=b;
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Exchanging
^ মানে XOR(exclusive OR)AntiviruShahriar wrote:এইটা কি লেখলা আপু???
a=a^b;
b=b^a;
a=a^b;
এইটার শর্ট ফরম হইল উপরেরটা... ভ্যালু বসাই দেখ, বুঝবা...
আমারে জিগায়া কাম নাই, আমি বর্তমানে নির্বাসিত জীবনযাপন করতেসি, বহুদিন পরপর গুহা থেইক্যা বাইর হই...কোনরকমে এমও-র রেজি. কইরা আসছি মাত্র... তবে পরশুর পেপারে দেখসি সিএমসি-র সভা হওয়ার কথা ছিল গতকাল... আর কিছু জানি না...চট্টগ্রামে কি গনিত কর্মশালা হচ্ছে??? আমি আর রাফিদ একজনো কর্মশালার খবর জানিনা
-
- Posts:125
- Joined:Mon Dec 13, 2010 12:05 pm
- Location:চট্রগ্রাম,Chittagong
- Contact:
Re: Exchanging
বহুদিন পরপর গুহা থেইক্যা বাইর হই.[/quote]
f.b একাউন্ট বন্ধ নাকি??? অইখানে কথা বলা যাবে...। এইখানে কম discuss ই ভাল...। থাকলে shahriar.md.04@gmail.com এ রিকুএস্ট পাঠাও...। বাই।
f.b একাউন্ট বন্ধ নাকি??? অইখানে কথা বলা যাবে...। এইখানে কম discuss ই ভাল...। থাকলে shahriar.md.04@gmail.com এ রিকুএস্ট পাঠাও...। বাই।
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Exchanging
btw, exchanging algorithm is usually called 'swap'...
Re: Exchanging
This is a very nice and easy problem.It was a problem in the dhaka divional informatics olympiad 2010.I got it at that time.Here is my solution is white.(please dont look at it at once,give it a try.It's one of the most simple question you will ever get.
a=a+b;
b=a-b;
a=a-b;
a=a+b;
b=a-b;
a=a-b;
-
- Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
Re: Exchanging
nice and easy tactic...
@sakib vaia, can problems of BdOI be found anywhere?
@sakib vaia, can problems of BdOI be found anywhere?
Re: Exchanging
The kind of exam we have in BDOI in actually not that much of a programming contest.
In last year divisional we were given mathematical puzzle type problems which were related to programming basics,but they were not that much of a programming contest.
In the national we were given programming problems,but we just had to write it in our pc and it was checked manually to check how good the algorithm was.
But for the team selection for IOI some online contest would be held.If you want to prepare for BDOI you must start learning programming.There are various site.The best place to start is usaco.(search usaco training and usaco contest in google).I will write a topic about usaco soon.
I dont know if there's any link to previous year's question.
In last year divisional we were given mathematical puzzle type problems which were related to programming basics,but they were not that much of a programming contest.
In the national we were given programming problems,but we just had to write it in our pc and it was checked manually to check how good the algorithm was.
But for the team selection for IOI some online contest would be held.If you want to prepare for BDOI you must start learning programming.There are various site.The best place to start is usaco.(search usaco training and usaco contest in google).I will write a topic about usaco soon.
I dont know if there's any link to previous year's question.
Re: Exchanging
I have posted the problemset of last year Here
Every logical solution to a problem has its own beauty.
(Important: Please make sure that you have read about the Rules, Posting Permissions and Forum Language)
(Important: Please make sure that you have read about the Rules, Posting Permissions and Forum Language)