#include<iostream>
using namespace std;
int a[1005]={0,1,3,4,2,1,4,7,6};
int n=8;
void print(){
	//puts("");
    for (int i=1;i<=n;++i)
        cout<<a[i]<<" "; 
	puts("");
    return;
}
/*void printB(){
	for (int i=1;i<=n;++i){
		cout<<a[i];
		puts("");
	}
	return;
}*/
void ssort(){
	//printB();
    int w;
    for (int i=1;i<=n;++i){
    	w=i;
        for (int j=i+1;j<=n;++j)
            if (a[j]<a[w]) w=j;
        swap(a[i],a[w]);
    }
    print();
    return;
}
int main(){
    ssort();
    return 0;
}
caopoy123(CAOpoy是个垃圾) - 2020-01-19 0 人
selectSort
#include <iostream>
#include <functional>
using namespace std;
 
class A
{
public:
    A() :m_a(0){}
    ~A(){}
 
    virtual void SetA(const int& a){ cout << "A:" << this << endl;  m_a = a; }
    int GetA()const { return m_a; }
protected:
    int m_a;
};
class B: public A
{
public:
    B():A(){;}
    ~B(){;}
    virtual void SetA(const int& a){ cout << "B:" << this << endl; m_a = a; }
private:
};
 
int main(void)
{
    A a;
    cout << "A:" << &a << endl;//0
    function<void(const int&)> func1 = std::bind(&A::SetA, a, std::placeholders::_1);
    func1(1);
    cout << a.GetA() << endl;//0
    function<void(const int&)> func2 = std::bind(&A::SetA, &a, std::placeholders::_1);
    func2(2);
    cout << a.GetA() << endl;//2
 
    cout << "---------" << endl;
    A* pa = new B();
    cout << "B:" << pa << endl;//0
    function<void(const int&)> func3 = std::bind(&A::SetA, pa, std::placeholders::_1);
    func3(3);
    cout << pa->GetA() << endl;//3
    function<void(const int&)> func4 = std::bind(&A::SetA, *pa, std::placeholders::_1);
    func4(4);
    cout << pa->GetA() << endl;//3
    delete pa;
    //system("pause");
    return 0;
}
ianc(前端大神) - 2020-01-04 0 人
std::bind &amp; function
#include <iostream>
using namespace std;
int main() {
    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << "Hello JSRUN!   \n\n         - from C++ ." << endl;
	return 0;
}
yqmjhym(前端大神) - 2020-01-01 0 人
学习写代码
#include <iostream>
using namespace std;
namespace xx{
class BB{ 
	int aa; 
};
}
class BB{ 
	int aa; 
};

int main() {
    

    //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 
	cout << typeid(bool).name() << endl;
	cout << typeid(int).name() << endl;
	cout << typeid(xx::BB).name() << endl;
	cout << typeid(BB).name() << endl;
	return 0;
}
ianc(前端大神) - 2019-12-31 0 人
typeid
 #include<iostream>

 #define REGISTER_TYPE(type)\
template<type> \
struct Extract < type_id(type* ) > {
	typedef type* type_t;
};

REGISTER_TYPE(int)
REGISTER_TYPE(long)
REGISTER_TYPE(char)
REGISTER_TYPE(double)


class A {
	public: virtual void func() {
		std::cout << "A" << std::endl;
	}
};
REGISTER_TYPE(A)

class B: public A {
	public: virtual void func() {
		std::cout << "B" << std::endl;
	}
};
REGISTER_TYPE(B)

int main() {
	B bb;
	A & aa = bb;
	type_of(aa)cc;
	cc.func();
	return 0;
}

using namespace std;
int main2() {
	//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。
	cout << "Hello JSRUN!   \n\n         - from C++ ." << endl;
	return 0;
}
ianc(前端大神) - 2019-12-31 0 人
REGISTER_TYPE
#include <iostream>
	#include <stdint.h>
	#include <stdio.h>

class B{ 
	public:
	B(){bb=2;}
	B(int n){bb=2;}
	int c;
	static int bb;
};
	
class Config { 
	public:
 static int a;
 static  B b;// = B();	
 static  int c;	
 
};



int Config::c=4;
int Config::a=1;
//B Config::b;// = B();
int B::bb=3;

int main() {
	 
 

	//std::cout << sizeof(Config) << std::endl;

	std::cout << Config::a << std::endl;
	std::cout << Config::c << std::endl;
	std::cout << Config::b.bb << std::endl;
	std::cout << Config::b.c << std::endl;
	return 0;
}
ianc(前端大神) - 2019-12-30 0 人
static test
没有了
1/6 下一页