c程序设计语言练习,c程序设计语言习题与答案.pptx

;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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值