//现代打印机自带缩放,于是只要计算出宽是高的1.414倍即可
#include <cmath>
#include <cstddef>
#include <fstream>
#include <iostream>
int main(int ,char **) {
double w,h;
std::cout<<R"(输入宽:)"<<std::endl;
std::cin>>w;
std::cout<<R"(输入高:)"<<std::endl;
std::cin>>h;
std::ofstream ofs(R"(ans.txt)");
w=std::abs(w);
h=std::abs(h);
auto c=w/h;
const auto l=std::sqrt(2.);
if (c==l) {
ofs<<w<<","<<h<<std::endl;
}
else if (c<l) {
const auto ans_w=h*l;
const auto ans_h=h;
ofs<<"!"<<ans_w<<","<<ans_h<<std::endl;
}
else {
const auto ans_w=w;
const auto ans_h=w/l;
ofs<<ans_w<<","<<"!"<<ans_h<<std::endl;
}
}
计算适合打印的图纸大小
最新推荐文章于 2020-09-11 18:23:16 发布