1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include <iostream>
#include <cmath>
using std::cout;
using std::endl;
int Fun1 ( int a, int b );
void Fun2 ( int * A, int b );
void Fun3 ( int * c, int * d );
void PrintOutput( int a, int b );
int main ( )
{
int a = 2;
int b = 10;
int *A = & a;
PrintOutput ( a, b );
a = Fun1 ( a, b );
cout << a << "\t" << b << endl;
Fun2 ( A, b );
PrintOutput ( a, b );
return 0;
}
// PrintOutput
void PrintOutput ( int a, int b )
{
cout << a << "\t" << b << endl;
}
// Fun1
int Fun1 ( int a, int b )
{
int c;
c = a + b;
a++;
--b;
cout << a << "\t" << b << "\t" << c << endl;
return c;
}
// Fun2
void Fun2 ( int * A, int b )
{
*A += 5;
double temp = pow(static_cast<double>(*A), 2);
b = static_cast<int>( temp );
PrintOutput ( a, b );
Fun3 ( a, b );
PrintOutput ( a, b );
}
// Fun3
void Fun3 ( int * c, int * d )
{
*c = 25;
*d = 10;
PrintOutput ( c, d );
}
|