自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(46)
  • 收藏
  • 关注

转载 python算法合集(更新中。。。)

一、数论算法1.求两数的最大公约数import sysdef gcd(p, q): if q == 0: return p return gcd(q, p%q)def main(): p = int(sys.argv[1]) q = int(sys.argv[2]) print(gcd(p, q))if...

2018-02-26 23:11:00 145

转载 Markdown学习

这里是一级标题这里是二级标题这里是三级标题如果需要强调,可以这样进行加粗或者可以斜体这里是引用int main(){ printf("Hello, World!\n"); }转载于:https://www.cnblogs.com/mocuishle/p/8465261.html...

2018-02-24 13:22:00 96

转载 在ubuntu下用sublime text3编译C++和pascal

编译C++:选择Tools -> Build System -> New Build System,把下面代码拷贝进去,保存,自己起个名字。然后打开C++文件,选择Tools -> Builid System ->你刚才保存的名字,按Ctrl + B就可以编译了。{ "cmd": ["g++", "-Wall", "-std=c++11"...

2018-02-10 00:11:00 220

转载 用vector实现通用堆栈的类模板

#include <iostream>#include <string>#include <vector>using namespace std;//定义一个模板类template <typename T>class Stack{public: Stack(){}; //构造函数 ~S...

2018-01-22 00:22:00 229

转载 认识类模板

#include <iostream>#include <string>#include <vector>using namespace std;//定义一个模板类template <typename T>class Stack{public: Stack(){}; //构造函数 ~Sta...

2018-01-21 22:22:00 102

转载 虚函数

首先来看一下静态联编的例子:#include <iostream>using namespace std;const double PI = 3.1415926;class Point{public: Point(int x = 0, int y = 0){ this->x = x; this->y = y; }...

2018-01-21 18:17:00 77

转载 派生类的构造函数

由于派生类包含基类的原因,我们在创建一个派生类的时候,系统会先创建一个基类。需要注意的是,派生类会吸纳基类的全部成员,但并不包括构造函数及后面讲的析构函数,那么就意味着创建派生类在调用自己的构造函数之前,会先调用基类的构造函数。#include <iostream>using namespace std;class Base{public: Bas...

2018-01-21 01:03:00 95

转载 C++:类的三种继承方式

转载于:https://www.cnblogs.com/mocuishle/p/8322419.html

2018-01-21 00:06:00 153

转载 C++:继承与派生

#include <iostream>using namespace std;class Clock{public: void setTime(int H, int M, int S){ this->H = H; this->M = M; this->S = S; } void showTime(){...

2018-01-20 22:52:00 134

转载 打印杨辉三角

#include <stdio.h>#define ROWS 10int main(){ int coef = 1, space, i, j; for(i = 0; i < ROWS; i++){ for(space = 1; space <= ROWS - i; space++) printf(" "); f...

2018-01-11 21:44:00 76

转载 九九乘法表

#include <stdio.h>int main(void){ int i, j; for(i = 1; i <= 9; i++){ for(j = 1; j <= i; j++){ printf("%d*%d=%d\t", j, i, i*j); } putchar('\n'); } return 0;...

2018-01-11 21:22:00 70

转载 非递归求裴波那契数列

#include <stdio.h>#include <time.h>#define N 41long fib1(int n){ if(n <= 2) return 1; return fib1(n - 1) + fib1(n - 2);}long fib2(int n){ long result; lo...

2018-01-11 21:01:00 135

转载 第一个汇编程序:打印hello world

;dm01.asm;print 'hello world'section .data ;数据段声明 msg db "Hello, world!", 0xA ;要输出的字符串 len equ $ - msg ;字符串长度section .text ;代码段声明global _start ;指定入口函数_start: ;在屏幕上显...

2017-12-23 17:56:00 366

转载 gkt笔记1:新建一个窗口

#include <gtk/gtk.h>int main(int argc, char *argv[]){ GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(windo...

2017-12-23 00:03:00 119

转载 Ubuntu16.04环境安装gtk3

使用一条命令可以快捷安装:$ sudo apt install libgtk-3*查看gtk版本:$ pkg-config --modversion gtk+-3.0我系统显示的是3.18.9版本。gtk3中文教程匮乏,只好硬着头皮看英文啦,最好的教程就是官方手册了:https://developer.gnome.org/gtk3/stable/g...

2017-12-22 22:31:00 869

转载 检测字符串是否位于另一个字符串尾端

#include <stdio.h>#include <stdbool.h>#include <string.h>/*寻找子串出现的最后的位置*/char *strrstr(const char *string, const char *ending){ char *pos, *last; int len; l...

2017-12-20 23:27:00 206

转载 leetcode3 Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assum...

2017-12-19 22:17:00 66

转载 leetcode2 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.分析:由于题目已经要求不能使用额外空间,故不可以把数字转换为字符串s,然后对s取反得到s',判断两字符串是否相等。解决方案是用循环直接将数字取反,最后将得到的新数字与原始数字比较。#include <stdio...

2017-12-19 21:32:00 89

转载 常见排序算法汇总

#include <stdio.h>#include <stdlib.h>typedef int Item;#define key(A) (A)#define less(A, B) (key(A) < key(B))#define exch(A, B) {Item t = A; A = B; B = t;}#define comp...

2017-12-19 20:35:00 83

转载 leetcode1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the ...

2017-12-18 20:31:00 64

转载 希尔排序

希尔排序:将无序数组分割为若干个子序列,子序列不是逐段分割的,而是相隔特定的增量的子序列,对各个子序列进行插入排序;然后再选择一个更小的增量,再将数组分割为多个子序列进行排序......最后选择增量为1,即使用直接插入排序,使最终数组成为有序。增量的选择:在每趟的排序过程都有一个增量,至少满足一个规则 增量关系 d[1] > d[2] > d[3] >..> ...

2017-12-15 21:10:00 81

转载 栈-数据结构

#include <stdio.h>#define MAX 30#define pop() stack[--top];#define push(s) stack[top++] = sint main(){ static int top = 0; int stack[MAX]; int i, a; for(i = 0; top &...

2017-12-14 23:18:00 81

转载 C语言实现单链表

#include <stdio.h>#include <stdlib.h>typedef int item_type;typedef struct _node{ item_type data; struct _node *next;}Node, List;/*头插法,传入指向首元素地址的指针和要插入的元素*/void...

2017-12-13 22:35:00 68

转载 埃拉托色尼筛法(sieve of Eratosthenes)打印素数

/** * 埃拉托色尼筛法(sieve of Eratosthenes)打印素数 * */#include <stdio.h>#define N 20000int main(){ int i, j, a[N]; for(i = 2; i < N; i++) a[i] = 1; for(i = 2; i < N; i...

2017-12-13 12:02:00 227

转载 二分查找

二分查找最多需要查找lgN + 1个数#include <stdio.h>int bineary_search(int a[], int key, int size){ int low = 0; int high = size - 1; while(low <= high){ int mid = (low + high) / ...

2017-12-13 11:41:00 68

转载 The power() function

#include <stdio.h>int power(a, n){ if(0 == n) return 1; int x = power(a, n/2); if(n % 2 == 0) return x * x; else return a * x * x;}int main(){ printf("%d\n"...

2017-12-12 16:04:00 133

转载 The qsort() function of C

#include <stdio.h>#include <stdlib.h>#include <time.h>#define MAX 5000void print_arr(int *a, int size){ int i; for(i = 0; i < size; ++i) printf("%d ", *(...

2017-12-11 21:51:00 77

转载 C++程序设计知识结构图

转载于:https://www.cnblogs.com/mocuishle/p/8008760.html

2017-12-09 01:26:00 251

转载 插入排序

/** *插入排序 *算法步骤: *1、将第一个待排序的序列的第一个元素看做是一个有序序列 *2、把第二个元素到最后一个元素当成为排序序列 *3、从头到尾扫描未排序的序列 *4、将扫描到的每个元素插入有序序列的恰当位置 * *命题:对于随机排列的长度为N且主键不重复的数组,平均情况下插入排序需要~N^2/4次 *比较以及~N^2/4次交换。最坏情况...

2017-12-08 17:07:00 72

转载 选择排序

/** * ========================================================================= *选择排序法 *找到第一个最小的数字,放在第一个位置;再找到第二个小的数字,放在第二个位置 *一次找一个数字,如此循环,知道把所有数字到排序好 * *命题A 对于长度为N的数组,选择排序需要大约N^2/...

2017-12-08 16:27:00 50

转载 ex10_14输出素数

#include <iostream>#include <vector>using namespace std;class StackOfInteger{ public: StackOfInteger(); ~StackOfInteger(); void push(int val); //添加素数 void re...

2017-12-07 15:09:00 83

转载 ex10_13几何:正n边形

头文件RegularPolygon.h#ifndef REGULARPOLYGON_H#define REGULARPOLYGON_Hclass RegularPolygon{ public: RegularPolygon(); ~RegularPolygon(); RegularPolygon(int n, double side); R...

2017-12-07 11:08:00 207

转载 Stock类

头文件Stock.h#ifndef STOCK_H#define STOCK_H#include <string>class Stock{public: Stock(); Stock(std::string symbol, std::string name); std::string getSymbol() const; s...

2017-12-06 21:46:00 521

转载 ex10_11修改Loan类

静态函数无须创建一个类的对象,静态成员函数和静态成员变量都是独立于对象的,如果其中一个对象修改了静态变量数据,那么所有对象次变量的值都发生改变。静态函数可以通过对象来访问,也可以通过类名直接访问。静态函数在多文件编译时,头文件用static声明,实现文件可以不用在写static关键字。头文件loan.h#ifndef LOAN_H#define LOAN_H...

2017-12-05 15:48:00 266

转载 ex10_10MyInteger类

头文件ex10.h#include <string> class MyInteger{ public: MyInteger(); MyInteger(int); int getValue() const; bool isEven() const; bool is...

2017-12-04 21:43:00 406

转载 ex10_9猜首府

#include <iostream>#include <ctime>#include <string>#include <cstdlib>using namespace std;int main(){ string stateArray[50][2] = { {"Alabama", "Montgomer...

2017-12-04 16:55:00 104

转载 ex10_8金融应用:货币单位

#include <iostream>#include <cstdlib>#include <cctype>#include <string>using namespace std;int myAtoi(const string &s){ //字符串转化为整数 int n = 0; for(aut...

2017-12-04 14:21:00 117

转载 vim简单配置

如果是一般配置(写C/C++等)可以直接拷贝通用配置和后面的通用配色到.vimrc中 ,如果是写Python用,可以直接拷贝Python专用和通用配色到.vimrc文件中。=================================通用配置====================================syntax on" 语法高亮autocm...

2017-12-03 15:37:00 116

转载 ex10_7统计字符串中各字母出现的次数

//// main.cpp// ex10_7//// Created by a007 on 17/12/2.// Copyright © 2017年 a007. All rights reserved.//#include <iostream>#include <string>#include &lt...

2017-12-02 14:13:00 123

转载 ex10_6计算字符串中的字母数量

//// main.cpp// ex10_6//// Created by a007 on 17/12/2.// Copyright © 2017年 a007. All rights reserved.//#include <iostream>#include <string>#include <cc...

2017-12-02 13:18:00 99

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除