- 0
- 0
- 约3.06千字
- 约 12页
- 2021-10-06 发布于北京
- 举报
编写程序,接受用户输入的整数,如果该整数为奇数则将其乘 3 加 1 后输出,偶数直接输出
#include iostream
using namespace std;
int main()
{
int a, result;
cout The program gets a number.\nIf it is an even, output it directly, \n;
cout otherwise multiply it by 3 then plus 1.\n;
cout The number: ;
cin a;
result = a;
if( a % 2 == 1 )
result = a * 3 + 1;
cout The result is result . endl;
return 0;
}
编写程序,接受用户输入的整数,如果该整数为奇数则将其乘 3 加 1 后输出,偶数除以 2 后输出
#include iostream
using namespace std;
int main()
{
int a, result;
cout The program gets a number.\nIf it is an even, divide it by 2, \n;
cout otherwise mul
您可能关注的文档
- 首自信迁钢冷轧项目bugs dorado新bug总结.pdf
- psg xap陕西工厂收得率改善.pdf
- 入团考试题库及答案.docx
- 康复系作业治疗学期末评测试卷及答案.docx
- 康复心理学考试题及答案.docx
- ISO 23150-20:2026 道路车辆 用于自动驾驶功能的传感器和数据融合单元之间的逻辑接口 第20部分支持和传感器输入接口标准立项发展报告.docx
- ISO 21927-6:2026 烟和热控制系统 第6部分压差系统规范标准立项发展报告.docx
- ISO 22028-52026 摄影和制图技术.数字图像存储、操作和交换用扩展颜色编码.第5部分静止图像的高动态范围和宽色域编码(HDRWCG)标准立项发展报告.docx
- ISO 23150-14:2026 道路车辆 用于自动驾驶功能的传感器和数据融合单元之间的逻辑接口 第14部分超声波专用接口标准立项发展报告.docx
- ISO 22544:2025 实验室设计-词汇标准立项发展报告.docx
原创力文档

文档评论(0)