by fox64194167
Below is the core code template <class T> int Partition(T a[], int p, int r){ int x = a[r]; int i = p – 1; for(int j = p;j <= r – 1;j++){ if(a[j] <= x){ i++; swap(a[i],a[j]); } } swap(a[i + 1],a[r]); return i + 1; } Figure below show how Partition works on an 8-element array. Array entry a[r] becomes the pivot element x. Lightly shaded array elements are all in the first partition with […]
by fox64194167
Introduction We speak of a Vector as a container because it contains other objects. All objects in a container must have the same type. To use a Vector, we must include the appropriate header. #include <vector> Using std::vector; In the case of Vector, we must say what type of objects the Vector will contain. We specify the type by putting it between a pair of angle brackets followin […]
by fox64194167
Since an array with one element is a sorted array. By insert second element into this one array, we get a sorted array of size 2, Continuing in this way, we obtain a sorted array of size n. // InsertionSort.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; template <class T> void PrintfNum(T a[], […]
by fox64194167
“Bubble Sort” is a simple way to sort elements. This sort employs a “bubbling strategy” to get the largetest element to the right. In a bubbling pass, pairs of adjacent elements are compared, the elements are swapped in case the one on the left is greater than the one on the right. At the end of the bubbling pass, we are assured that the largest element is in the right-mo […]
by fox64194167
首先我们来看下这个项目的效果,一个照片被”黑白化” 下面这张是原图。 我们来看下是如何实现的,首先你要有点知识关于“DirectX Texture(纹理)”. 如果你还没有的话,可以看下这篇文章 “DirectX 9.0 C++ tutorial Texture ”. 今天的主题是 HLSL and Pixel Shader(像素着色器), 这两个主题有点难。 介绍: HLSL 是 “High-LevelShading Language” 的简写. 我们可以使用 HLSL去写一些小的 Pixel Shade 项目.简要地说, 顶点着色器和像素着色器就是我们自行编写的一些规模较小的定制程序。这些定制程序可取代固定功能流水线中的某一功能,并在图形卡的GPU中执 […]
by fox64194167
First we look at the project result: A picture that looks “grey”. Below is the original Picture. So let’s see how to do it. First you had to know some knowledge about “DirectX Texture”. If you don’t, you can see the article “DirectX 9.0 C++ tutorial Texture ” Firstly. Today’s topic is HLSL and Pixel Shader, it’s a some kind difficult topic. Introduction: H […]