代码练习
qq_2773878606
学生
展开
-
Fast Radial Symmetry Transform/快速径向对称变换(代码)
function [ filtered ] = frst2d( image, radii, alpha, stdFactor, mode )%FRST2D Applies Fast radial symmetry transform to image% Check paper Loy, G., & Zelinsky, A. (2002). A fast radial symmetry tr原创 2015-09-07 19:13:46 · 2132 阅读 · 0 评论 -
Remove Element(删除数组某一元素)
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.class Solu原创 2015-09-26 12:22:01 · 1006 阅读 · 0 评论 -
set集合中元素的比较
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;void Output(char val){ cout << val << ' ';}int main(){ set<char> cset; cset.ins原创 2015-09-26 14:08:57 · 726 阅读 · 0 评论 -
二维数组中行最大值中的最小值
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;int main(){ int max,min; int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };原创 2015-09-26 16:32:33 · 968 阅读 · 0 评论 -
嵌套类
当一个类只想被另外一个单独的类使用时,可以定义嵌套类。。只能被所在域内的类使用,#include#includeusing namespace std;#define MAXLEN 128class clist{public: class cnode { friend class clist; private: int mtag; public: c原创 2015-09-24 22:23:59 · 303 阅读 · 0 评论 -
二维数组变一维
#includeusing namespace std;int main(){ int i, j; int array[3][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; cout << "输出数组" << endl; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) c原创 2015-09-25 20:31:26 · 586 阅读 · 0 评论 -
指针访问二维数组
#includeusing namespace std;int main(){ int a[4][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; int *p; p = a[0]; for (int i = 0; i < sizeof(a) / sizeof(int); i++) { cout << "address"; co原创 2015-09-25 20:40:28 · 406 阅读 · 0 评论 -
计算n!中结尾零的个数
计算n!中结尾零的个数(C++实现) 。[cpp] view plaincopy#include /*计算n!结尾零的个数,返回零的个数。*/ int CalZeroNum(int n) { int result=1; int num=0;转载 2015-09-25 22:24:08 · 539 阅读 · 0 评论 -
random_shuffle函数改变vector容器中元素的次序
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;void Output(int val){ cout << val << ' ';}int main(){ vector<int> intvec; for (原创 2015-09-26 14:17:33 · 875 阅读 · 0 评论 -
vector中迭代器的用法
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;void Output(int val){ cout << val << ' ';}int main(){ vector<int> it(5); vector原创 2015-09-26 14:26:03 · 571 阅读 · 0 评论 -
list容器的使用
#include<iostream>#include<vector>#include<list>#include<algorithm>using namespace std;void Output(char val){ cout << val << ' ';}int main(){ char temp; list<char> charlist; fo原创 2015-09-26 13:57:24 · 310 阅读 · 0 评论 -
vector容器的遍历
#include#include#includeusing namespace std;void Output(char val){ cout << val << ' ';}int main(){ vector a; a.push_back('a'); a.push_back('b'); a.push_back('d'); a.push_back('g'); a.pu原创 2015-09-25 22:05:07 · 266 阅读 · 0 评论 -
set(集合类)模板的使用
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;void Output(char val){ cout << val << ' ';}int main(){ set<char> cset; cset.ins原创 2015-09-26 14:04:33 · 1023 阅读 · 0 评论 -
二维数组中每行最大值
#include<iostream>#include<vector>#include<list>#include<set>#include<algorithm>using namespace std;int main(){ int max; int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; for原创 2015-09-26 16:21:42 · 7711 阅读 · 0 评论 -
纯虚函数
#includeusing namespace std;class subject{public: virtual void display() = 0;};class china :public subject{public: virtual void display() { cout << "这是中国" << endl; }};class english :p原创 2015-09-24 22:11:51 · 330 阅读 · 0 评论 -
顺序查找数据
#includeusing namespace std;int main(){ int i, n = 0, num; int a[10]; //从键盘输入 for (i = 0; i < 10; i++) { cout << "a[" << i << "]="; cin >> a[i]; } cout << "输入查找的数据" << endl; cin >> num;原创 2015-09-25 17:08:06 · 294 阅读 · 0 评论 -
字符串中单词的个数
#include<iostream>using namespace std;int main(){ char cstring[100]; int index, iword = 1; char blank; gets(cstring); if (cstring[0] == '\0') { cout << "there is no c原创 2015-09-25 20:08:55 · 345 阅读 · 0 评论 -
数组存储字符串
#includeusing namespace std;int main(){ char* array[5]; int index; array[0] = "jdbgk"; array[1] = "jkbkd"; array[2] = "lkang;"; array[3] = "lknnl"; array[4] = "jkbddfh"; for (index = 0; ind原创 2015-09-25 20:55:23 · 3960 阅读 · 0 评论 -
折半查找
#includeusing namespace std;int main(){ int i, j, t, n = 0, num; int a[10]; for (i = 0; i < 10; i++) { cout << "a[" << i << "]=" << endl; cin >> a[i]; } //对数组进行排序 for (i = 0; i < 9; i++)原创 2015-09-25 18:29:40 · 306 阅读 · 0 评论 -
获取数组元素的个数
在不知道数组个数的情况下,我们可以用sizeof ()的方法得到,数组中元素的个数,首先得到数组变量占的总字节数,,除以数组元素的类型所占的字节数,这样就可以的到数组中元素的个数。。用法::sizeof(array)/sizeof(int)#includeusing namespace std;int main(){ int array[] = { 1, 2,原创 2015-09-25 20:19:06 · 5077 阅读 · 0 评论 -
二维数组的反转
#includeusing namespace std;void invert(int array[][3]){ int t; for (int i = 0; i < 3; i++) for (int j = 0; j < i; j++) { t = array[i][j]; array[i][j] = array[j][i]; array[j][i] = t原创 2015-09-25 20:27:13 · 740 阅读 · 0 评论 -
字符串反转
#includeusing namespace std;int main(){ char ctring[7] = { "nkijdg" }; char revers[7] = { 0 }; int size = sizeof(ctring); for (int i = 0; i <6; i++) { revers[size - i - 2] = ctring[i]; } c原创 2015-09-25 20:52:22 · 328 阅读 · 0 评论 -
ASM模型对人脸特征点的检测
// Face_ASM.cpp : 定义控制台应用程序的入口点。////#include "stdafx.h"#include #include //#include "stdafx.h"#include "opencv2/highgui/highgui.hpp"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/ob原创 2015-09-07 15:58:00 · 3739 阅读 · 0 评论 -
Length of last word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2015-09-28 16:21:15 · 288 阅读 · 0 评论 -
Given two strings s and t, write a function to determine if t is an anagram of s.
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may原创 2015-09-28 16:38:21 · 1523 阅读 · 0 评论 -
Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that the to原创 2015-09-28 16:48:00 · 404 阅读 · 0 评论 -
经常让写的关于链表的代码
#include using namespace std;struct Node{public: int data; Node *next; Node(){}; Node(int i) { data = i; next = NULL; }};class List{public: Node *原创 2015-09-27 21:06:59 · 305 阅读 · 0 评论 -
RANSC算法(随机样本一致性)
一、基本思想 它是根据一组包含异常数据的样本数据集,计算出数据的数学模型参数,得到有效样本数据的算法。它于1981年由 Fischler和Bolles最先提出[1]。 二、算法描述 (1)输入: 1、判断样本是否满足模型的误差容忍度t。t可以看作为对内点噪声均方差的假设,对于不同的输入数据需采用人工干预的方式预设合适的门限,且该参数对RANSA转载 2015-09-01 18:14:24 · 6421 阅读 · 0 评论 -
随机样本一致抽样
function testRansac()% real model coefk = .5;b = 10;ptNum = 200;outlrRatio = .4; %非模型店的个数比率 inlrStd = 5; %距离模型点的距离pts = genRansacTestPoints(ptNum,outlrRatio,inlrStd,[k b]);%%产生随机点 线性点和噪声点原创 2015-09-06 22:25:58 · 817 阅读 · 0 评论 -
快速径向对称 只检测暗对称 代码(2)
%RST 径向对称变换 % function [FilterImage,Image_out] = RST(I);I = imread('lena.jpg');% I=zeros(80,80) ;% for x=1:1:80% for y=1:1:80% I(y,x) =255;% end;% end;% % r2 =8*8 ;% for原创 2015-09-07 19:22:03 · 1056 阅读 · 0 评论 -
MATLAB 图像处理小实践
% Script to make (synthesize) a perfect X-Rite Color Checker Chart% from the X-Rite supplied sRGB values.% (This chart has been known in the past as the Gretag Macbeth ColorChecker Chart,% and the原创 2015-09-08 18:54:05 · 993 阅读 · 0 评论 -
MATLAB中对视频进行提取图像
% Demo to extract frames and get frame means from a movie% and save individual frames to separate image files.% Then rebuilds a new movie by recalling the saved images from disk.% Also computes the原创 2015-09-08 19:17:51 · 5176 阅读 · 4 评论 -
Fast Radial Symmetry Transform/快速径向对称变换
本文主要介绍一下利用径向变换进行特征提取的方法和原理,基本原理主要来自Gareth Loy and Alexander Zelinsky的A Fast Radial Symmetry Transform for Detecting Points of Interest一文。需要原文的可以留下邮箱。Radial Symmetry Transform(径向对称变换)在某种程度上类似于霍夫圆变换转载 2015-09-07 19:08:43 · 1868 阅读 · 0 评论 -
Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.原创 2015-09-28 16:15:38 · 294 阅读 · 0 评论 -
Given an integer, write a function to determine if it is a power of two
Given an integer, write a function to determine if it is a power of two.判断一个整数是不是2的次方:class Solution {public: bool isPowerOfTwo(int n) { int cnt = 0; while (n > 0) {原创 2015-09-28 17:08:52 · 1177 阅读 · 0 评论 -
用opencv的检测器检测人眼
#include "highgui.h"#include "cv.h"#include #include using namespace std;using namespace cv;void DetectAndDraw(IplImage* img, CascadeClassifier& cascade);//String cascadeName = "haarcascade原创 2015-09-07 19:45:18 · 1685 阅读 · 0 评论 -
c++ 实例精通(1)
//引入必须的头文件#include #include //宏定义,要排序的数字个数#define MAX_NUM 10//宏定义,判断数组中的数字,并将较大的一个向后移动#define SWITCH(ar, i) if(ar[i] < ar[i + 1]){ \ int nTemp = ar[i]; \ ar[i] = nNums[i + 1]; \ ar[i + 1] =原创 2015-09-14 20:34:31 · 300 阅读 · 0 评论 -
FisherFace 进行人脸分裂
clear allclcclose alladdress=[pwd,'\ORL','\s'];rows=112;cols=92;ClassNum=40;tol_num=10;image_fmt='.bmp';train_samplesize=5;%---------------------------------------------------------------原创 2015-09-14 22:32:59 · 913 阅读 · 1 评论 -
matlab用几张图片形成一个三维图
% IM_3D creates a solid, 3D image of multiple slices. First, create a % string of the directory name of the files (DIRECT1) and a cell of the % .png filenames (FILES). All files must be the same dim原创 2015-09-14 22:26:08 · 5455 阅读 · 1 评论 -
商品打折问题
#include#include#includeusing namespace std;int main(){ cout << "======================" << endl; cout << "| 满500打九折 " << endl; cout << " 满1000打八折 " << endl; cout << " 满原创 2015-09-16 21:33:28 · 2056 阅读 · 0 评论