2分段函数
4自动取款机 # include<iostream>
using namespace std;
int main()
{
int x,z;
const int y=199710;
cin>>x;
if(x==y)
{
cout<<"1.查询\n"<<"2.取款\n"<<"3.存款\n"<<"4.转账\n"<<"0.退出\n";
cin>>z;
cout<<"谢谢,"<<"你选择了" <<z<<"号功能";
}
else
cout<<"密码错误";
return 0;
#include<iostream>
using namespace std;
int main()
{
double x,y;
cin>>x;
if(x>=1)
{
y=x-1;
cout<<y;
}
else
{
y=1-x;
cout<<y;
}
return 0;
}
3两点距离
# include<iostream>
# include<cmath>
using namespace std;
int main()
{
double x1,x2,y1,y2,a,b,c;
cin>>x1>>x2>>y1>>y2;
a=(x1-x2)*(x1-x2);
b=(y1-y2)*(y1-y2);
c=sqrt(a+b);
cout<<c<<endl;
}
4自动取款机 # include<iostream>
using namespace std;
int main()
{
int x,z;
const int y=199710;
cin>>x;
if(x==y)
{
cout<<"1.查询\n"<<"2.取款\n"<<"3.存款\n"<<"4.转账\n"<<"0.退出\n";
cin>>z;
cout<<"谢谢,"<<"你选择了" <<z<<"号功能";
}
else
cout<<"密码错误";
return 0;
}