forked from newde/homework
镇乃天子
This commit is contained in:
13
666/交换.cpp
Normal file
13
666/交换.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int a,b,c;
|
||||||
|
cin>>a>>b;
|
||||||
|
cout<<a<<" "<<b<<" ";
|
||||||
|
c=a;
|
||||||
|
a=b;
|
||||||
|
b=c;
|
||||||
|
cout<<a<<" "<<b<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
13
666/交换2.cpp
Normal file
13
666/交换2.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int a,b,c;
|
||||||
|
cin>>a>>b;
|
||||||
|
cout<<a<<" "<<b<<" ";
|
||||||
|
c=a;
|
||||||
|
a=b;
|
||||||
|
b=c;
|
||||||
|
cout<<a<<" "<<b<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
666/交换3.cpp
Normal file
18
666/交换3.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
int a=25,b=32,tmp;
|
||||||
|
int *ptr_a, *ptr_b;
|
||||||
|
|
||||||
|
ptr_a=&a;
|
||||||
|
ptr_b=&b;
|
||||||
|
|
||||||
|
cout<<*ptr_a<<" "<<*ptr_b<<" ";
|
||||||
|
cout<<ptr_a<<" "<<ptr_b<<" ";
|
||||||
|
tmp=*ptr_a;
|
||||||
|
*ptr_a=*ptr_b;
|
||||||
|
*ptr_b=tmp;
|
||||||
|
cout<<a<<" "<<b<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
24
666/最大值2.cpp
Normal file
24
666/最大值2.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int a[5]={87,99,3,12,1};
|
||||||
|
int max=a[0];
|
||||||
|
int * ptr_x;
|
||||||
|
ptr_x=a;
|
||||||
|
|
||||||
|
|
||||||
|
for(int i=1;i<5;i++){
|
||||||
|
|
||||||
|
if(*ptr_x > max){
|
||||||
|
max = *ptr_x;
|
||||||
|
}
|
||||||
|
ptr_x++;
|
||||||
|
cout<<ptr_x<<endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cout<<max<<" ";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
17
666/最大值3.cpp
Normal file
17
666/最大值3.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include<iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main(){
|
||||||
|
int a[5]={9,99,999,9999,99999};
|
||||||
|
int *ptr_x;
|
||||||
|
int max;
|
||||||
|
ptr_x=a;
|
||||||
|
max=*ptr_x;
|
||||||
|
for(int i=1;i<=5;i++){
|
||||||
|
if(*ptr_x>max)
|
||||||
|
max=*ptr_x;
|
||||||
|
ptr_x++;
|
||||||
|
}
|
||||||
|
cout<<max<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user