天天看點

c語言兩個指針交換指向_C ++程式使用指針交換兩個數字

c語言兩個指針交換指向_C ++程式使用指針交換兩個數字

c語言兩個指針交換指向

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int *a,*b,*temp;

cout<<“Enter value of a and b:”;

cin>>*a>>*b;

temp=a;

a=b;

b=temp;

cout<<“nAfter swapingna=”<<*a<<“nb=”<<*b;

getch();

}

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr();

int *a,*b,*temp;

cout<<“Enter value of a and b:”;

cin>>*a>>*b;

temp=a;

a=b;

b=temp;

cout<<“n After swaping na=”<<*a<<“nb=”<<*b;

getch();

}

翻譯自: https://www.thecrazyprogrammer.com/2013/05/c-program-to-swap-two-numbers-using_30.html

c語言兩個指針交換指向