上传文件至「20260314」
This commit is contained in:
17
20260314/交换指针.cpp
Normal file
17
20260314/交换指针.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int * ptr_a, * ptr_b,temp;
|
||||||
|
ptr_a = new int;
|
||||||
|
ptr_b = new int;
|
||||||
|
cout<<"请输入*ptr_a的值:";
|
||||||
|
cin>>*ptr_a;
|
||||||
|
cout<<"请输入*ptr_b的值:";
|
||||||
|
cin>>*ptr_b;
|
||||||
|
temp=*ptr_a;
|
||||||
|
*ptr_a=*ptr_b;
|
||||||
|
*ptr_b=temp;
|
||||||
|
cout<<*ptr_a<<" "<<*ptr_b<<endl;
|
||||||
|
delete ptr_a,ptr_b;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user