sedran

Pointer Denemeleri Vol1

Oct 15th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. /*
  2.  * pointer.cpp
  3.  *
  4.  *  Created on: 15 Eki 2011
  5.  *      Author: Serdar Kuzucu
  6.  *      WebPage: http://blog.asosyalbebe.com
  7.  */
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. void swapp(int *x, int *y) {
  14.     int temp = *x;
  15.     *x = *y;
  16.     *y = temp;
  17. }
  18.  
  19. void swappp(int &x, int &y) {
  20.     int temp = x;
  21.     x = y;
  22.     y = temp;
  23. }
  24.  
  25. int main() {
  26.     int x = 5, y = 2;
  27.     cout << "x = " << x << " | y = " << y << endl;
  28.     swapp(&x, &y);
  29.     cout << "x = " << x << " | y = " << y << endl;
  30.     swappp(x, y);
  31.     cout << "x = " << x << " | y = " << y << endl;
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment