引用

  1 #include <iostream>
  2 #include <cstdio>
  3 #include <cstring>
  4 #include <algorithm>
  5 #include  <set>
  6 #include <map>
  7 #include <vector>
  8 #include <cmath>
  9 using namespace std;
 10 typedef long long ll;
 11 const int inf=0x3f3f3f3f;
 12 typedef struct Node
 13 {
 14     int num;
 15 Node *next;
 16 }Node,*Nod;
 17 void ex1(int a,int b)
 18 {
 19     int t;
 20     t=a,a=b,b=t;
 21 }
 22 void ex2(int *a,int *b)
 23 {
 24     int t;
 25     t=*a,*a=*b,*b=t;
 26 }
 27 void ex3(Nod x)
 28 {
 29     Nod y;
 30     y=new Node;
 31     x->next=y;
 32     x=y;
 33 }
 34 void ex4(Nod &x){
 35     Nod y;
 36     y=new Node;
 37     x->next=y;
 38     x=y;
 39 }
 40 void ex5(Nod x)
 41 {
 42     x->num=45;
 43 }
 44 int main()
 45 {
 46     /*
 47     int a,b;
 48     scanf("%d%d",&a,&b);
 49     printf("%d %d
",a,b);
 50     ex1(a,b);
 51     printf("%d %d
",a,b);
 52     ex2(&a,&b);
 53     printf("%d %d
",a,b);
 54     
 55     /*
 56 3 5
 57 3 5
 58 3 5
 59 5 3
 60 
 61 */
 62     
 63     Nod x;
 64     x=new Node;
 65     x->num=9;
 66     cout<<x->num<<endl;
 67     ex3(x);
 68     cout<<x->num<<endl;
 69     ex4(x);
 70     cout<<x->num<<endl;
 71     ex5(x);
 72     cout<<x->num<<endl;
 73     /*
 74     9
 75     9
 76     14577624
 77     45
 78 */
 79 
 80     
 81 
 82     return 0;
 83 }
 84 
 85 
 86 
 87 
 88 
 89 #include <iostream>
 90 #include <cstdio>
 91 #include <cstdlib>
 92 #include <cstring>
 93 #include <iostream>
 94 #include <algorithm>
 95 #include <cmath>
 96 #include <queue>
 97 #include <set>
 98 #include <string>
 99 #include <map>
100 using namespace std;
101 #define  pi acos(-1.0)
102 #define e 1e-8
103 typedef long long ll;
104 const int N=150100;
105 void f1(int x)
106 {
107     x=2;
108     
109     return ;
110 }
111 void f2(int &x)
112 {
113     x<<=1;
114     
115 }
116 int main()
117 {
118     int x;
119     scanf("%d",&x);
120     f1(x);
121     printf("%d
",x);
122     f2(x);
123     printf("%d
",x);
124     return 0;
125 }
126 5
127 5
128 10
129 
130 
131 
132 #include <iostream>
133 #include <cstdio>
134 #include <cstring>
135 #include <algorithm>
136 #include  <set>
137 #include <map>
138 #include <vector>
139 #include <cmath>
140 using namespace std;
141 typedef long long ll;
142 const int inf=0x3f3f3f3f;
143 struct Node
144 {
145     int num;
146 };
147 void f1(Node x)
148 {
149     x.num=1;
150 }
151 void f2(Node &x)
152 {
153     x.num=1;
154 }
155 int main()
156 {
157     Node x;
158     x.num=9;
159     f1(x);
160     cout<<x.num<<endl;
161     f2(x);
162     cout<<x.num<<endl;
163 }
164 9
165 1
 1 int b=2;
 2 void f(int x){
 3     b=b+x;
 4 }
 5 int   main(){
 6     
 7     f(2);
 8     printf("%d
",b);
 9 }
10 4
/*
已知学生的记录由学号和学习成绩构成,n 名学生的数据已存入 a 结构体数组
中。请编写函数 fun,该函数的功能是:找出成绩最低的学生记录,通过形参返回主函数(规
定只有一个最低分)。
*/
void f(stu a[],stu &s){
    int i,min;
    min=a[0].s;
    for(int i=0;i<5;i++){
        if(a[i].s>min){
            min=a[i].s;
            s=a[i];
        }
    }
}

stu a[5],st;
int main()
{
    for(int i=0;i<5;i++){
        a[i].s=i;
    }
    f(a,st);
    printf("%d
",st.s);
    return 0;
}
原文地址:https://www.cnblogs.com/tingtin/p/9965859.html