Skip to content

Commit

Permalink
Update ex6_12.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy authored and pezy committed Jun 21, 2015
1 parent 3ad3294 commit 2c9d697
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions ch06/ex6_12.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//!@Alan
//!@Yue Wang
//!
//! Exercise 6.12:
//! Rewrite the program from exercise 6.10 in § 6.2.1 (p. 210) to use
Expand All @@ -8,34 +8,28 @@
//!



#include <iostream>
#include <string>
#include <stdexcept>

using namespace std;

void swap(int& _n1, int& _n2);
void swap(int& lhs, int& rhs)
{
int temp = lhs;
lhs = rhs;
rhs = temp;
}

int main()
{
int n1, n2;

cout<<"Please Enter:\n";
while(cin>>n1>>n2)
int left, right;
std::cout << "Please Enter:\n";
while (std::cin >> left >> right)
{
swap(n1, n2);
cout<<n1<<" "<<n2<<endl;
swap(left, right);
std::cout << left << " " << right << std::endl;
}

return 0;
}

void swap(int &_n1, int &_n2)
{
int temp;
temp = _n1;
_n1 = _n2;
_n2 = temp;

}

0 comments on commit 2c9d697

Please sign in to comment.