THE CODERS

Thursday, 12 January 2017

Swapping 3 variable without extra variable

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;

    a=(a+c)-(c=a);
    b=(c+b)-(c=b);

    cout<<a<<" "<<b<<" "<<c;
    return 0;
}

Posted by Unknown at 03:47
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: Algorithm

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

Unknown
View my complete profile

Labels

  • Algorithm
  • Data Structure
  • MyLibrary
  • Project Euler

Blog Archive

  • ►  2018 (4)
    • ►  September (3)
    • ►  August (1)
  • ▼  2017 (17)
    • ▼  January (17)
      • Longest Palindrome subsequences
      • HackeRank_weekofcode28_theValueofFriendship
      • Swapping 3 variable without extra variable
      • Euler's Totient Function
      • Prime (SieveOfEratosthenes)
      • Project Euler #47: Distinct primes factors
      • Find the element that appears once (Bit Algorithms)
      • Longest Increasing Subsequence (Dynamic Programming)
      • Stack Data Structure Implementation using class in...
      • Heap Sort Implementation in Cpp
      • Power Funtion with Complexity (log(n))
      • Sorting of multiple number in structure of array i...
      • Cycle Detection in connected undirected graph usin...
      • Cycle Detection in directed graph using DFS (Imple...
      • BFS Implementation in cpp
      • DFS Implementation in cpp
      • Linked list implementation using class in cpp
  • ►  2016 (2)
    • ►  December (2)
Simple theme. Powered by Blogger.