首页 > 其他分享 >软工打卡

软工打卡

时间:2023-04-15 22:11:55浏览次数:33  
标签:area int 软工 float public Shape 打卡 class

1.class Car:public Vehicle
{
private:
int zai,zhong;
public:
Car(string NO,int z,int l):Vehicle(NO),zai(z),zhong(l)
{}
int fee()
{
return zai*8+zhong*2;
}
};
class Truck:public Vehicle
{
private:
int zhong;
public:
Truck(string NO,int l):Vehicle(NO),zhong(l)
{}
int fee()
{
return zhong*5;
}
};
class Bus:public Vehicle
{
private:
int zai;
public:
Bus(string NO,int z):Vehicle(NO),zai(z)
{}
int fee()
{
return zai*3;
}
};

2.class Shape
{
public:
Shape()
{

}
virtual float area()=0;
virtual ~Shape()
{

}
};
class Circle:public Shape
{
private:
int x,y;
float radius;
public:
Circle(int X,int Y,float r):x(X),y(Y),radius(r)
{}
float area()
{
return 3.1415*radius*radius;
}
~Circle()
{

}
};
class Rectangle:public Shape
{
private:
int width,height;
public:
Rectangle(int w,int h):width(w),height(h)
{}
float area()
{
return width*height;
}
~Rectangle()
{

}
};

3.#include <iostream>
using namespace std;
class Person
{
public:
Person()
{

}
virtual void bellRing()=0;
virtual ~Person(){}
};
class Student:public Person
{
public:
Student()
{

}
void bellRing()
{
cout<<"I am a student learning in classroom."<<endl;
}
~Student()
{
cout<<"A student object destroyed."<<endl;
}
};
class Teacher:public Person
{
public:
Teacher()
{

}
void bellRing()
{
cout<<"I am a teacher teaching in classroom."<<endl;
}
~Teacher()
{
cout<<"A teacher object destroyed."<<endl;
}
};
class Principal:public Person
{
public:
Principal()
{

}
void bellRing()
{
cout<<"I am the principal inspecting in campus."<<endl;
}
~Principal()
{
cout<<"A principal object destroyed."<<endl;
}
};

4.

#include<iostream>
using namespace std;
class Shape
{
public:
Shape()
{

}
virtual float area()=0;
};
class Circle:public Shape
{
private:
float radus;
public:
Circle(float r):radus(r)
{}
float area()
{
return 3.1415926*radus*radus;
}
};
class Square:public Shape
{
private:
float bian;
public:
Square(float a):bian(a)
{}
float area()
{
return bian*bian;
}
};
class Rectangle:public Shape
{
private:
float width,length;
public:
Rectangle(float w,float l):width(w),length(l)
{}
float area()
{
return width*length;
}
};
class Trapezoid:public Shape
{
private:
float shang,xia,gao;
public:
Trapezoid(float s,float x,float g):shang(s),xia(x),gao(g)
{}
float area()
{
return (shang+xia)*gao/2;
}
};
class Triangle:public Shape
{
private:
float di,ha;
public:
Triangle(float d,float h):di(d),ha(h)
{}
float area()
{
return di*ha/2;
}
};
int main()
{
float a,b,c,d,e,f,g,h,i;
cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
Shape *shape[5]={new Circle(a),new Square(b),new Rectangle(c,d),
new Trapezoid(e,f,g),new Triangle(h,i)};
printf("total of all areas = %.3f\n",shape[0]->area()+shape[1]->area()+
shape[2]->area()+shape[3]->area()+shape[4]->area());
return 0;
}

5.

#include<iostream>
using namespace std;
class Shape
{
public:
Shape()
{

}
virtual float area()=0;
};
class Circle:public Shape
{
private:
float ra;
public:
Circle(float r):ra(r)
{}
float area()
{
return 3.14159*ra*ra;
}
};
class Rectangle:public Shape
{
private:
float width,length;
public:
Rectangle(float w,float l):width(w),length(l)
{}
float area()
{
return width*length;
}
};
class Triangle:public Shape
{
private:
float di,gao;
public:
Triangle(float d,float g):di(d),gao(g)
{}
float area()
{
return di*gao/2;
}
};
int main()
{
float a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
Circle c1(a);
Rectangle r(b,c);
Triangle t(d,e);
printf("%.2f\n%.2f\n%.2f\n",c1.area(),r.area(),t.area());
return 0;
}

标签:area,int,软工,float,public,Shape,打卡,class
From: https://www.cnblogs.com/wwj1/p/17322033.html

相关文章

  • 4.15打卡
    #include<iostream>#include<iomanip>usingnamespacestd;intmain(){charA,D,S,Q,ch;while(ch!='Q'){cout<<"Menu:A(dd)D(elete)S(ort)Q(uit),SelectOne:";cin>>ch;if(ch=='A&#......
  • 天天打卡一小时——2
    一.问题描述输入两个数字,比较两者之间的大小二.设计思路1.输入两个数2.比较二者的大小三.程序流程图  四.代码实现#include<iostream>usingnamespacestd;intmain(){intx,y;cout<<"Enterxandy:";cin>>x>>y;if(x!=y)if(x>y)cout......
  • 建民打卡日记4.15
    五本新书,借给a,b,c三人,每人借一本,共有多少种借书方案?二、设计思路1.从五个数中选取三个排列组合,确立循环范围2.建立循环穷举所有情况3.符合条件的情况输出三、程序流程图  四、代码实现#include<iostream>usingnamespacestd;intmain(){ inta,b,c,i=0;......
  • 华电软工非全研究生室内定位研究-室内定位物联网平台中的时序数据库和mq队列他们的作
    时序数据库(TimeSeriesDatabase,TSDB)是一种专门用于存储和处理时间序列数据的数据库系统。在室内定位物联网平台中,时序数据库通常用于存储传感器采集的数据,如定位节点的位置、传感器数据等。时序数据库具有以下优点:优点:快速插入和查询时序数据,适用于海量数据存储和实时数据分析;......
  • 打卡第四天
    比较两个数大小一、1.先定义两个变量xy,用于将输入值存与变量中2.运用if语句,如果两个数不相等,就比较两个数大小,若相等则直接输出x=y3.如果x>y,则输出结果,反之输出x<y二、 三、#include<iostream>usingnamespacestd;intmain(){ intx,y; cout<<"输入两个数的值"; cin>>x>......
  • 每天打卡一小时 第五天 编译四部曲
      第一部曲自然语言 建立双重循环求解选择语句输出 第二部曲流程图  第三部曲伪代码(代码)#include<stdio.h>intmain(){    intN;    scanf("%d",&N);    inta,b;    intf=0;    for(a=1;a*a<=N;a++)    {      ......
  • 4月14日打卡
    打卡c++趣味  #include<bits/stdc++.h>usingnamespacestd;intmain(){inti;doubleb=0.0,a=1000;for(i<=0;i<5;i++){b=(b+a)/(1+12*0.063);}printf("%0.2lf\n",b);return0;......
  • 第一天打卡
     #include<iostream>usingnamespacestd;intmain(){ intcock,hen,chicken; for(cock=0;cock<=20;cock++){ for(hen=0;hen<=33;hen++){ chicken=100-cock-hen; if(cock*5+hen*3+chicken/3.0==100){ cout<<"cock="<<coc......
  • c++打卡第五天
    嵌套和递归一、嵌套调用。 1、嵌套调用是指在一个函数中调用另一个函数,也可以在一个类中使用另一个类作为成员变量。 2、实例 ①函数成员调用#include<iostream>usingnamespacestd;intfa2(inta){returna+1;}intfa1(intn){return2*fa2(n);}......
  • 每日打卡
    #include<iostream>冒泡排序usingnamespacestd;#defineN10intmain(){ intarr[N]={1,4,6,3,0,2,5,9,8,7}; Bubble_Sort(arr,10); for(inti=0;i<N;i++) { cout<<arr[i]<<","; } cout<<endl; return0;}voidBubbl......