ex213.cpp
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:0k
源码类别:

书籍源码

开发平台:

Visual C++

  1. #include <iostream.h>
  2. int max(int x,int y);        //函数声明,max()函数版本1
  3. float max(float x,float y);//函数声明,max()函数版本2
  4. void main()
  5. {
  6. int x1,y1,z1;
  7. float x2,y2,z2;
  8. cout<<"Please input two int and two float:"<<endl;
  9. cin>>x1>>y1; //读入两个数值赋给x1和y1
  10. cin>>x2>>y2; //读入两个数值赋给x2和y2
  11. z1=max(x1,y1);
  12. z2=max(x2,y2);
  13. cout<<"z1="<<z1<<endl;
  14. cout<<"z2="<<z2<<endl;
  15. }
  16. int max(int x,int y)
  17. {
  18. return x>y?x:y;
  19. }
  20. float max(float x,float y)
  21. {
  22. return x>y?x:y;
  23. }