Variable switch with no other variables or temps

I am a first level Java student in college. We have been instructed to write a Java program that promts the user to input three integers to int variables a, b,c and switch them so that a=c b=a and c=b with out using any other variables or temp variables. I know how to do everything except switch the variables without losing one. The only hint that he gave us was that
x^y^y=x also when we print the variables after rotation we must do it as follows:
System.out.println("a =" a "b=" b "c=" c);
I would really appreciate any hints or advise you can give me to help me out with this problem
again I have only been studying programming for a few weeks so my skills are limited.
Thank You

If
a = 2; (0010) and
b = 4; (0100) than
a ^ b = 6 (0110)
try
a = a ^ c; //=a ^ c
b = b ^ c; //=b ^ c
c = c ^ b; //=b
b = b ^ a; //=a ^ b
a = a ^ c ^ b; //=c
b = b ^ c;
to solve your problem. Do not know if it is the shortest way, but it works. :)

Similar Messages

  • I have 2 different libraries and would like to switch one with the other. Can I simply authorize the one I want to switch to the same user and Password that refers to the one I want to get to.

    I have 2 Itunes libraries on 2 different computers and would like to switch one to become the other in order to have one complete library on both computers. Can I simply deauthorize and reauthorize the computer i want changed with the other library.

    hi melansonp, these 2 emails accounts are from one webmail or from 2 differents ?

  • I think things would have been better without this icloud mess......  someone help me like it again.   1). i have more than 1 account set up with icloud. so i deleted 1 account from the settings on my iphone to try and switch to the other account and ever

    i think things would have been better without this icloud mess......
    someone help me like it again.
    1). i have more than 1 account set up with icloud. so i deleted 1 account from the settings on my iphone to try and switch to the other account and everything became a huge mess. (on my iphone i LOST some of my contacts, all of my reminders are gone, and nothing is showing up on the ical on my iphone, and only some notes are showing).......
    2). everything is still shown on my macbook pro.... but when i tired to go and sync it..... nothing is transfering to my phone........
    3). when i log into the 2 icloud accounts i have with icloud(.com) nothing is showing up in there also......
    whats is going on..... this is a huge mess for me. i want to go back the way is was like 1-2 years ago. when you can just sync things from the computer to the phone and not have to go through icloud....... ive been struggling with icloud but today just me hate it to the max.
    ANY HELP ON HOW I CAN FIX ALL OF THIS.....
    THANK YOU VERY MUCH!

    the version im using is 10.7.5
    im not sure what you mean by you second statement. when i open those application on my macbook its on my macbook but when i sign into icloud. i have those option selected.
    maybe my problem is im using the wrong ID...... lol.
    is there away you can delete or change icloud accounts/ ID's???

  • Why doesn't the rotate gesture on my trackpad behave as it used to for switching between tabs when it works the same with all other programs besides Firefox?

    Why doesn't the rotate gesture on my trackpad behave as it used to for switching between tabs when it works the same with all other programs besides Firefox?
    I changed the about:config to make the rotate gesture move between tabs, and it worked great for well over a year. Now it behaves erratically as described here:
    https://bugzilla.mozilla.org/show_bug.cgi?id=877598
    It used to be very controllable to move one tab over, now it is erratic and moves quickly and to unexpected tabs regardless of how slow I do the rotate gesture. This is the main reason I use Firefox over Chrome and I would like to continue to do so unless there is no fix to this.

    Just set the browser.gesture.twist.threshold to something around 15-25.

  • Hi my mum has recently gotten a white iphone4 and i have a black iphone4 we both would really want to switch over our phones with each other i was just wondering if there would be any issues would the data contract be switched over???

    please can someone help me i have got a black iphone 4 and my mum has got a white iphone 4 we would like to switch both of our phones with each other we are just worried if the data services and our contracts will be switched over we dont care about our phone music and contacts ok thankyou

    Most carrers won't care if you change phones as long as you are payng for al the services they require.  Since you both have iPhones, it probably won't be an issue, but since we don't know who your carrier is we can't say it they will have a problem with you making that change or not.  The only way to make certain it won't be a problem is to contact your carrier...

  • HT5225 I have an imac 24 , imac 27, mac book pro, airbook and Iphone 3G.  I have switched to icloud from mobile and all the computers synch with each other but data entered from my iphone in ical won't sync to the other computers.

    I have an imac 24 , imac 27, mac book pro, airbook and Iphone 3G.  I have switched to icloud from mobile and all the computers synch with each other but data entered from my iphone in ical won't sync to the other computers.
    Is there a setting on the iphone that will allow ical entries on the iphone to sink to my other computers
    Thank-you

    Welcome to the Apple community.
    First check that all your settings are correct, that calendar syncing is checked on all devices (system preferences > iCloud on a mac and settings > iCloud on a iPhone, iPad or iPod).
    Make sure the calendars you are using are in your 'iCloud' account and not an 'On My Mac', 'On My Phone' or other non iCloud account (you can do this by clicking/tapping the calendar button in the top left corner of the application ), non iCloud calendars will not sync.
    If you are sure that everything is set up correctly and your calendars are in the iCloud account, you might try unchecking calendar syncing in the iCloud settings, restarting your device and then re-enabling calendar syncing settings.

  • Two switches in server mode do not advertise their vlan info. with each other

    Hello All,
    I have some queries regarding the VTP advertisement as below.
    Scenario.....
    I have taken two switches named as switch-A and Switch-B connected with each other with port f0/1.I have defined f0/1 as trunk on both the switches.
    Then i created the Vlan 2,3,4 on switch-A ,Switch-A configurations revision number got changed from 0 to 3.But when i look up the same on switch-B the revision number is 0 and the vlan that was created on Switch-A is not replicated to Switch-B.
    Both Switch-A and Switch-B has default VTP domain configured i.e Null
    Both the Switches are in Server mode.
    On both the Switches domain password set to null.
    Why the vlan is not getting advertise from Switch-A to Switch-B?.According to the vtp configuration they both belong to the same vtp domain i.e null.
    So they should advertise the vlan information with each other.
    Your suggestion will be appreciated on this.Awaiting for your reply
    Thanks,
    Mrityunjay singh

    Hi Jon,
    The trunk is up and running fine.Please find the output for  trunk and vtp status as below.
    SWITCH-A output---------
    SWITCH-A(config)#do sh int f0/1 switch
    Name: Fa0/1
    Switchport: Enabled
    Administrative Mode: trunk
    Operational Mode: trunk
    Administrative Trunking Encapsulation: dot1q
    Operational Trunking Encapsulation: dot1q
    Negotiation of Trunking: On
    Access Mode VLAN: 1 (default)
    Trunking Native Mode VLAN: 1 (default)
    Voice VLAN: none
    Administrative private-vlan host-association: none
    Administrative private-vlan mapping: none
    Administrative private-vlan trunk native VLAN: none
    Administrative private-vlan trunk encapsulation: dot1q
    Administrative private-vlan trunk normal VLANs: none
    Administrative private-vlan trunk private VLANs: none
    Operational private-vlan: none
    Trunking VLANs Enabled: ALL
    Pruning VLANs Enabled: 2-1001
    SWITCH-A(config)#do sh vtp status
    VTP Version                     : 2
    Configuration Revision          : 3
    Maximum VLANs supported locally : 255
    Number of existing VLANs        : 8
    VTP Operating Mode              : Server
    VTP Domain Name                 : 
    VTP Pruning Mode                : Disabled
    VTP V2 Mode                     : Disabled
    VTP Traps Generation            : Disabled
    MD5 digest                      : 0x58 0xD0 0x3C 0x06 0x01 0xE3 0xD7 0x4D 
    Configuration last modified by 0.0.0.0 at 3-1-93 00:03:02
    Local updater ID is 0.0.0.0 (no valid interface found)
    SWITCH-B output.......
    SWITCH-B(config)#do sh int f0/1 swit
    Name: Fa0/1
    Switchport: Enabled
    Administrative Mode: trunk
    Operational Mode: trunk
    Administrative Trunking Encapsulation: dot1q
    Operational Trunking Encapsulation: dot1q
    Negotiation of Trunking: On
    Access Mode VLAN: 1 (default)
    Trunking Native Mode VLAN: 1 (default)
    Voice VLAN: none
    Administrative private-vlan host-association: none
    Administrative private-vlan mapping: none
    Administrative private-vlan trunk native VLAN: none
    Administrative private-vlan trunk encapsulation: dot1q
    Administrative private-vlan trunk normal VLANs: none
    Administrative private-vlan trunk private VLANs: none
    Operational private-vlan: none
    Trunking VLANs Enabled: ALL
    Pruning VLANs Enabled: 2-1001
    Capture Mode Disabled
    Capture VLANs Allowed: ALL
    SWITCH-B(config)#do sh vtp status
    VTP Version                     : 2
    Configuration Revision          : 0
    Maximum VLANs supported locally : 255
    Number of existing VLANs        : 5
    VTP Operating Mode              : Server
    VTP Domain Name                 : 
    VTP Pruning Mode                : Disabled
    VTP V2 Mode                     : Disabled
    VTP Traps Generation            : Disabled
    MD5 digest                      : 0x7D 0x5A 0xA6 0x0E 0x9A 0x72 0xA0 0x3A 
    Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
    Local updater ID is 0.0.0.0 (no valid interface found)
    I have tried by changing the vtp domain name instead of null and it is working fine in that scenario.But my question is why not is works when the  vtp domain is set to null on both the switches.
    Your update would be appreciated.
    Thanks,
    Mrityunjay Singh

  • How do I Help Apple Care Stop Warring with Each Other and Fix the Problem with My iPhone that They Acknowledge Creating?

    How Do I Help Apple US & Apple Europe Stop Warring With Each Other And Fix The Problem They Created?
    PROBLEM
    Apple will not replace, as promised, the iPhone 5 (A1429 GSM model) that they gave me in London, UK, with an iPhone 5 (A1429 CDMA model).
    BACKGROUND
    My iPhone 5 (A1429 CDMA model) was purchased this year in September on an existing Verizon Wireless (VZW) line using an upgrade. The purchase took place in California and the product was picked up using Apple Personal Pickup through the Cerritos Apple Retail Store. I will refer to this phone at my "original" phone.
    The original phone was taken into the Apple Store Regent Street in London, England, UK on November 15, 2012. The reason for this visit was that my original phone's camera would not focus.
    The Apple Store Regent Street verified there was a hardware problem but was unable to replace the part.
    The Apple Store Regent Street had me call the US AppleCare. At first they denied support, but then a supervisor, name can be provided upon request, approved the replacement of my original phone with an iPhone 5 (A1429 GSM model) as a temporary solution until I got back in the US. And approved that the GSM model would be replaced with a CDMA model when I came back to the US. I will refer to the GSM model as the "replacement". They gave me the case number --------.
    The Apple Store Regent Street gave me the replacement and took the original. The first replacement did not work for reasons I do not understand. They switched out the replacement several times until they got one that worked on the T-Mobile nano SIM card that I had purchased in England, UK. Please refer to the repair IDs below to track the progression of phones given to me at the Apple Store Regent Street:
    Repair ID ----------- (Nov 15)
    Repair ID ----------- (Nov 16)
    Repair ID ----------- (Nov 16)
    The following case number was either created in the UK or France between November 15 to November 24. Case number -----------
    On November 19, 2012, I went to France and purchased an Orange nano SIM card. The phone would not activate like the first two repair IDs above.
    On November 24, 2012, I went to the Apple Store Les Quatre Temps. The Genius told me that my CDMA phone should not have been replaced with a GSM model in the UK and that this was clearly Apple's fault. They had me call the AppleCare UK.
    My issue was escalated to a tier 2 UK AppleCare agent. His contact information can be provided upon request. He gave me the case number -----------.
    The UK tier 2 agent became upset when he heard that I was calling from France and that the France Apple Store or France AppleCare were not helping me. He told me that my CDMA phone should not have been replaced with a GSM model in the UK and that this was clearly Apple's fault.
    The UK tier 2 agent said he was working with engineers to resolve my problem and would call me back the next day on November 25, 2012.
    While at the Apple Store Les Quatre Temps, a Genius switched the phone given to from repair ID ----------- with a new one that worked with the French nano SIM card.
    Also, while at the Apple Store Les Quatre Temps, I initiated a call with AppleCare US to get assistance because it seems that AppleCare UK was more upset that France was not addressing the issue rather than helping me. I have email correspondance with the AppleCare US representative.
    A Genius at the Apple Store Les Quatre Temps switched the replacement with a new GSM model that worked on the French SIM card but would not work if restored, received a software update, or had the SIM card changed. This is the same temporary solution I received from the Apple Store Regent Street in the UK.
    By this point, I had spent between 12-14 hours in Apple Store or on the phone with an AppleCare representative.
    Upon arriving in the US, I went to my local Apple Store Brea Mall to have the replacement switched with a CDMA model. They could not support me. He told me that my CDMA phone should not have been replaced with a GSM model in the UK and that this was clearly Apple's fault. My instructions were to call AppleCare US again.
    My call with AppleCare US was escalated to a Senior Advisor, name can be provided upon request, and they gave me the case number -----------. After being on the phone with him for over an hour, his instructions were to call the Apple Store Regent Street and tell them to review my latest notes. They were to process a refund for a full retail priced iPhone 5 64BG black onto my credit card so that I could use that money to buy a new iPhone 5 64GB black at the Apple Store Brea Mall to reoslve the problem.
    The Apple Store Regent Street did not process my refund. He, name can be provided upon request, told me that the AppleCare US did not do a good job reviewing my case, that they were incapable of getting to the bottom of it like they were, and instructed me to call AppleCare US and tell them to review this case number and this repair id. I asked if he read the notes from the AppleCare US Senior Advisor and he would not confirm nor deny. When I offered to give him the case number he accepted but it seemed like would do no good. Our call was disconnected. When I tried calling back the stores automated system was turned on and I could not get back through.
    Now I have the full retail price of an iPhone 5 64GB black CDMA on my credit card and Apple will not process the refund as they said they would.
    I've, at this point, spent between 14-16 hours at Apple Stores or on the phone with AppleCare representatives, and still do not have the problem resolved.
    SOLUTION
    AppleCare US and AppleCare Europe need to resolve their internal family issues without further impacting their customers.
    Apple is to process a refund to my credit card for the cost of a full retail priced iPhone 5 64GB black.
    DESIRED OUTCOMES
    I have an iPhone 5 (A1429 CDMA model) that works in the US on VZW as it did before I received the replacement phone in the UK.
    Apple covers the cost of the solution because I did not create the problem.
    Apple resolves their internal issue without costing me more time, energy, or money.
    This becomes a case study for AppleCare so that future customers are not impacted like I have been by their support system.
    Does anyone have recommendations for me?
    Thank you!
    <Edited by Host>

    Thanks, but I've been on the phone with AppleCare US (where I am and live) and AppleCare UK. They continue bouncing me back and forth without helping resolve the problem.
    Perhaps someones knows how to further escalate the issue at Apple?

  • How can I have threads communicate with each other?

    I'm working on a project that requires a group of classes communicating with each other. I decided on using a server and carrying out communication that way. However, my app only has communication between the client and server. I need the clients to be able to communicate with each other. Does anyone know how I can do this or point me to a good tutorial?

    Sorry, here's a bone stock example of my server and client:
    <SERVER>
    package testserver;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class TestServer
    static int portOpen;
    public static void main(String[] args)
    portOpen=4000;
    try
    ServerSocket portListener = new ServerSocket(portOpen);
    TestServer userThreads = new TestServer();
    while (1==1)
    Socket userConnection=portListener.accept();
    userThreads.new PortConnection(userConnection);
    catch (Exception e)
    System.out.println("The server encountered a serious error. Server shut down.");
    e.printStackTrace();
    System.exit(0);
    class PortConnection extends Thread
    //Declare variables to handle connections.
    Socket ourConnection;
    BufferedReader serverInput;
    PrintWriter serverOutput;
    PortConnection(Socket userConnection)
    try
    ourConnection=userConnection;
    serverInput=new BufferedReader(new InputStreamReader(userConnection.getInputStream()));
    serverOutput=new PrintWriter(userConnection.getOutputStream(),true);
    start();
    catch (Exception e)
    System.out.println("An error occurred when a user attempted a connection.");
    public void run()
    serverOutput.println("Welcome to the Server.");
    try
    serverOutput.close();
    serverInput.close();
    ourConnection.close();
    catch (Exception e)
    </SERVER>
    <CLIENT>
    package testclient;
    import java.io.*;
    import java.util.*;
    import java.net.*;
    public class TestClient {
    static BufferedReader userInput;
    static Socket quizServer;
    static BufferedReader serverInput;
    static PrintWriter serverOutput;
    static String serverData;
    public static void main(String[] args) {
    userInput = new BufferedReader(new InputStreamReader(System.in));
    try {
    quizServer=new Socket("localhost",4000);
    catch (Exception e) {}
    try
    serverInput=new BufferedReader(new InputStreamReader(quizServer.getInputStream()));
    serverOutput=new PrintWriter(quizServer.getOutputStream(),true);
    catch (Exception e) {}
    try {
    serverData=serverInput.readLine();
    catch (Exception e) {}
    System.out.println(serverData);
    </CLIENT>

  • Pdf documents merging with each other

    Hi all
    I am facing a problem regarding writing pdf documents using iText. I have an application that generates different pdf documents using a common function that generates the pdf. Problem occurs when two or more people generate pdfs. Most of the times the pdfs get merged with each other, which is a serious problem. Please help me regarding this.
    Thanks
    Gurpreet Singh

    sounds like this fuction of yours is making use of a static variable or two.

  • I have 2 Apple ids and two corresponding iCloud accounts. My five Apple devices are linked to one or the other. As one consequence a small number of my contacts are associated with one iCloud account, the majority with the other. How can I merge?

    For reasons not entirely clear to me I have ended up with two Apple ids, two iCloud accounts and my Apple devices being associated with one or the other iCloud account/Apple id. One of the complications is that my contacts are partially owned by one iCloud account, partially by the other.
    Is there any way to
    - merge the contacts (I have tried exporting from one and importing into the other but one set will overwrite the other)?
    - migrate all devices to one single iCloud account without being locked out for 3 months?
    - merge Apple ids or just delete one of them without locking out devices?
    Grateful for any suggestions because this is turning into a headache.

    You can merge the contacts from one account with your other one without overwriting them.  Sign into the first account, download them as vCard (iCloud: Export contact information as a vCard), email them to a device signed into the account you want to merge them with, tap the vCard and choose Add..., then Create New Contacts.
    You can also migrate a copy of the data in one account and merge it with the other by signing into the account you are leaving, then signing out (or deleting the account if not running iOS 8), then choosing Keep on My iDevice when prompted.  Then sign into the other account and choose Merge when prompted.  This won't move Notes however.  If you are syncing notes that you want to migrate from the other account, you can temporarily add the account to your Mac as a secondary account by going to System Preferences>Internet Accounts (or Mail,Contacts,Calendars)>Add Account>iCloud and signing in with the other account ID.  Then enable notes syncing in the secondary account.  You will then be able to open the notes app and drag and drop notes from one account to the other.  When you're done, delete the secondary account from your Mac.
    You can't merge IDs as Apple does not allow it.  Also, you won't be locked out of anything for 3 months.  The "90-day switch" rule only applies to changing your iTunes store account, not your iCloud account.  Just leave your iTunes store account as-is.  The ID you use for the iTunes store does not have to be the same as the ID you use for iCloud.

  • Using Catalyst 3550 Switch with Linksys Home Router and Cable Internet

    I've about pulled what little hair I have out of my head on this one, and need some configuration help.
    I have a Cisco Catalyst 3550 switch with five Windows 7 desktops, an Avaya PBX and five Avaya IP phones attached.  All of these devices are on a 192.168.0.0/24 subnet, and are communicating properly.  I will refer to this as network # 1. I also have SEPARATE network, we'll call network # 2, using AT&T ADSL service and a Netgear 4-port/wireless router/ADSL modem combo device, which is functioning properly with a couple of other Windows 7 desktops over its own wired Ethernet network, using DHCP, and also on a 192.168.0.0/24 subnet.  I thought it would be a simple integration, just plugging one of the 3550's ports to one of the DSL router's ports, in order to give the five Windows 7 desktop computers on network # 1 internet access via the DSL modem. Guess I was wrong.  When I connect the two switches together, although I get a good connectivity (green lights on both ports) and am able to ping the DSL router's gateway address (192.168.0.252) from network # 1's computers, the computers on network # 1 cannot access the internet. Also, the working computers on network # 2 lose their internet access as long as the two switches are connected together. I am not a Cisco guru, but there's got to be a way to make this scenario work.  Can someone provide me with a 3550 configuration that will allow me to extend my internet service from network # 2 on the DSL router to my 3550 switch and their computers?  Here's what I am looking for:
    INTERNET ---> ADSL MODEM ---> NETGEAR ROUTER ---> CISCO 3550 SWITCH ---> NETWORK DEVICES WITH INTERNET ACCESS

    The Netgear router is probably what's doing the natting. Is the 3550 configured for routing or is it straight L2? If you have the 3550 configured as L3, then it's going to be easy to do what you want. Just add a static route on the Netgear to point the subnet that it doesn't know about to the 3550. For example, if the Netgear is addressed at 192.168.1.1 and the Cisco 3550 is addressed at 192.168.1.2, but it also knows about the 192.168.0.0/24 (separate vlan), then you would put a static route on your Netgear for 192.168.0.0/24 to go to 192.168.1.2.
    The way that I would do it is to create a separate vlan on the 3550 and assign an address to it. Once you do that, make the port that the other switch connects to an access port of that vlan. (It would need to be on the same subnet as the existing equipment.) All of your devices would use it as a default gateway and then you would do the rest as above. You could also use RIP between the Netgear and Cisco if you can't do static routing.
    HTH,
    John

  • After installing an update I am no longer able to hear sound out of my speakers. A red light comes on where the headphone jack is. I have already attempted to trip to switch with a wooden toothpick in the headphone jack but have not had luck.

    after installing an update I am no longer able to hear sound out of my speakers. A red light comes on where the headphone jack is. I have already attempted to trip to switch with a wooden toothpick in the headphone jack but have not had luck.

    Have you gone into system prefs nad made sure that the headphone port is set to audio out. And not audio in.
    Also make sure that you are selecting built in speakers for your audio output.
    If that does not fix it try doing a Pram reset.
    Shut your mac down.
    Press the startup button.
    Hold down the following keys. Command Option P and R. Wait till you hear the chime 2 times. Then let go. See if that fixes it.

  • Toggle switches with if else

    I am trying to toggle various switches based off of others and am wondering how I can go about this. For example, if switch A is on, B should toggle off. If I toggle B on, A should toggle off. Any help in doing this would be appreciated. Thanks.

    Thank you for an easy question..... 
    There's a mode in the Switch options that allows you to create a single switch with two channels, where only one will be on.
    - cj
    Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.

  • HELP I have lost all my motion 4 content from all the files, ive looked in all the files and they are all empty. can i get replacement content as I my dvds where stolen along. with my other laptop.

    HELP I have lost all my motion 4 content from all the files, ive looked in all the files and they are all empty. can i get replacement content as I my dvds where stolen along. with my other laptop. any Ideas. would be a great help. For Motion 4.

    Try a hard reset:- hold the home button AND the power switch - ignore the red "Slide to power off" and wait ubntil the iPhone powers down, and then restarts - at the Apple logo, release all the buttons and see if your contacts reappear.

Maybe you are looking for

  • Disturbing TM deletion behavior after multiple restores

    I have found a seriously disturbing (to me, at least) behavior in Time Machine after doing two system restores. Here is the scenario: November 19: Time Machine has been working fine for months, and I have full weekly backups to June when I first upgr

  • Check marks when texting

    I've recently noticed that when I send texts on my phone to other numbers that are Verizon there is no longer a check mark to confirm that they have received the text. I have a Samsung intensity 2 and its always done the check mark thing before. I wa

  • How to increase painting performance ?

    First off all, i'd like to apologize for my poor english, because I'm from brazil, and even knowing very well how to speak english, my spelling sometimes comes out really nasty. Now getting to the subject... ;^) I study computer science here in brazi

  • What features not available to crystal reports would you like???

    Post Author: Saiedh CA Forum: General Read my blog and post to the comments to let me know what you would like: http://xaisoft.blogspot.com/2007/10/development-of-automated-crystal.html

  • Do I need security, anti-virus etc on mac?

    Should I get anti virus security or some sort of security on my macbook. Are there any free downloads i could get that would do the job?