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 66 67 68 69 70 71
|
#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, b = 10;
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 );
}
// Output
//2 10
//3 9 12
//12 10
//17 289
//25 10
//25 10
//25 10
|