全局变量的例子

 1 #include<iostream>
 2 using namespace std;
 3 int a=0; int b=0;
 4 void exchange(){
 5     int p;
 6     if(a<b){
 7     
 8     p=a;
 9     a=b;
10     b=p;
11     
12 }
13 }
14 
15 int main(){
16     cin>>a>>b;
17     exchange();
18     cout<<a<<""<<b<<endl;
19     return 0;
20     
21     
22     
23 }

 

posted @ 2017-07-05 15:52  阿元不会写代码啦  阅读(273)  评论(0编辑  收藏  举报