c++第二次作业

来源:互联网 发布:淘宝客户维护方案 编辑:程序博客网 时间:2024/05/21 08:00
<pre name="code" class="cpp">#include<iostream>  using namespace std;  int main()  {       int x,y;       cout<<"输入x的值:";       cin>>x;       if(x>=1)           cout<<"y="<<x-1<<endl;       else           cout<<"y="<<-x+1<<endl;       return 0;  } 

 #include<cmath>  #include<iostream>    using namespace std;  int main()  {      double x1,y1,x2,y2;      cout<<"输入第一个点的坐标:";      cout<<"x1=";      cin>>x1;      cout<<"y1=";      cin>>y1;          cout<<"输入第二个点的坐标:";      cout<<"x2=";      cin>>x2;      cout<<"y2=";      cin>>y2;      cout<<"两点间的距离:"<<sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))<<endl;      return 0;  }  

#include<iostream>  using namespace std;  int main()  {      int m=199704,m1,x;      cout<<"刘氏银行欢迎你!"<<endl;      cout<<"请输入密码:";      cin>>m1;      if(m1==m)      {          cout<<"密码正确"<<endl;          cout<<"请选择操作内容:1.查询2.取款3.存款4.转帐0.退出"<<endl;          cin>>x;          if(x==1)              cout<<"谢谢,您选择了1号功能"<<endl;          else if(x==2)              cout<<"谢谢,您选择了2号功能"<<endl;          else if(x==3)              cout<<"谢谢,您选择了3号功能"<<endl;          else if(x==4)              cout<<"谢谢,您选择了4号功能"<<endl;          else if(x==0)              cout<<"谢谢,您选择了0号功能"<<endl;      }      if(m1!=m)          cout<<"对不起,密码错误,请重新输入"<<endl;      return 0;  }



0 0
原创粉丝点击