C++ Primer Plus (第六版) 编程练习3.7

#1:

#include "iostream"
using namespace std;
int main()
{
int inchHeight;
const int p = 12;
cout << "Please Enter Your height(inch):______\b\b\b\b\b";
cin >> inchHeight;
cout << "That is " << inchHeight / p << " foot and " << inchHeight%p << " inch\n";
system("pause");
return 0;
}

#2:

#include "iostream"
using namespace std;
int main()
{
const int footToinch = 12;
const double inchTometer = 0.0254;
const double kgTopound = 2.2;
int footHeight, inchHeight, Height;
double poundWeight, Weight;
cout << "Please Enter Your Height:\n___ foot\b\b\b\b\b\b\b\b";
cin >> footHeight;
cout << "___ inch\b\b\b\b\b\b\b\b";
cin >> inchHeight;
cout << "Please Enter Your Weight:\n";
cout << "___ pounds\b\b\b\b\b\b\b\b\b\b";
cin >> poundWeight;
Height = (footHeight*footToinch + inchHeight)*inchTometer;
Weight = poundWeight / kgTopound;
double BMI = Weight / (Height*Height);
cout << "Your BMI = " << BMI << endl;
system("pause");
return 0;
}

#3:

#include "iostream"
using namespace std;
int main()
{
const int degTomin = 60;// 1度等于60分
const int minTosec = 60;// 1分等于60秒
double _degrees, _minutes, _seconds;
double result;
cout << "Enter a latitude in degrees,minutes,and seconds:\n";
cout << "Firs, enter the degrees: ";
cin >> _degrees;
cout << "Next,enter the minutes of arc: ";
cin >> _minutes;
cout << "Finally,enter the seconds of arc: ";
cin >> _seconds;
result = _degrees + (_minutes + _seconds / minTosec) / degTomin;
cout << _degrees << " degrees, " << _minutes << " minutes, " << _seconds << " seconds = " << result << " degrees\n";
system("pause");
return 0;
}

#4:

#include "iostream"
using namespace std;
int main()
{
long long _seconds;
const int p = 60;
int _days, _hours, _mins, _sec;
cout << "Enter the number of seconds: ";
cin >> _seconds;
_days = _seconds / (p*p * 24);
_seconds %= (p*p * 24);
_hours = _seconds / (p*p);
_seconds %= (p*p);
_mins = _seconds / p;
_sec = _seconds % p;
cout << _seconds << " seconds = " << _days << " days, " << _hours << " hours, " << _mins << " minutes, " << _sec << " seconds\n";
system("pause");
return 0;
}

#5:

#include "iostream"
using namespace std;
int main()
{
long long worldPop, usPop;
double part;
cout << "Enter the world's population: ";
cin >> worldPop;
cout << "Enter the population of the US: ";
cin >> usPop;
part = double(usPop) / double(worldPop)*100.00;
cout << "The population of the US is " << part << "% of the world population.\6n";
system("pause");
return 0;
}

#6:

#include "iostream"
using namespace std;
int main()
{
double distance, oilWear;
cout << "Please Enter the distance: ___ km\b\b\b\b\b\b";
cin >> distance;
cout << "Please Enter the oil wear: ___ L\b\b\b\b\b";
cin >> oilWear;
double oilWear_per_100km = oilWear / distance * 100;
cout << "The oil wear per 100km is " << oilWear_per_100km <<" L"<< endl;
system("pause");
return 0;
}

#7:

#include "iostream"
using namespace std;
int main()
{
double oilwear_Europe, oilwear_US;
double kmToMile = 62.14, gallonTolitre = 3.875;
cout << "Pleas enter the oil wear per 100 km in the Europe: ___ L/100km\b\b\b\b\b\b\b\b\b\b\b";
cin >> oilwear_Europe;
oilwear_US = kmToMile / (oilwear_Europe / gallonTolitre);
cout << oilwear_Europe << " L/100km in the Europe is about " << oilwear_US << " mpg in the US.\n";
system("pause");
return 0;
}

基于Swin Transformer与ASPP模块的图像分类系统设计与实现 本文介绍了一种结合Swin Transformer与空洞空间金字塔池化(ASPP)模块的高效图像分类系统。该系统通过融合Transformer的全局建模能力和ASPP的多尺度特征提取优势,显著提升了模型在复杂场景下的分类性能。 模型架构创新 系统核心采用Swin Transformer作为骨干网络,其层次化窗口注意力机制能高效捕获长距离依赖关系。在特征提取阶段,创新性地引入ASPP模块,通过并行空洞卷积(膨胀率6/12/18)和全局平均池化分支,实现多尺度上下文信息融合。ASPP输出经1x1卷积降维后与原始特征拼接,有效增强了模型对物体尺寸变化的鲁棒性。 训练优化策略 训练流程采用Adam优化器(学习率0.0001)和交叉熵损失函数,支持多GPU并行训练。系统实现了完整的评估指标体系,包括准确率、精确率、召回率、特异度和F1分数等6项指标,并通过动态曲线可视化模块实时监控训练过程。采用早停机制保存最佳模型,验证集准确率提升可达3.2%。 工程实现亮点 1. 模块化设计:分离数据加载、模型构建和训练流程,支持快速迭代 2. 自动化评估:每轮训练自动生成指标报告和可视化曲线 3. 设备自适应:智能检测CUDA可用性,无缝切换训练设备 4. 中文支持:优化可视化界面的中文显示与负号渲染 实验表明,该系统在224×224分辨率图像分类任务中,仅需2个epoch即可达到92%以上的验证准确率。ASPP模块的引入使小目标识别准确率提升15%,特别适用于医疗影像等需要细粒度分类的场景。未来可通过轻量化改造进一步优化推理速度。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值