This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
from functools import wraps | |
from datetime import datetime | |
import time | |
def func_timer(function): | |
''' | |
用装饰器实现函数计时 | |
:param function: 需要计时的函数 | |
:return: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> // stoi()函数 | |
using namespace std; | |
int main() | |
{ | |
// 将string字符串转换为int类型 | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 删除容器里的重复元素 | |
// 1. 排序; | |
sort(pStr.begin(), pStr.end()); | |
// unique()返回的是容器里的重复元素的起始位置 | |
pStr.erase(unique(pStr.begin(), pStr.end()), pStr.end()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------------------------------------------------------------- | |
// 作 者:adoredee | |
// 创建时间:2019.04.24 | |
// 描 述:归并排序 | |
//----------------------------------------------------------------------------- | |
#include <iostream> | |
#include <vector> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------------------------------------------------------------------- | |
// 作 者:adoredee | |
// 创建时间:2019.04.23 | |
// 描 述:插入排序 | |
//----------------------------------------------------------------------------- | |
/* | |
数组前面是排序好的,乱序的数依次向有序的数比较 | |
*/ | |
#include <iostream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/* | |
关于NULL和nullptr | |
NULL ——> 宏定义为0(C++中, 在C中, NULL可以表示为空指针) | |
nullptr ——> 标识空指针,可以被转换成任意类型的指针和bool类型,但不能转换为整数。 | |
*/ | |
// 函数重载 | |
void func(char*) | |
{ | |
cout << "It's me!" << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------- 读入二维数组---------------*/ | |
int row; | |
cin >> row; // 设置为row行 | |
int col; | |
cin >> col; // 设置为col列 | |
vector<vector<int>> arr(row, vector<int>(col)); // 创建一个容器arr,有row个vector<int>类型的数据, | |
// 每一个row里又是一个容器vector组成,有col个元素,既col列 | |
// arr也是这个容器的首地址 |