Code
爱吃的小花猫
来者皆客
展开
-
Verification and validation
VerificationVerification is the process to make sure the product satisfies the conditions imposed at the start of the development phase. In other words, to make sure the product behaves the way原创 2015-06-14 12:32:02 · 1095 阅读 · 0 评论 -
Unity KillCount
using UnityEngine;using System.Collections;public class KillCountMult : MonoBehaviour {public GUIText kText;public static int kills1;public static int kills2;public static bool playe原创 2015-03-13 15:53:34 · 870 阅读 · 0 评论 -
Unity Enemy behaviour
using UnityEngine;using System.Collections;public class enemyBehaviour : MonoBehaviour{ //enemy that moves to player when close enough public float speed = 6f; public Tran原创 2015-03-13 15:37:06 · 795 阅读 · 0 评论 -
C++ classes and uniform initialization
// classes and uniform initialization#include using namespace std;class Circle { double radius; public: Circle(double r) { radius = r; } double circum() {return 2*radius*3.141592原创 2015-03-18 02:50:04 · 627 阅读 · 0 评论 -
programming error (function overloading)
Here is the definition of function overloading:Function overloading or meth overloading is the ability to create multiple methods of same name with different implementations:Here is an exa原创 2015-03-18 02:41:37 · 824 阅读 · 0 评论 -
Class constructor
// example: class constructor#include using namespace std;class Rectangle { int width, height; public: Rectangle (int,int); int area () {return (width*height);}};Rectangle::Re原创 2015-03-18 02:47:29 · 1149 阅读 · 0 评论 -
Pointers to classes (From the note of my firend)
Pointers to classesObjects can also be pointed to by pointers: Once declared, a class becomes a valid type, so it can be used as the type pointed to by a pointer. For example:原创 2015-03-18 01:49:25 · 1060 阅读 · 1 评论 -
Matlab 如何输入矩阵
A=[1 2 3;4 5 6;7 8 9],每行之间用分号隔开也可以用循环控制输入n=input('请输入矩阵阶数:')for i=1:n for j=1:n a(i,j)=input('请输入矩阵元素:'); endenda原创 2015-03-29 12:04:47 · 18434 阅读 · 0 评论 -
Launching New_configuration error
An internal error occurred during: "Launching New_configuration". Path for project must have only one segment.Project -> Properties -> Run/Debug Settings:1. select "Launching New_configurati原创 2015-03-21 13:14:55 · 871 阅读 · 0 评论 -
What is the name of the “-->” operator?(Stackoverflow)
Question:After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that it compiled and worked in both Visual Studio 2008 and G++ 4.4.T原创 2015-03-21 01:27:53 · 3885 阅读 · 0 评论 -
算法 Heap sort
// -------------------------------------------------------------------------------------------------------------------- // // // Respect the work. // // // // // Heap sort.原创 2015-03-13 16:28:20 · 734 阅读 · 0 评论 -
Unity multiplayer
using UnityEngine;using System.Collections;public class multiplayer_Button : MonoBehaviour {void OnGUI(){const int buttonWidth = 150;const int buttonHeight = 60;// Determine the原创 2015-03-13 16:10:08 · 901 阅读 · 0 评论 -
Fzreo matlab
fzeroRoot of nonlinear functioncollapse all in pageSyntaxx = fzero(fun,x0) examplex = fzero(fun,x0,options) examplex = fzero(problem) example[x,fval,exi转载 2015-04-15 08:57:54 · 1142 阅读 · 0 评论 -
constructor C++ example
The constructor for this class could be defined, as usual, as: Rectangle::Rectangle (int x, int y) { width=x; height=y; } But it could also be defined using membe原创 2015-04-08 06:21:17 · 1275 阅读 · 0 评论 -
c++类构造函数详解
//一、 构造函数是干什么的/* 类对象被创建时,编译系统对象分配内存空间,并自动调用该构造函数->由构造函数完成成员的初始化工作 eg: Counter c1; 编译系统为对象c1的每个数据成员(m_value)分配内存空间,并调用构造函数Counter( )自动地初始化对象,初始化之后c1的m_value值设置为0 故:构造函原创 2015-04-04 04:13:40 · 951 阅读 · 0 评论 -
Matlab adaptive quadrature
% script to perform adaptive quadratureclear all, close allglobal pts% function to be integrated defined in routine ff = 'integrand';a = 1; b = 3;pts = [a;b];tol = input('Enter error toleran原创 2015-03-31 10:07:36 · 1581 阅读 · 1 评论 -
C++中的class (2)
class Father{ protected void methodA(){ //do something } private void methodB(){//do something }}class Child:Father{}那么Child child=new Child();child.methodA(); //Rightchild.methodB原创 2015-03-14 03:33:59 · 621 阅读 · 0 评论 -
C++ overloading contructor
// overloading class constructors#include using namespace std;class Rectangle { int width, height; public: Rectangle (); Rectangle (int,int); int area (void) {return (width*h原创 2015-03-18 02:48:57 · 825 阅读 · 0 评论 -
Answer's Question about pointer
When you create a new pointer, this will be in heap until you delete it. So what you said is sort of mistake, "函数内部有个局部变量指针", then the pointer should not exist after the function return.Therefor原创 2015-03-14 01:16:23 · 607 阅读 · 0 评论 -
算法 binary search
// -------------------------------------------------------------------------------------------------------------------- // // Respect the work. // // // The binary search (not recurs原创 2015-03-13 16:31:23 · 1258 阅读 · 1 评论 -
算法 quick sort
// -------------------------------------------------------------------------------------------------------------------- // // // Respect the work. // // // // // The quick sor原创 2015-03-13 16:28:34 · 694 阅读 · 0 评论 -
数组-条件求和(Code)
static void Main(string[] args){ // Generate data int arraySize; int[] data; Random rnd; arraySize = 32768; data = new int[arraySize]; rnd = new Random(0); for (int原创 2015-03-21 02:26:45 · 3978 阅读 · 0 评论 -
Matlab function lorenzgui
function lorenzgui%LORENZGUI Plot the orbit around the Lorenz chaotic attractor.% This function animates the integration of the three coupled% nonlinear differential equations that define the原创 2015-03-28 07:41:48 · 2469 阅读 · 0 评论 -
atoi C语言的基本用法 code
#include #include int main(void){ float n; char const *str = "12345.67"; n = atoi(str); printf("string=%sint=%dfloat=%f\n",str,n,n); return 0;原创 2015-03-20 12:58:48 · 607 阅读 · 1 评论 -
C++的class的例子
私有就是只能够通过内部调用,在类外面是不可以使用私有成员的简单的写一个 Class A{ public: //你可以通过公有的函数去访问私有成员 Demo() //可以在这使用私有成员 { m_buff = 0; } private: //私有成员 int m_buff;}void main(){ A a原创 2015-03-14 18:04:53 · 889 阅读 · 0 评论 -
C++ The Bisection Method
C++语言中的二分查找法算法:当数据量很大适宜采用该方法。采用二分法查找时,数据需是排好序的。基本思想:假设数据是按升序排序的,对于给定值x,从序列的中间位置开始比较,如果当前位置值等于x,则查找成功;若x小于当前位置值,则在数列的前半段中查找;若x大于当前位置值则在数列的后半段中继续查找,直到找到为止。假如有一组数为3,12,24,36,55,68,75,88要查给定的值原创 2015-03-16 07:04:08 · 1903 阅读 · 0 评论 -
Matlab Newton‘s method
定义函数function y=f(x)y=f(x);%函数f(x)的表达式endfunction z=h(x)z=h(x);%函数h(x)的表达式end主程序x=X;%迭代初值i=0;%迭代次数计算while ix0=X-f(X)/h(X);%牛顿迭代格式if abs(x0-X)>0.01;%收敛判断原创 2015-03-16 09:34:37 · 1750 阅读 · 0 评论 -
Class 找出一个整形数组中的元素的最大值
目的:找出一个整形数组中的元素的最大值 下面,我们用类和对象的方法来做。 #include using namespace std; class Array_max{ private://声明在类的外部不可访问的隐私成员 int array[10]; int max; public://声明在原创 2015-03-14 19:43:56 · 5344 阅读 · 0 评论 -
C++类和对象的一个简单的实例
#include usingnamespace std; classArray_max{ private://声明在类的外部不可访问的隐私成员 intarray[10]; intmax; public://声明在类的外部可以访问的开放的成员函数原创 2015-03-14 19:48:37 · 900 阅读 · 0 评论 -
The Secant Method(正割法、弦截法) 附C语言代码
弦截法是一种求方程根的基该方法,在计算机编程中常用。他的思路是这样的:任取两个数x1、x2,求得对应的函数值f(x1)、f(x2)。如果两函数值同号,则重新取数,直到这两个函数值异号为止。连接(x1,f(x1))与(x2,f(x2))这两点形成的直线与x轴相交于一点x,求得对应的f(x),判断其与f(x1)、f(x2)中的哪个值同号。如f(x)与f(x1)同号,则f(x)为新的f(原创 2015-03-16 13:29:26 · 5703 阅读 · 2 评论 -
牛顿迭代法 C
double func(double x) //函数{return x*x*x*x-3*x*x*x+1.5*x*x-4.0;}double func1(double x) //导函数{return 4*x*x*x-9*x*x+3*x;}int Newton(double *x,double precision,int maxcyc)原创 2015-03-16 09:33:01 · 995 阅读 · 0 评论 -
Matlab The Bisection Method
MATLAB语言function y=f(x)y=f(x); %函数f(t)的表达式i=0; %二分次数记数a=a; %求根区间左端b=b; %求根区间右端fa=f(a); %计算f(a)的值fb=f(b); %计算f(b)的值c=(a+b)/2; %计算区间中点fc=f(c); %计算区间中点f(c)while ab原创 2015-03-16 07:55:32 · 2579 阅读 · 1 评论 -
命名空间std::的例子(2)
int x = 20; namespaceouter { intx = 10; namespaceinner { intz = x; } } int main() { std::cout << outer::inner::z;// 输出10 return 0;原创 2015-03-20 15:00:55 · 685 阅读 · 0 评论 -
C语言100个经典的算法
C语言的学习要从基础开始,这里是100个经典的算法-1C语言的学习要从基础开始,这里是100个经典的算法题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?______________________________________________原创 2015-03-13 22:38:25 · 7985 阅读 · 3 评论 -
Matlab forward Euler demo
% forward Euler demo% take two steps in the solution of % dy/dt = y, y(0) = 1% exact solution is y(t) = exp(t)clear allclose all% the exact solutiont = 0:0.01:1;yexact = exp(t);% initial c原创 2015-03-28 07:40:19 · 1676 阅读 · 0 评论 -
Matlab arenstorf problem
% right-hand side of arenstorf problemfunction yDot = arenstorf(t,y)global mu muHat% unpack yu1 = y(1);u2 = y(2);u1Dot = y(3);u2Dot = y(4);% define variables of conveniencer1 = ((u1+mu)^2原创 2015-03-28 07:42:41 · 1565 阅读 · 0 评论 -
C++继承经典例子
c++继承经典例子#include class Base{private: int b_number;public: Base( ){} Base(int i) : b_number (i) { } int get_number( ) {return b_number;} void p原创 2015-03-17 08:33:14 · 3263 阅读 · 1 评论 -
Matlab Error (Matrix dimensions must agree)
xOld =input('Enter initial guess: '); errortmp =2;counter =0; while (errortmp>10^-10)xNew =xOld - Jf3(xOld)\f3(xOld)counter=counter+1error=norm(xNew-xOld,inf)+4*eps*norm(xNew,inf)if(原创 2015-03-17 07:38:14 · 12678 阅读 · 1 评论 -
Matlab Newton iteration
% matlab script to demonstrate Newton iteration in higher dimensions% the system of nonlinear equations to be solved is defined in function f% the Jacobian of f is defined in function JfxOld = in原创 2015-03-17 07:38:38 · 1254 阅读 · 0 评论 -
Matlab 随机数字
1.随机生成只有0,1元素的矩阵(m行n列)A=round(rand(m,n))2.随机生成每行有若干个0,1元素的矩阵,比如每行只有2个元素为1,其他元素为0A=zeros(4,5)for i=1:4 A(i,:)=randperm(5); for j=1:5 if A(i,j) A(i,j)=1;原创 2015-03-17 14:55:55 · 1098 阅读 · 0 评论