【修改的C++版Opengl艺术画实现】教程文章相关的互联网学习教程文章

C#调用C++ memcpy实现各种参数类型的内存拷贝【代码】

using System; using System.Runtime.InteropServices; using System.IO; namespace tx {struct ST{publicchar c1;publicint x;publicint y;}class Ct{[DllImport("msvcrt.dll", EntryPoint = "memcpy", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]publicstaticexternvoid MemCopy(byte[] dest, byte[] src, int count);//字节数组到字节数组的拷贝[DllImport("msvcrt.dll", EntryPoint = "memcpy", Cal...

C++实现链表的进本操作及测试用例【代码】

今天实现了下链表的基本操作,包括节点的创建,头插尾插,头删尾删,一次遍历寻找链表的中间节点,寻找链表的倒数第x个节点,删除无头链表的非尾节点,链表的逆置,代码如下:#include "SLinkList.h" #include <stdlib.h> #include <stdio.h> #include <assert.h> void PrintList(SListNode* pHead)//从指针位置打印链表 { while (pHead) { printf("->%d", pHead->data); pHead = pHead->next; } printf("\n"); } static SListNode...

c/c++ 反汇编学习 加法的实现【代码】【图】

汇编的学习需要掌握一些基本的汇编指令,也要了解汇编的格式,今天采用c语言内嵌汇编的形式实现了简单的加法运算。 1 #include "stdafx.h" 2 3int main(int argc, char* argv[])4{5int a = 1;6int b = 2;7int c;8 _asm{9 mov eax,a 10 mov ebx,b 11 add eax,ebx 12 mov c,eax; 13 } 14 printf("a+b=%d\n",c); 15return0; 16 } 原文:https://www.cnblogs.com/justinyee/p/12293153.html

单链表C++实现【代码】

1// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。2//3 4 #include "stdafx.h" 5 #include"iostream" 6usingnamespace std;7 8 typedef int data;9 10 typedef struct node_list11{12 data info;;13 node_list *next;14}node;15 16 node *init();17 node *insert_head(node *head, data x);18 node *insert_rear(node *head, data x);19 node *insert_x(node *head, data x, data y);20 node *del_x(node *h...

约瑟夫问题(c++实现)【代码】

描述:约瑟夫问题:有n只猴子,按顺时针方向围成一圈选大王(编号从1到n),从第1号开始报数,一直数到m,数到m的猴子退出圈外,剩下的猴子再接着从1 开始报数。就这样,直到圈内只剩下一只猴子时,这个猴子就是猴王,编程求输入n,m后,输出最后猴王的编号。输入:每行是用空格分开的两个整数,第一个是 n, 第二个是 m ( 0 < m, n < 300)。最后一行是: 0 0输出:对于每行输入数据(最后一行除外),输出数据也是一行,即最...

C/C++ 知识点---排序实现

1.冒泡排序冒泡排序是O(N^2)复杂度的排序算法,效率较低,需要N趟遍历,每次将候选集中最小的数通过交换浮到最上面;template <typename Type>void BubbleSort(vector<Type> &arraySort, int lowIndex, int hightIndex){ bool bChange; for (int i=lowIndex; i<hightIndex; ++i) { bChange = false; for (int j=hightIndex; j>i; --j) { if (arraySort[j-1] > arraySort[j]) ...

Quicksort的算法分析及C++实现【代码】【图】

一、关于Quicksort的简单介绍Quicksort算法属于divide and conquer算法,核心思想是取array中的一个元素作为pivot,然后把array除了pivot的其他元素与这个pivot进行比较,比pivot小的元素放在pivot左边,比pivot大的元素放在pivot的右边,我们就得到了两个subarray(左边和右边),然后再对新的subarray进行同样的操作,直到得到新array中只有一个元素。二、quicksort的C++程序实现://// main.cpp // quicksort //// Created b...

Headfirst设计模式的C++实现——观察者模式(Observer)【代码】

WeatherData.h 1#ifndef WEATHERDATA_H_INCLUDED2#define WEATHERDATA_H_INCLUDED3 4 #include <set>5 #include "Display.h" 6 7class WeatherData8{9public: 10void measurementsChanged(); 11void registerObserver( Display *p_display ); 12void removeObserver( Display *p_display ); 1314private: 15int getTemperature() { return25; } 16int getHumidity() { return90; } 17int getPressure() { return120; } 1819 st...

c++实现冒泡排序【代码】【图】

# include<iostream> #include<stdio.h>usingnamespace std;void maopao(int *list){int i,j,temp;for(i=0;i<9;i++){for(j=0;j<9-i;j++){if(list[j]>list[j+1]){temp = list[j];list[j] = list[j+1];list[j+1] = temp;//用于检测每一步的输出/* cout<<"i等于"<<i<<"j等于"<<j<<endl;for(int temp=0;temp<10;temp++){cout<<list[temp]<<" ";}cout<<endl;*/}}} }int main(){int list[10];int n =9,m=0,i;cout<<"input 10 number"<<e...

JNI实现JAVA和C++互相调用【代码】

SDK.h 1#ifndef SDK_H2#define SDK_H3 4 #include "AsyncProxy.h" 5 #include "Module.h" 6 #include <map>7 #include <vector>8 #include <string>9using std::map; 10using std::vector; 11using std::string; 121314class SDK 15{ 16private: 17 vector<Module*> m_modules; 18 AsyncProxy* mp_asyncProxy; 19 map<string,Method*> m_methodIndex; 20private: 21 Method* checkMethod(string methodName, map<s...

图的广度优先/层次 遍历(BFS) c++ 队列实现【代码】

在之前的博文中,介绍了图的深度优先遍历,并分别进行了递归和非递归实现。BFS 无法递归实现,最广泛的实现是利用队列(queue)。这与DFS的栈实现是极其相似的,甚至代码几乎都很少需要改动。从给定的起点节点开始,依次将其邻接节点全部塞入队列,每次访问一个节点时将其pop()出队列,并将其邻接节点也塞入队列。直到队列为空,算法结束。  代码实现并无太大障碍,c++实现: 1 #include <iostream>2 #include <queue>3usingnam...

大话设计模式C++实现-第27章-解释器模式【图】

一、UML图二、概念解释器模式(interpreter):给定一个语言,定义它的文法的一种表示,并定义一个解释器,这个解释器使用该表示来解释语言中的句子。三、说明包含哪些角色?(1)AbstractExpression(抽象表达式):声明一个抽象的解释操作,这个接口为抽象语法树中所有的节点所共享。(2)TerminalExpression(终结符表达式):实现与文法中的终结符相关联的解释操作。实现抽象表达式中所要求的接口,主要是一个interpreter()方...

c++ 实现二叉树高度【代码】【图】

1 #include<iostream>2usingnamespace std;3 4//二叉树节点 5struct BinaryNode6{7char ch;8 BinaryNode* lchild;9 BinaryNode* rchild; 10}; 11int HeightTree(BinaryNode* root); 12//初始化二叉树13void CreateBinaryTree() { 14 BinaryNode node1 = { ‘A‘,NULL,NULL }; 15 BinaryNode node2 = { ‘B‘,NULL,NULL }; 16 BinaryNode node3 = { ‘C‘,NULL,NULL }; 17 BinaryNode node4 = { ‘D‘,NULL...

C++实现快速排序

void quickSort(int a[], int low, int high){ if (low <= high) return; int i = low; int j = high; int key = a[i]; while (i < j) { while (i < j && a[j] >= key) --j; a[i] = a[j]; while (i < j && a[i] <= key) ++i; a[j] = a[i]; } a[i] = key; quickSort(a, low, i - 1); quickSort(a, i + 1, high);}原文:http://sharep.blog...

简单的加密与解密的实现---仿射密码(c++使用string)【代码】

使用c++中string类,相比于使用数组,没有了数组长度的限制,而且操作跟加的方便 #include <iostream> #include <string> using namespace std; string jiami(string str,int k,int b); string jiemi(string pass,int k,int b); int canshu(int k,int b); int main() { string str; //明文 string pass; //密文 string res; //明文 int k,b; //加密算法的参数 cout<<"请输入明文:"; ...