50道C++编程练习题及解答.docVIP

  • 884
  • 0
  • 约1.15万字
  • 约 8页
  • 2017-03-23 发布于重庆
  • 举报
50道C编程练习题及解答

50道C/C++编程练习题 1、输入3个数,求最大值 int main() { int a,b,c,m; cinabc; m=a; if(bm) m=b; if(cm) m=c; coutm; } 2、编程序,求方程ax2+bx+c=0的根 #includeiostream #includecmath using namespace std; int main() { double a,b,c,d,x1,x2; cinabc; if(a==0) if(b==0) couterror\n; else cout x=-c/bendl; else { d=b*b-4*a*c; if(fabs(d)=1e-6) coutx1=x2=-b/(2*a)endl; else if(d1e-6) { x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); coutx1=x1,x2=x2endl; } else cout方程无实根\n; } } 3、输入一个成绩,打印相应的等级 int main() { int a; cin a; if(a=90) coutA; else if(a=80)

文档评论(0)

1亿VIP精品文档

相关文档