From fe91ecf665a4b867a90a89937c99d7ee3f8ccb4c Mon Sep 17 00:00:00 2001 From: haoxuan Date: Sat, 14 Mar 2026 05:43:26 -0400 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=E3=80=8C20260314=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 20260314/交换指针.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 20260314/交换指针.cpp diff --git a/20260314/交换指针.cpp b/20260314/交换指针.cpp new file mode 100644 index 0000000..3b2a649 --- /dev/null +++ b/20260314/交换指针.cpp @@ -0,0 +1,17 @@ +#include +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<