;1;
1.2 把下列数学表达式写成 c++算术表达式1. 12. x{x[x(ax+b)+c]+d}+e 1 ???11 ? 1;4;5;5;5;
< ; case 2: ; case 'p': ; { x0 = x; x =( x0 + a/x0 )/2; ;10.求 100 到 999 中的水仙花数。所谓水仙花数是指一个三位数??它的每位数字的立方之和等于该数。;* * * * * * * * * ;(a) int a = 21; fun2( a ); ;{ int i; ;} ;*t1=20,*t2=25,*rt=20 ;using namespace std; ;【解答】 ;3. 什么叫形式参数?什么叫实际参数?C++函数参数有什么不同的传递方式?请写一个验证程序说;30;31;32; ; cout << "max=" << max << endl; ; cout << "输入难度错误,重新输入!" << endl; ;36;37;
#include using namespace std; void print( int w ) { for( int i = 1 ; i <= w ; i ++ ) { for( int j = 1 ; j <= i ; j ++ ) cout << i << " " ; cout << endl ; } } int main() { print( 5 ) ; } 运行显示: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 【解答】 #include using namespace std; void print(int w) { int i; if( w ) ; ;
using namespace std; void display( double d ) { cout << "a double:" << d << endl; } void display( int i ) { cout << "a int:" << i << endl; } void display( char c ) { cout << "a char:" << c << endl; } int main() { double d = 1.5; int i = 100; char c = 'a'; display( d ); display( i ); display( c ); } 9.使用重载函数编程序分别把两个数和三个数从大到小排列。 【解答】 #include using namespace std; void sort( double x,double y ); void sort( double x,double y,double z ); int main() { sort( 5.6, 79 ); sort( 0.5, 30.8, 5.9 ); } void sort(double x,double y) { if ( x>y ) cout << x << '\t' << y << endl; else cout << y << '\t' << x << endl; } void sort( double x,double y,double z ) { double t; if( y