当前位置: 首页 > 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.dtcms.com/a/321161.html

相关文章:

  • 【深度学习新浪潮】近三年高精度大规模三维实景重建研究进展(2022-2025)
  • Java零散知识点
  • Webpack 核心配置与最佳实践指南
  • cAdvisor 容器监控软件学习
  • 移动端app专项测试
  • 园区应急调度系统的核心功能
  • 塔罗耳语:免费在线AI塔罗牌占卜工具
  • 1-10〔 OSCP ◈ 研记 〕❘ 信息收集▸主动采集H:SNMP基础
  • WinForm利用 RichTextBox组件实现输出各种颜色字体日志信息
  • MMBFJ310LT1G一款N沟道JFE 晶体管适用于高频放大器和振荡器等射频应用MMBFJ310LT1
  • STM32CubeMX(十二)SPI驱动W25Qxx(Flash)
  • VUE+SPRINGBOOT从0-1打造前后端-前后台系统-视频列表与视频播放
  • 【嵌入式C语言】
  • C语言:结构体
  • mac电脑解决在不同项目需要频繁手动切换node版本的困扰
  • Autosar AP功能组状态和模型进程是否预定义后不改变了?
  • Mac 电脑放在环境变量中的通用脚本
  • 从浅拷贝到深拷贝:C++赋值运算符重载的核心技术
  • SITIME汽车时钟发生器Chorus保障智能汽车安全
  • 《告别Bug!GDB/CGDB调试实战指南》
  • 「iOS」————优先级反转
  • 解决Docker部署的MySQL8错误日志里面的 mbind: Operation not permitted 问题
  • 构建安全 Web 应用:从用户认证与授权到 JWT 原理解析
  • python使用python-docx自动化操作word
  • 【杂谈】-逆缩放悖论:为何更多思考会让AI变“笨“?
  • Numpy科学计算与数据分析:Numpy布尔索引与花式索引实战
  • 一种对白点进行多重加权并利用三角剖分插值微调白平衡增益的白平衡矫正算法
  • RAG问答系统:Spring Boot + ChromaDB 知识库检索实战
  • 3D Tiles 格式中,Bounding Volum
  • 基于AutoDL平台的3D_Gaussian_Splatting初体验