当前位置: 首页 > backend >正文

C++信息学奥赛一本通-第一部分-基础一-第3章-第1节

C++信息学奥赛一本通-第一部分-基础一-第3章-第1节

2051 偶数

#include <iostream>using namespace std;int main() {int number; cin >> number;if (number % 2 == 0) {cout << "yes";}
}

2052 范围判断

#include <iostream>using namespace std;int main() {int number; cin >> number;if (number > 1 && number < 100) {cout << "yes";}
}

2053 三个数

sort 是左闭右开 这里事实上是指针

#include <iostream>
#include <algorithm>using namespace std;int main() {int nums[3]; cin >> nums[0] >> nums[1] >> nums[2]; sort(nums, nums + 3);cout << nums[2] << " " << nums[1] << " " << nums[0] << endl;
}

2054 适合晨练

#include <iostream>using namespace std;int main() {int number; cin >> number;if (number >= 25 && number < 30) cout << "ok!";else cout << "no!";
}

2055 收费

#include <iostream>using namespace std;int main() {double weight; cin >> weight;double result;if (weight <= 20.0) result = 1.68 * weight;else result = 1.98 * weight;printf("%.2f", result);
}

2056 最大的数

#include <iostream>
#include <algorithm>using namespace std;int main() {double nums[3]; cin >> nums[0] >> nums[1] >> nums[2];sort(nums, nums + 3);cout << nums[2];
}

1039 判断数正负

#include <iostream>using namespace std;int main() {long long num; cin >> num;if (num > 0) cout << "positive";else if (num < 0) cout << "negative";else cout << "zero";
}

1040 输出绝对值

#include <iostream>
#include <cmath>using namespace std;int main() {double num; cin >> num;cout << abs(num);
}

1041 奇偶数判断

#include <iostream>using namespace std;int main() {int number; cin >> number;if (number % 2 == 0) cout << "even";else cout << "odd";
}

1042 奇偶ASCII值判断

#include <iostream>using namespace std;int main() {char ch; cin >> ch;if ((int)ch % 2 == 0) cout << "NO";else cout << "YES";
}

1043 整数大小比较

#include <iostream>using namespace std;int main() {long long a, b; cin >> a >> b;if (a > b) cout << ">";else if (a == b) cout << "=";else cout << "<";
}

1044 判断是否为两位数

#include <iostream>using namespace std;int main() {int num; cin >> num;if (num >= 10 && num <= 99) cout << "1";else cout << "0";
}

1045 收集瓶盖赢大奖

#include <iostream>using namespace std;int main() {int a, b; cin >> a >> b;if (a >= 10 || b >= 20) cout << "1";else cout << "0";
}

1046 判断一个数能否同时被3和5整除

#include <iostream>using namespace std;int main() {int num; cin >> num;if (num % 3 == 0 && num % 5 == 0) cout << "YES";else cout << "NO";
}

1047 判断能否被3 5 7整除

#include <iostream>using namespace std;int main() {int num; cin >> num;if (num % 3 == 0) cout << "3" << " ";if (num % 5 == 0) cout << "5" << " ";if (num % 7 == 0) cout << "7" << " ";if (num % 3 != 0 && num % 5 != 0 && num % 7 != 0) cout << 'n';
}

1048 有一门课不及格的学生

#include <iostream>using namespace std;int main() {int a, b; cin >> a >> b;if ((a < 60 && b < 60) || (a >= 60 && b >= 60)) cout << "0";else cout << "1";
}
http://www.xdnf.cn/news/17244.html

相关文章:

  • RAG初步实战:从 PDF 到问答:我的第一个轻量级 RAG 系统(附详细项目代码内容与说明)
  • 2025年渗透测试面试题总结-07(题目+回答)
  • 系统网络端口安全扫描脚本及详解
  • Chrome与Firefox浏览器安全运维配置命令大全:从攻防到优化的专业实践
  • 分治-快排-215.数组中的第k个最大元素-力扣(LeetCode)
  • 【Linux】从零开始:RPM 打包全流程实战万字指南(含目录结构、spec 编写、分步调试)
  • Android 的CameraX的使用(配置,预览,拍照,图像分析,录视频)
  • 使用Python提取PDF大纲(书签)完整指南
  • 持中文的 TXT 合并 PDF 工具 —— GUI + ReportLab 实战
  • Emacs 折腾日记(二十九)—— 打造C++ IDE
  • 使用 Grunt 替换 XML 文件中的属性值
  • 亚马逊跨类目铺货广告运营:从粗放投放to智能提效的省力法则
  • iOS混淆工具有哪些?跨平台 App 混淆与保护的实用方案
  • 零基础深度学习规划路线:从数学公式到AI大模型的系统进阶指南
  • 基于linux环境在centos7上部署gitlab
  • Claude Code 实战场景解析:从代码生成到系统重构的典型应用案例
  • 【类与对象(中)】C++类默认成员函数全解析
  • 智慧农业温室大棚物联网远程监控与智能监测系统
  • 一站式体育赛事平台源码解决方案
  • 虚拟机Ubuntu图形化界面root用户登录错误
  • 用 Go 写个极简反向代理,把 CC 攻击挡在业务容器之外
  • 设计模式(二)——策略模式
  • ABP VNext + Fody AOP:编译期织入与性能监控
  • JDK、eclipse的安装,配置JDK、Tomcat并使用eclipse创建项目
  • 为什么提升模型尺度可以提升模型的CoT能力
  • 人工智能基础知识笔记十五:文本分块(Chunk)
  • React+TypeScript代码注释规范指南
  • 【JMeter】调试取样器的使用
  • 【性能测试】-2- JMeter工具的使用
  • c++注意点(15)----设计模式(桥接模式与适配器模式)