![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++学习
jlu_TLss
这个作者很懒,什么都没留下…
展开
-
重新学习c++ day02
关于数组的地址的小问题int main() { short tell[10]; cout << "tell:" << tell << endl; cout << "&tell:" << &tell << endl; cout << "tell + 1" << tell + 1 << endl; cout << "&tell + 1" << &tell + 1原创 2016-10-02 16:27:05 · 187 阅读 · 0 评论 -
重新学习c++ day01
课本以《c++ primer plus(第六版)》为主 第四章 复合类型一、跟string有关的几个函数 1.strcpy 原型声明:char strcpy(char dest, const char *src); 其中dest为目标字符串,src为原字符串; 头文件:string.h 功能:把从src地址开始且含有NULL结束符的字符串复制到以dest开始的地址空间 说明:src和de原创 2016-10-02 17:13:47 · 180 阅读 · 0 评论 -
C++ primer plus的编程练习 1
编程练习5.9的第5题代码:const int iSize = 12; int main() { string month[iSize] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; int monthSell[iSize] = {原创 2016-10-03 17:47:23 · 326 阅读 · 0 评论 -
重新学习c++ day04
简单的文件I/O打开文件,最后一定要关闭文件流对象一、写入到文件中主要步骤: 包含头文件fstream 创建一个ofsteam对象 将该ofstream对象同一个文件关联起来 像使用cout那样使用该ofstream对象 例子:1. #include<fstream> 2. ofstream fout("xxx.txt") 3. fout << "Hello World!"二、读取文件主要步骤: 包原创 2016-10-07 13:48:57 · 147 阅读 · 0 评论 -
重新学习c++ day03
c++ primer plus 的第五章循环和文本输入 for循环和while循环都是入口条件循环,do while循环是出口条件循环 1. 使用原始的cin输入 程序经常要使用循环来读取来自键盘的文本输入,则必须有办法知道何时停止读取,一种方法是选择某个特殊的字符(如“#”)——有时被称为哨兵字符,将其作为停止标记. cin在读取char值时将忽略空格和换行符 2. 使用cin.get(char)原创 2016-10-03 20:58:18 · 206 阅读 · 0 评论 -
数据机构-排序(1):直接插入排序
void InsertSort(int a[], int arrSize) { for(int i = 0; i < arrSize; i++) { int j = i; while(j > 0 && (a[j] < a[j - 1])) { swap(a[j], a[j - 1]); j原创 2016-12-23 19:13:07 · 341 阅读 · 0 评论 -
数据结构-排序(2):冒泡排序
void BubbleSort(int a[], int arrSize) { bool flag = ture; for(int i = 0; i < arrSize - 1; i++) { flag = true; for(int j = 0; j < arrSize - 1 - i; j++) {原创 2016-12-23 19:57:14 · 218 阅读 · 0 评论 -
数据结构-排序(3):快速排序
void QSort(int a[], int l, int r) { int left, right, mid; if(l >= r) return; left =l; right = r; mid = a[(l + r) / 2]; while(left <= right) { while(a[left] < mid) left++原创 2016-12-23 20:56:40 · 214 阅读 · 0 评论 -
数据结构-排序(4):直接选择排序
void SelectionSort(int a[], int arrSize) { int min; for(int i = 0; i < arrSize; i++) { min = i; for(int j = i + 1; j < arrSize; j++) { if(a[j] < a[min])原创 2016-12-24 20:24:45 · 234 阅读 · 0 评论