1.box����Դ��
2.定义一个Box(盒子)类,盒盒源捐款html源码在该类定义中包括数据成员: length(长),width(宽)和height(
box����Դ��
import java.util.Scanner;
public class Box
{
private int a,b,c;
public Box(int a,int b,int c)
{
this.a=a;
this.b=b;
this.c=c;
}
public int getVol()
{
return a*b*c;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("输入第一个的长宽高:");
System.out.println("长");
int a;
a=sc.nextInt();
System.out.println("宽");
int b;
b=sc.nextInt();
System.out.println("高");
int c;
c=sc.nextInt();
Box b1=new Box(a,b,c);
System.out.println("输入第二个的长宽高:");
System.out.println("长");
a=sc.nextInt();
System.out.println("宽");
b=sc.nextInt();
System.out.println("高");
c=sc.nextInt();
Box b2=new Box(a,b,c);
System.out.println("输入第三个的长宽高:");
System.out.println("长");
a=sc.nextInt();
System.out.println("宽");
b=sc.nextInt();
System.out.println("高");
c=sc.nextInt();
Box b3=new Box(a,b,c);
System.out.println("三个的体积分别为:");
System.out.println(b1.getVol());
System.out.println(b2.getVol());
System.out.println(b3.getVol());
}
}
定义一个Box(盒子)类,在该类定义中包括数据成员: length(长),width(宽)和height(
#include <iostream>
using namespace std;
class Box {
float length, width, height;
public:
Box(float l, float w, float h);
float GetVolume() const;
};
Box::Box(float l = 1, float w = 1, float h = 1)
: length(l), width(w), height(h) { }
float Box::GetVolume() const {
return height * width * length;
}
int main()
{
Box b1, b2(2, 3, 4);
float v1, v2;
v1 = b1.GetVolume();
v2 = b2.GetVolume();
if (v1>v2)
cout << v1 << " " << v2 << endl;
else
cout << v2 << " " << v1 << endl;
return 0;
}
2025-01-31 14:582295人浏览
2025-01-31 14:552109人浏览
2025-01-31 14:531081人浏览
2025-01-31 14:261981人浏览
2025-01-31 13:162266人浏览
2025-01-31 12:521881人浏览
张淑宝 农健/图)张淑宝有一个蓝色塑料袋,里面装着12本证书:自考学位证、毕业证和各种资格证。“我不是爱慕虚荣的人”。他很少向外人展示证书,装进蓝色塑料袋塞进了床头柜。12本证书是张淑宝12年考证的结
1.phpyun人才招聘系统v6.1vip版网站源码(2022-05-16)有注册机制验证漏洞已经修复phpyun人才招聘系统v6.1vip版网站源码(2022-05-16)有注册机制验证漏洞已经修复
1.出色的开源中国象棋棋谱APP-Chess2.VB中国象棋源代码出色的开源中国象棋棋谱APP-Chess 推荐一款名为“Chess中国象棋”的开源小游戏APP,适合中国象棋爱好者。这款软件由一位