资源简介
Essential_C++ 程序源代码
本書的所有程式,以及習題解答中的完整程式碼,皆可線上取得。你可以在 Addison Wesley Longman 的網站(www.awl.com/cseng/titles/0-201-48518-4)或我的個人首頁(www.objectwrite.com)中取得。所有程式皆在 Visual C++ 5.0 環境中以 Intel C++ 編譯器測試過,並且也在 Visual C++ 6.0 環境中以 Microsoft C++ 編譯器測試過。你或許需要稍微修改程式碼,才能在自己的系統上編譯成功。如果你需要做任何修改並且也做了,請將修改結果寄一份給我(slippman@objectwrite.com),我會將它們附上你的大名,附於習題解答程式碼中。
代码片段和文件信息
/**************************************************
* Essential C++ -- Stanley Lippman
* Addison-Wesley
* ISBN 0-201-48518-4
* homepage: www.objectwrite.com
* email: slippman@objectwrite.com
*************************************************/
#include
#include
using namespace std;
int ex1_5_string()
{
string user_name;
cout << “Please enter your name: “;
cin >> user_name;
switch ( user_name.size() ){
case 0:
cout << “Ah the user with no name. “
<< “Well ok hi user with no name\n“;
break;
case 1:
cout << “A 1-character name? Hmm have you read Kafka?: “
<< “hello “ << user_name << endl;
break;
default:
// any string longer than 1 character
cout << “Hello “ << user_name
<< “ -- happy to make your acquaintance!\n“;
break;
}
return 0;
}
#include
#include
#include
using namespace std;
int ex1_5_cstyle()
{
// must allocate a fixed size
const int nm_size = 128;
char user_name[ nm_size ];
cout << “Please enter your name: “;
cin >> setw( nm_size ) >> user_name;
switch ( strlen( user_name ))
{
// case labels the same for 0 1
case 127:
// maybe string was truncated by setw()
cout << “That is a very big name indeed -- “
<< “we may have needed to shorten it!\n“
<< “In any case\n“;
// no break -- we fall through ...
default:
// the 127 case drops through to here -- no break
cout << “Hello “ << user_name
<< “ -- happy to make your acquaintance!\n“;
break;
}
return 0;
}
#include
#include
using namespace std;
void ex1_6_vector()
{
vector ivec;
int ival;
while ( cin >> ival )
ivec.push_back( ival );
// we could have calculated the sum as we entered the
// values but the idea is to iterate over the vector ...
int sum = 0;
for ( int ix = 0; ix < ivec.size(); ++ix )
{
cout << endl << ix << “) “ << ivec[ ix ];
sum += ivec[ ix ]; }
int average = sum / ivec.size();
cout << “Sum of “ << ivec.size()
<< “ elements: “ << sum
<< “. Average: “ << average << endl;
}
void ex1_6_array()
{
const int arr_size = 128;
int ia[ arr_size ];
int ival icnt = 0;
while ( cin >> ival && icnt < arr_size )
ia[ icnt++ ] = ival;
// icnt is 1 greater than number of elements!
int sum = 0;
for ( int ix = 0; ix < icnt; ++ix )
sum += ia[ ix ];
int average = sum / icnt;
cout << endl
<< “Sum of “ << icnt
<< “ elements: “ << sum
<< “. Average: “ << average << endl;
}
#include
#include
void ex1_xtra1()
{
vector< string* > sp_vec;
string st;
cout << “P
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 366333 1999-12-07 13:25 Essential C++\codeEssential\Appendix.pdf
文件 4471 1999-12-07 08:06 Essential C++\codeEssential\chapter1\ch1solutions\ch1solutions.dsp
文件 547 1999-12-07 01:04 Essential C++\codeEssential\chapter1\ch1solutions\ch1solutions.dsw
文件 41984 1999-12-07 13:04 Essential C++\codeEssential\chapter1\ch1solutions\ch1solutions.ncb
文件 54784 1999-12-07 13:04 Essential C++\codeEssential\chapter1\ch1solutions\ch1solutions.opt
文件 5157 1999-12-07 12:58 Essential C++\codeEssential\chapter1\ch1solutions\ch1solutions.plg
文件 371 1999-12-07 13:01 Essential C++\codeEssential\chapter1\ch1solutions\input.txt
文件 368 1999-12-07 13:04 Essential C++\codeEssential\chapter1\ch1solutions\input.txt.sort
文件 5970 1999-12-07 13:13 Essential C++\codeEssential\chapter1\ch1solutions\main.cpp
文件 124 1999-12-07 01:09 Essential C++\codeEssential\chapter1\ch1solutions\text.sort
文件 114 1999-12-07 12:59 Essential C++\codeEssential\chapter1\ch1solutions\text.txt
文件 112 1999-12-07 13:02 Essential C++\codeEssential\chapter1\ch1solutions\text.txt.sort
文件 7943 1999-12-07 13:13 Essential C++\codeEssential\chapter1\chap1\ch1.cpp
文件 3344 1999-12-07 13:14 Essential C++\codeEssential\chapter1\chap1\ch1.h
文件 491 1999-12-07 13:14 Essential C++\codeEssential\chapter1\chap1\ch1_main.cpp
文件 4393 1999-12-06 08:18 Essential C++\codeEssential\chapter1\chap1\chap1.dsp
文件 533 1999-12-06 08:14 Essential C++\codeEssential\chapter1\chap1\chap1.dsw
文件 50176 2009-04-21 19:22 Essential C++\codeEssential\chapter1\chap1\chap1.ncb
文件 48640 2009-04-21 19:22 Essential C++\codeEssential\chapter1\chap1\chap1.opt
文件 1386 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\chap1.plg
文件 326582 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\ch1.obj
文件 22013 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\ch1_main.obj
文件 573526 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\chap1.exe
文件 814880 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\chap1.ilk
文件 2064228 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\chap1.pch
文件 1131520 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\chap1.pdb
文件 82944 2009-04-21 19:20 Essential C++\codeEssential\chapter1\chap1\Debug\vc60.idb
文件 126976 2009-04-21 19:15 Essential C++\codeEssential\chapter1\chap1\Debug\vc60.pdb
文件 6906 2009-04-21 19:22 Essential C++\codeEssential\chapter2\ch2solutions\ch2main.cpp
文件 3460 1999-12-07 08:06 Essential C++\codeEssential\chapter2\ch2solutions\ch2solutions.dsp
............此处省略150个文件信息
相关资源
- 孔令德 计算机图形学基础教程visual
- Visual C++6.0精简绿色版支持WIN10
- C++学习实用实践项目源代码
- 《Essential_C++》(中文版) pdf
- 数据结构C++语言版邓俊辉 高清版
- c++ 图像处理
- Effective C++ 3rd Edition 中文版.pdf
- 基于GBN的可靠数据传输
- VISUAL C++MFC编程85个PDF电子书
- C++ 编程思想238458
- Data Structures and Algorithms in C++ 2nd Edit
- Visual C++实践与提高-COM和COM+篇高清p
- C++程序设计基础(第4版)PPT课后答案
- C\\C++ 读写 HDF5 所需头文件和库文件
- C++ Templates 第2版 英文版
- C/C++ 程序员 面试宝典
- NSGA II代码实现集合包含、讲解及 网络
- C++游戏编程入门 中文版 第4版 高清
- C++语言程序设计-郑莉-清华大学本科教
- 台达ASDA2伺服电机简单控制C++程序
- c++ primer plus 高清pdf+ 源码
- Matlab安装MinGW-w64 C/C++ 编译器
- C和C++程序员面试秘笈完整版-董山海
- C和C++程序员面试秘笈
- 基于最短路径的物流分配方法
- C++程序设计教程(第二版)钱能高清
- c++超市管理系统 毕业论文参考
- C++_MFC的CButtonST含使用说明书及多个
- 《数字图像处理与机器视觉-VC++与Ma
- C++编程规范 中文 PDF 扫描版
评论
共有 条评论