Commit 6a2ec4d8 by songxinkai

add c++/queue

parent ca1e3418
*core *core
*a.out *a.out
.*.swp .*.swp
*bin
*bin.finish
...@@ -47,8 +47,8 @@ void read(const string file, vector<vector<float> >& feas, ...@@ -47,8 +47,8 @@ void read(const string file, vector<vector<float> >& feas,
void write(const string file){ void write(const string file){
int steps_out = 400; int steps_out = 400;
int winner_out = 1; // 1: black win, 0: white win int winner_out = 1; // 1: black win, 0: white win
unsigned char feas_out[400 * 17*19*19] = {0}; unsigned char* feas_out = new unsigned char[steps_out * 17*19*19];
float pis_out[400 * 362] = {0.0}; float* pis_out = new float[steps_out * 362];
srand((int)time(0)); srand((int)time(0));
for (int i = 0; i < steps_out; ++i){ for (int i = 0; i < steps_out; ++i){
int position_0 = int(361.0 * rand()/(RAND_MAX+1.0)); int position_0 = int(361.0 * rand()/(RAND_MAX+1.0));
...@@ -81,31 +81,31 @@ void write(const string file){ ...@@ -81,31 +81,31 @@ void write(const string file){
int main (){ int main (){
stringstream ss; stringstream ss;
for (int i = 0; i < 1000; ++i){ // for (int i = 0; i < 1000; ++i){
ss.str(""); // ss.str("");
ss << "go/" << i << ".bin"; // ss << "go/" << i << ".bin";
// write(ss.str()); // write(ss.str());
vector<vector<float> > feas; // }
vector<vector<float> > pis; vector<vector<float> > feas;
vector<float> vs; vector<vector<float> > pis;
read(ss.str(), feas, pis, vs); vector<float> vs;
cout << feas.size() << ", " << pis.size() << ", " << vs.size() << ", " << endl; read("0.bin", feas, pis, vs);
for (int i = 0; i < feas.size(); ++i){ cout << feas.size() << ", " << pis.size() << ", " << vs.size() << ", " << endl;
cout << "========" << i << "======" << endl; for (int i = 0; i < feas.size(); ++i){
for (int j = 0; j < 19*19; ++j){ cout << "========" << i << "======" << endl;
cout << j << ": "; for (int j = 0; j < 19*19; ++j){
for (int c = 0; c < 17; ++c){ cout << j << ": ";
cout << feas[i][j*17+c] << ", "; for (int c = 0; c < 17; ++c){
} cout << feas[i][j*17+c] << ", ";
cout << endl;
} }
for (int j = 0; j < pis[i].size(); ++j){ cout << endl;
if (pis[i][j] != 0){ }
cout << "(" << j << "-" << pis[i][j] << "), "; for (int j = 0; j < pis[i].size(); ++j){
} if (pis[i][j] != 0){
cout << "(" << j << "-" << pis[i][j] << "), ";
} }
cout << endl << vs[i] << endl;
} }
cout << endl << vs[i] << endl;
} }
return 0; return 0;
......
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
\ No newline at end of file
#include <queue>
#include <iostream>
#include <string>
#include <thread>
using namespace std;
int main (){
queue<int> q;
cout << "q.empty(): " << q.empty() << endl;
q.push(0);
q.push(1);
q.push(2);
q.push(3);
cout << "q.size(): " << q.size() << endl;
cout << "q.front(): " << q.front() << endl;
cout << "q.size(): " << q.size() << endl;
cout << "q.back(): " << q.back() << endl;
cout << "q.size(): " << q.size() << endl;
q.pop();
cout << "q.size(): " << q.size() << endl;
cout << "q.front(): " << q.front() << endl;
cout << "q.size(): " << q.size() << endl;
cout << "q.back(): " << q.back() << endl;
cout << "q.size(): " << q.size() << endl;
//cout << "q.front(): " << q.pop() << endl;
return 0;
}
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
using namespace std; using namespace std;
int main(){ int main(){
const int len0 = 3;
int len1 = 3;
int aa[len0] = {1,2,3};
int bb[len1] = {11,22,33};
cout << "aa: " << aa[0] << ", " << aa[1] << ", " << aa[2] << ", " << aa[3] << endl;
cout << "bb: " << bb[0] << ", " << bb[1] << ", " << bb[2] << ", " << bb[3] << endl;
vector<int> a(5,1); vector<int> a(5,1);
vector<int> b = {1,1,1,1,1}; vector<int> b = {1,1,1,1,1};
vector<int> c = {1,1,1}; vector<int> c = {1,1,1};
......
/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment