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

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.lryc.cn/news/613924.html

相关文章:

  • 支持向量机(SVM)全解析:原理、类别与实践
  • MySQL数据库操作练习
  • Go通道操作全解析:从基础到高并发模式
  • 微算法科技(NASDAQ:MLGO)使用循环QSC和QKD的量子区块链架构,提高交易安全性和透明度
  • 机器学习——KMeans聚类算法(算法原理+超参数详解+实战案例)
  • 计算机视觉CS231n学习(5)
  • 手搓MCP全流程指南:从本地开发部署到PyPI公开发布
  • 构建健壮的数据库连接池:高并发 Web 应用的制胜之匙
  • 面向真实场景的定制化图像降质模型设计方案
  • 深度剖析主流AI大模型的编程语言与架构选择:行业实践与技术细节解读
  • Linux系统编程Day9 -- gdb (linux)和lldb(macOS)调试工具
  • 什么是2米分辨率卫星影像数据?
  • Baumer相机如何通过YoloV8深度学习模型实现高速公路车辆的实时检测计数(C#代码UI界面版)
  • 无服务器日志分析由 Elasticsearch 提供支持,推出新的低价层
  • 14. isaacsim4.2教程-April Tags/给相机加噪声
  • 解析工业机器视觉中的飞拍技术
  • MySQL binlog日志文件转为可正常查看的文本文件
  • 双目标定中旋转矩阵参数应用及旋转角度计算(聚焦坐标系平行)
  • 系统网络端口安全扫描脚本及详解
  • Fabarta个人专属智能体:三维搜索链+动态大纲重构教材开发范式
  • 南方略咨询与与清源科技正式启动国际市场GTM流程规划咨询项目!!!
  • 论文阅读:User Behavior Simulation with Large Language Model-based Agents
  • Langchain入门:构建一个基于SQL数据的问答系统
  • 云平台运维工具 ——Azure 原生工具
  • 化工厂安全升级:分布式光纤传感的 “实时监测 + 精准预警” 方案
  • 高校合作 | 世冠科技联合普华、北邮项目入选教育部第二批工程案例
  • 分布式膛压应变测量系统
  • 稿定科技:多云架构下的 AI 存储挑战与 JuiceFS 实践
  • No time to train! Training-Free Reference-Based Instance Segmentation之论文阅读
  • 无人机教育热潮下,超优航空如何为青少年插上科技翅膀?