1.2. 初窥输入/输出
2015-06-18 16:02
190 查看
Exercise 1.3: Write a program to print "Hello, World" on the standard output. 编一个程序,在标准输出上打印“Hello, World”。
int main(void){cout << "Hello,world" << endl;return 0;}Exercise 1.4: Our program used the built-in addition operator, +, to generate the sum of two numbers. Write a program that uses the multiplication operator, *, to generate the product of two numbers.我们的程序利用内置的加法操作符“+”来产生两个数的和。编写程序,使用乘法操作符“*”产生两个数的积。 #include <iostream>using namespace std;int main(void){int val1 = 0,val2 = 0;cout << "Please input two numbers:";cin >> val1 >> val2;cout << val1 << "*" << val2 << " = " << val1*val2 << endl;return 0;}Exercise 1.6: Explain what the following program fragment does:解释下面的程序段: std::cout << "The sum of " << v1; << " and " << v2; << " is " << v1 + v2 << std::endl;Is this code legal? If so, why? If not, why not?这段代码合法吗?如果合法,为什么?如果不合法,又为什么? 答:非法。因为1,2,4句有分号,形成单独的一句。234没有左操作数。
相关文章推荐
- Android中的枚举
- 微信公众号nodejs版
- 创业周
- jeecg公开课今晚主题:新版本功能介绍、online原理和代码生成器,欢迎大家报名
- (转) centos安装oracle11.2 pdksh软件包的说明
- JavaEE中用response向客户端输出中文数据乱码问题分析
- VirtualBox虚拟机,更改默认路径,迁移
- Hive安装
- 图像翻转
- SOJ.Parity
- CodeForces 124B Permutations
- opencv学习笔记8:跟踪与运动
- 第一阶段冲刺报告(五)
- linux下日期表示法~
- 杨子江gre填空词汇分类整理
- java中的基本数据类型与封装类
- java用BufferedImage转换图片大小并保存
- Objective-C代码块语法(block)使用
- 找出100以内的质数并求和
- EMMA-代码覆盖率测试工具