C++ Primer_5th<第一章>
Aclite
这个作者很懒,什么都没留下…
展开
-
<C++ Primer_5th>习题_1.3
/******************************************** ** 功能:显示输出“Hello World!”字符串 ** *********************************************/ #include // 编译预处理命令 using namespace std; // 使用标准名空间std /*以下是主函数原创 2017-09-29 11:26:29 · 142 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.23
//编写程序,读取多条销售记录,并统计每个ISBN(每本书)有几条销售记录。#include#include "Sales_item.h"int main(){ Sales_item trans1, trans2; int num = 1; std::cout << "请输入若干销售记录: " << std::endl; //判断输入是否正确 if (std::cin >>原创 2017-09-30 09:30:58 · 347 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.22
// 编写程序,读取多个具有相同的ISBN的销售记录,输出所有记录的和。#include#include"Sales_item.h"int main(){ Sales_item total, trans; std::cout << "请输入几条ISBN相同的销售记录: " << std::endl; //判断是否为相同的ISBN if (std::cin >> total)原创 2017-09-30 09:29:53 · 216 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.21
//编写程序,读取两个ISBN相同的Sales_item对象,输出它们的和。#include#include"Sales_item.h"int main(){ Sales_item trans1, trans2; std::cout << "请输入两条ISBN相同的销售记录" << std::endl; std::cin >> trans1 >> trans2; //判断两条原创 2017-09-29 13:01:00 · 211 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.20
//读取一组书籍销售记录,将每条记录打印到标准输出上。#include#include"Sales_item.h"int main(){ Sales_item book; std::cout << "请输入销售记录: " << std::endl; while (std::cin >> book) { std::cout << "ISBN、售出本数、销售额和平均售价为原创 2017-09-29 13:00:03 · 301 阅读 · 1 评论 -
<C++ Primer_5th>习题_1.16
//编写程序,从cin读取一组数,输出其和。#includeint main(){int sum = 0, value = 0;//提示用户输入一些数,按ctrl+z表示结束std::cout > value) //从输入流读取值,并返回左值{sum += value;}std::cout << sum << std::endl;system("pause");return 0;}//也可使用fo原创 2017-09-29 12:55:41 · 190 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.11
//编写程序,提示用户输入两个数,打印出这两个整数所指定的范围内的所有整数。#includeint main(){ std::cout << "请输入两个数: "; std::cout << std::endl; int v1, v2; std::cin >> v1 >> v2; if(v1 > v2) while (v1 >= v2) //选择循环语句,依原创 2017-09-29 12:53:09 · 173 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.10
/*除了++运算符将运算对象的值增加1以外,还有一个递减运算符(--)实现将值减1。编写递减运算符在循环中按递减打印出10到0之间的整数。*/#includeint main(){int sum = 0;int i = 10;while (i >= 0){sum += i;--i;}std::cout << "10到0之间的整数和为: " << sum << std::endl;system("p原创 2017-09-29 12:48:48 · 161 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.9
//编写程序,使用while循环将50到100的整数相加。#includeint main(){ int sum = 0; int i = 50; while (i <= 100) { sum += i; ++i; } std::cout << "50到100之间的整数之和为: " << sum << std::endl; system("pause"); r原创 2017-09-29 12:45:40 · 222 阅读 · 0 评论 -
<C++ Primer_5th>习题_1.4
/*我们的程序使用加法运算+来将两个数相加。编写程序使用乘法运算*,来打印两个数的积*/#includeint main(){ std::cout << "Please enter two numbers " << std::endl; int v1, v2; std::cin >> v1 >> v2; std::cout << v1 << "和" << v2 << "的积为"原创 2017-09-29 12:28:27 · 173 阅读 · 0 评论 -
<C++ Primer_5th>第一章用到的头文件<Sales_item.h>
//头文件:Sales_item.h/* * This file contains code from "C++ Primer, Fifth Edition", by Stanley B. * Lippman, Josee Lajoie, and Barbara E. Moo, and is covered under the * copyright and warranty notic原创 2017-09-30 09:37:28 · 298 阅读 · 0 评论