#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int w1, h1, w2, h2;
int ans;
int main() {
scanf("%d %d %d %d", &w1, &h1, &w2, &h2);
ans += (h1 * 2 + 2 + w1);
if (w1 == w2) {
ans += (h2 * 2 + 2 + w2);
}
else {
ans += (h2 * 2 + 2 + w2);
ans += (w1 - w2);
}
printf("%d\n", ans);
return 0;
}
本文介绍了一个简单的C++程序,该程序用于计算两个矩形的周长,并考虑了当两个矩形宽度相同时的特殊情况。通过输入矩形的宽和高,程序能够计算并输出总周长。
200

被折叠的 条评论
为什么被折叠?



