
C++其它习题
neicole
积极乐观,稳扎稳打,一步一个脚印。
展开
-
(2011.07.14) 类的基本应用实例。
2011.07.14 类的基本应用实例。// stocks.cpp -- the whole program#include #include class Stock // class declaration{ private: char company[30]; int shares; double share_val; double转载 2011-07-14 22:08:05 · 890 阅读 · 0 评论 -
(2011.07.11)程序清单_16.6_vect2.cpp -- methods and iterators
// 程序清单_16.6_vect2.cpp -- methods and iterators// 这次的注释是个人加上去的/*******************************************************************************让我们先看一下运行结果吧:Enter book title(quit to quit):The原创 2011-07-11 19:11:31 · 766 阅读 · 0 评论 -
(2011.07.06)C++ 结构体中字符指针在main中使用new的赋值问题。
// 编程练习 04.01_display message_2.cpp/***************************************************************1.编写一个C++程序,如下述输出范例所示的那样请求并显示信息: What is your first name? Betty Sue What is your last name原创 2011-07-06 22:46:32 · 1807 阅读 · 2 评论 -
(2011.07.19)C++ 顺序表 destructor tag mismatch错误!
// 4.1 假设一个线性表包含下列元素:// // 用顺序表写出这些元素,并且删除值为15的元素。#include using namespace std;const int Default = 5;template class List{public:Elem element;List *next;};temp原创 2011-07-19 16:05:09 · 5434 阅读 · 3 评论 -
(2011.07.08)编程练习_07.08_处理数组和结构的函数.cpp 输出结果有问题。
// 编程练习_07.08_处理数组和结构的函数.cpp/******************************************************************8.这个练习让您编写处理数组和结构的函数。下面是程序的框架,请提供其中描述的函数,以完成该程序。#include using namespace std;cons原创 2011-07-08 18:36:22 · 1275 阅读 · 1 评论 -
(2011.07.07) 编程练习_07.02_处理数组的函数
// 编程练习_07.02_处理数组的函数.cpp/**********************************************************************2.编写一个程序,要求用户输入最多10个高尔夫成绩,并将其存储在一个数组中。 程序允许用户提早结束输入,并在一行上显示所有成绩,然后报告平均成绩。 请使用3个数组处理函数来分别进行输入、显示和原创 2011-07-07 22:20:03 · 1544 阅读 · 0 评论 -
(2011.07.11)读取字符串并计算总字符数.cpp
// 读取字符串并计算总字符数.cpp/*******************************************************************程序的输出:Enter a line:nice pants"nice pants" contains 9 characters9 characters totalEnter next line(em原创 2011-07-11 00:31:27 · 822 阅读 · 0 评论 -
(2012.01.03) 输出程序中的指定位置的行数与该文件的路径及标题。
前些天,在C++奋斗园那里看见这么一道小题目,觉得挺有意思的,于是,这里收藏一下。 题目要求是:要输出程序中的指定位置的行数,另外,再输出该文件的路径及标题。 下面是源程序:// 输出当前行以及标题 #include#includeusing namespace std;int main(int argc,char **argv){原创 2012-01-04 20:58:12 · 791 阅读 · 0 评论 -
(2011.07.11)程序清单16.5_vect1.cpp -- introducing the vector template
// 程序清单16.5_vect1.cpp -- introducing the vector template#include #include #include const int NUM = 5;int main(){ using std::vector; using std::string; using std::cin; using std::原创 2011-07-11 19:10:53 · 699 阅读 · 0 评论 -
(2011.07.26)以二进制方式读写文件(C++ Primer Plus)
// binary.cpp -- binary file I/O#include // not required by most systems#include #include #include // (or stdlib.h)for exit()inline void eatline() { while(std::cin.get()!= '\n') continu原创 2011-07-26 12:04:31 · 1039 阅读 · 0 评论