【提示】
在一行中输入三个整数
,表示长、宽和高。
第一行输出一个整数,表示表面积
。
第二行输出一个整数,表示体积
。
1 1 1
6 1
在这个样例中:
表面积:
;
体积:
。
本题已于下方时间节点更新,请注意题解时效性:
1. 2025-06-03 优化题面文本与格式。
2. 2025-06-05 优化题面文本与格式。
3. 2025-11-07 优化题面文本与格式,新增若干组数据。
#include <iostream>
using namespace std;
class Cuboid{
public:
Cuboid(int a, int b, int c){
this->m_a = a;
this->m_b = b;
this->m_c = c;
}
void getCuboidS(){
cout << 2 * (m_a*m_b + m_a*m_c + m_b*m_c) << endl;
}
void getCuboidV(){
cout << m_a*m_b*m_c << endl;
}
private:
int m_a;
int m_b;
int m_c;
};
int main(){
int a,b,c;
cin >> a >> b >> c;
Cuboid cuboid(a,b,c);
cuboid.getCuboidS();
cuboid.getCuboidV();
return 0;
} #include <stdio.h>
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int s = 2 * a * b + 2 * a * c + 2 * b * c, v = a * b * c;
printf("%d\n%d", s, v);
return 0;
} #include <stdio.h>
#define CUBOID_SURFACE_AREA(L, W, H) (2 * ((L) * (W) + (W) * (H) + (H) * (L)))
#define CUBOID_VOLUME(L, W, H) ((L) * (W) * (H))
int main() {
int a = 0, b = 0, c = 0;
scanf("%d %d %d", &a, &b, &c);
printf("%d\n%d", CUBOID_SURFACE_AREA(a, b, c), CUBOID_VOLUME(a, b, c));
return 0;
} use std::io;
fn main() {
let mut stdin = String::new();
io::stdin()
.read_line(&mut stdin)
.expect("");
let num: Vec<i64> = stdin
.split_whitespace()
.map(|x| x.parse().expect(""))
.collect();
let a = num[0];
let b = num[1];
let c = num[2];
let s = 2 * (a * b + b * c + c * a);
let v = a * b * c;
println!("{}\n{}", s, v);
}
#include <stdio.h>
int main() {
int a,b,c;
if(scanf("%d %d %d",&a,&b,&c) != 3){
printf("输入错误!\n");
return 1;
}
if(a<1 || a>1000 || b<1 || b>1000 || c<1 || c>1000){
printf("输入错误,不在范围内!\n");
return 1;
}
int Area = 2*(a*b+a*c+b*c);
int Volume = a*b*c;
printf("%d\n%d",Area,Volume);
return 0;
}