第二周作业

来源:互联网 发布:mac原版系统下载 编辑:程序博客网 时间:2024/06/13 05:41
/*************************输出个人信息******************************/#include<iostream>using namespace std;int main(){cout<<"班级:自动化1121"<<endl;cout<<"姓名:陈泽强"<<endl;                                      cout<<"学号:201211632105"<<endl;return 0;}

   

/* 功能: 求两个数的最大值 */  # include < iostream >  using namespace std ;           //编辑预处理命令    int max ( int x , int y )       //求两个数的最大值函数  {      int t ;                     //定义一个整型变量t      if ( x > y )             //if判断语句                          t = x ;      else           t = y ;                       return t ;                  //return语句将t的值返回给主函数main()  }  /* 以下是主函数 */  int main ()                         //主函数  {      int number1 , number2 ;         //定义两个基本整型变量      cout << "请输入两个数:" ;      cin >> number1 >> number2 ;     //从键盘输入两个变量的值(个人觉得,这里用两次cin语句来进行两个数的输入更好)      int maxValue ;      maxValue = max ( number1 , number2 ) ;      //调用求最大值函数max                               //并赋值给maxValue       cout << "最大值 = " << maxValue <<endl ; //输出结果      return 0 ;  }  


0 0