《C++编程复习题A》由会员分享,可在线阅读,更多相关《C++编程复习题A(18页珍藏版)》请在金锄头文库上搜索。
1、第 1 页 共 18 页C+ 编程复习题A 01、编写一个 C+程序以求出:大于0 且小于 1001的偶数之和。#include using namespace std; void main() int j=0; for(int i=1;i using namespace std; void main() int j=0; for(int i=1;i #include using namespace std; void main() int i=10,j=0; while (j #include using namespace std; void main() int i=10,j=0; 第
2、3 页 共 18 页while (j #include using namespace std; void main() int i=1,j=0; while (j #include 第 4 页 共 18 页using namespace std; void main() int i=1,j=0; while (j #define f(a,b,c) (ab?(ac?a:c):(bc?b:c) using namespace std; void main() int a,b,c; cinabc; cout #define f(a,b,c) (aabc; cout using namespace
3、std; void main() int x,y; cinxy; cout using namespace std; 第 6 页 共 18 页void main() int a,b,c; cinabc; cout using namespace std; void main() int i,j=0; for(i=100;i using namespace std; void main() int i,j=0; for(i=100;i #include using namespace std; void main() double j=200,k=200; for(int i=1;i #incl
4、ude using namespace std; 第 9 页 共 18 页void main() double j=1; for(double i=2;i #include using namespace std; void main() double j=0,k=1,l=2; for(int i=0;i #include using namespace std; void main() char a100; cina; for(int i=0;i=A void main() char a100; cina; for(int i=0;i=a void main() double t,k,a,b
5、; int j; cinab; 第 12 页 共 18 页t=a*0.300+b*0.700; j=(int)t; k=t-j; k*=10; if(k #include using namespace std; int a(int i) for(int j=2;j #include 第 14 页 共 18 页#include using namespace std; void main() double x1,x2,a; cina; x1=sqrt(a); cout using namespace std; void main() int l; for(int i=1;i #include
6、using namespace std; void main() double b; for(double i=0;i #include using namespace std; void main() int a10; for(int i=0;i=0;j-) cout using namespace std; int sign(double b) if(bb; cout using namespace std; double centigrade( int fahrenheit ) double l; l=5.0/9.0*(fahrenheit-32); return l; void main() 第 18 页 共 18 页 int b; cinb; cout using namespace std; void stringCopy( char *from, char *to ) to=from; couttoendl; void main() char s1=“abcdef“,*p; stringCopy(s1,p);