基于linux的c课件第二节linuxcpp.pptxVIP

  • 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

文档评论(0)

1亿VIP精品文档

相关文档