北邮C++实验四作业.pdfVIP

  • 6
  • 0
  • 约5.27千字
  • 约 13页
  • 2022-04-20 发布于中国
  • 举报
5.3 实验题 一、基础题 1.修改下列程序中的错误,输出结果,输出示例如图5-1所示。并对有注释标记的语句进 行功能注释。 #includeiostream usingnamespacestd; void f1(int x[ ]) { for(int i=0;i10;i++) {x[i]=2*x[i]+1; if(i==5) //第六个元素后换行 coutx[i]endl; else coutx[i] ;} coutendl; } void main() { int a[10]; for(int i=0;i10;i++) cina[i]; //输入并赋值给数组a[] f1(a); //执行函数f1 () system(pause); } 2.修改下列程序的错误,完成求最大数的功能。 #includeiostream usingnamespacestd; inlineint f1(intx,int y) { return xy?x:y; } void main() { int a=120,b=300,c=40; intd,e,f;

文档评论(0)

1亿VIP精品文档

相关文档