473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

swapping of position of elements in a sequence

2
Please help me in this problem.

write a program that gets a sequence of unsigned integers.the user can enter at most 100 integers.

After getting the numbers, the program allows the user to repeatedly choose one of the three options
1. swap the location of two entries in the sequence. if this option is chosen the user is prompted to enter the two locations to be swapped.
2. print out the sequence.
3. repeatedly swap two locations in the sequence until getting back to the state before this operation started. then print out the number of swaps performed.
Oct 24 '13 #1
3 1261
weaknessforcats
9,208 Expert Mod 8TB
OK. I read the problem statement.

So, exactly where are you stuck?
Oct 24 '13 #2
mc501
2
I am stuck at the third case that requires swapping until getting back to the state before this operation started. then print out the number of swaps performed. thanks
Oct 25 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
If your sequence is 1234 and you swap the first and last number you get 4231. Swap them again and you get 1234, which is the original sequence. Your print out would show 1234 4231 1234.

That is, assuming I read the problem correctly.
Oct 25 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

270
by: Jatinder | last post by:
I found these questions on a web site and wish to share with all of u out there,Can SomeOne Solve these Porgramming puzzles. Programming Puzzles Some companies certainly ask for these...
0
by: Thu | last post by:
Can anyone help me please.. I am using vb.net to WriteXML from Ms Access tables to an output stream. Basically, I retrieve data from 3 tables then use DataRelations to link these three tables,...
1
by: Thu | last post by:
I export some database data to an XML file. How do I change the sequence of the elements (fields) appear in the XML document? For example, my XML output from TableA is: <TableA> <Field(0)>...
1
by: Gi | last post by:
Hi, Can anyone tell me you can I transform this kind of XML: <Cont ID='faqs'> <Conts ID=''> <Elements> <Data></Data> <Pergunta></Pergunta> <Resposta></Resposta> </Elements>
2
by: Noah Sussman | last post by:
Hello, I am writing a function to reposition an element based on whether one of its edges is outside the visible area of the browser window (the code is below). My client has asked for code...
3
by: Chris | last post by:
How would I replace the elements with matching keys between $array1 and $array2 to end up with 'a,b,c,d,e,f'. $array1 - Array ( =c =d ) $array2 - Array ( =a =b =x =x =e => f ) ...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
0
by: Ian Collins | last post by:
Jrdman wrote: They are summarised in Annex C of the standard. Dig out a copy of n1124.pdf and have a look. -- Ian Collins.
8
by: Jrdman | last post by:
what's a sequence point and how to know the position of sequence point in our source code?
18
by: Bito | last post by:
Some one help me write a function that can swap elements in a singly linked list?Having a problem swapping the elements without, loosing some of the data?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.