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

  1. 1、本文档共133页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
;1; 1.2 把下列数学表达式写成 c++算术表达式 1. 1 2. x{x[x(ax+b)+c]+d}+e 1 ???1 1 ? 1 ;4;5;5;5; <<"\nra="<<ra<<"\n*rt="<<*rt<<endl; } 程序输出结果为: ; case 2 : i -- ; ; 20 ; ; for( j=0; j<=3; j++ ) ;} ;循环控制是在特定的条件下,程序重复执行一些特定动作。 ; ;程序运行后,输入a 的值为 4,b 的值为 9,显示结果如下: ;#include<iostream> ; 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 <iostream> 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<iostream> 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<iostream> 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<z ) { t = y; y = z; z = t; } if( x<z ) { t = x; x = z; z = t; } if( x<y ) { t = x; x = y ;y = t; } cout << x << '\t' << y << '\t' << z << '\t' << endl; } ;41;42;43;int f( int a[][3], int row, int col ) ; int i ; char c ; ; { if ( *p == *q ) ;3.要把一维数组 int a[m*n

文档评论(0)

moxideshijie2012 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档