李爱华、程_面向对象程序设计课后答案.docVIP

  • 67
  • 0
  • 约1.37万字
  • 约 28页
  • 2016-12-02 发布于贵州
  • 举报

李爱华、程_面向对象程序设计课后答案.doc

李爱华、程_面向对象程序设计课后答案

第二章 2-4 #include iostream using namespace std; Add(int a,int b); int main() { int x,y,sum; coutplease input x and y:; cinxy; sum = add(x,y); cout x+y=sumendl; } Add(int a,int b) { return a+b; } 2-5 (1)this is a C++ program. (2) x=50.6 y=10 z=A x=216.34 y=10 z=A x=216.34 y=2 z=A x=216.34 y=2 z=E (3) x y z 500 1000 0 500 1500 1500 500 200 1500 2-6 #include iostream using namespace std; int main() { int *p,*init; int countp=0; int countn=0; p = new int[20]; init = p; for(int i=0;i20;i++) { cin*p; p++; } p = p-20; for( i=0;i20;i++) { if(*p0) countp++; i

文档评论(0)

1亿VIP精品文档

相关文档