- 博客(13)
- 收藏
- 关注
原创 stl库学习
A.pop_back()出栈 无返回值,纯出栈,且内容还在容器中,只是size的值改变。A.erase(初始地址, 结束地址)擦除一个区间的元素。sort(需排序数组初始地址, 末尾地址, 定义函数)A.insert(有插入的地址, 要插入的元素)A.begin()返回A容器的初始地址。A.erase(一个地址)擦除指定元素。A.end()返回A容器的末尾地址。A.clear()一键清除所有元素。A.size()返回A容器的大小。A.push_back()入栈。需要添加include 算法库。
2023-03-16 15:50:50
87
原创 数据结构编程题
#include <iostream> using namespace std; typedef int Keytype; typedef char Infotype; typedef int Elemtype; typedef struct { Keytype key; Infotype data; }Rectype; typedef struct { Keytype key; int link; }Idxtype; int Binsearch(Rec
2021-07-04 22:26:14
462
原创 第五章习题
第五章习题 7、写出下列程序的运行结果。 #include <iostream> using namespace std; class A { public: A(int i) : x(i) {} A() { x = 0; } friend A operator++(A a); friend A operator--(A &a); void print(); private: int x; }; A operator++(A a)
2021-06-20 23:31:54
589
原创 C++第四章习题
C++第四章习题 写出下面程序的运行结果。 #include <iostream> using namespace std; class B1 { public: B1(int i) { b1=i; cout<<”constructor B1.”<<endl; } void Print( ) { cout<<b1<<endl; } private: int b1; }; class B2 { public: B2(int i) { b
2021-06-20 23:28:28
2604
1
原创 C++第三章习题
C++第三章习题 写出程序的运行结果: #include <iostream> using namespace std; class toy { public: toy(int q, int p) { quan = q; price = p; } int get_quan() { return quan; } int get_price() { return price; } private: int quan
2021-06-20 20:59:27
1861
1
原创 第五章作业
5-1 写一个程序,定义抽象基类Container,由它派生出三个派生类:Sphere(球体)、Cylinder(圆柱体)、Cube(正方体)。用虚函数分别计算几种图形的表面积和体积。 #include <iostream> #include <string> using namespace std; class Container{ protected: double radius; public: Container(double ra): radius(ra)
2021-06-11 11:19:10
2517
3
原创 第二章.字符串功能练习
实现功能 按照提示输入单个字符串,把输入的字符串连接后输出。 #include<iostream> #include <string> using namespace std; int main() { string s, result; char cont = 'y' ; while ( cin >> s ) { if ( ! result. size()) { result += s; }
2021-04-11 16:35:46
251
原创 第一章.书店程序
实现功能: 输入一组书店的销售记录,包括书的isdn号,销售数量,售出单价。输出同一isdn书籍的合并销售记录。对前面类的定义是复制其他博主的。 #include <iostream> #include <string> #include <cassert> #include <algorithm> #include <vector> using namespace std; class Sales_data { friend std::
2021-04-11 14:14:24
252
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅