![在这里插入图片描述](https://img-blog.csdnimg.cn/86ae5f36419049ac819f7bf231491588.png)
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
double fun(int n)
{
if(n==1)
return 1;
else
return fun(n-1)+pow(0.5,n-2);
}
int main()
{
int n;
double h;
cout<<"请输入高度h和次数n"<<endl;
while(cin>>h>>n)
{
if(h==0&&n==0)
break;
if(h<0||n<1)
cout<<"请输入正确的h和n"<<endl;
else
{
cout<<fixed<<setprecision(2)<<fun(n)*h<<endl;
cout<<"请输入高度h和次数n,以0 0结束"<<endl;
}
}
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/9fd4083b0fda42d6b75b02c77b492b81.png)
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
class CPoint
{
private:
double x,y;
public:
CPoint(){};
CPoint(double i,double j)
{
x=i;
y=j;
}
double operator-(CPoint d)
{
return (sqrt(pow(x-d.x,2)+pow(y-d.y,2)));
}
};
int main()
{
double x1,y1,x2,y2;
cout<<"请输入第一个点的坐标"<<endl;
cin>>x1>>y1;
CPoint c1(x1,y1);
cout<<"请输入第而个点的坐标"<<endl;
cin>>x2>>y2;
CPoint c2(x2,y2);
cout<<"两点之间的距离为:"<<endl;
cout<<c1-c2<<endl;
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/49c2a61b01db44dba865d0813286bbfe.png)
#include <iostream>
#include <cmath>
using namespace std;
class Cpoint{
private:
double x;
double y;
public:
Cpoint() {};
Cpoint(double a,double b):x(a),y(b) {};
double operator-(Cpoint a)
{
return abs(sqrt(pow(x-a.x,2)+pow(y-a.y,2)));
}
};
class CTriangle:public Cpoint
{
private:
double a,b,c;
public:
CTriangle(){};
CTriangle(double i,double j,double k)
{
a=i;
b=j;
c=k;
}
bool Isjudge0()
{
if(a+b>c&&a+c>b&&b+c>a)
return true;
else
return false;
}
bool Isjudge()
{
if(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)
return true;
else
return false;
}
double showc()
{
return a+b+c;
}
};
int main()
{
double a,b,c,d,e,f,d1,d2,d3;
cout<<"请输入平面上三个点的坐标"<<endl;
while(cin>>a>>b>>c>>d>>e>>f)
{
if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0)
break;
Cpoint c1(a,b);
Cpoint c2(c,d);
Cpoint c3(e,f);
CTriangle c(c1-c2,c1-c3,c2-c3);
if(!c.Isjudge0())
{
cout<<"该三点不能围成三角形,请重新输入"<<endl;
}
else
{
if(c.Isjudge())
{
cout<<"周长为:"<<c.showc()<<",该三角形是直角三角形"<<endl;
}
else
cout<<"周长为:"<<c.showc()<<",该三角形不是直角三角形"<<endl;
}
cout<<"请输入平面上三个点的坐标,以0 0 0 0 0 0结束"<<endl;
}
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/e6c7bd0dac5e4f7aac5095b00335a867.png)
#include<iostream>
using namespace std;
class Student
{
private:
char name[10];
int num;
public:
Student(){};
Student(char n[],int j)
{
for(int i=0;i<10;i++)
name[i]=n[i];
num=j;
}
void input()
{
cout<<"请输入学生的名字和学号"<<endl;
cin>>name>>num;
}
void ReadFile(istream & in)
{
in>>name>>num ;
}
void show()
{
cout<<"该生的名字为:"<<name<<" 学号为:"<<num<<endl;
}
};
class Message
{
Message(){};
void showmenu()
{
d
}
void search()
void displayup()
void displaydown()
};
int main()
{
int x;
bool quit=false;
Message mass;
sleep(1000);
while(!quit)
{
system("cls");
mass.showmenu();
cin>>x;
switch(x)
{
case 0:quit=true;break;
case 1:mass.search();break;
case 2:mass.displayup();break;
case 3:mass.displaydown();break;
}
}
return 0;
}