blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
6f7c02eefe804c8068ec91ee7e3d528c68c892f2
6703e05cf76a7b78c031447fa124f3f0c030f2da
/src/qt/winshutdownmonitor.cpp
56686f9d7d0d0b829f222ba92790302075efb205
[ "MIT" ]
permissive
cenut/donu-core
d26e46f76107fe00ef5fd2d27fbfac6afff83149
abd6580ca4df833fe5d08face22a1694a83a9d6b
refs/heads/master
2020-06-23T04:35:49.513160
2019-07-23T23:09:55
2019-07-23T23:09:55
198,514,932
0
0
NOASSERTION
2019-07-23T22:04:18
2019-07-23T22:04:18
null
UTF-8
C++
false
false
2,438
cpp
// Copyright (c) 2014-2018 The Bitcoin Core Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <qt/winshutdownmonitor.h> #if defined(Q_OS_WIN) #include <shutdown.h> #include <util.h> #include <windows.h> #include <QDebug> #include <openssl/rand.h> // If we don't want a message to be processed by Qt, return true and set result to // the value that the window procedure should return. Otherwise return false. bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult) { Q_UNUSED(eventType); MSG *pMsg = static_cast<MSG *>(pMessage); // Seed OpenSSL PRNG with Windows event data (e.g. mouse movements and other user interactions) if (RAND_event(pMsg->message, pMsg->wParam, pMsg->lParam) == 0) { // Warn only once as this is performance-critical static bool warned = false; if (!warned) { LogPrintf("%s: OpenSSL RAND_event() failed to seed OpenSSL PRNG with enough data.\n", __func__); warned = true; } } switch(pMsg->message) { case WM_QUERYENDSESSION: { // Initiate a client shutdown after receiving a WM_QUERYENDSESSION and block // Windows session end until we have finished client shutdown. StartShutdown(); *pnResult = FALSE; return true; } case WM_ENDSESSION: { *pnResult = FALSE; return true; } } return false; } void WinShutdownMonitor::registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId) { typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR); PSHUTDOWNBRCREATE shutdownBRCreate = (PSHUTDOWNBRCREATE)GetProcAddress(GetModuleHandleA("User32.dll"), "ShutdownBlockReasonCreate"); if (shutdownBRCreate == nullptr) { qWarning() << "registerShutdownBlockReason: GetProcAddress for ShutdownBlockReasonCreate failed"; return; } if (shutdownBRCreate(mainWinId, strReason.toStdWString().c_str())) qWarning() << "registerShutdownBlockReason: Successfully registered: " + strReason; else qWarning() << "registerShutdownBlockReason: Failed to register: " + strReason; } #endif
[ "kris@blockchaindatasystems.com" ]
kris@blockchaindatasystems.com
f6f349c263f8b138d9d74fcb46fb424d33aded9e
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
/sstd_boost/sstd/boost/fusion/algorithm/query/count_if.hpp
b82eef011fab34e29ec7440a102d38ec48a2b93e
[ "BSL-1.0" ]
permissive
KqSMea8/sstd_library
9e4e622e1b01bed5de7322c2682539400d13dd58
0fcb815f50d538517e70a788914da7fbbe786ce1
refs/heads/master
2020-05-03T21:07:01.650034
2019-04-01T00:10:47
2019-04-01T00:10:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,324
hpp
/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2007 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_FUSION_COUNT_IF_09162005_0137) #define BOOST_FUSION_COUNT_IF_09162005_0137 #include <sstd/boost/fusion/support/config.hpp> #include <sstd/boost/fusion/algorithm/query/detail/count_if.hpp> #include <sstd/boost/fusion/support/category_of.hpp> #include <sstd/boost/fusion/support/is_sequence.hpp> #include <sstd/boost/utility/enable_if.hpp> namespace boost { namespace fusion { namespace result_of { template <typename Sequence, typename F> struct count_if { typedef int type; }; } template <typename Sequence, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename enable_if< traits::is_sequence<Sequence> , int >::type count_if(Sequence const& seq, F f) { return detail::count_if( seq, f, typename traits::category_of<Sequence>::type()); } }} #endif
[ "zhaixueqiang@hotmail.com" ]
zhaixueqiang@hotmail.com
e2fb4d8f1c3c7920d592962e6574ddadb2d4ca62
edab80463c1286ac55d411af8af908ae878876e6
/N-queen/NQueen.cpp
8d0c5cd0a79fa57d75376eed0c6b2c787f3f2f70
[]
no_license
seunghwa5/algorithm
444c893c7298c03f1aeab32a5c8a34dbea907ffd
d7fe07ca07225dc03f4570314cd49ea47b53b1e0
refs/heads/master
2021-01-10T04:16:17.835751
2016-01-20T16:22:42
2016-01-20T16:22:42
49,312,794
1
0
null
null
null
null
UTF-8
C++
false
false
732
cpp
#include <iostream> #include <cmath> using namespace std; int *col; int N; int count; void N_Queens(int); bool possible(int); void print_board(); int main() { count = 0; cin>>N; col = new int[N+1]; N_Queens(0); cout<<count<<endl; } void N_Queens(int i) { if(possible(i)) { if(i==N) { //print_board(); count++; } else for(int j=1; j<=N; j++) { col[i+1] = j; N_Queens(i+1); } } } bool possible(int i) { for(int j=1; j<i; j++) { if( abs(i-j)==abs(col[i]-col[j]) || col[i]==col[j]) return false; } return true; } void print_board() { for(int i=1; i<=N; i++) { for(int j=1; j<=N; j++) if(col[i]==j) cout<<"Q"; else cout<<" "; cout<<endl; } cout<<"------"<<endl; }
[ "seunghwa.dev@gmail.com" ]
seunghwa.dev@gmail.com
4d1125c013c7cedd6ad8a085f1169e8201a7887b
a9141309c9d61caf149f54ba6f4713a1c3c4e5fd
/Proj Euler Codes/3prime/pe3.cpp
9fca90a02cee2168e9535defad8e9b784c4c15bd
[]
no_license
TrigonaMinima/Minima-C
4ddef8a98ed33f00f173bfab17479fd6878da6cf
589ad53d682ebe7eea838ddd8f673d90bfd453cd
refs/heads/master
2021-01-23T20:46:50.630174
2015-09-22T13:21:13
2015-09-22T13:21:13
14,394,298
0
0
null
null
null
null
UTF-8
C++
false
false
150
cpp
# include <iostream> using namespace std; int main() { long int j,i=600851475143; for(j=2;j<i/2;j++) { if(i%j==0) cout<<j<<endl; } return 0; }
[ "shivamrana95@yahoo.in" ]
shivamrana95@yahoo.in
2ee3bee0e00e103e0b08ac0031583fe63155c2fd
105ac3f78122b133b632c29ed0cf8648f315bf94
/tests/syslog.cpp
6b4bbcfad32967ed79b0052310bcd1a4e2d87434
[ "MIT" ]
permissive
mistralol/liblogger
cb85c53bcb4753280b6f265e77ef6d9c2caf726c
b9b81bd707a9c83e6ec9a7f802a6fff138bed2ec
refs/heads/master
2020-12-18T13:49:10.833190
2020-02-04T15:41:02
2020-02-04T15:41:02
11,122,237
2
1
null
null
null
null
UTF-8
C++
false
false
202
cpp
#include <liblogger.h> using namespace liblogger; #include "examples.h" int main(int argc, char ** argv) { LogManager::Add(new LogSyslog()); examples(); LogManager::RemoveAll(); return 0; }
[ "james@stev.org" ]
james@stev.org
5455ced4e2eb51052c7df5b1edc7e2c3f52d29b4
ede14884b614d3b569c633313058c75974b43ecb
/Classes/IGameScene.h
35990270e0233115016f7e56b9347afcdb897c36
[]
no_license
codeoneclick/iGaia-Tanks
7245b5a23d4c77158c6bcfb6b4ec76dcdf79dd79
766e68ef5aeef8c50c3c0825596631231435124c
HEAD
2018-12-28T04:47:33.014104
2012-09-28T15:48:26
2012-09-28T15:48:26
5,230,304
1
0
null
2012-08-20T10:23:45
2012-07-30T09:11:23
C++
UTF-8
C++
false
false
1,201
h
// // IGameScene.h // iGaia // // Created by sergey sergeev on 7/4/12. // // #ifndef __iGaia__IGameScene__ #define __iGaia__IGameScene__ #include "CGameCharaterControllerMgr.h" #include "CGameAIMgr.h" #include "IGameLevel.h" #include "CSceneMgr.h" #include "CCharacterControllerPlayer.h" #include "CGameShooterMgr.h" class IGameScene { protected: CGameCharaterControllerMgr* m_pCharaterControllerMgr; CGameShooterMgr* m_pGameShooterMgr; CGameAIMgr* m_pGameAIMgr; IGameLevel* m_pLevel; ICharacterController* m_pMainCharacterController; ICamera* m_pCamera; ILight* m_pLight; public: IGameScene(void); virtual ~IGameScene(void); IGameLevel* Get_Level(void) { return m_pLevel; } CGameCharaterControllerMgr* Get_GameCharaterControllerMgr(void) { return m_pCharaterControllerMgr; } CGameAIMgr* Get_GameAIMgr(void) { return m_pGameAIMgr; } CGameShooterMgr* Get_GameShooterMgr(void) { return m_pGameShooterMgr; } ICharacterController* Get_MainCharacterController(void) { return m_pMainCharacterController; } virtual void Load(void); virtual void Unload(void); virtual void Update(void); }; #endif /* defined(__iGaia__IGameScene__) */
[ "sergey.sergeev.oneclick@gmail.com" ]
sergey.sergeev.oneclick@gmail.com
73a162a7c31958a03fa0b4b7ef8fb7ad177e64fe
40545061306f562b7651a46c8102d3db8f06a639
/core/projects/redmax/python_interface.cpp
2ea01aa30763651ccfd5a2516faa48ae5f9589bb
[ "MIT" ]
permissive
TrendingTechnology/DiffHand
4d79e1322a97b47c259cf6678f95426bc06e6394
d7b9c068b7fa364935f3dc9d964d63e1e3a774c8
refs/heads/master
2023-06-19T10:46:49.776006
2021-07-14T17:26:36
2021-07-14T17:26:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,008
cpp
#include <pybind11/pybind11.h> #include <pybind11/eigen.h> #include <pybind11/stl.h> #include "Simulation.h" #include "SimEnvGenerator.h" using namespace redmax; namespace py = pybind11; Simulation* make_sim(std::string env_name, std::string integrator = "BDF2") { Simulation* sim = nullptr; if (env_name == "SinglePendulum-Test") { sim = SimEnvGenerator::createSinglePendulumTest(integrator); } else if (env_name == "Prismatic-Test") { sim = SimEnvGenerator::createPrismaticTest(integrator); } else if (env_name == "Free2D-Test") { sim = SimEnvGenerator::createFree2DTest(integrator); } else if (env_name == "GroundContact-Test") { sim = SimEnvGenerator::createGroundContactTest(integrator); } else if (env_name == "BoxContact-Test") { sim = SimEnvGenerator::createBoxContactTest(integrator); } else if (env_name == "TorqueFingerFlick-Demo") { sim = SimEnvGenerator::createTorqueFingerFlickDemo(integrator); } else if (env_name == "TorqueFinger-Demo") { sim = SimEnvGenerator::createTorqueFingerDemo(integrator); } else { return NULL; } return sim; } PYBIND11_MODULE(redmax_py, m) { // simulation options py::class_<Simulation::Options>(m, "Options") .def(py::init<Vector3, dtype, string>(), py::arg("gravity") = -980. * Vector3::UnitZ(), py::arg("h") = 0.02, py::arg("integrator") = "BDF1") .def_readwrite("gravity", &Simulation::Options::_gravity) .def_readwrite("h", &Simulation::Options::_h) .def_readwrite("integrator", &Simulation::Options::_integrator); // viewer options py::class_<Simulation::ViewerOptions>(m, "ViewerOptions") .def(py::init()) .def_readwrite("fps", &Simulation::ViewerOptions::_fps) .def_readwrite("speed", &Simulation::ViewerOptions::_speed) .def_readwrite("camera_pos", &Simulation::ViewerOptions::_camera_pos) .def_readwrite("camera_up", &Simulation::ViewerOptions::_camera_up) .def_readwrite("camera_lookat", &Simulation::ViewerOptions::_camera_lookat) .def_readwrite("ground", &Simulation::ViewerOptions::_ground) .def_readwrite("E_g", &Simulation::ViewerOptions::_E_g) .def_readwrite("record", &Simulation::ViewerOptions::_record) .def_readwrite("record_folder", &Simulation::ViewerOptions::_record_folder) .def_readwrite("loop", &Simulation::ViewerOptions::_loop) .def_readwrite("infinite", &Simulation::ViewerOptions::_infinite); // backward data py::class_<BackwardInfo>(m, "BackwardInfo") .def_readwrite("df_dq0", &BackwardInfo::_df_dq0) .def_readwrite("df_dqdot0", &BackwardInfo::_df_dqdot0) .def_readwrite("df_dp", &BackwardInfo::_df_dp) .def_readwrite("df_du", &BackwardInfo::_df_du) .def_readwrite("df_dq", &BackwardInfo::_df_dq) .def_readwrite("df_dvar", &BackwardInfo::_df_dvar) .def("set_flags", &BackwardInfo::set_flags, "set the flags for backward", py::arg("flag_q0"), py::arg("flag_qdot0"), py::arg("flag_p"), py::arg("flag_u")); // backward results py::class_<BackwardResults>(m, "BackwardResults") .def_readonly("df_dq0", &BackwardResults::_df_dq0) .def_readonly("df_dqdot0", &BackwardResults::_df_dqdot0) .def_readonly("df_dp", &BackwardResults::_df_dp) .def_readonly("df_du", &BackwardResults::_df_du); py::class_<Simulation>(m, "Simulation") .def(py::init<std::string, bool>(), py::arg("xml_file_path"), py::arg("verbose") = false) .def_readonly("options", &Simulation::_options) .def_readonly("viewer_options", &Simulation::_viewer_options) .def_readonly("ndof_r", &Simulation::_ndof_r) .def_readonly("ndof_m", &Simulation::_ndof_m) .def_readonly("ndof_p", &Simulation::_ndof_p) .def_readonly("ndof_u", &Simulation::_ndof_u) .def_readonly("ndof_var", &Simulation::_ndof_var) .def("init", &Simulation::init, "initialize the simulation") .def("get_q_init", &Simulation::get_q_init, "get init q for simulation") .def("get_qdot_init", &Simulation::get_qdot_init, "get init qdot for simulation") .def("set_state_init", &Simulation::set_state_init, "set init state (q, qdot) for simulation", py::arg("q_init"), py::arg("qdot_init")) .def("set_q_init", &Simulation::set_q_init, "set init q for simulation", py::arg("q_init")) .def("set_qdot_init", &Simulation::set_qdot_init, "set init qdot for simulation", py::arg("qdot_init")) .def_property_readonly("q_init", &Simulation::get_q_init) .def_property_readonly("qdot_init", &Simulation::get_qdot_init) .def("get_q", &Simulation::get_q, "get q") .def("get_qdot", &Simulation::get_qdot, "get qdot") .def("get_variables", &Simulation::get_variables, "get variables") .def("get_design_params", &Simulation::get_design_params, "get design parameters") .def_property_readonly("q", &Simulation::get_q) .def_property_readonly("qdot", &Simulation::get_qdot) .def_property_readonly("variables", &Simulation::get_variables) .def_property_readonly("design_params", &Simulation::get_design_params) .def("set_design_params", &Simulation::set_design_params, "set design parameters", py::arg("design_params")) .def("set_u", &Simulation::set_u, "set u", py::arg("u")) .def("get_ctrl_range", &Simulation::get_ctrl_range, "get the range of the ctrl", py::arg("ctrl_min"), py::arg("ctrl_max")) .def("print_ctrl_info", &Simulation::print_ctrl_info) .def("print_design_params_info", &Simulation::print_design_params_info) .def("set_contact_scale", &Simulation::set_contact_scale, "set the contact scale for continuation method", py::arg("scale")) .def("set_rendering_mesh_vertices", &Simulation::set_rendering_mesh_vertices, "set the rendering mesh vertices for abstract body", py::arg("Vs")) .def("set_rendering_mesh", &Simulation::set_rendering_mesh, "set the rendering mesh for abstract body", py::arg("Vs"), py::arg("Fs")) .def("update_virtual_object", &Simulation::update_virtual_object, "update the properties of the virtual objects by name", py::arg("name"), py::arg("data")) .def_readonly("backward_info", &Simulation::_backward_info) .def_readonly("backward_results", &Simulation::_backward_results) .def("reset", &Simulation::reset, "reset the simulation.", py::arg("backward_flag") = false, py::arg("backward_design_params_flag") = true) .def("forward", &Simulation::forward, "step forward the simulation.", py::arg("num_steps"), py::arg("verbose") = false, py::arg("test_derivatives") = false) .def("backward", &Simulation::backward, "backward differentiation.") .def("replay", &Simulation::replay, "replay (render) the simulation.") .def("export_replay", &Simulation::export_replay, "export the body transformations in each step.", py::arg("folder")) .def("print_time_report", &Simulation::print_time_report, "print time report of the simulation."); m.def("make_sim", &make_sim, "initialize a simulation instance", py::arg("env_name"), py::arg("integrator") = "BDF2"); }
[ "xujie7979@gmail.com" ]
xujie7979@gmail.com
29d4e27c823c5f72e77673604d3ead95b86fdfd8
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5751500831719424_0/C++/diko/a.cpp
cbe78c3ef1e7b1daa30affc3cc9d50dcb4ea8e29
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,839
cpp
#include <iostream> #include <cstdio> #include <vector> #include <string> #include <cmath> using namespace std; vector<string> vs; int vi[103][103]; char vc[103][103]; int vk[103]; int n; string st; int clc(int x, int tar){ int tot=0; for(int i=0;i<n;i++){ tot+= abs(vi[i][x]-tar); } return tot; } int clc(int x){ int mx=vi[0][x]; int mn=vi[0][x]; for(int i=1;i<n;i++){ mx= max(mx,vi[i][x]); mn= min(mn,vi[i][x]); } int nowmn= clc(x,mn); for(int i=mn;i<=mx;i++){ nowmn= min(nowmn, clc(x,i)); } return nowmn; } int main() { freopen("as.in","rt",stdin); //freopen("out.txt","wt",stdout); int gt; cin>>gt; for(int run=1;run<=gt;run++) { vs.clear(); cin>>n; for(int i=0;i<n;i++){ cin>>st; vs.push_back(st); } int k; for(int i=0;i<n;i++){ int j=0; k=0; char pr= vs[i][j]; while(j<vs[i].size()){ pr= vs[i][j]; int ct=0; while(j<vs[i].size() && vs[i][j]==pr) {j++;ct++;} vi[i][k]=ct; vc[i][k++]=pr; } vk[i]=k; } bool flag=1; int fk=vk[0]; for(int i=1;i<n;i++){ if(vk[i]!=fk) flag=0; } if(flag){ for(int i=1;i<n;i++){ for(int j=0;j<fk;j++) if(vc[i][j]!=vc[0][j]) flag=0; } } int sum=0; if(flag){ for(int i=0;i<fk;i++){ sum+= clc(i); } } printf("Case #%d: ",run); if(flag==0) cout<<"Fegla Won\n"; else cout<<sum<<"\n"; } return 0; }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
9d280121d2fec59c2e64735d97537227e16e6b2c
ba5b1590cf55c5f163d124f5e65b556eeae279ca
/tests/hash-map.h
2929ce36a0bc0d1e0234df9fbe04703a7c00546f
[ "MIT" ]
permissive
orbitrc/primer
0c264a87349da9a0e8fc9d3c8506795ee96fff4d
e92806dece0d7cd50cbbae0b6cf7a133f154651d
refs/heads/main
2023-08-17T13:02:21.225796
2023-08-17T12:27:35
2023-08-17T12:27:35
177,574,239
0
0
MIT
2023-09-11T07:26:31
2019-03-25T11:35:47
C++
UTF-8
C++
false
false
200
h
#ifndef _TESTS_HASH_MAP_H #define _TESTS_HASH_MAP_H namespace tests { void hash_map_length(); void hash_map_insert(); void hash_map_get(); void hash_map_remove(); } #endif // _TESTS_HASH_MAP_H
[ "hardboiled65@gmail.com" ]
hardboiled65@gmail.com
b5231498a4d882a88654cbcfb58b66bf6e0fe771
93d26a235f8223aa055b26ec604ddcd217ca4e3b
/ClipboardWatcher/ClipboardWatcher.cpp
5325760529c3a5b57e45e8f68acedce0f54ec86e
[ "BSD-3-Clause" ]
permissive
stadub/WinClipboardApi
e4b4d81c5776326f339f689999693d0cd6287602
fff8521a29b8a2dcea8953b77590cc3b5431f528
refs/heads/master
2021-01-19T18:30:21.878128
2015-06-22T19:35:05
2015-06-22T19:35:05
27,974,126
1
1
null
null
null
null
UTF-8
C++
false
false
734
cpp
// ClipboardWatcher.cpp : Defines the entry point for the console application. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { Messages msg; if (argc != 2) { std::wstring appName(argv[0]); std::string asciiAppName(appName.begin(), appName.end()); std::stringstream errText; errText << "Incorrect command line." << "Expected " << asciiAppName << " [WindowClassName]"; msg.WriteError(errText.str()); return 1; } std::wstring windowClassName(argv[1]); MsgWindow window(&msg); window.InitWindowClass(windowClassName); window.CreateMessageWindow(); window.RegisterClipboardListener(); window.CreateWatchDogTimer(); window.ChagngeMessageFilter(); window.StartMainLoop(); return 0; }
[ "dima_@live.at" ]
dima_@live.at
e227a53cc58276045b2c06c25a4afc88b0569c09
5abd8052981c783f6afff99000148867128d7c40
/SharedUtility/DataReader/LibsvmReaderSparse.h
052233686ec5d7d0468dc7b4bac43383d693521d
[ "Apache-2.0" ]
permissive
YawenChen0823/gpu-svm
d6c60541a441ea3ee3fa7f41f1e4ed4d532aff1a
d0bfdbc70c8bca5112e1bbe305b140c1ad3aae76
refs/heads/master
2021-06-23T22:07:07.622827
2017-08-31T06:46:42
2017-08-31T06:46:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,499
h
/** * trainingDataIO.h * Created on: May 21, 2012 * Author: Zeyi Wen **/ #ifndef TRAININGDATAIO_H_ #define TRAININGDATAIO_H_ #include <assert.h> #include <sstream> #include <iostream> #include <stdlib.h> #include <fstream> #include <vector> #include <limits> #include "BaseLibsvmReader.h" #include "../DataType.h" #include "../KeyValue.h" using std::string; using std::vector; using std::istringstream; using std::ifstream; using std::cerr; using std::endl; using std::cout; class LibSVMDataReader: public BaseLibSVMReader { public: LibSVMDataReader(){} ~LibSVMDataReader(){} template<class T> void ReadLibSVMAsDense(vector<vector<real> > &v_vSample, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofInstance = -1); template<class T> void ReadLibSVMAsSparse(vector<vector<KeyValue> > &v_vSample, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofInstance = -1); private: template<class T> void ReaderHelper(vector<vector<KeyValue> > &v_vSample, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofInstance, bool bUseDense); void Push(int feaId, real value, vector<KeyValue> &vIns){ KeyValue pair; pair.id = feaId; pair.featureValue = value; vIns.push_back(pair); } }; /** * @brief: represent the data in a sparse form */ template<class T> void LibSVMDataReader::ReadLibSVMAsSparse(vector<vector<KeyValue> > &v_vInstance, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofInstance) { if(nNumofInstance == -1){ nNumofInstance = std::numeric_limits<int>::max(); } cout << "reading libsvm data as sparse format..." << endl; ReaderHelper(v_vInstance, v_targetValue, strFileName, nNumofFeatures, nNumofInstance, false); } /** * @brief: store the instances in a dense form */ template<class T> void LibSVMDataReader::ReadLibSVMAsDense(vector<vector<real> > &v_vInstance, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofExamples) { if(nNumofExamples == -1){ nNumofExamples = std::numeric_limits<int>::max(); } vector<vector<KeyValue> > v_vInstanceKeyValue; cout << "reading libsvm data as dense format..." << endl; ReaderHelper(v_vInstanceKeyValue, v_targetValue, strFileName, nNumofFeatures, nNumofExamples, true); //convert key values to values only. for(int i = 0; i < v_vInstanceKeyValue.size(); i++) { vector<real> vIns; for(int j = 0; j < nNumofFeatures; j++) { vIns.push_back(v_vInstanceKeyValue[i][j].featureValue); } v_vInstance.push_back(vIns); } } /** * @brief: a function to read instances from libsvm format as either sparse or dense instances. */ template<class T> void LibSVMDataReader::ReaderHelper(vector<vector<KeyValue> > &v_vInstance, vector<T> &v_targetValue, string strFileName, int nNumofFeatures, int nNumofInstance, bool bUseDense) { ifstream readIn; readIn.open(strFileName.c_str()); assert(readIn.is_open()); vector<KeyValue> vSample; //for storing character from file int j = 0; string str; //get a sample char cColon; uint numFeaValue = 0; do { j++; getline(readIn, str); if (str == "") break; istringstream in(str); int i = 0; T fValue = 0; in >> fValue; v_targetValue.push_back(fValue); //get features of a sample int nFeature; real x; while (in >> nFeature >> cColon >> x) { numFeaValue++; assert(cColon == ':'); if(bUseDense == true) { while(int(vSample.size()) < nFeature - 1 && int(vSample.size()) < nNumofFeatures) { Push(i, 0, vSample); i++; } } if(nNumofFeatures == int(vSample.size())) { break; } assert(int(vSample.size()) <= nNumofFeatures); if(bUseDense == true) assert(i == nFeature - 1); Push(nFeature - 1, x, vSample); i++; } //fill the value of the rest of the features as 0 if(bUseDense == true) { while(int(vSample.size()) < nNumofFeatures) { Push(i, 0, vSample); i++; } } v_vInstance.push_back(vSample); //clear vector vSample.clear(); }while (readIn.eof() != true && j < nNumofInstance);//nNumofInstance is to enable reading a subset. //clean eof bit, when pointer reaches end of file if(readIn.eof()) { readIn.clear(); } printf("# of instances: %d; # of features: %d; # of fvalue: %d\n", v_vInstance.size(), nNumofFeatures, numFeaValue); } #endif /* TRAININGDATAIO_H_ */
[ "wenzeyi@gmail.com" ]
wenzeyi@gmail.com
0de2be3784769a5726b284546b261552ae4d3668
e21dc658f810aec497b879bf05974fdd993e76d5
/SimpleShooter/SimpleShooter09/SimpleShooter/Enemy.cpp
b7bd1d093e1d80579f2bb9838bf1c96c7ebd0a1b
[]
no_license
levidsmith/AllegroExamples
ca8612d2398e0f4915ba05ab5fef075808cfaa84
8fe7d97eea7fee15ffc0528f548a8c798109375e
refs/heads/master
2023-02-09T13:10:37.073497
2020-12-31T15:57:56
2020-12-31T15:57:56
325,827,504
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
//2020 Levi D. Smith #include "Enemy.h" Enemy::Enemy(float init_x, float init_y) : GameObject(init_x, init_y, 64, 64) { x = init_x; y = init_y; fSpeed = 2 * GameManager::UNIT_SIZE; vel_x = fSpeed; fLifetime = 0; isAlive = true; } void Enemy::Update() { x += vel_x * GameManager::DELTA_TIME; fLifetime += GameManager::DELTA_TIME; if (fLifetime > 2) { vel_x *= -1; fLifetime -= 2; } } void Enemy::Draw() { if (isAlive) { al_draw_filled_rectangle(x, y, x + w, y + h, al_map_rgb(0, 255, 0)); } } void Enemy::damageReceived() { isAlive = false; }
[ "me@levidsmith.com" ]
me@levidsmith.com
8a8313e8542ea1a0167f8437f3935ff7afe2f888
2aa153c6f3ec4484a70769ad9ef753f212b3cc57
/Header_Files/Pocket.h
5742e81a7e229e5666f2e058b1c1f66c6e73efff
[]
no_license
marstodd/genetic-algorithm
4346d6c98f7b89f63d44bd50c8af0b2989500bfe
00f38f30285f8dfd8c2c2a7c8b2cff4f0fb4f300
refs/heads/master
2021-01-10T20:14:04.094056
2011-11-29T20:38:42
2011-11-29T20:38:42
2,877,304
0
0
null
null
null
null
UTF-8
C++
false
false
1,513
h
#pragma once #include<vector> #include "Random.h" #include<math.h> #include<iostream> using std::cout; using std::endl; using std::vector; #define NUMBER_OF_COINS 6 enum Coins { PENNY = 1, NICKEL = 5, DIME = 10, QUARTER = 25, HALF_DOLLAR = 50, DOLLAR = 100 }; class Pocket { private: bool coinsAllowed[NUMBER_OF_COINS]; //The user selects which coins are used, this array keeps track of which coins can be used and which ones can't vector<int> coins; int numberOfCoinsInPocket; Random RNG; int targetValue; //the desired amount of money in pocket (defined by user) the value is multiplied by 100 to work with the enum //i.e. $5.01 = 501 int currentValue; int fitness; // |targetValue - currentValue| -- lower number is better int GetCoin(); //Returns a random coin for use with Randomize() and Mutate(), not to be confused with GetCoins public: void UpdateStats(); //updates void Randomize(); //sets all slots in pocket to a random coin void Mutate(); //changes the value of ONE slot to a random coin(changes one coin, can remain the same) //test function void Display(); int GetFitness(); vector<int> GetCoins(); //returns array of coins, used most noteably in Population::PerformCrossover() void SetCoins(vector<int>); //sets the coins in pocket from an array rather than randomizing, used mostly in Population::PerformCrossover() when generating new children. Pocket(bool initCoinsAllowed[], int initNumberOfCoinsInPocket, int targetValue); Pocket(void); ~Pocket(void); };
[ "nanook889@gmail.com" ]
nanook889@gmail.com
6f946ca9936f027a41c7e71e49462bb2366653b1
e3e8b7056b8c5a604cc1a576da0d6d5134870f93
/src/lc149/lc149.cpp
2af5e4414269a35d2cd0a5210a3e89c4c4588fd0
[]
no_license
zou-song/leetcode
a2acc8d01538f8bc84dbb83f11c24fe876cd071b
5172da312cba7e185d155386bc5527432c40c2f8
refs/heads/master
2020-04-25T14:57:22.251872
2019-05-20T11:59:18
2019-05-20T11:59:18
172,860,827
0
0
null
2019-05-20T11:59:19
2019-02-27T06:55:26
C++
UTF-8
C++
false
false
2,167
cpp
#include "lc.h" class Solution { struct Coeff {//ax + by + c = 0; long long a; long long b; long long c; }; struct Hasher { size_t operator()(const Coeff& c) const { if (c.b == 0) { if (c.a == 0) { return hash<int>()(0); } return hash<double>()(1.0 * c.c / c.a); } return hash<double>()(1.0 * c.a / c.b) ^ hash<double>()(1.0 * c.c / c.b); } }; struct Equaller { bool operator()(const Coeff& c1, const Coeff& c2) const { bool b1 = ((c1.a * c2.b) == (c1.b * c2.a)); bool b2 = ((c1.a * c2.c) == (c1.c * c2.a)); bool b3 = ((c1.b * c2.c) == (c1.c * c2.b)); return b1 && b2 && b3; } }; public: int maxPoints(vector<vector<int>>& points) { int len = points.size(); if (len == 1) { return 1; } unordered_map<Coeff, int, Hasher, Equaller> hashmap; for (int i = 0; i < len; ++i) { for (int j = i + 1; j < len; ++j) { Coeff c; c.a = points[i][1] - points[j][1]; c.b = points[j][0] - points[i][0]; c.c = (long long)points[i][0] * points[j][1] - (long long)points[j][0] * points[i][1]; hashmap[c]++; } } auto iter = max_element(hashmap.begin(), hashmap.end(), [](const pair<Coeff, int>& lhs, const pair<Coeff, int>& rhs){ return lhs.second < rhs.second; }); if (iter == hashmap.end()) return 0; int ret = 0; for (auto &p : points) { if (iter->first.a * p[0] + iter->first.b * p[1] + iter->first.c == 0) { ret++; } } return ret; } }; int main(int argc, char const *argv[]) { string line; while (getline(cin, line)) { vector<vector<int>> points; walkString(points, line); cout << toString(Solution().maxPoints(points)) << endl; } return 0; }
[ "zousong0322@qq.com" ]
zousong0322@qq.com
ad4ae470859fcb794230671389520c3a5f6399ec
967482ce7998d8814a13d8509db947b0df31f8e0
/src/lib/eng/tst/t_reserved.cpp
8bcd01b20adb51c568fa0117b032c0d48e727633
[]
no_license
loongarch64/afnix
38dc9c9808f18ff5517f7c43f641057a9583aeda
88cc629cc09086cda707e5ad6d8a1bd412491bbe
refs/heads/main
2023-05-31T17:16:56.743466
2021-06-22T05:18:32
2021-06-22T05:18:32
379,150,535
0
0
null
2021-06-25T03:05:27
2021-06-22T05:20:29
C++
UTF-8
C++
false
false
1,599
cpp
// --------------------------------------------------------------------------- // - t_reserved.cpp - // - afnix engine - reserved tester module - // --------------------------------------------------------------------------- // - This program is free software; you can redistribute it and/or modify - // - it provided that this copyright notice is kept intact. - // - - // - This program is distributed in the hope that it will be useful, but - // - without any warranty; without even the implied warranty of - // - merchantability or fitness for a particular purpose. In no event shall - // - the copyright holder be liable for any direct, indirect, incidental or - // - special damages arising in any way out of the use of this software. - // --------------------------------------------------------------------------- // - copyright (c) 1999-2021 amaury darsch - // --------------------------------------------------------------------------- #include "Reserved.hpp" int main (int, char**) { using namespace afnix; // create a reserved keyword by name and line Reserved rsv ("afnix", 1); if (rsv.repr () != "Reserved") return 1; // check the literal and value if (rsv.tostring () != "afnix") return 1; if (rsv.toliteral () != "afnix") return 1; // check the line number if (rsv.getlnum () != 1) return 1; // success return 0; }
[ "wuxiaotian@loongson.cn" ]
wuxiaotian@loongson.cn
3a95f681201e06a20a803d8d19ea53f8cf4d9137
c81c61f13bcc3a15ccac935969d074d2eb7fce12
/C++/SGI STL/stl_stack.h
9dc3194d5d36a71294e65615275e193c8140ba2e
[]
no_license
cheris-c/c-plus-plus
6331dad0f46a8bd25a33d337d8fcd74b21639c57
cdd413c548249dbdc22e060e16ca4f6513060ae6
refs/heads/master
2023-05-02T22:31:16.353875
2021-05-19T08:25:23
2021-05-19T08:25:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,593
h
/* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */ #ifndef __SGI_STL_INTERNAL_STACK_H #define __SGI_STL_INTERNAL_STACK_H __STL_BEGIN_NAMESPACE #ifndef __STL_LIMITED_DEFAULT_TEMPLATES template <class T, class Sequence = deque<T> > #else template <class T, class Sequence> #endif class stack { friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&); friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&); public: typedef typename Sequence::value_type value_type; typedef typename Sequence::size_type size_type; typedef typename Sequence::reference reference; typedef typename Sequence::const_reference const_reference; protected: Sequence c; public: bool empty() const { return c.empty(); } size_type size() const { return c.size(); } reference top() { return c.back(); } const_reference top() const { return c.back(); } void push(const value_type& x) { c.push_back(x); } void pop() { c.pop_back(); } }; template <class T, class Sequence> bool operator==(const stack<T, Sequence>& x, const stack<T, Sequence>& y) { return x.c == y.c; } template <class T, class Sequence> bool operator<(const stack<T, Sequence>& x, const stack<T, Sequence>& y) { return x.c < y.c; } __STL_END_NAMESPACE #endif /* __SGI_STL_INTERNAL_STACK_H */ // Local Variables: // mode:C++ // End:
[ "393673587@qq.com" ]
393673587@qq.com
243108f074a7e3d0e2388194e5b48709dd28e4d3
b27d100efea585c45ec2ebcef3e140b95a12869f
/ultimas/12_12_13/ARDUINO 2/recepcion_prueba/recepcion_prueba.ino
d172c1df3d74d3093469ad374609563c5a6a2e8a
[]
no_license
arturocontreras/Codes_4_Arduino
012b6f6dd8ba35d77f24baa36739d656fe790bcd
5b5a5ba95937564cfbe8bb70110302f78cc7c8e6
refs/heads/master
2020-07-03T16:41:18.103490
2016-12-28T03:00:57
2016-12-28T03:00:57
74,245,895
0
0
null
null
null
null
UTF-8
C++
false
false
1,077
ino
// receptor nrf24l01 con Mirf #include <SPI.h> #include <Mirf.h> #include <nRF24L01.h> #include <MirfHardwareSpiDriver.h> int rate[9]; int rate2[9]; void setup(){ Serial.begin(9600); Mirf.cePin = 48; //ce pin on Mega 2560, REMOVE THIS LINE IF YOU ARE USING AN UNO Mirf.csnPin = 49; //csn pin on Mega 2560, REMOVE THIS LINE IF YOU ARE USING AN UNO Mirf.spi = &MirfHardwareSpi; Mirf.init(); Mirf.setRADDR((byte *)"serv1"); Mirf.payload = sizeof(rate); Mirf.config(); } void loop(){ Mirf.setRADDR((byte *)"clie1"); while(!Mirf.dataReady()){} Mirf.getData((byte *) &rate2); Serial.print(rate2[0]); Serial.print(" "); Serial.print(rate2[1]); Serial.print(" "); Serial.print(rate2[2]); Serial.print(" "); Serial.print(rate2[3]); Serial.print(" "); Serial.print(rate2[4]); Serial.print(" "); Serial.print(rate2[5]); Serial.print(" "); Serial.print(rate2[6]); Serial.print(" "); Serial.print(rate2[7]); Serial.print(" "); Serial.println(rate2[8]); delay(20); }
[ "arturocontrerasmartinez@gmail.com" ]
arturocontrerasmartinez@gmail.com
2019b79044ef18780ad830e1a0a96e085df2e8d4
fa55d8ed32564195f2687d1e18b99f80c5683073
/lbc_usaco/3.1-agrinet.cc
259dd58c6fcdd2710fdd8ce1e418c2f38b393111
[]
no_license
TenFifteen/SummerCamp
1841bf1bd212938cee818540658185cd3e429f0c
383b9321eee9e0721772f93a897c890f737f2eff
refs/heads/master
2020-04-05T23:48:01.393256
2018-03-11T12:37:38
2018-03-11T12:37:38
38,595,086
9
4
null
2016-07-18T14:21:15
2015-07-06T03:15:55
C++
UTF-8
C++
false
false
1,327
cc
/* ID: libench1 PROG: agrinet LANG: C++11 */ #include <iostream> #include <fstream> #include <string> #include <vector> #include <climits> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <algorithm> #include <cmath> using namespace std; int main() { ofstream fout ("agrinet.out"); ifstream fin ("agrinet.in"); int n; fin >> n; int len; vector<vector<int> > edges(n, vector<int>(n)); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { fin >> edges[i][j]; } } vector<bool> flag(n, false); flag[0] = true; vector<int> dist(n, INT_MAX); for (int i = 1; i < n; ++i) { dist[i] = edges[0][i]; } int total = 0; for (int i = 1; i < n; ++i) { int cur = -1; for (int j = 0; j < n; ++j) { if (flag[j] == false && dist[j] != INT_MAX) { if (cur == -1) { cur = j; } else if (dist[j] < dist[cur]) { cur = j; } } } total += dist[cur]; flag[cur] = true; for (int j = 0; j < n; ++j) { dist[j] = min(dist[j], edges[cur][j]); } } fout << total << endl; return 0; }
[ "libenchao@gmail.com" ]
libenchao@gmail.com
a0a012ad106a1b70e796bd54e396123b5bf180d4
53871321c2e8295c91f3f041fce59ec2bef8df0f
/Assignment5/Mark_Sort_Database/main.cpp
89f96ad133a4bb918f9444065ba42c570c8da510
[]
no_license
DrewAllensworth/da2225087
19efcc32cbcbc10549054e1c87425d2cc1a2bd13
3a32275122b2627d84be680ac4c03d83e273ee0c
refs/heads/master
2021-01-22T11:54:55.138924
2014-02-12T18:49:54
2014-02-12T18:49:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,030
cpp
/* * File: main.cpp * Author: Drew Allensworth * Created on February 3, 2014, 8:13 AM * Purpose: Mark Sort Database converted to pointer notation and * dynamic allocation */ //System Libraries #include <cstdlib> #include <iostream> #include <ctime> using namespace std; //Global Constants //Function Prototypes void filAray(int *,int *,int); void prntAry(int *,int *,int,int); void prntAry(int *,int,int); void swap(int &,int &); void minPos(int *,int*,int,int); void mrkSort(int *,int *,int); //Executions Begin Here! int main(int argc, char** argv) { //Declare variables and initialize the //random number generator const int SIZE=200; int *array=new int [SIZE]; int *index=new int [SIZE]; srand(static_cast<unsigned int>(time(0))); //Fill the arrays filAray(array,index,SIZE); //Print the arrays prntAry(array,index,SIZE,10); //Test out the min pos routine mrkSort(array,index,SIZE); //Print the array prntAry(array,index,SIZE,10); prntAry(index,SIZE,10); prntAry(array,SIZE,10); //Clean up delete [] array; delete [] index; //Exit Stage Right!!! return 0; } void mrkSort(int *a,int *indx,int n){ for(int i=0;i<n-1;i++){ minPos(a,indx,n,i); } } void minPos(int *a,int *indx,int n,int pos){ for(int i=pos+1;i<n;i++){ if(*(a+(*(indx+pos)))>*(a+(*(indx+i)))) swap(*(indx+pos),*(indx+i)); } } void swap(int &a,int &b){ int temp=a; a=b; b=temp; } void prntAry(int *a,int n,int perLine){ cout<<endl; for(int i=0;i<n;i++){ cout<<*(a+i)<<" "; if(i%10==(perLine-1))cout<<endl; } cout<<endl; } void prntAry(int *a,int *indx,int n,int perLine){ cout<<endl; for(int i=0;i<n;i++){ cout<<*(a+(*(indx+i)))<<" "; if(i%10==(perLine-1))cout<<endl; } cout<<endl; } //2 Digit random numbers void filAray(int *a,int *indx,int n){ for(int i=0;i<n;i++){ *(a+i)=rand()%90+10; *(indx+i)=i; } }
[ "allensworthdrew@aol.com" ]
allensworthdrew@aol.com
ba35be35b2fa7e8e4e424210295d452ee5a926ad
415980fd8919e316194677d7192eb73b6c74f172
/ecs/include/alibabacloud/ecs/model/InstallCloudAssistantRequest.h
10ee82fe7fbbb8138221b261ebd0b578a3122f1f
[ "Apache-2.0" ]
permissive
cctvbtx/aliyun-openapi-cpp-sdk
c3174d008a81afa1c3874825a6c5524e9ffc0f81
6d801b67b6d9b3034a29678e6b820eb88908c45b
refs/heads/master
2020-06-20T01:19:45.307426
2019-07-14T15:46:19
2019-07-14T15:46:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,529
h
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ALIBABACLOUD_ECS_MODEL_INSTALLCLOUDASSISTANTREQUEST_H_ #define ALIBABACLOUD_ECS_MODEL_INSTALLCLOUDASSISTANTREQUEST_H_ #include <string> #include <vector> #include <alibabacloud/core/RpcServiceRequest.h> #include <alibabacloud/ecs/EcsExport.h> namespace AlibabaCloud { namespace Ecs { namespace Model { class ALIBABACLOUD_ECS_EXPORT InstallCloudAssistantRequest : public RpcServiceRequest { public: InstallCloudAssistantRequest(); ~InstallCloudAssistantRequest(); long getResourceOwnerId()const; void setResourceOwnerId(long resourceOwnerId); long getCallerParentId()const; void setCallerParentId(long callerParentId); bool getProxy_original_security_transport()const; void setProxy_original_security_transport(bool proxy_original_security_transport); std::string getProxy_original_source_ip()const; void setProxy_original_source_ip(const std::string& proxy_original_source_ip); std::string getOwnerIdLoginEmail()const; void setOwnerIdLoginEmail(const std::string& ownerIdLoginEmail); std::string getCallerType()const; void setCallerType(const std::string& callerType); std::string getAccessKeyId()const; void setAccessKeyId(const std::string& accessKeyId); std::string getSourceRegionId()const; void setSourceRegionId(const std::string& sourceRegionId); std::string getSecurityToken()const; void setSecurityToken(const std::string& securityToken); std::string getRegionId()const; void setRegionId(const std::string& regionId); bool getEnable()const; void setEnable(bool enable); std::string getRequestContent()const; void setRequestContent(const std::string& requestContent); std::string getCallerBidEmail()const; void setCallerBidEmail(const std::string& callerBidEmail); std::string getCallerUidEmail()const; void setCallerUidEmail(const std::string& callerUidEmail); long getCallerUid()const; void setCallerUid(long callerUid); std::string getApp_ip()const; void setApp_ip(const std::string& app_ip); std::string getResourceOwnerAccount()const; void setResourceOwnerAccount(const std::string& resourceOwnerAccount); std::string getOwnerAccount()const; void setOwnerAccount(const std::string& ownerAccount); std::string getCallerBid()const; void setCallerBid(const std::string& callerBid); long getOwnerId()const; void setOwnerId(long ownerId); bool getProxy_trust_transport_info()const; void setProxy_trust_transport_info(bool proxy_trust_transport_info); bool getAk_mfa_present()const; void setAk_mfa_present(bool ak_mfa_present); bool getSecurity_transport()const; void setSecurity_transport(bool security_transport); std::vector<std::string> getInstanceId()const; void setInstanceId(const std::vector<std::string>& instanceId); std::string getRequestId()const; void setRequestId(const std::string& requestId); private: long resourceOwnerId_; long callerParentId_; bool proxy_original_security_transport_; std::string proxy_original_source_ip_; std::string ownerIdLoginEmail_; std::string callerType_; std::string accessKeyId_; std::string sourceRegionId_; std::string securityToken_; std::string regionId_; bool enable_; std::string requestContent_; std::string callerBidEmail_; std::string callerUidEmail_; long callerUid_; std::string app_ip_; std::string resourceOwnerAccount_; std::string ownerAccount_; std::string callerBid_; long ownerId_; bool proxy_trust_transport_info_; bool ak_mfa_present_; bool security_transport_; std::vector<std::string> instanceId_; std::string requestId_; }; } } } #endif // !ALIBABACLOUD_ECS_MODEL_INSTALLCLOUDASSISTANTREQUEST_H_
[ "haowei.yao@alibaba-inc.com" ]
haowei.yao@alibaba-inc.com
dec6d3fb712f19ab930f9ed42637b88a362250c1
4163fac20a5a88691322de9f7cea84e25ab19ff0
/KTL/test/functional/test_functional.cpp
2e0e4b365d44f4af0bfa24b84853cd0dd147b6ec
[]
no_license
jk983294/algorithms
c522cce35aff21fcd764922aaa58098a270a028c
d46a0b41a2f4c47879eacfffa0e3151ac3edba76
refs/heads/master
2022-12-07T06:40:19.532262
2022-11-24T07:42:06
2022-11-24T07:42:06
87,617,484
2
1
null
null
null
null
UTF-8
C++
false
false
486
cpp
#include "catch.hpp" #include "functional/functional.h" using namespace ktl; TEST_CASE("math", "[functional]") { plus<int> plusObj; minus<int> minusObj; multiply<int> multiplyObj; divide<int> divideObj; module<int> moduleObj; negate<int> negateObj; REQUIRE(plusObj(1, 2) == 3); REQUIRE(minusObj(1, 2) == -1); REQUIRE(multiplyObj(1, 2) == 2); REQUIRE(divideObj(2, 1) == 2); REQUIRE(moduleObj(1, 2) == 1); REQUIRE(negateObj(1) == -1); }
[ "jk983294@gmail.com" ]
jk983294@gmail.com
798d69f8d4a6227e16e215b5fa1e6c7d66d45ac6
7fc05b96bcd7ed355a0c358962c15a97e7342661
/CodeForces/CF599/C.cpp
1c0ebf03ff273248246f4c2761d2cab7a475925f
[]
no_license
Basasuya/ACM
84234b72662d32a5c6a3d1165344ab45868f9b8a
5ebcc3a82acb812daba8af053832ea666126d639
refs/heads/master
2022-10-09T02:53:24.201286
2022-10-03T02:52:29
2022-10-03T02:52:29
116,901,477
4
1
null
null
null
null
UTF-8
C++
false
false
2,937
cpp
#include <iostream> #include <fstream> #include <vector> #include <set> #include <map> #include <bitset> #include <algorithm> #include <iomanip> #include <cmath> #include <ctime> #include <functional> #include <unordered_set> #include <unordered_map> #include <queue> #include <deque> #include <stack> #include <complex> #include <cassert> #include <random> #include <cstring> #include <numeric> #define mp make_pair #define ll long long #define ld long double #define null NULL #define all(a) a.begin(), a.end() #define forn(i, n) for (int i = 0; i < n; ++i) #define sz(a) (int)a.size() #define lson l , m , rt << 1 #define rson m + 1 , r , rt << 1 | 1 #define bitCount(a) __builtin_popcount(a) template<class T> int gmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; } template<class T> int gmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; } using namespace std; string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif const int N = 1e6 + 5; int isPrime[N]; int Prime[N]; int primeTot; int main() { primeTot = 0; for(int i = 2; i < N; ++i) { if(!isPrime[i]) { Prime[++primeTot] = i; } for(int j = 2*i; j < N; j += i) { isPrime[j] = 1; } } ll n; while(~scanf("%lld", &n)) { ll tmp = n; if(n <= 3) { printf("%lld\n", n); continue; } set<ll> st; for(int i = 1; i <= primeTot; ++i) { if(1ll * Prime[i] * Prime[i] > n) break; if(n % Prime[i] == 0) { while(n % Prime[i] == 0) { n /= Prime[i]; } st.insert(Prime[i]); } } if(n != 1) { st.insert(n); } if(st.size() == 1) { ll fr = *(st.begin()); if(fr == tmp) printf("%lld\n", tmp); else printf("%lld\n", fr); } else { ll fr = *(st.begin()); if(fr == 2) { // assert(0); printf("%lld\n", 1ll); } else { // assert(0); printf("%lld\n", 1ll); } } } return 0; }
[ "961256668@qq.com" ]
961256668@qq.com
b436446efa452b5d0eca39dc49ec3fffff8f8e14
96f7b825c92bca0a7aa59cd564056d8afbd6b9ba
/usecases/gtplat/GTPlatScenarioCreator.h
780b2764257b8c8bca90df9777609559ffdba7c5
[]
no_license
AnderPijoan/GTPlat
4d0a9452fcf56b0d018d987cecdbd22ffe355210
4981a430bf18eab26177e9cb2f1dfbeb1aff109e
refs/heads/master
2020-12-30T14:45:32.494225
2017-05-12T11:56:24
2017-05-12T11:56:24
91,085,149
0
0
null
null
null
null
UTF-8
C++
false
false
1,725
h
#ifndef GTPLATSCENARIOCREATOR_H #define GTPLATSCENARIOCREATOR_H #include <QObject> #include <QDate> #include <QTime> #include <QThread> #include "usecases/gtplat/GTPlatAgent.h" #include "usecases/gtplat/GTPlatIncentive.h" #include "usecases/gtplat/GTPlatJourney.h" #include "usecases/gtplat/GTPlatProfile.h" #include "skills/route/RoutingSkill.h" #include "skills/route/TransportLineRoutingSkill.h" #include "utils/websocket_server/WebSocketServer.h" #include "utils/api/ASyncAPIDriver.h" #include "utils/fuzzy_logic/FuzzyLogic.h" #include "utils/random_generators/RouletteWheel.h" QT_FORWARD_DECLARE_CLASS(Environment) class GTPlatScenarioCreator : public QObject { Q_OBJECT public: GTPlatScenarioCreator(Environment* environment , WebSocketServer* ws_server); QJsonObject toJSON(); QMap<QString,GTPlatIncentive*> incentives; QMap<QString,GTPlatProfile*> profiles; QList<GTPlatJourney*> journeys; int max_parallel_queries_gtalg; // GTALG API DRIVER QList<ASyncAPIDriver*> api_drivers; // ROUTING GRAPHS QMap< QString, GSSDijkstraRoutingGraph*> routing_graphs; // ITINERARY STORAGE QMap<QString , GTPlatItinerary*> itineraries; // PENDING TO BE RUN GTPLATAGENTS QHash<GTPlatAgent* , QDateTime> to_be_run; // RESULTS QMap<QString , int> current_using_leg_mode; QMap<QString , int> global_chosen_mode; QMap<QString , double> global_impact_cc; public slots: void loadScenario(); void runScenario( QString class_name , int id ); void cycle(); private: Environment* environment; WebSocketServer* ws_server; void createRoutingGraph( QString graph_name , QStringList modes ); }; #endif // GTPLATSCENARIOCREATOR_H
[ "system@laboratorius.com" ]
system@laboratorius.com
88f218b6831c14a3990e59be029cbcf47064368f
0fcbef4b0cde82093e4d9409b7ff4194cd93237d
/source/Hyundo/week23/1991.cpp
2f14e1abddad59c7f6b07e75f5d4c5df5aa09cfa
[]
no_license
BreakAlgorithm/algorithm-study
53bc141ae12933b1bee794b987ac6d0dedf8c29f
3fa739b68c8bd1ce22888ae8d773a09300f87589
refs/heads/master
2023-03-07T18:06:12.873979
2021-02-24T01:52:21
2021-02-24T01:52:21
284,370,387
0
6
null
2021-02-21T06:08:58
2020-08-02T01:44:19
C++
UTF-8
C++
false
false
797
cpp
#include<iostream> using namespace std; char tree[26][2] = { '.', }; void preorder(char root) { if (root == '.') return; else { cout << root; preorder(tree[root - 'A'][0]); preorder(tree[root - 'A'][1]); } } void inorder(char root) { if (root == '.') return; else { inorder(tree[root - 'A'][0]); cout << root; inorder(tree[root - 'A'][1]); } } void postorder(char root) { if (root == '.') return; else { postorder(tree[root - 'A'][0]); postorder(tree[root - 'A'][1]); cout << root; } } int main() { int n; cin >> n; char root, left, right; for (int i = 0; i < n; i++) { cin >> root >> left >> right; tree[root - 'A'][0] = left; tree[root - 'A'][1] = right; } preorder('A'); cout << endl; inorder('A'); cout << endl; postorder('A'); return 0; }
[ "kk090303@naver.com" ]
kk090303@naver.com
e165bf7e35646a7ef7dd1289725c97f14b72ff65
d900f398e217bb7cb604f3386262fc12c54760ce
/exttb/exttb_impl.h
c9fbc6e4c8e23a5b88b3f2c6ef96bacf6a00004f
[]
no_license
wlix/exttb
3ff1706a72ab265db0b3bc068cc01cc4cd3215df
49139b33d214c9fc921879dcc47c05cfb1ac5ca0
refs/heads/master
2022-12-20T05:35:19.613743
2020-10-13T15:18:11
2020-10-13T15:18:11
301,228,132
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,748
h
#pragma once #include <array> #include "framework.h" #include <shlwapi.h> #pragma comment(lib, "shlwapi.lib") // PathRenameExtension, PathRemoveFileSpec #include "include/File.hpp" extern HINSTANCE g_hInst; // コマンドID enum CMD : INT32 { CMD_EXIT, CMD_SETTINGS, CMD_SHOW_VER_INFO, CMD_RELOAD, CMD_OPEN_FOLDER, CMD_TRAYICON, CMD_COUNT }; class settings { public: static settings& get() { static settings s; return s; } public: bool TTBaseCompatible; bool ShowTaskTrayIcon; DWORD logLevel; bool logToWindow; bool logToFile; win_file file; public: void load(); void save(); private: settings() { load(); } ~settings() = default; }; inline void settings::load() { std::array<wchar_t, MAX_PATH> path; // iniファイル名取得 ::GetModuleFileNameW(g_hInst, path.data(), (DWORD)path.size()); ::PathRenameExtensionW(path.data(), L".ini"); // パラメータの取得 TTBaseCompatible = ::GetPrivateProfileIntW ( L"Setting", L"TTBaseCompatible", 0, path.data() ) ? true : false; ShowTaskTrayIcon = ::GetPrivateProfileIntW ( L"Setting", L"ShowTaskTrayIcon", 1, path.data() ) ? true : false; logLevel = ::GetPrivateProfileIntW ( L"Setting", L"logLevel", ERROR_LEVEL(5), path.data() ); logToWindow = ::GetPrivateProfileIntW ( L"Setting", L"logToWindow", 1, path.data() ) ? true : false; logToFile = ::GetPrivateProfileIntW ( L"Setting", L"logToFile", 1, path.data() ) ? true : false; // ログの出力先がファイルの場合 if (logLevel && logToFile) { // ログフォルダのパスを合成 ::PathRemoveFileSpecW(path.data()); ::StringCchCatW(path.data(), path.size(), LR"(\log)"); if (!::PathIsDirectoryW(path.data())) { // フォルダを作成 ::CreateDirectoryW(path.data(), nullptr); } // ログファイルのパスを合成 SYSTEMTIME st; ::GetLocalTime(&st); std::array<wchar_t, MAX_PATH> log; ::StringCchPrintfW ( log.data(), log.size(), LR"(%s\%04u%02u%02u.log)", path.data(), st.wYear, st.wMonth, st.wDay ); // ログファイルを開く using namespace tapetums; const auto result = file.Open ( log.data(), File::ACCESS::WRITE, File::SHARE::WRITE, File::OPEN::OR_CREATE ); if (!result) { ::MessageBoxW(nullptr, log.data(), L"ログファイルを作成できません", MB_OK); file.Close(); } else { // 末尾に追記していく file.Seek(0, File::ORIGIN::END); #if defined(_UNICODE) || defined(UNICODE) if (file.position() == 0) { file.Write(UINT16(0xFEFF)); // UTF-16 BOM を出力 } #endif } } }
[ "tsubasa.ie.wlix@gmail.com" ]
tsubasa.ie.wlix@gmail.com
69cb24f2f95c9154377b0cf04bdb3ffb4085a3ea
4e9aa6d8635d6bfcbaeecbb9420ebdc4c4489fba
/ARXTest/cadtest/DefGEPlugin/DoubleTunnelDraw_ConfigDlg.cpp
650c54e8dac50b08a1c5b3715b5e9c17032bc474
[]
no_license
softwarekid/myexercise
4daf73591917c8ba96f81e620fd2c353323a1ae5
7bea007029c4c656c49490a69062648797084117
refs/heads/master
2021-01-22T11:47:01.421922
2014-03-15T09:47:41
2014-03-15T09:47:41
18,024,710
0
3
null
null
null
null
GB18030
C++
false
false
1,625
cpp
#include "stdafx.h" #include "DoubleTunnelDraw_ConfigDlg.h" IMPLEMENT_DYNAMIC( DoubleTunnelDraw_ConfigDlg, CAcUiDialog ) DoubleTunnelDraw_ConfigDlg::DoubleTunnelDraw_ConfigDlg( CWnd* pParent /*=NULL*/ ) : CAcUiDialog( DoubleTunnelDraw_ConfigDlg::IDD, pParent ) { m_jdt = 0; } DoubleTunnelDraw_ConfigDlg::~DoubleTunnelDraw_ConfigDlg() { } void DoubleTunnelDraw_ConfigDlg::DoDataExchange( CDataExchange* pDX ) { CDialog::DoDataExchange( pDX ); DDX_Control( pDX, IDC_WIDTH_EDIT, m_widthEdit ); DDX_Control( pDX, IDC_JOINT_DRAW_TYPE_LIST, m_jointDrawList ); } BEGIN_MESSAGE_MAP( DoubleTunnelDraw_ConfigDlg, CDialog ) ON_EN_KILLFOCUS( IDC_WIDTH_EDIT, &DoubleTunnelDraw_ConfigDlg::OnEnKillfocusWidthEdit ) ON_BN_CLICKED( IDOK, &DoubleTunnelDraw_ConfigDlg::OnBnClickedOk ) END_MESSAGE_MAP() // DoubleTunnelDraw_ConfigDlg 消息处理程序 void DoubleTunnelDraw_ConfigDlg::OnEnKillfocusWidthEdit() { m_widthEdit.Convert(); m_widthEdit.GetWindowText( m_strWidth ); } void DoubleTunnelDraw_ConfigDlg::OnBnClickedOk() { m_jdt = m_jointDrawList.GetCurSel(); OnOK(); } BOOL DoubleTunnelDraw_ConfigDlg::OnInitDialog() { CAcUiDialog::OnInitDialog(); // 初始化显示当前宽度 m_widthEdit.SetWindowText( m_strWidth ); m_widthEdit.Convert(); m_jointDrawList.AddString( _T( "无" ) ); m_jointDrawList.AddString( _T( "十字交叉圆" ) ); m_jointDrawList.AddString( _T( "填充实心圆" ) ); m_jointDrawList.SetCurSel( m_jdt ); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
[ "anheihb03dlj@163.com" ]
anheihb03dlj@163.com
1328a2e4ba62a6890ecbdf6a46210fc9abb98195
2aad21460b2aa836721bc211ef9b1e7727dcf824
/libImgEdit/include/ImgLayerGroup.h
771ccbde16c96f08b142ac7d7085d5d3a30b7292
[ "BSD-3-Clause" ]
permissive
chazix/frayer
4b38c9d378ce8b3b50d66d1e90426792b2196e5b
ec0a671bc6df3c5f0fe3a94d07b6748a14a8ba91
refs/heads/master
2020-03-16T20:28:34.440698
2018-01-09T15:13:03
2018-01-09T15:13:03
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,087
h
#ifndef _IMGLAYERGROUP_H_ #define _IMGLAYERGROUP_H_ #include "IImgLayer.h" typedef std::vector<IImgLayer_Ptr> IImgLayer_Vec; _EXPORTCPP ImgLayerGroup_Ptr CreateIEImgLayerGroup(ImgFile_Ptr parent_file); //_EXPORT void ReleaseIEImgLayerGroup(ImgLayerGroup_Ptr* ppLayerGroup); // class _EXPORTCPP ImgLayerGroup : public IImgLayer, public std::enable_shared_from_this<ImgLayerGroup> { public: ImgLayerGroup(ImgFile_Ptr parent_file) :IImgLayer(parent_file) { m_NumOfChildLayers = 0; m_MaxLayerIndex = 0; m_IsNeedCountChildLayers = false; m_IsNeedCountMaxLayerIndex = false; m_IsOpen = true; } ~ImgLayerGroup(); inline int GetLayerType(){ return IE_LAYER_TYPE::GROUP_LAYER; } bool Update(const LPRECT enable_lprc, LPRECT updated_lprc); void ClearUpdateData(); void LockUpdateData(); void UnlockUpdateData(); void PushUpdateDataToAllLayer(const LPUPDATE_DATA data); /////////////////////////////////////// /*! add layer @param[in] add_layer 追加するレイヤーのポインタ @param[in] index 追加先インデックス */ void AddLayer(IImgLayer_Ptr add_layer); //最後尾に追加 void AddLayer(IImgLayer_Ptr add_layer, int index); /////////////////////////////////////// /*! remove layer @param[in,out] delete_layer 取り除くレイヤーのポインタ @preturn if find remove layer return true, */ bool RemoveLayer(IImgLayer_Ptr remove_layer); /////////////////////////////////////// /*! レイヤーの並びを変える */ void ChangeLayerLine(int from_index, int to_index); void ChangeLayerLine(IImgLayer_Ptr from_layer, int to_index); /////////////////////////////////////// /*! ファイルが保持しているレイヤーの数を返す @return レイヤー枚数 */ inline int GetNumOfChildLayers() const { return m_NumOfChildLayers; } inline int GetMaxLayerIndex() const { return m_MaxLayerIndex; } int CountNumOfChildLayers(); int CountMaxLayerIndex(); /////////////////////////////////////// /*! レイヤーのインデックスを得る 見つからない場合は-1を返す @param[in] find_layer */ int GetLayerIndex(const IImgLayer_weakPtr find_layer) const; /////////////////////////////////////// /*! インデックスを指定してレイヤーオブジェクトのポインタを返す @return レイヤーオブジェクトのポインタ */ IImgLayer_Ptr const GetLayerAtIndex(int index) const; ////////////////////////////////// /*! return layer group state @return display state */ inline bool IsOpen() const { return m_IsOpen; } ///////////////////////////////// /*! set display state @param[in] bl display state */ inline void SetOpen(bool bl){ m_IsOpen = bl; } #ifdef _DEBUG ////////////////////////////////// /*! dump child layer data */ void DumpChildLayers(int tab_num=0); #endif //_DEBUG private: bool m_IsNeedCountChildLayers; bool m_IsNeedCountMaxLayerIndex; int m_NumOfChildLayers; // int m_MaxLayerIndex; // bool m_IsOpen; //下の階層のレイヤーを見せるか? }; #endif //_IMGLAYERGROUP_H_
[ "key0note@gmail.com" ]
key0note@gmail.com
b56ad65a2fa2fe298e7d66916d2a9b797241e36c
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/multimedia/include/SoundResource.h
194375cea8e6c9c7a98da54506458452022f14d1
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
ISO-8859-3
C++
false
false
2,553
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #ifndef SOUNDRESOURCE_H #define SOUNDRESOURCE_H #include "MultimediaPrerequisites.h" #include <OgreResource.h> #include <OgreDataStream.h> namespace rl { /** Diese Basisklasse kapselt eine fmod-Source fuer * den ResourceManager von Ogre * @author Josch * @date 06-19-2004 * @date 07-23-2004 * @date 10-10-2004 * @date 06-26-2005 * @version 4.0 */ class _RlMultimediaExport SoundResource: public Ogre::Resource { private: /// Unsere Daten von Ogres ResourceManager. Ogre::DataStreamPtr mDataStream; public: /// Der Standardkonstruktor SoundResource(Ogre::ResourceManager* creator, const Ogre::String& name, Ogre::ResourceHandle handle, const Ogre::String& group, bool isManual, Ogre::ManualResourceLoader* loader); /// Der Destruktor virtual ~SoundResource(); /// Den Datenstrom zurückgeben const Ogre::DataStreamPtr &getDataStream() const; /// Groesse zurueckgeben. int getSize() const; protected: /// Laedt die Soundquelle. virtual void loadImpl(); /// Entlaedt die Soundquelle. virtual void unloadImpl(); /// Bestimmt die Groesse im Speicher (wird erst nach dem Laden aufgerufen) virtual size_t calculateSize() const; }; class _RlMultimediaExport SoundResourcePtr : public Ogre::SharedPtr<SoundResource> { public: SoundResourcePtr() : Ogre::SharedPtr<SoundResource>() {} explicit SoundResourcePtr(SoundResource* rep) : Ogre::SharedPtr<SoundResource>(rep) {} SoundResourcePtr(const SoundResourcePtr& res) : Ogre::SharedPtr<SoundResource>(res) {} SoundResourcePtr(const Ogre::ResourcePtr& res); SoundResourcePtr& operator=(const Ogre::ResourcePtr& res); protected: void destroy(); }; } #endif
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013
dfc108f8df1d00c6509ba501344fa5aa82156357
09d9b50726c2e5cdc768c57930a84edc984d2a6e
/UVA ONLINE JUDGE/102 - Ecological Bin Packing .cpp
02e51b79ebef9e402f7b62ee6f1c8d28720f3fd3
[]
no_license
omar-sharif03/Competitive-Programming
86b4e99f16a6711131d503eb8e99889daa92b53d
c8bc015af372eeb328c572d16038d0d0aac6bb6a
refs/heads/master
2022-11-15T08:22:08.474648
2020-07-15T12:30:53
2020-07-15T12:30:53
279,789,803
0
0
null
null
null
null
UTF-8
C++
false
false
1,271
cpp
#include<bits/stdc++.h> using namespace std; int main() { long brown[3],green[3],clear[3]; while(cin>>brown[0]>>green[0]>>clear[0]>>brown[1]>>green[1]>>clear[1]>>brown[2]>>green[2]>>clear[2]) { long summation[7]; string s[7],s1; summation[1]=green[0]+clear[0]+brown[1]+clear[1]+brown[2]+green[2]; s[1]="BGC"; summation[2]=green[0]+clear[0]+brown[1]+green[1]+brown[2]+clear[2]; s[2]="BCG"; summation[3]=green[0]+brown[0]+green[1]+clear[1]+brown[2]+clear[2]; s[3]="CBG"; summation[4]=green[0]+brown[0]+brown[1]+clear[1]+green[2]+clear[2]; s[4]="CGB"; summation[5]=clear[0]+brown[0]+green[1]+clear[1]+green[2]+brown[2]; s[5]="GBC"; summation[6]=clear[0]+brown[0]+green[1]+brown[1]+green[2]+clear[2]; s[6]="GCB"; long min,i,j,k; min=summation[1]; s1=s[1]; for(i=2;i<7;i++){ if(summation[i]<=min){ if(summation[i]==min){ if(s[i]<s1) s1=s[i]; } else{ min=summation[i]; s1=s[i]; } } } cout<<s1<<' '<<min<<endl; } return 0; }
[ "omar.sharif1303@gmail.com" ]
omar.sharif1303@gmail.com
6f2107769f4293029ee2c0e8e1b6d17f3e3c5bf9
67a67272162d1224d01e7cf299afea28a50d1b16
/calc.h
60e7e271d73dc2c9ce1b42368f0496fd08aba6e6
[]
no_license
BReakMyMinD/calculator
fef60120f0103f2e79f0e31d490a2b10f71c7263
e59c61239f35129374146c3f6ee1de244993d38c
refs/heads/master
2020-05-20T12:46:34.473748
2019-05-08T10:06:29
2019-05-08T10:06:29
185,580,582
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
446
h
#pragma once #include "node.h" class calculator { public: std::string getRPN(std::string &str);//возвращает строку в обратной польской нотации token count(std::string &str);//возвращает математический результат выражения private: void getAllTokens(std::string &str); int sort(); customStack bufferStack; customQueue exitQueue; std::vector<token> tokens; };
[ "aisaev00@gmail.com" ]
aisaev00@gmail.com
4f5b0c6077eb276d0e44a2d773e7e36f14e16082
0106a54ff8393e97495d414560d7d5b06fec895a
/Problems[LV3]/[LV3]N으로 표현.cpp
fdf0e01f991f582d4370ea32774038a2b12e626a
[]
no_license
ssoo2024/Programmers
28cab1a7a3fb2cafd28e8d80bcaf8ec2388f7494
8aa9c50df029dd622e23c80477f7fc96c267e1d2
refs/heads/main
2022-12-28T21:36:50.424355
2020-10-16T05:36:10
2020-10-16T05:36:10
303,936,542
0
0
null
null
null
null
UTF-8
C++
false
false
1,323
cpp
// 문제가 개편되었습니다. 이로 인해 함수 구성이나 테스트케이스가 변경되어, 과거의 코드는 동작하지 않을 수 있습니다. // 새로운 함수 구성을 적용하려면 [코드 초기화] 버튼을 누르세요. 단, [코드 초기화] 버튼을 누르면 작성 중인 코드는 사라집니다. #include <string> #include <vector> #include <iostream> #include <unordered_set> using namespace std; int solution(int N, int number) { vector<unordered_set<int>> dp(9); vector<int> nums(9); for(int i = 1; i <= 8; i++){ nums[i] = stoi(string(i, N+'0').substr(0,i)); dp[i].insert(nums[i]); } for(int i = 1; i <= 8; i++){ for(auto e : dp[i - 1]){ if(e == number) return i - 1; dp[i].insert(e + N); dp[i].insert(e - N); dp[i].insert(e * N); dp[i].insert(e * (-N)); dp[i].insert(e / N); dp[i].insert(e / (-N)); for(int k = 2; k + i - 1 <= 8; k++){ dp[k + i - 1].insert(e + nums[k]); dp[k + i - 1].insert(e - nums[k]); dp[k + i - 1].insert(e * nums[k]); dp[k + i - 1].insert(e / nums[k]); } } } for(auto e : dp[8]) if(e == number) return 8; return -1; }
[ "sskim@gimseongsuui-MacBookPro.local" ]
sskim@gimseongsuui-MacBookPro.local
c4f9d8178516cdbb0e96b9d6a3c2797ad7726aae
8f7b1883fdff59cae01a594aa1e10e21a607353c
/src/ngraph/op/experimental/dyn_pad.hpp
bc4ae382efc936ab4b7348218f47c56710e171ed
[ "Apache-2.0" ]
permissive
evelynfay/ngraph
6f2f046b5c1a95aa35c218d6ae87c4cd46ba4bb2
07179ba24a6d681e4c783eda5fdb9e76b6aa31ca
refs/heads/master
2020-06-12T03:06:12.336381
2019-06-21T22:11:16
2019-06-21T22:11:16
187,723,447
0
0
Apache-2.0
2019-05-20T22:47:07
2019-05-20T22:47:06
null
UTF-8
C++
false
false
2,103
hpp
//***************************************************************************** // Copyright 2017-2019 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //***************************************************************************** #pragma once #include "ngraph/op/op.hpp" namespace ngraph { namespace op { /// \brief Generic padding operation which takes padding below and above as dynamic shapes. /// This is similar to existing Pad operation except padding values are dynamic. class DynPad : public Op { public: /// \brief Perform dynamic padding of a tensor /// /// \param arg The node producing input tensor to be padded. /// \param padding_below The node producing the padding-below widths. /// \param padding_above The node producing the padding-above widths. /// \param padding_value The value to be used for padding. Must be scalar. DynPad(const std::shared_ptr<Node>& arg, const std::shared_ptr<Node>& padding_below, const std::shared_ptr<Node>& padding_above, const std::shared_ptr<Node>& padding_value); void validate_and_infer_types() override; virtual std::shared_ptr<Node> copy_with_new_args(const NodeVector& new_args) const override; protected: virtual void generate_adjoints(autodiff::Adjoints& adjoints, const NodeVector& deltas) override; }; } }
[ "robert.kimball@intel.com" ]
robert.kimball@intel.com
d16fa8c87c7f60585e24c9275b42b95fa1c0ee26
ae9d81201f73840fe7eec0a1000360daf34ed4fc
/C++_Curso/12_Punteros/Ejercicio_2.cpp
902b770eddc3fff0c35bc30a665a278f528b2128
[]
no_license
Pimed23/UNSA
924e5f7320dc79a1d78f155ac60fac915b973d21
8618a5708ac7002b622543e9c4c670ab30ce4392
refs/heads/master
2020-05-03T16:44:55.696608
2019-04-17T06:47:02
2019-04-17T06:47:02
178,730,246
0
0
null
null
null
null
UTF-8
C++
false
false
610
cpp
#include <iostream> using namespace std; int main() { int divisores = 0, num, *numPtr; cout << "Ingrese un numero: " << endl; cin >> num; numPtr = &num; for( int i = 1; i <= *numPtr; i++ ) { if( *numPtr % i == 0 ) { divisores++; } if( divisores == 3 ) { break; } } if( divisores == 2 ) { cout << "El numero " << *numPtr << " es primo." << endl; } else { cout << "El numero " << *numPtr << " no es primo." << endl; } cout << "La direccion de mem: " << numPtr << endl; return 0; }
[ "b.pimed@gmail.com" ]
b.pimed@gmail.com
e9fc6c1a92263646dd441de6c9ad1629072ede56
9967ef82668908b22bb6bb66274d421012b84fbd
/primitives/transaction.h
107dbec76f8e61ca22a40918f7bb7730dd07b564
[]
no_license
ccyanxyz/bim
a31288fcdf6aa9ac61c3640d0a99ef3c5c1ce9f5
736e483f614bc76bca663ba8ed6042eddc168427
refs/heads/master
2020-04-29T04:34:26.858102
2019-04-03T15:45:40
2019-04-03T15:45:40
175,851,017
0
0
null
null
null
null
UTF-8
C++
false
false
2,619
h
#ifndef PRIMITIVES_TRANSACTION_H #define PRIMITIVES_TRANSACTION_H #include <vector> #include "uint256.h" #include "script/script.h" class COutPoint { public: // transaction hash uint256 hash; // vout index uint32_t index; // -1 overflow COutPoint(): n((uint32_t) -1) { } COutPoint(const uint256 &hash_in, uint32_t idx_in): hash(hash_in), index(idx_in) { } void set_null() { hash.set_null(); n = (uint32_t) -1; } bool is_null() { return (hash.is_null && n == (uint32_t) -1); } friend bool operator<(const COutPoint &a, const COutPoint &b) { int cmp = a.hash.compare(b.hash); return cmp < 0 || (cmp == 0 && a.n < b.n); } friend bool operator==(const COutPoint &a, const COutPoint &b) { return a.hash == b.hash && a.n == b.n; } friend bool operator!=(const COutPoint &a, const COutPoint &b) { return !(a == b); } std::string to_string() const; }; class CTxIn { public: COutPoint prevout; CScript script_sig; CTxIn() { } explicit CTxIn(COutPoint prevout_in, CScript script_sig_in = CScript()); CTxIn(uint256 hash_prevtx, uint32_t index, CScript script_sig_in = CScript()); friend bool operator==(const CTxIn &a, const CTxIn &b) { return a.prevout == b.prevout && a.script_sig == b.script_sig; } friend bool operator!=(const CTxIn &a, const CTxIn &b) { return !(a == b); } std::string to_string() const; }; class CTxOut { public: int64_t value; CScript script_pubkey; CTxOut() { set_null(); } CTxOut(const int64_t &value_in, CScript script_pubkey_in); void set_null() { value = -1; script_pubkey.clear(); } bool is_null() const { return value == -1; } friend bool operator==(const CTxOut &a, const CTxOut &b) { return a.value == b.value && a.script_pubkey == b.script_pubkey; } friend bool operator!=(const CTxOut &a, const CTxOut &b) { return !(a == b); } std::string to_string() const; }; class CTransaction { public: const std::vector<CTxIn> vin; const std::vector<CTxOut> vout; private: // memory only const uint256 hash; uint256 compute_hash() const; public: CTransaction(); bool is_null() const { return vin.empty() && vout.empty(); } const uint256 &get_hash() const { return hash; } // return sum of txouts int64_t get_value_out() const; bool is_coinbase() const { // why??? return vin.size() == 1 && vin[0].prevout.is_null(); } friend bool operator==(const CTransaction &a, const CTransaction &b) { return a.hash == b.hash; } friend bool operator!=(const CTransaction &a, const CTransaction &b) { return !(a == b); } std::string to_string() const; }; #endif
[ "790266922@qq.com" ]
790266922@qq.com
fad2c7381e8d84db3e0520d5611b2196bec162a9
aecc869e094f4cc27307cd40a7f0939286792bf3
/2. String Problems/10. Palindrome Break.cpp
a9c5eec72656820c6ee75c89db87bcc80aee2f14
[]
no_license
ravi2319/coding-minutes-data-structures-levelup-solutions
7ed290ac45c4971434b611e44ec99699ad412143
ce270d86ab8bc1afc3e21b42cc342465bcb48995
refs/heads/master
2023-07-13T01:29:01.297957
2021-08-11T20:32:11
2021-08-11T20:32:11
394,411,274
0
0
null
null
null
null
UTF-8
C++
false
false
377
cpp
#include<bits/stdc++.h> #include<string> using namespace std; string breakPalindrome(string s) { if(s.length() == 1) return ""; //string s = palindrome.copy(); for(int i=0; i<s.length()/2; i++) { if(s[i]!='a') { s[i] = 'a'; return s; } } s[s.length()-1] = 'b'; return s; }
[ "ravirana2319@gmail.com" ]
ravirana2319@gmail.com
43536775bd10b2d2ca66fcce3f46cd3ef3453698
936f55058b46b334b39d97f385e0a95ab361b012
/source/Helper.cpp
fba7105b542fcd3b33150f5ecedd71981748f427
[]
no_license
utia-econometrics/sddp
9ec87e85c873e2a6d154c9158910678ba517a486
ee4405aa1c9be7ec539d0bf48ce4fe5e6f84e891
refs/heads/master
2021-01-19T11:10:28.010179
2019-08-21T17:55:08
2019-08-21T17:55:08
63,052,364
2
0
null
null
null
null
UTF-8
C++
false
false
82
cpp
#include "Helper.h" Helper::Helper(void) { } Helper::~Helper(void) { }
[ "vaclav@kozmik.cz" ]
vaclav@kozmik.cz
8c0d8c8a0e6690c72881c046f0de31a7600289f8
f3eff540dd706098a59e9fa81f5b21a5773b2164
/Project 1/utilities.cpp
02ab687463c7b3c4b9a7569f646ff3888f43cc4d
[]
no_license
Jingjing1025/UCLA-CS32
de3f63e25e68f4ef4660b172b7d90b3d526c055d
6825d5f9bd1ca906101e18d4647266116d5a88b9
refs/heads/master
2020-04-04T22:20:48.294043
2018-11-06T03:31:39
2018-11-06T03:31:39
156,320,591
0
0
null
null
null
null
UTF-8
C++
false
false
2,049
cpp
// // utilities.cpp // Project 1 // // Created by Jingjing on 11/01/2018. // Copyright © 2018 Jingjing. All rights reserved. // #include <iostream> #include <random> using namespace std; /////////////////////////////////////////////////////////////////////////// // clearScreen implementation /////////////////////////////////////////////////////////////////////////// // DO NOT MODIFY OR REMOVE ANY CODE BETWEEN HERE AND THE END OF THE FILE!!! // THE CODE IS SUITABLE FOR VISUAL C++, XCODE, AND g++ UNDER LINUX. // Note to Xcode users: clearScreen() will just write a newline instead // of clearing the window if you launch your program from within Xcode. // That's acceptable. (The Xcode output window doesn't have the capability // of being cleared.) #ifdef _MSC_VER // Microsoft Visual C++ #include <windows.h> void clearScreen() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hConsole, &csbi); DWORD dwConSize = csbi.dwSize.X * csbi.dwSize.Y; COORD upperLeft = { 0, 0 }; DWORD dwCharsWritten; FillConsoleOutputCharacter(hConsole, TCHAR(' '), dwConSize, upperLeft, &dwCharsWritten); SetConsoleCursorPosition(hConsole, upperLeft); } #else // not Microsoft Visual C++, so assume UNIX interface #include <iostream> #include <cstring> #include <cstdlib> void clearScreen() // will just write a newline in an Xcode output window { static const char* term = getenv("TERM"); if (term == nullptr || strcmp(term, "dumb") == 0) cout << endl; else { static const char* ESC_SEQ = "\x1B["; // ANSI Terminal esc seq: ESC [ cout << ESC_SEQ << "2J" << ESC_SEQ << "H" << flush; } } #endif // Return a random int from min to max, inclusive int randInt(int min, int max) { if (max < min) swap(max, min); static random_device rd; static mt19937 generator(rd()); uniform_int_distribution<> distro(min, max); return distro(generator); }
[ "niejingjing@g.ucla.edu" ]
niejingjing@g.ucla.edu
20c1b42037d439b0e9f5b71361a74a3687473388
dc0246248061c858e69a6b18af8fd6a49411d91c
/src/zggh/accumulators.h
743034c5332e947d3ff445f85ae0da18c8c5e410
[ "MIT" ]
permissive
GGCash-Official/GGCash-Core
f930c47ed75ad1e9c4dd4a949a6adddb8a2b8b16
3525ab9fa53857dacbdb8558ce58fb844068e4a5
refs/heads/main
2023-04-10T16:30:38.314872
2021-04-14T23:43:50
2021-04-14T23:43:50
316,496,612
1
1
null
null
null
null
UTF-8
C++
false
false
3,430
h
// Copyright (c) 2017-2019 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef GGCash_ACCUMULATORS_H #define GGCash_ACCUMULATORS_H #include "libzerocoin/Accumulator.h" #include "libzerocoin/Coin.h" #include "libzerocoin/Denominations.h" #include "zggh/zerocoin.h" #include "accumulatormap.h" #include "chain.h" #include "uint256.h" #include "bloom.h" #include "witness.h" class CBlockIndex; std::map<libzerocoin::CoinDenomination, int> GetMintMaturityHeight(); /** * Calculate the acc witness for a single coin. * @return true if the witness was calculated well */ bool CalculateAccumulatorWitnessFor( const libzerocoin::ZerocoinParams* params, int startingHeight, int maxCalculationRange, libzerocoin::CoinDenomination den, const CBloomFilter& filter, libzerocoin::Accumulator& accumulator, libzerocoin::AccumulatorWitness& witness, int& nMintsAdded, string& strError, list<CBigNum>& ret, int &heightStop ); bool GenerateAccumulatorWitness( const libzerocoin::PublicCoin &coin, libzerocoin::Accumulator& accumulator, libzerocoin::AccumulatorWitness& witness, int& nMintsAdded, string& strError, CBlockIndex* pindexCheckpoint = nullptr); bool GenerateAccumulatorWitness(CoinWitnessData* coinWitness, AccumulatorMap& mapAccumulators, CBlockIndex* pindexCheckpoint); list<libzerocoin::PublicCoin> GetPubcoinFromBlock(const CBlockIndex* pindex); bool GetAccumulatorValueFromDB(uint256 nCheckpoint, libzerocoin::CoinDenomination denom, CBigNum& bnAccValue); bool GetAccumulatorValue(int& nHeight, const libzerocoin::CoinDenomination denom, CBigNum& bnAccValue); bool GetAccumulatorValueFromChecksum(uint32_t nChecksum, bool fMemoryOnly, CBigNum& bnAccValue); void AddAccumulatorChecksum(const uint32_t nChecksum, const CBigNum &bnValue, bool fMemoryOnly); bool CalculateAccumulatorCheckpoint(int nHeight, uint256& nCheckpoint, AccumulatorMap& mapAccumulators); void DatabaseChecksums(AccumulatorMap& mapAccumulators); bool LoadAccumulatorValuesFromDB(const uint256 nCheckpoint); bool EraseAccumulatorValues(const uint256& nCheckpointErase, const uint256& nCheckpointPrevious); uint32_t ParseChecksum(uint256 nChecksum, libzerocoin::CoinDenomination denomination); uint32_t GetChecksum(const CBigNum &bnValue); int GetChecksumHeight(uint32_t nChecksum, libzerocoin::CoinDenomination denomination); bool InvalidCheckpointRange(int nHeight); bool ValidateAccumulatorCheckpoint(const CBlock& block, CBlockIndex* pindex, AccumulatorMap& mapAccumulators); // Exceptions class NotEnoughMintsException : public std::exception { public: std::string message; NotEnoughMintsException(const string &message) : message(message) {} }; class GetPubcoinException : public std::exception { public: std::string message; GetPubcoinException(const string &message) : message(message) {} }; class ChecksumInDbNotFoundException : public std::exception { public: std::string message; ChecksumInDbNotFoundException(const string &message) : message(message) {} }; class searchMintHeightException : public std::exception { public: std::string message; searchMintHeightException(const string &message) : message(message) {} }; #endif //GGCash_ACCUMULATORS_H
[ "fanaticosfaucet@gmail.com" ]
fanaticosfaucet@gmail.com
d2c984112371a2f10dcbffea3a4bea61fa227bf8
d2e95afd235eadedfa7dd3b5bc8415c5f5e53dd0
/nidsform.h
8921245f5ba83110f03dc703b00c146bba1633d6
[]
no_license
BJLIYANLIANG/NidsOnQT
4e5dc7e3b1d3e31e8123d34d8066aa3fab68a6d6
38430f944371937ba7a8c994529277cbf0cf4436
refs/heads/master
2021-12-02T08:08:29.053990
2012-11-24T12:18:23
2012-11-24T12:18:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
500
h
#ifndef NIDSFORM_H #define NIDSFORM_H #include <QWidget> #include <QComboBox> namespace Ui { class NidsForm; } class NidsForm : public QWidget { Q_OBJECT public: explicit NidsForm(QWidget *parent = 0); ~NidsForm(); private slots: void on_comboBoxProto_currentIndexChanged(int index); void on_comboBoxAlarm_currentIndexChanged(int index); private: void setCombox (QComboBox* pCombox,QStringList itemList); private: Ui::NidsForm *ui; }; #endif // NIDSFORM_H
[ "SudyDuan@gmail.com" ]
SudyDuan@gmail.com
dde6574562b3686781c9327e15bb2aa8f488dd85
b09b0a8cdf87dbf680f018124af143b1018337b8
/src/acquire/include/hdfsconnector.h
5763f706eb04d2c152c2ebc72f6327206aed2df1
[]
no_license
yip-jek/RevenueAudit
dc8639bceae73739cefeee4d93803ff42442d51c
681440c633424256249c6285ec6919273f1cef3d
refs/heads/master
2020-12-09T05:01:45.912886
2019-05-03T12:18:31
2019-05-03T12:18:31
55,571,437
0
0
null
null
null
null
UTF-8
C++
false
false
482
h
#pragma once #include "autodisconnect.h" #include "hdfs.h" namespace base { class Log; } class HdfsConnector : public base::BaseConnector { public: HdfsConnector(const std::string& host, int port); virtual ~HdfsConnector(); public: virtual void ToConnect(); virtual void ToDisconnect(); public: hdfsFS GetHdfsFS() const; private: base::Log* m_pLogger; private: std::string m_sHost; // 主机信息 int m_nPort; // 端口号 private: hdfsFS m_hdfsFS; };
[ "yiyijie@foxmail.com" ]
yiyijie@foxmail.com
485ac5b65e0f2b6b2443fd429a13dc9fe7b84699
55afd019408adc46a917cbbf87a87e403ad39439
/sort/exchange_sort/exchange_sort.cpp
7db5b3c8b8b51a934944e4a60287e319b6eea416
[]
no_license
JieTrancender/DataStructures-Algorithms-Applications
b2877d1535212c4ce3d0494ade38fe6a9aed8792
4db576d56b91b77b9a9693db8ccfcce7eba68edc
refs/heads/master
2021-01-10T16:36:33.036178
2016-10-24T16:09:18
2016-10-24T16:09:18
44,176,453
3
0
null
null
null
null
UTF-8
C++
false
false
947
cpp
#include <iostream> #include <algorithm> #include <iterator> using namespace std; //交换法排序 template <typename anytype> void ExchangeSort(anytype *element, int n); //打印数组元素 template <typename anytype> inline void Print(anytype element[], int n); int main() { int num[] = {2, 5, 3, 45, 9, 123, 34, 6, 2}; Print(num, sizeof(num) / sizeof(num[0])); ExchangeSort(num, sizeof(num) / sizeof(num[0])); Print(num, sizeof(num) / sizeof(num[0])); return 0; } template <typename anytype> void ExchangeSort(anytype *element, int n) { for(int i = 0; i < n - 1; ++i) { for(int j = i + 1; j < n; ++j) { if(element[i] > element[j]) { swap(element[i], element[j]); } } } } template <typename anytype> void Print(anytype element[], int n) { copy(element, element + n, ostream_iterator<anytype>(cout, " ")); cout << endl; }
[ "trancender@vip.qq.com" ]
trancender@vip.qq.com
f04c0ba0280a6bd863b012221a664dcea02857eb
5f63d4329cfc69d584a51be37358f830691ed0ea
/20161020/Student_heap.cc
4ba85c226fe8de5fc55dd5b7d5fa8e390f382ab1
[]
no_license
SaberLele/learngit
022091484ed36457c12699f3e7108010e9715649
2533d33d3feb374c74c91abfa426e31b2edd871a
refs/heads/master
2021-01-11T02:21:28.297780
2016-12-15T07:53:37
2016-12-15T07:53:37
70,976,791
1
0
null
null
null
null
UTF-8
C++
false
false
1,115
cc
/// /// @file Student.cc /// @author SaberLele(le13424274771@gmail.com) /// @date 2016-10-20 04:11:35 /// #include <stdlib.h> #include <string.h> #include <iostream> using std::cout; using std::endl; class Student { public: Student(int id,const char* name) :_id(id) ,_name(new char[strlen(name)+1]) { cout << "Student(int,const char*)" <<endl; strcpy(_name,name); } void display() { cout << "学号:" << _id << endl; cout << "姓名:" << _name << endl; } static void* operator new(size_t size) { cout << "void* operator new(size_t)" << endl; void *p=malloc(size); return p; } static void operator delete(void *p) { cout << "void operator delete(void*)" << endl; free(p); } void destory() { cout << "destory()" << endl; delete this; } private: ~Student() { cout << "~Student()" << endl; delete [] _name; } int _id; char* _name; }; int main() { //只能生成堆对象 Student *stu=new Student(111,"Mike"); stu->display(); //delete stu; //delete调用不到析构函数 stu->destory(); return 0; }
[ "le13424274771@gmail.com" ]
le13424274771@gmail.com
b34bbde69824b3e61d7a65fbef5ea8911d3fa67a
29fb827671e7c8a0af1e34a1c2bf8070dc12d0c2
/Program3/hash_cache.h
dcb2618e529cc284795ca6d510bcd7f8b1755295
[]
no_license
NingSSS/cse411
f4beb77f8bb97a5c1e9f6f3fe01beb6ec7f31abf
5c9840a74ec6fa1ee91d36248a9dba761d43b78f
refs/heads/master
2020-04-27T03:46:29.066434
2019-03-05T23:11:10
2019-03-05T23:11:10
174,034,236
0
0
null
null
null
null
UTF-8
C++
false
false
1,464
h
#ifndef HASH_CACHE_H #define HASH_CACHE_H #include <vector> #include <unordered_map> #include <fstream> #include <string> //#include "node.h" #define PAGE_SIZE 2000 #define CACHE_SIZE 200 #define DISK_SIZE 2000 #define FAILED -1 using namespace std; class HashCache { private: class Page; class Node; Page* entries_; vector<Page*> free_entries_; unordered_map<string, Node* > hash_map; unordered_map<string, int> key_file_map; Page* get_new_page(); Page* put_page; bool put_page_existed; const char**file_list_; int new_file_index_; Page *head_, *tail_; void detach(Page* page); void attach(Page* page); Node* search(string key); int load_file_to_page(const int &file_num, Page* &page, unordered_map<string, Node* > &hash_map); int save_page_to_file(Page* &page); void erase_page_of_cache(Page* &page, unordered_map<string, Node* > &hash_map); int load_new_file_index(const char* save_file_index = "file_index.dat"); void save_new_file_index(const char* save_file_index = "file_index.dat"); void load_key_file_map(const char* key_filename = "key_file.dat"); void push_key_to_keymap(Page* &page, const char* key_filename = "key_file.dat"); public: HashCache(int capacity = CACHE_SIZE); ~HashCache(); void save_cache(); string get(string key); void put(string key, string value); void del(string key); string where(string regexkey); }; #endif
[ "1354048433@qq.com" ]
1354048433@qq.com
c4feca8870de6d0f963a714187e6b92640130a56
de460e930ea8dd606b30bb35a6407e824ea4fdb8
/image.h
6c872dff979a3ea519d6e21431d51935d2518864
[]
no_license
tytheg/ImageProcessor
f20170f3b8be961e710f31779c0ceb360779f7bc
f5e5e0b4104efc3d2562756b2172e1635ea99303
refs/heads/master
2021-04-27T19:43:16.428280
2018-02-21T16:34:55
2018-02-21T16:34:55
122,362,015
0
0
null
null
null
null
UTF-8
C++
false
false
709
h
#ifndef IMAGE_H #define IMAGE_H //#include "Source.h" class Source; struct Pixel { unsigned char r, g, b; }; class Image { // Data members go here private: Pixel* pixel; int height, width, maxval; protected: Source* src; public: Image(); Image(int wid, int hit, int max); Image(Image &); void setSize(int hit, int wid, int max = 255); int getHeight() const; void setHeight(int val); int getWidth() const; void setWidth(int val); int getMaxval() const; void setMaxval(int val); Pixel* getPixel() const; void setPixel(Pixel* pix); Source *getSource() const; void setSource(Source *s); virtual void Update() const; }; #endif
[ "tyler22green@gmail.com" ]
tyler22green@gmail.com
25b95896c25544097de369c3b3a43703ee05446b
546d00dd96099d7ad669373f5771b9b200938f6e
/Sources/Autoupdate/GameOption.h
b0c1b72cfc0e30ca41767f6697cbc028efb96ab3
[]
no_license
lubing521/mmo-resourse
74f6bcbd78aba61de0e8a681c4c6850f564e08d8
94fc594acba9bba9a9c3d0a5ecbca7a6363b42a5
refs/heads/master
2021-01-22T01:43:29.825927
2015-03-17T02:24:16
2015-03-17T02:24:16
36,480,084
2
1
null
2015-05-29T03:16:18
2015-05-29T03:16:18
null
UTF-8
C++
false
false
1,223
h
#if !defined(AFX_GAMEOPTION_H__6B4C9CDB_7C82_4B78_9BD9_ACC6F9CF8141__INCLUDED_) #define AFX_GAMEOPTION_H__6B4C9CDB_7C82_4B78_9BD9_ACC6F9CF8141__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // GameOption.h : header file // ///////////////////////////////////////////////////////////////////////////// // GameOption dialog class GameOption : public CDialog { // Construction public: GameOption(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(GameOption) enum { IDD = IDD_DIALOGBAR }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(GameOption) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(GameOption) afx_msg void OnCancel(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GAMEOPTION_H__6B4C9CDB_7C82_4B78_9BD9_ACC6F9CF8141__INCLUDED_)
[ "ichenq@gmail.com@6f215214-8c51-1d4b-a490-e1557286002c" ]
ichenq@gmail.com@6f215214-8c51-1d4b-a490-e1557286002c
2450cff6ac8ae3f664dd7161ff27b921c3310d48
0c5461dec012986b620f46596b543cd0769f2b32
/atcoder/abc130c_rectanglecutting.cpp
05e45672c7d29417e7ec7bd1ccc429f3901900e0
[ "MIT" ]
permissive
aoibird/pc
ec6e0d634cf7bd03f102416c7847decf80a5e493
01b7c006df899365eaa73ff179a220f6a7d799c6
refs/heads/master
2022-11-28T04:48:15.458782
2022-11-21T01:30:39
2022-11-21T01:30:39
205,393,242
0
0
null
null
null
null
UTF-8
C++
false
false
233
cpp
#include <iostream> using namespace std; int main() { int W, H, x, y; scanf("%d%d%d%d", &W, &H, &x, &y); if (x * 2 == W && y * 2 == H) { printf("%.6f 1\n", (W*H)/2.0); } else { printf("%.6f 0\n", (W*H)/2.0); } }
[ "aoi@aoibird.com" ]
aoi@aoibird.com
fed0fe330422d66f297727b0d6406adf498dca91
c4bf03dff950e421eae66311bad4b9a6dd59973a
/core/modules/qana/ScanTablePlugin.h
6172146438bbfe156d30e57fc414f264a0d0abe8
[]
no_license
tsengj10/qserv
eee6a1b8de7db2a8eaf99e1bd17d4f008c9617bc
97a6c2d206c5d8394d0355461674ae6ce5d449ab
refs/heads/master
2021-06-18T06:00:34.424789
2018-08-22T00:16:59
2018-08-22T00:16:59
96,400,110
0
0
null
2017-07-06T07:13:54
2017-07-06T07:13:54
null
UTF-8
C++
false
false
2,138
h
// -*- LSST-C++ -*- /* * LSST Data Management System * Copyright 2016 LSST Corporation. * * This product includes software developed by the * LSST Project (http://www.lsst.org/). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the LSST License Statement and * the GNU General Public License along with this program. If not, * see <http://www.lsstcorp.org/LegalNotices/>. */ #ifndef LSST_QSERV_QANA_SCANTABLEPLUGIN_H #define LSST_QSERV_QANA_SCANTABLEPLUGIN_H // Class header #include "qana/QueryPlugin.h" // Qserv headers #include "proto/ScanTableInfo.h" namespace lsst { namespace qserv { namespace qana { /// ScanTablePlugin is a query plugin that detects the "scan tables" /// of a query. A scan table is a partitioned table that must be /// scanned in order to answer the query. If the number of chunks /// involved is less than a threshold number (2, currently), then the /// scan table annotation is removed--the query is no longer /// considered a "scanning" query because it involves a small piece of /// the data set. class ScanTablePlugin : public QueryPlugin { public: // Types typedef std::shared_ptr<ScanTablePlugin> Ptr; ScanTablePlugin() {} virtual ~ScanTablePlugin() {} void prepare() override {} void applyLogical(query::SelectStmt& stmt, query::QueryContext&) override; void applyFinal(query::QueryContext& context) override; private: proto::ScanInfo _findScanTables(query::SelectStmt& stmt, query::QueryContext& context); proto::ScanInfo _scanInfo; }; }}} // namespace lsst::qserv::qana #endif // LSST_QSERV_QANA_SCANTABLEPLUGIN_H
[ "jgates@slac.stanford.edu" ]
jgates@slac.stanford.edu
c0b24c0528ee863513e8014be7fd7af7f0e46ba2
438f0ddc02ba37fe45496eae3f7c0294432a15e2
/src/qt/transactionrecord.cpp
f749fc6458033b39f3c289ce4ab116c1eb864428
[ "MIT" ]
permissive
Xcgtech/Wallet
73922b6363b7ac01d22d652985c2883eb03ed624
abf1b93486e30a4c4877400f2af574f85005a6f8
refs/heads/master
2020-03-13T17:10:44.125329
2019-02-05T14:05:15
2019-02-05T14:05:15
131,212,480
19
6
MIT
2019-01-03T14:51:44
2018-04-26T21:27:04
C++
UTF-8
C++
false
false
11,312
cpp
// Copyright (c) 2011-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Xchange Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "transactionrecord.h" #include "base58.h" #include "consensus/consensus.h" #include "validation.h" #include "timedata.h" #include "wallet/wallet.h" #include "instantx.h" #include "privatesend.h" #include <stdint.h> #include <boost/foreach.hpp> /* Return positive answer if transaction should be shown in list. */ bool TransactionRecord::showTransaction(const CWalletTx &wtx) { if (wtx.IsCoinBase()) { // Ensures we show generated coins / mined transactions at depth 1 if (!wtx.IsInMainChain()) { return false; } } return true; } /* * Decompose CWallet transaction to model transaction records. */ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx) { QList<TransactionRecord> parts; int64_t nTime = wtx.GetTxTime(); CAmount nCredit = wtx.GetCredit(ISMINE_ALL); CAmount nDebit = wtx.GetDebit(ISMINE_ALL); CAmount nNet = nCredit - nDebit; uint256 hash = wtx.GetHash(); std::map<std::string, std::string> mapValue = wtx.mapValue; if (nNet > 0 || wtx.IsCoinBase()) { // // Credit // BOOST_FOREACH(const CTxOut& txout, wtx.vout) { isminetype mine = wallet->IsMine(txout); if(mine) { TransactionRecord sub(hash, nTime); CTxDestination address; sub.idx = parts.size(); // sequence number sub.credit = txout.nValue; sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) { // Received by Xchange Address sub.type = TransactionRecord::RecvWithAddress; sub.address = CBitcoinAddress(address).ToString(); } else { // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction sub.type = TransactionRecord::RecvFromOther; sub.address = mapValue["from"]; } if (wtx.IsCoinBase()) { // Generated sub.type = TransactionRecord::Generated; } parts.append(sub); } } } else { bool fAllFromMeDenom = true; int nFromMe = 0; bool involvesWatchAddress = false; isminetype fAllFromMe = ISMINE_SPENDABLE; BOOST_FOREACH(const CTxIn& txin, wtx.vin) { if(wallet->IsMine(txin)) { fAllFromMeDenom = fAllFromMeDenom && wallet->IsDenominated(txin.prevout); nFromMe++; } isminetype mine = wallet->IsMine(txin); if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; if(fAllFromMe > mine) fAllFromMe = mine; } isminetype fAllToMe = ISMINE_SPENDABLE; bool fAllToMeDenom = true; int nToMe = 0; BOOST_FOREACH(const CTxOut& txout, wtx.vout) { if(wallet->IsMine(txout)) { fAllToMeDenom = fAllToMeDenom && CPrivateSend::IsDenominatedAmount(txout.nValue); nToMe++; } isminetype mine = wallet->IsMine(txout); if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; if(fAllToMe > mine) fAllToMe = mine; } if(fAllFromMeDenom && fAllToMeDenom && nFromMe * nToMe) { parts.append(TransactionRecord(hash, nTime, TransactionRecord::PrivateSendDenominate, "", -nDebit, nCredit)); parts.last().involvesWatchAddress = false; // maybe pass to TransactionRecord as constructor argument } else if (fAllFromMe && fAllToMe) { // Payment to self // TODO: this section still not accurate but covers most cases, // might need some additional work however TransactionRecord sub(hash, nTime); // Payment to self by default sub.type = TransactionRecord::SendToSelf; sub.address = ""; if(mapValue["DS"] == "1") { sub.type = TransactionRecord::PrivateSend; CTxDestination address; if (ExtractDestination(wtx.vout[0].scriptPubKey, address)) { // Sent to Xchange Address sub.address = CBitcoinAddress(address).ToString(); } else { // Sent to IP, or other non-address transaction like OP_EVAL sub.address = mapValue["to"]; } } else { for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) { const CTxOut& txout = wtx.vout[nOut]; sub.idx = parts.size(); if(CPrivateSend::IsCollateralAmount(txout.nValue)) sub.type = TransactionRecord::PrivateSendMakeCollaterals; if(CPrivateSend::IsDenominatedAmount(txout.nValue)) sub.type = TransactionRecord::PrivateSendCreateDenominations; if(nDebit - wtx.GetValueOut() == CPrivateSend::GetCollateralAmount()) sub.type = TransactionRecord::PrivateSendCollateralPayment; } } CAmount nChange = wtx.GetChange(); sub.debit = -(nDebit - nChange); sub.credit = nCredit - nChange; parts.append(sub); parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument } else if (fAllFromMe) { // // Debit // CAmount nTxFee = nDebit - wtx.GetValueOut(); for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) { const CTxOut& txout = wtx.vout[nOut]; TransactionRecord sub(hash, nTime); sub.idx = parts.size(); sub.involvesWatchAddress = involvesWatchAddress; if(wallet->IsMine(txout)) { // Ignore parts sent to self, as this is usually the change // from a transaction sent back to our own address. continue; } CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address)) { // Sent to Xchange Address sub.type = TransactionRecord::SendToAddress; sub.address = CBitcoinAddress(address).ToString(); } else { // Sent to IP, or other non-address transaction like OP_EVAL sub.type = TransactionRecord::SendToOther; sub.address = mapValue["to"]; } if(mapValue["DS"] == "1") { sub.type = TransactionRecord::PrivateSend; } CAmount nValue = txout.nValue; /* Add fee to first output */ if (nTxFee > 0) { nValue += nTxFee; nTxFee = 0; } sub.debit = -nValue; parts.append(sub); } } else { // // Mixed debit transaction, can't break down payees // parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0)); parts.last().involvesWatchAddress = involvesWatchAddress; } } return parts; } void TransactionRecord::updateStatus(const CWalletTx &wtx) { AssertLockHeld(cs_main); // Determine transaction status // Find the block the tx is in CBlockIndex* pindex = NULL; BlockMap::iterator mi = mapBlockIndex.find(wtx.hashBlock); if (mi != mapBlockIndex.end()) pindex = (*mi).second; // Sort order, unrecorded transactions sort to the top status.sortKey = strprintf("%010d-%01d-%010u-%03d", (pindex ? pindex->nHeight : std::numeric_limits<int>::max()), (wtx.IsCoinBase() ? 1 : 0), wtx.nTimeReceived, idx); status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0); status.depth = wtx.GetDepthInMainChain(); status.cur_num_blocks = chainActive.Height(); status.cur_num_ix_locks = nCompleteTXLocks; if (!CheckFinalTx(wtx)) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) { status.status = TransactionStatus::OpenUntilBlock; status.open_for = wtx.nLockTime - chainActive.Height(); } else { status.status = TransactionStatus::OpenUntilDate; status.open_for = wtx.nLockTime; } } // For generated transactions, determine maturity else if(type == TransactionRecord::Generated) { if (wtx.GetBlocksToMaturity() > 0) { status.status = TransactionStatus::Immature; if (wtx.IsInMainChain()) { status.matures_in = wtx.GetBlocksToMaturity(); // Check if the block was requested by anyone if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) status.status = TransactionStatus::MaturesWarning; } else { status.status = TransactionStatus::NotAccepted; } } else { status.status = TransactionStatus::Confirmed; } } else { if (status.depth < 0) { status.status = TransactionStatus::Conflicted; } else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) { status.status = TransactionStatus::Offline; } else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; if (wtx.isAbandoned()) status.status = TransactionStatus::Abandoned; } else if (status.depth < RecommendedNumConfirmations) { status.status = TransactionStatus::Confirming; } else { status.status = TransactionStatus::Confirmed; } } } bool TransactionRecord::statusUpdateNeeded() { AssertLockHeld(cs_main); return status.cur_num_blocks != chainActive.Height() || status.cur_num_ix_locks != nCompleteTXLocks; } QString TransactionRecord::getTxID() const { return formatSubTxId(hash, idx); } QString TransactionRecord::formatSubTxId(const uint256 &hash, int vout) { return QString::fromStdString(hash.ToString() + strprintf("-%03d", vout)); }
[ "36750226+cryptforall@users.noreply.github.com" ]
36750226+cryptforall@users.noreply.github.com
ff880ec18ca41dbe1620ae507f0f1f1bc5feb7db
7f2255fd0fce35a14556dda32ff06113c83b2e88
/洛谷/P2719.cpp
7e9b5d619283e1145076cc70042b270801bf774e
[]
no_license
cordercorder/ProgrammingCompetionCareer
c54e2c35c64a1a5fd45fc1e86ddfe5b72ab0cb01
acc27440d3a9643d06bfbfc130958b1a38970f0a
refs/heads/master
2023-08-16T18:21:27.520885
2023-08-13T15:13:44
2023-08-13T15:13:44
225,124,408
3
0
null
null
null
null
UTF-8
C++
false
false
1,258
cpp
#include<bits/stdc++.h> using namespace std; #define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define deb(args...) std::cerr<<"DEBUG------"<<'\n';std::cerr<<#args<<"------>";err(args) void err(){ std::cerr<<'\n'<<"END OF DEBUG"<<'\n'<<'\n'; } template<typename T,typename... Args> void err(T a,Args... args){ std::cerr<<a<<", "; err(args...); } template<template<typename...> class T,typename t,typename... Args> void err(T<t> a, Args... args){ for(auto x: a){ std::cerr<<x<<", "; } err(args...); } const long double PI=acos(-1.0); const long double eps=1e-6; const long long maxw=(long long)1e17+(long long)10; using ll=long long; using ull=unsigned long long; using pii=pair<int,int>; /*head------[@cordercorder]*/ const int maxn=1300; int n; double dp[maxn][maxn]; void solve(){ n/=2; for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ if(i<=1&&j<=1){ dp[i][j]=0; } else if(i==0||j==0){ dp[i][j]=1; } else{ dp[i][j]=(dp[i-1][j]+dp[i][j-1])*0.5; } } } printf("%.4f\n",dp[n][n]); } int main(void){ scanf("%d",&n); solve(); return 0; }
[ "2205722269@qq.com" ]
2205722269@qq.com
6c0066ce263aba33344d67d777d718b3f48acb36
ea72bd9110a0f20dfec1767b4fe8079976935352
/qdraughts/train.h
7c166d051859249348ca0aaefe91da840c690ef6
[]
no_license
onezeronine/qdraughts
882ab9e2b1b11b882b3db74dcee6564800a6ab71
6897272a3c65d4c60705f8dc0e3f17967fecf564
refs/heads/master
2021-05-08T21:44:56.951589
2019-04-10T06:59:00
2019-04-10T06:59:00
119,647,265
0
0
null
null
null
null
UTF-8
C++
false
false
751
h
#ifndef __TDTRAIN #define __TDTRAIN #include <iostream> #include <fstream> #include "dirnet.h" #include "board.h" //const float LOSEVALUE =-1.0; //const float DRAWVALUE =0.0; //const float WINVALUE =1.0; #define WINVALUE 1.0 #define LOSEVALUE -1.0 #define DRAWVALUE 0 #define DRAWVALUE1 +0.3 //if above UPPERVAL #define DRAWVALUE2 -0.3 //if below LOWERVAL #define UPPERVAL +10 #define LOWERVAL -10 enum INPUTTYPE {BLACKWON=1, REDWON, DRAW, BLACKMOVE, REDMOVE, COMMENT}; float TrainfromFile(DirectNet* dnet, char* fname, float gamma=0.98, float lambda=0.1); void PDNtoBoards(char* pdnfname, char* boardfile, int ignore_draws); void WriteBoards(char* boardfile, MOVE** movelist, int moves, INPUTTYPE whowon); #endif
[ "kenneth.g.bastian@descouvre.com" ]
kenneth.g.bastian@descouvre.com
dd407d5b630ab5bf7a3417a18b50eeebb5380733
3d2cf05c31bda142702c43907d3d1db7bc422446
/header/SettingWindow.h
2d96b227b7ed0f45703618997adead058b2ef80b
[ "MIT" ]
permissive
Kami-code/Snaker
ffd3c26152b601a59627633675aa18b4b7e55fe6
4fa67e393e099a1d7d3ee99f774a5db5265978d7
refs/heads/master
2023-02-09T19:59:08.298703
2020-12-29T06:43:23
2020-12-29T06:43:23
316,961,098
0
0
null
2020-12-24T01:12:40
2020-11-29T13:48:34
C++
UTF-8
C++
false
false
803
h
#pragma once #ifndef SETTINGWINDOW_H #define SETTINGWINDOW_H #include <QtWidgets/QWidget> #include <QtWidgets/QPushButton> #include <QSlider> class SettingWindow : public QWidget { Q_OBJECT public: explicit SettingWindow(QWidget *parent = 0); ~SettingWindow(); void ChangeToDesktop(); void ChangeAudioSetting(); void ChangeFigureSetting(); void SetSnakes(int); void SetBackgroundSize(int); void ChangeAISnakeSetting(); void ChangePenetrateSetting(); signals: void SignalChangeToDesktop(); public slots: private: QPushButton * audioButton; QPushButton * figureButton; QPushButton * returnButton; QPushButton * aiSnakeButton; QPushButton * penetrateButton; QSlider * slider; QSlider * slider2; }; #endif // SETTINGWINDOW_H
[ "im.B.C@live.com" ]
im.B.C@live.com
861f6380b5e5f47eedb20b0947adfa0ab1e11c46
6273683fde5b193cff43a4a65571c113d3577d64
/EyerVideoWand/EyerWand/UIView/WandTimeLineDrawEvent_Line.cpp
d6089c1f4cf376d9b2d3880b79e54a5607681c4f
[]
no_license
redknotmiaoyuqiao/EyerVideoWand
4bb84a1e35564becac2954df77fee209f55d8783
fe6ad8f9f66128e99689b6fa4f8efe38fdfad18b
refs/heads/master
2020-11-30T00:55:11.896681
2020-08-18T09:00:44
2020-08-18T09:00:44
230,255,265
4
1
null
2020-08-18T09:00:45
2019-12-26T11:48:37
C++
UTF-8
C++
false
false
1,809
cpp
#include "WandUIView.hpp" namespace Eyer { WandTimeLineDrawEvent_Line::WandTimeLineDrawEvent_Line() { } WandTimeLineDrawEvent_Line::~WandTimeLineDrawEvent_Line() { } WandTimeLineDrawEventType WandTimeLineDrawEvent_Line::GetType() { return WandTimeLineDrawEventType::LINE; } WandTimeLineDrawEvent_Line::WandTimeLineDrawEvent_Line(WandTimeLineDrawEvent_Line & line) { *this = line; } WandTimeLineDrawEvent_Line & WandTimeLineDrawEvent_Line::operator = (WandTimeLineDrawEvent_Line & line) { start = line.start; end = line.end; color = line.color; strokeWidth = line.strokeWidth; return *this; } int WandTimeLineDrawEvent_Line::SetLine(float startX, float startY, float endX, float endY) { start.SetX(startX); start.SetY(startY); end.SetX(endX); end.SetY(endY); return 0; } int WandTimeLineDrawEvent_Line::SetColor(EyerVec4 _color) { color = _color; return 0; } int WandTimeLineDrawEvent_Line::SetColor(float red, float green, float blue, float alpha) { color.SetX(red); color.SetY(green); color.SetZ(blue); color.SetW(alpha); return 0; } int WandTimeLineDrawEvent_Line::GetLine(EyerVec2 & _start, EyerVec2 & _end) { _start = start; _end = end; return 0; } int WandTimeLineDrawEvent_Line::GetColor(EyerVec4 & _color) { _color = color; return 0; } int WandTimeLineDrawEvent_Line::SetStrokeWidth(int _strokeWidth) { strokeWidth = _strokeWidth; return 0; } int WandTimeLineDrawEvent_Line::GetStrokeWidth() { return strokeWidth; } }
[ "redknotmiaoyuqiao@gmail.com" ]
redknotmiaoyuqiao@gmail.com
7bd2967c248bc6f47cdf7fe989b4d198e0db084d
8d447ea004b36ca0da473dc110cb1be61c5273d8
/Code/Joe/JoeSceneV2.h
2446defa4e90b7f36886f627f3f6485c3a663b29
[]
no_license
MORTAL2000/LIT-Yr4-GamePhysics
bcfc166ea3fa2f0dcba468937b1b4513027b3813
1f1df54087d632010d2ec2896a9171948047725c
refs/heads/master
2022-04-05T18:10:56.906414
2020-01-09T04:17:00
2020-01-09T04:17:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,656
h
#include "../BulletOpenGLApplication.h" #include "btBulletDynamicsCommon.h" #include <iostream> #define SDL_MAIN_HANDLED // JOR Handling SDL main definition ourselves #define BLOCKS_IN_ROW 11 // Number of blocks in a row in castle walls #define EXPLOSION_STRENGTH 50.0f // Strength of the explosion #define RADIANS_PER_DEGREE 0.01745329f // Number of radians per degree class JoeSceneV2 : public BulletOpenGLApplication { public: JoeSceneV2(); // Constructor virtual void InitializePhysics() override; // Initialise physics. Override BulletOpenGLApplication function virtual void ShutdownPhysics() override; // Clear physics elements from scene. Override BulletOpenGLApplication function void InitSDLAudio(); // Initialise music and sound effects void CreateObjects(); virtual void Keyboard(unsigned char key, int x, int y) override; // Override Key function of BulletOpenGLApplication virtual void KeyboardUp(unsigned char key, int x, int y) override; // Override Key up function of BulletOpenGLApplication virtual void Mouse(int button, int state, int x, int y) override; // Override the Mouse() function of BulletOpenGLApplication virtual void RenderScene() override; // Override the RenderScene() functione of BulletOpenGLApplication virtual void UpdateScene(float dt); // Scene updating. Overriden from parent class virtual void CollisionEvent(btRigidBody* pBody0, btRigidBody* pBody1) override; // Handle collisions. Override BulletOpenGLApplication function // New projectiles void ShootBall(const btVector3 &direction); // Fire sphere objects from camera position void ShootArrow(const btVector3 &direction); // Collection of shapes making up arrow void ShootArrowCompound(const btVector3 &direction); // Compound shape arrow projectile void CreateExplosion(const btVector3 &origin); // Create explosion at position //void CreateExplosion2(btTransform &transform); void incrementScore(int amount) { m_score += amount; } // Add value to score protected: GameObject* m_pBox; // Right click - box to lift //btCollisionObject* m_pTrigger; // Simple trigger volume bool m_bApplyForce; // Is the 'g' key held down // Explosion variables btCollisionObject* m_pExplosion; // Explosion object bool m_canFireBall; // Can only fire one ball at a time bool m_bCanExplode; // If an explosion can happen or not int m_score; // Score for hitting an object };
[ "k00203642@student.lit.ie" ]
k00203642@student.lit.ie
3442f3860c6213eab380deecba5afb3de6bf0cd2
24f26275ffcd9324998d7570ea9fda82578eeb9e
/chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h
f7fd962bb856b750f347af6a01d6385dca6fc03f
[ "BSD-3-Clause" ]
permissive
Vizionnation/chromenohistory
70a51193c8538d7b995000a1b2a654e70603040f
146feeb85985a6835f4b8826ad67be9195455402
refs/heads/master
2022-12-15T07:02:54.461083
2019-10-25T15:07:06
2019-10-25T15:07:06
217,557,501
2
1
BSD-3-Clause
2022-11-19T06:53:07
2019-10-25T14:58:54
null
UTF-8
C++
false
false
4,272
h
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_ #include <list> #include <memory> #include <string> #include "ash/public/cpp/shelf_item_delegate.h" #include "base/macros.h" #include "base/scoped_observer.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" namespace ui { class BaseWindow; } class LauncherContextMenu; // This is a ShelfItemDelegate for abstract app windows (extension or ARC). // There is one instance per app, per launcher id. For apps with multiple // windows, each item controller keeps track of all windows associated with the // app and their activation order. Instances are owned by ash::ShelfModel. // // Tests are in chrome_launcher_controller_browsertest.cc class AppWindowLauncherItemController : public ash::ShelfItemDelegate, public aura::WindowObserver { public: using WindowList = std::list<ui::BaseWindow*>; explicit AppWindowLauncherItemController(const ash::ShelfID& shelf_id); ~AppWindowLauncherItemController() override; void AddWindow(ui::BaseWindow* window); void RemoveWindow(ui::BaseWindow* window); void SetActiveWindow(aura::Window* window); ui::BaseWindow* GetAppWindow(aura::Window* window); // ash::ShelfItemDelegate overrides: AppWindowLauncherItemController* AsAppWindowLauncherItemController() override; void ItemSelected(std::unique_ptr<ui::Event> event, int64_t display_id, ash::ShelfLaunchSource source, ItemSelectedCallback callback) override; AppMenuItems GetAppMenuItems(int event_flags) override; void GetContextMenu(int64_t display_id, GetContextMenuCallback callback) override; void ExecuteCommand(bool from_context_menu, int64_t command_id, int32_t event_flags, int64_t display_id) override; void Close() override; // aura::WindowObserver overrides: void OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) override; // Activates the window at position |index|. void ActivateIndexedApp(size_t index); // Get the number of running applications/incarnations of this. size_t window_count() const { return windows_.size(); } const WindowList& windows() const { return windows_; } protected: // Returns last active window in the controller or first window. ui::BaseWindow* GetLastActiveWindow(); private: friend class ChromeLauncherControllerTest; // Returns the action performed. Should be one of SHELF_ACTION_NONE, // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. ash::ShelfAction ShowAndActivateOrMinimize(ui::BaseWindow* window); // Activate the given |window_to_show|, or - if already selected - advance to // the next window of similar type. // Returns the action performed. Should be one of SHELF_ACTION_NONE, // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_WINDOW_MINIMIZED. ash::ShelfAction ActivateOrAdvanceToNextAppWindow( ui::BaseWindow* window_to_show); WindowList::iterator GetFromNativeWindow(aura::Window* window); // Handles the case when the app window in this controller has been changed, // and sets the new controller icon based on the currently active window. void UpdateShelfItemIcon(); // List of associated app windows WindowList windows_; // Pointer to the most recently active app window // TODO(khmel): Get rid of |last_active_window_| and provide more reliable // way to determine active window. ui::BaseWindow* last_active_window_ = nullptr; // Scoped list of observed windows (for removal on destruction) ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_{this}; std::unique_ptr<LauncherContextMenu> context_menu_; DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController); }; #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
[ "rjkroege@chromium.org" ]
rjkroege@chromium.org
01ab3060210372ed4f23f3da3812cdd6fce86957
fecea3684862892ee1abd1d88201b693948e622d
/code/source/playfab/OneDSEventsApi.cpp
bb1d5ae837ede76a2134b3f1365fbb467e6e74bb
[ "Apache-2.0" ]
permissive
v-yuehxu/XPlatCppSdk
299a8e849be7e6f657486472c51771f4b731f881
f86ea3223a50ff0ed6eead42cda4a9115e9a5064
refs/heads/master
2020-04-14T22:32:57.016378
2018-12-21T18:39:32
2018-12-21T18:39:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,485
cpp
#include <stdafx.h> #ifndef DISABLE_ONEDS_API #include <playfab/OneDSHttpPlugin.h> #include <playfab/OneDSEventsApi.h> #include <playfab/PlayFabPluginManager.h> #include <playfab/PlayFabSettings.h> #include <playfab/PlayFabError.h> #include "../external/aria/lib/include/public/Enums.hpp" #include "../external/aria/lib/include/public/Version.hpp" #include "../external/aria/lib/include/aria/Config.hpp" #include "../external/aria/lib/bond/generated/AriaProtocol_types.hpp" #include "../external/aria/lib/bond/generated/AriaProtocol_writers.hpp" #include "../external/aria/lib/bond/generated/AriaProtocol_readers.hpp" #include "../external/aria/bondlite/include/bond_lite/CompactBinaryProtocolWriter.hpp" #include "../external/aria/bondlite/include/bond_lite/Common.hpp" #pragma warning (disable: 4100) // formal parameters are part of a public interface // This file contains implementation of the main interface for OneDS (One Data Collector) events API. // It requires OneDS protocol handling and Common Schema 3.0 serialization. // A lot of the code included and referenced in this file is based on or was surgically taken from Aria OneDS SDK // to provide minimum required functionality to support OneDS events without bringing the whole Aria SDK as a dependency. // The references to original sources are provided in the comments to each method below. namespace PlayFab { using namespace EventsModels; using namespace Microsoft::Applications::Events; uint64_t oneDSEventSequenceId = 0; // Validates a OneDS event name. This is taken from Aria SDK (see its Utils.cpp). EventRejectedReason ValidateOneDSEventName(std::string const& name) { // Data collector uses this regex (avoided here for code size reasons): // ^[a-zA-Z0-9]([a-zA-Z0-9]|_){2,98}[a-zA-Z0-9]$ if (name.length() < 1 + 2 + 1 || name.length() > 1 + 98 + 1) { //LOG_ERROR("Invalid event name - \"%s\": must be between 4 and 100 characters long", name.c_str()); return REJECTED_REASON_VALIDATION_FAILED; } auto filter = [](char ch) -> bool { return !isalnum(static_cast<uint8_t>(ch)) && (ch != '_') && (ch != '.'); }; if (std::find_if(name.begin(), name.end(), filter) != name.end()) { //LOG_ERROR("Invalid event name - \"%s\": must contain [0-9A-Za-z_] characters only", name.c_str()); return REJECTED_REASON_VALIDATION_FAILED; } return REJECTED_REASON_OK; } // Validates a OneDS event's property name. This is taken from Aria SDK (see its Utils.cpp). EventRejectedReason ValidateOneDSPropertyName(std::string const& name) { // Data collector does not seem to validate property names at all. // The ObjC SDK uses this regex (avoided here for code size reasons): // ^[a-zA-Z0-9](([a-zA-Z0-9|_|.]){0,98}[a-zA-Z0-9])?$ if (name.length() < 1 + 0 || name.length() > 1 + 98 + 1) { //LOG_ERROR("Invalid property name - \"%s\": must be between 1 and 100 characters long", name.c_str()); return REJECTED_REASON_VALIDATION_FAILED; } auto filter = [](char ch) -> bool { return !isalnum(static_cast<uint8_t>(ch)) && (ch != '_') && (ch != '.'); }; if (std::find_if(name.begin(), name.end(), filter) != name.end()) { //LOG_ERROR("Invalid property name - \"%s\": must contain [0-9A-Za-z_.] characters only", name.c_str()); return REJECTED_REASON_VALIDATION_FAILED; } if ((name.front() == '.' || name.back() == '.') /* || (name.front() == '_' || name.back() == '_') */) { //LOG_ERROR("Invalid property name - \"%s\": must not start or end with _ or . characters", name.c_str()); return REJECTED_REASON_VALIDATION_FAILED; } return REJECTED_REASON_OK; } // Decorator of a OneDS record. The content of this decorator is heavily based on the code in Aria's SDK (see its Logger and decorators implementation). bool DecorateOneDSRecord(AriaProtocol::Record& record, EventContents const& eventContents, const std::string& oneDSProjectIdIkey, const std::string& oneDSHeaderJwtTicketKey) { // --- Default parameters used in the Aria sample app: EventLatency eventLatency = EventLatency::EventLatency_Normal; EventPersistence eventPersistence = EventPersistence::EventPersistence_Normal; double eventPopSample = 100; std::string initId = "B8F9A36D-3677-42FF-BE0E-73D3A97A2E74"; std::string installId = "C34A2D50 - CB8A - 4330 - B249 - DDCAB22B2975"; // --- Apply common decoration record.name = eventContents.Name; if (record.name.empty()) { record.name = "NotSpecified"; } record.baseType = EVENTRECORD_TYPE_CUSTOM_EVENT; record.iKey = oneDSProjectIdIkey; // --- Apply base decoration if (record.extSdk.size() == 0) { AriaProtocol::Sdk sdk; record.extSdk.push_back(sdk); } record.time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); record.ver = "3.0"; if (record.baseType.empty()) { record.baseType = record.name; } record.extSdk[0].seq = ++oneDSEventSequenceId; record.extSdk[0].epoch = initId; std::string sdkVersion = std::string("EVT-PlayFab-XPlat-C++-No-") + BUILD_VERSION_STR; record.extSdk[0].libVer = sdkVersion; record.extSdk[0].installId = installId; //m_owner.GetLogSessionData()->getSessionSDKUid(); // set Tickets record.extProtocol.push_back(::AriaProtocol::Protocol()); std::vector<std::string> ticketKeys; ticketKeys.push_back(oneDSHeaderJwtTicketKey); record.extProtocol[0].ticketKeys.push_back(ticketKeys); // --- Apply semantic context decoration if (record.data.size() == 0) { AriaProtocol::Data data; record.data.push_back(data); } if (record.extApp.size() == 0) { AriaProtocol::App app; record.extApp.push_back(app); } if (record.extDevice.size() == 0) { AriaProtocol::Device device; record.extDevice.push_back(device); } if (record.extOs.size() == 0) { AriaProtocol::Os os; record.extOs.push_back(os); } if (record.extUser.size() == 0) { AriaProtocol::User user; record.extUser.push_back(user); } if (record.extLoc.size() == 0) { AriaProtocol::Loc loc; record.extLoc.push_back(loc); } if (record.extNet.size() == 0) { AriaProtocol::Net net; record.extNet.push_back(net); } if (record.extProtocol.size() == 0) { AriaProtocol::Protocol proto; record.extProtocol.push_back(proto); } // --- Apply properties decoration if (eventLatency == EventLatency_Unspecified) eventLatency = EventLatency_Normal; if (eventContents.Name.empty()) { // OK, using some default set by earlier decorator. } else { EventRejectedReason isValidEventName = ValidateOneDSEventName(eventContents.Name); if (isValidEventName != REJECTED_REASON_OK) { //LOG_ERROR("Invalid event properties!"); return false; } } record.popSample = eventPopSample; int64_t flags = 0; if (EventPersistence_Critical == eventPersistence) { flags = flags | 0x02; } else { flags = flags | 0x01; } if (eventLatency >= EventLatency_RealTime) { flags = flags | 0x0200; } else if (eventLatency == EventLatency_CostDeferred) { flags = flags | 0x0300; } else { flags = flags | 0x0100; } record.flags = flags; std::map<std::string, ::AriaProtocol::Value>& ext = record.data[0].properties; std::map<std::string, ::AriaProtocol::Value> extPartB; for (auto &propName : eventContents.Payload.getMemberNames()) { EventRejectedReason isValidPropertyName = ValidateOneDSPropertyName(propName); if (isValidPropertyName != REJECTED_REASON_OK) { return false; } const auto &v = eventContents.Payload[propName]; std::vector<uint8_t> guid; switch (v.type()) { case Json::ValueType::stringValue: { AriaProtocol::Value temp; temp.stringValue = v.asString(); ext[propName] = temp; break; } case Json::ValueType::intValue: { AriaProtocol::Value temp; temp.type = ::AriaProtocol::ValueKind::ValueInt64; temp.longValue = v.asInt64(); ext[propName] = temp; break; } case Json::ValueType::uintValue: { AriaProtocol::Value temp; temp.type = ::AriaProtocol::ValueKind::ValueUInt64; temp.longValue = v.asUInt64(); ext[propName] = temp; break; } case Json::ValueType::realValue: { AriaProtocol::Value temp; temp.type = ::AriaProtocol::ValueKind::ValueDouble; temp.doubleValue = v.asDouble(); ext[propName] = temp; break; } case Json::ValueType::booleanValue: { AriaProtocol::Value temp; temp.type = ::AriaProtocol::ValueKind::ValueBool; temp.longValue = v.asBool(); ext[propName] = temp; break; } case Json::ValueType::arrayValue: { AriaProtocol::Value temp; temp.type = ::AriaProtocol::ValueKind::ValueArrayString; temp.stringValue = v.asString(); ext[propName] = temp; break; } default: { // Convert all unknown types to string AriaProtocol::Value temp; temp.stringValue = v.asString(); ext[propName] = temp; } } } if (extPartB.size() > 0) { AriaProtocol::Data partBdata; partBdata.properties = extPartB; record.baseData.push_back(partBdata); } return true; } size_t OneDSEventsAPI::Update() { IPlayFabHttpPlugin& http = *PlayFabPluginManager::GetPlugin<IPlayFabHttpPlugin>(PlayFabPluginContract::PlayFab_Transport, PLUGIN_TRANSPORT_ONEDS); return http.Update(); } void OneDSEventsAPI::SetCredentials(const std::string& projectIdIkey, const std::string& ingestionKey, const std::string& jwtToken, const std::string& headerJwtTicketKey, const std::string& headerJwtTicketPrefix) { oneDSProjectIdIkey = projectIdIkey; oneDSIngestionKey = ingestionKey; oneDSJwtToken = jwtToken; oneDSHeaderJwtTicketKey = headerJwtTicketKey; oneDSHeaderJwtTicketPrefix = headerJwtTicketPrefix; isOneDSAuthenticated = true; } void OneDSEventsAPI::ForgetAllCredentials() { isOneDSAuthenticated = false; oneDSProjectIdIkey = ""; oneDSIngestionKey = ""; oneDSJwtToken = ""; oneDSHeaderJwtTicketKey = ""; oneDSHeaderJwtTicketPrefix = ""; } bool OneDSEventsAPI::GetIsOneDSAuthenticated() const { return isOneDSAuthenticated; } void OneDSEventsAPI::GetTelemetryIngestionConfig( TelemetryIngestionConfigRequest& request, ProcessApiCallback<TelemetryIngestionConfigResponse> callback, ErrorCallback errorCallback, void* customData ) { IPlayFabHttpPlugin& http = *PlayFabPluginManager::GetPlugin<IPlayFabHttpPlugin>(PlayFabPluginContract::PlayFab_Transport); const auto requestJson = request.ToJson(); Json::FastWriter writer; std::string jsonAsString = writer.write(requestJson); std::unordered_map<std::string, std::string> headers; headers.emplace("X-EntityToken", PlayFabSettings::entityToken); auto reqContainer = std::unique_ptr<CallRequestContainer>(new CallRequestContainer( "/Event/GetTelemetryIngestionConfig", headers, jsonAsString, OnGetTelemetryIngestionConfigResult, customData)); reqContainer->successCallback = std::shared_ptr<void>((callback == nullptr) ? nullptr : new ProcessApiCallback<TelemetryIngestionConfigResponse>(callback)); reqContainer->errorCallback = errorCallback; http.MakePostRequest(std::unique_ptr<CallRequestContainerBase>(static_cast<CallRequestContainerBase*>(reqContainer.release()))); } void OneDSEventsAPI::OnGetTelemetryIngestionConfigResult(int httpCode, std::string result, std::unique_ptr<CallRequestContainerBase> reqContainer) { CallRequestContainer& container = static_cast<CallRequestContainer&>(*reqContainer); TelemetryIngestionConfigResponse outResult; if (ValidateResult(outResult, container)) { const auto internalPtr = container.successCallback.get(); if (internalPtr != nullptr) { const auto callback = (*static_cast<ProcessApiCallback<TelemetryIngestionConfigResponse> *>(internalPtr)); callback(outResult, container.GetCustomData()); } } } void OneDSEventsAPI::WriteTelemetryEvents( WriteEventsRequest& request, ProcessApiCallback<EventsModels::OneDSWriteEventsResponse> callback, ErrorCallback errorCallback, void* customData ) { if (!isOneDSAuthenticated) { PlayFabError result; result.ErrorCode = PlayFabErrorCode::PlayFabErrorAuthTokenDoesNotExist; result.ErrorName = "OneDSError"; result.ErrorMessage = "OneDS API client is not authenticated. Please make sure OneDS credentials are set."; if (PlayFabSettings::globalErrorHandler != nullptr) PlayFabSettings::globalErrorHandler(result, customData); if (errorCallback != nullptr) errorCallback(result, customData); return; } // get transport plugin for OneDS IPlayFabHttpPlugin& http = *PlayFabPluginManager::GetPlugin<IPlayFabHttpPlugin>(PlayFabPluginContract::PlayFab_Transport, PLUGIN_TRANSPORT_ONEDS); std::vector<uint8_t> serializedBatch; bond_lite::CompactBinaryProtocolWriter batchWriter(serializedBatch); for (const auto& event : request.Events) { AriaProtocol::Record record; if (DecorateOneDSRecord(record, event, oneDSProjectIdIkey, oneDSHeaderJwtTicketKey)) { // OneDS record was composed successfully, // serialize it std::vector<uint8_t> serializedRecord; bond_lite::CompactBinaryProtocolWriter recordWriter(serializedRecord); bond_lite::Serialize(recordWriter, record); // add to OneDS batch serialization batchWriter.WriteBlob(serializedRecord.data(), serializedRecord.size()); } } // send batch std::unordered_map<std::string, std::string> headers; headers.emplace("APIKey", oneDSIngestionKey); headers.emplace("Tickets", "\"" + oneDSHeaderJwtTicketKey + "\": \"" + oneDSHeaderJwtTicketPrefix + ":" + oneDSJwtToken + "\""); auto reqContainer = std::unique_ptr<OneDSCallRequestContainer>(new OneDSCallRequestContainer( headers, serializedBatch, OnWriteTelemetryEventsResult, customData)); reqContainer->successCallback = std::shared_ptr<void>((callback == nullptr) ? nullptr : new ProcessApiCallback<OneDSWriteEventsResponse>(callback)); reqContainer->errorCallback = errorCallback; http.MakePostRequest(std::unique_ptr<CallRequestContainerBase>(static_cast<CallRequestContainerBase*>(reqContainer.release()))); } void OneDSEventsAPI::OnWriteTelemetryEventsResult(int httpCode, std::string result, std::unique_ptr<CallRequestContainerBase> reqContainer) { CallRequestContainer& container = static_cast<CallRequestContainer&>(*reqContainer); OneDSWriteEventsResponse outResult; if (ValidateResult(outResult, container)) { outResult.errorWrapper = &container.errorWrapper; const auto internalPtr = container.successCallback.get(); if (internalPtr != nullptr) { const auto callback = (*static_cast<ProcessApiCallback<OneDSWriteEventsResponse> *>(internalPtr)); callback(outResult, container.GetCustomData()); } } } bool OneDSEventsAPI::ValidateResult(PlayFabResultCommon& resultCommon, CallRequestContainer& container) { if (container.errorWrapper.ErrorCode == PlayFabErrorCode::PlayFabErrorSuccess) { resultCommon.FromJson(container.errorWrapper.Data); resultCommon.Request = container.errorWrapper.Request; return true; } else // Process the error case { if (PlayFabSettings::globalErrorHandler != nullptr) PlayFabSettings::globalErrorHandler(container.errorWrapper, container.GetCustomData()); if (container.errorCallback != nullptr) container.errorCallback(container.errorWrapper, container.GetCustomData()); return false; } } } #endif
[ "jenkins-bot@playfab.com" ]
jenkins-bot@playfab.com
55f91793fc49f8de8027eca9b2f3a572112a7585
9be239f5cfab351545dc6468a4ce791948e84ecb
/Mragpp/Window.cpp
8b63017c90708f45fe6bced992c9ee9d1ab51570
[ "MIT" ]
permissive
jabearis/MragPP
4a6baeb8ffbaab18e5c3e25748826985c1931881
96c1c5474ea552f364e6c04da7cc72923fdade0a
refs/heads/master
2020-03-28T00:38:36.945395
2015-09-03T11:01:29
2015-09-03T11:01:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
#include "StdH.h" #include "Window.h" #include <SDL.h> #include <GL/glew.h> MRAGPP_NAMESPACE_BEGIN; CWindow::CWindow() { win_pWindow = 0; } CWindow::CWindow(SDL_Window* pWindow) { win_pWindow = pWindow; } CWindow::~CWindow() { Destroy(); } void CWindow::Create(Scratch::String strTitle, int width, int height, ULONG ulFlags) { #if WINDOWS int iScreenWidth = GetSystemMetrics(SM_CXFULLSCREEN); int iScreenHeight = GetSystemMetrics(SM_CYFULLSCREEN); int iX = iScreenWidth / 2 - width / 2; int iY = iScreenHeight / 2 - height / 2; #else int iX = 70; int iY = 50; #endif win_pWindow = SDL_CreateWindow(strTitle, iX, iY, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | ulFlags); if(win_pWindow == 0) { printf("SDL window creation error: '%s'\n", SDL_GetError()); return; } } void CWindow::Destroy() { if(win_pWindow == 0) { return; } SDL_DestroyWindow(win_pWindow); win_pWindow = 0; } void CWindow::SetTitle(const Scratch::String &strTitle) { SDL_SetWindowTitle(win_pWindow, strTitle); } CWindow::operator SDL_Window*() { return win_pWindow; } MRAGPP_NAMESPACE_END;
[ "spansjh@gmail.com" ]
spansjh@gmail.com
c41e2a6ed16377386467c1d0cc52fcdbdc5ae36d
70418d8faa76b41715c707c54a8b0cddfb393fb3
/12223.cpp
f6848744914bcf48aa0eb6fadadffe7cae1d5c2e
[]
no_license
evandrix/UVa
ca79c25c8bf28e9e05cae8414f52236dc5ac1c68
17a902ece2457c8cb0ee70c320bf0583c0f9a4ce
refs/heads/master
2021-06-05T01:44:17.908960
2017-10-22T18:59:42
2017-10-22T18:59:42
107,893,680
3
1
null
null
null
null
UTF-8
C++
false
false
2,565
cpp
#include <bits/stdc++.h> using namespace std; #define esp 1e-6 #define pi acos(-1.0) #define inf 0x0f0f0f0f #define pb push_back #define lson l, m, rt << 1 #define rson m + 1, r, rt << 1 | 1 #define lowbit(x) (x & (-x)) #define mp(a, b) make_pair((a), (b)) #define bit(k) (1 << (k)) #define in freopen("solve_in.txt", "r", stdin); #define out freopen("solve_out.txt", "w", stdout); #define bug puts("********))))))"); #define inout in out #define SET(a, v) memset(a, (v), sizeof(a)) #define SORT(a) sort((a).begin(), (a).end()) #define REV(a) reverse((a).begin(), (a).end()) #define READ(a, n) \ { \ REP(i, n) \ cin >> (a)[i]; \ } #define REP(i, n) for (int i = 0; i < (n); i++) #define Rep(i, base, n) for (int i = base; i < n; i++) #define REPS(s, i) for (int i = 0; s[i]; i++) #define pf(x) ((x) * (x)) #define mod(n) ((n)) #define Log(a, b) (log((double)b) / log((double)a)) #define Srand() srand((int)time(0)) #define random(number) (rand() % number) #define random_range(a, b) (int)(((double)rand() / RAND_MAX) * (b - a) + a) typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef pair<int, int> PII; typedef vector<PII> VII; typedef vector<PII, int> VIII; typedef VI::iterator IT; typedef map<string, int> Mps; typedef map<int, int> Mpi; typedef map<int, PII> Mpii; typedef map<PII, int> Mpiii; const int maxn = 50000 + 100; VII g[maxn]; LL dp[maxn], cnt[maxn], num[maxn], Max; int n, m; void dfs(int u, int fa) { dp[u] = 0; cnt[u] = num[u]; REP(i, g[u].size()) { int v = g[u][i].first; int d = g[u][i].second; if (v == fa) { continue; } dfs(v, u); cnt[u] += cnt[v]; dp[u] += dp[v] + (LL)cnt[v] * d; } } void dfs1(int u, int fa) { REP(i, g[u].size()) { int v = g[u][i].first; int d = g[u][i].second; if (v == fa) { continue; } dp[v] += (dp[u] - dp[v] - (LL)d * cnt[v]) + (LL)d * (cnt[1] - cnt[v]); Max = min(Max, dp[v]); dfs1(v, u); } } int main() { for (int T, t = scanf("%d", &T); t <= T; t++) { REP(i, maxn) g[i].clear(), cnt[i] = num[i] = 0; scanf("%d", &n); REP(i, n - 1) { int u, v, d; scanf("%d%d%d", &u, &v, &d); g[u].pb(mp(v, d)); g[v].pb(mp(u, d)); } scanf("%d", &m); REP(i, m) { int u; scanf("%d", &u); scanf("%d", &num[u]); } dfs(1, 1); Max = dp[1]; dfs1(1, 1); int ok = 0; printf("%lld\n", Max * 2); Rep(i, 1, n + 1) { if (Max == dp[i]) { if (ok) { putchar(' '); } printf("%d", i); ok = 1; } } puts(""); } return 0; }
[ "yleewei@dso.org.sg" ]
yleewei@dso.org.sg
2033201a270c40157b354665de5f8ca9af01dea1
a7b4206055a590f7eeabd3a09032ea17ea0a3b01
/src/Visualisation/ImageWindow.cpp
b8b1864ffa6302c054888e34b7cc1c1871687a46
[]
no_license
duncanfrost/PSLAM
d28e4ac0198f7393d248626b51f70396bf676195
1727e52534a2e147d14ad4fa04a9ad882105da8e
refs/heads/master
2020-12-24T14:36:18.717974
2015-02-05T16:19:00
2015-02-05T16:19:00
30,294,524
0
0
null
null
null
null
UTF-8
C++
false
false
1,202
cpp
//Copyright 2008 Isis Innovation Limited #include "ImageWindow.h" static int nb_Image_windows=0; namespace ImageWindowNs { TextureSet tempTextureImageWindow; } using namespace ImageWindowNs; ImageWindow::ImageWindow(std::string _title,amoVideoSource *_vid_source) { title=_title; vid_source=_vid_source; width=vid_source->getSize()[0]; height=vid_source->getSize()[1]; pt_img=NULL; nb_Image_windows++; //vid_source2=_vid_source; } ImageWindow::ImageWindow(std::string _title,cv::Mat *_img) { title=_title; pt_img=_img; width=pt_img->cols; height=pt_img->rows; vid_source=NULL; nb_Image_windows++; } void ImageWindow::prepare_draw() { cv::Mat *ptmimFrame; if(pt_img==NULL) ptmimFrame=vid_source->GetFramePointer(); else ptmimFrame=pt_img; LoadTexture(*ptmimFrame,tempTextureImageWindow); //use to be in drawImageWindow but was causing a synchronisation problem glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); DrawTextureBackground(tempTextureImageWindow); } void ImageWindow::CreateWindow() { #ifdef AMOVERBOSE std::cout<<"ImageWindow::CreateWindow()"<<std::endl; #endif glutInitWindowSize(width, height); window = glutCreateWindow(title.c_str()); }
[ "frosd01@gmail.com" ]
frosd01@gmail.com
bbbe75c6d8fd13b149cf73aff8502f23cab13bca
5b86fc7a21376a3878db0d195c8fa1f5740018cb
/src/render_dump.cc
fa50e60021dbfc20f119b6b56be89d1e74ec4953
[]
no_license
nbirkbeck/ennes
0ffa63537d317c07dc6d5025130ace3d8b1031ec
0fbcbad8ee820ee182b51c202fabea84de2f9564
refs/heads/master
2020-12-15T05:14:41.663464
2020-01-20T23:50:54
2020-01-20T23:50:54
235,004,567
0
0
null
null
null
null
UTF-8
C++
false
false
3,226
cc
// This is a plugin for the nes emulator that allows us to extract some state // For example: // ./a.out --smb1_hack=1 --render_hook ~/Desktop/ennes/nes/render_dump.so smb1.nes #include "plugins/render_hook.h" #include "proto/render_state.pb.h" #include <iostream> #include <nimage/image.h> bool ConvertState(const RenderState& render_state, nes::RenderState* nes_state, bool copy_data = true) { if (copy_data) { nes_state->set_image_palette(render_state.image_palette, kPaletteSize); nes_state->set_sprite_palette(render_state.sprite_palette, kPaletteSize); for (int i = 0; i < 2; ++i) { nes_state->add_pattern_table(render_state.pattern_tables[i], kPatternTableSize); } nes_state->set_sprite_data(render_state.sprite_data, kSpriteDataSize); for (int i = 0; i < 4; ++i) { nes_state->add_name_table(render_state.name_tables[i], kNameTableSize); } } auto* ppu = nes_state->mutable_ppu(); ppu->set_sprite_pattern_table(render_state.ppu.sprite_pattern_table); ppu->set_screen_pattern_table(render_state.ppu.screen_pattern_table); ppu->set_sprite_8_by_16_size(render_state.ppu.sprite_8_by_16_size); ppu->set_hit_switch(render_state.ppu.hit_switch); ppu->set_vblank_switch(render_state.ppu.vblank_switch); ppu->set_hscroll(render_state.ppu.hscroll); ppu->set_vscroll(render_state.ppu.vscroll); ppu->set_vertical_mirror(render_state.ppu.vertical_mirror); ppu->set_name_table(render_state.ppu.name_table); ppu->set_scan_line(render_state.ppu.scan_line); return true; } class RenderDump : public RenderHook { public: void StartFrame(const RenderState& render_state) override { auto* frame_state = sequence_.add_frame_state(); ConvertState(render_state, frame_state->mutable_start_frame()); } void StateUpdate(const RenderState& render_state) override { auto* frame_state = sequence_.mutable_frame_state(sequence_.frame_state_size() - 1); ConvertState(render_state, frame_state->add_state_update(), false); } void EndFrame(const RenderState& render_state) override { auto* frame_state = sequence_.mutable_frame_state(sequence_.frame_state_size() - 1); ConvertState(render_state, frame_state->mutable_end_frame()); } void RenderedFrame(const uint8_t* image, int w, int h) override { if (frame_ % 30 == 0) { nacb::Image8 full_image(w, h, 3); memcpy(full_image.data, image, w * h * 3); char image_path[1024]; snprintf(image_path, sizeof(image_path), "/tmp/image-%04d.png", frame_); full_image.write(image_path); } if (frame_ % 300 == 0) { std::string bytes; sequence_.SerializeToString(&bytes); sequence_.Clear(); char image_path[1024]; snprintf(image_path, sizeof(image_path), "/tmp/data-%04d.pb", frame_); FILE* file = fopen(image_path, "w"); fwrite(bytes.data(), 1, bytes.size(), file); fclose(file); } frame_++; } bool WantRenderedFrame() override { return true; } int frame_ = 0; nes::RenderSequence sequence_; }; static RenderHook* render_hook = 0; extern "C" RenderHook* CreateRenderHook() { return (render_hook = new RenderDump); }
[ "neil.birkbeck@gmail.com" ]
neil.birkbeck@gmail.com
2bab384b80ce60e09c687ec5753dfe20e8722a7a
9089d5a653d6af99b0590f8a21125f9210ce1204
/test-codes/check.cpp
f739e36347afffcaf64d05c766d3057cf9ac2870
[]
no_license
ratnesh1729/algo_codes
9d54e3c68876f62f80b2683795c62ee4e1cf9a3b
3dc67b00d4bed14843b91c9a3545d6e327a9e240
refs/heads/master
2021-01-10T05:00:35.169069
2017-01-01T23:25:52
2017-01-01T23:25:52
55,922,603
0
1
null
null
null
null
UTF-8
C++
false
false
1,532
cpp
#include <iostream> #include <type_traits> template <bool Cond, typename T= void> using enable_if_t= typename std::enable_if<Cond, T>::type; template <typename T> using rref_only= enable_if_t<std::is_reference<T>::value>; template <typename T, typename= rref_only<T>> void check_enableif(T&& x) { std::cout << "Can call !!\n"; } //--------------------------------- template <typename T> void disp_type(const T& x) { std::cout << " [const&]." << std::endl; } template <typename T> void disp_type(T& x) { std::cout << " [&]." << std::endl; } template <typename T> void disp_type(T&& x) { std::cout << " [&&]." << std::endl; } //---------------------------------- template <typename T1> void mycheck(T1&& e) { disp_type(e); //should always choose lvalue overloads } template <typename T1> void pushback_forward(T1&& e) { } template <typename T1> void mycheck_forward(T1&& e) { disp_type(std::forward<T1>(e)); } int main(int argc, char* argv[]) { const int i = 1; int j = 2; std::cout << "Just check type " << std::endl; disp_type(i); disp_type(j); disp_type(5); std::cout << "More testing -- without forward" << std::endl; mycheck(i); mycheck(j); mycheck(5); std::cout << "More testing with forward " << std::endl; mycheck_forward(i); mycheck_forward(j); mycheck_forward(3); //check enable if std::cout << "\n Check enable if " << std::endl; check_enableif(i); check_enableif(j); //check_enableif(5);/// oops!! not allowed before ! compilation error return 0; }
[ "ratnesh1729@gmail.com" ]
ratnesh1729@gmail.com
7a2aa5596a7bbb5387d53cff4b27526156cd9e33
8fcb1c271da597ecc4aeb75855ff4b372b4bb05e
/UVA/TeXQuotes.cpp
6d50e049fd096f508fc330393b7942ef2c33d723
[ "Apache-2.0" ]
permissive
MartinAparicioPons/Competitive-Programming
9c67c6e15a2ea0e2aa8d0ef79de6b4d1f16d3223
58151df0ed08a5e4e605abefdd69fef1ecc10fa0
refs/heads/master
2020-12-15T21:33:39.504595
2016-10-08T20:40:10
2016-10-08T20:40:10
20,273,032
1
0
null
null
null
null
UTF-8
C++
false
false
624
cpp
#include <cstdio> #include <vector> #include <set> #include <queue> #include <stack> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <cstdlib> #define scd(x) scanf("%d", &x) #define scc(x) scanf("%c", &x) #define scd2(y,x) scanf("%d %d", &y, &x) #define prd(x) printf("%d\n", x) using namespace std; int main(){ int i, k=0, n; char s[100000]; while(gets(s)){ for(n = strlen(s), i=0; i < n; i++){ if(s[i] == '"'){ if(k == 0){ printf("``"); k = 1; } else { printf("''"); k = 0; } } else { printf("%c", s[i]); } } printf("\n"); } }
[ "martin.aparicio.pons@gmail.com" ]
martin.aparicio.pons@gmail.com
648f3506df6fc88e655d1a3865d168c33152d430
1a61e8d323e98836efe55fa34704031244feb5ac
/openML/OS/WIN32DLL/QueryTester/QueryTestDlg.h
8c7061ebfe41a3bca7b7dfc14025955496d8e2c9
[]
no_license
skwoo/openLamp
0d37c59d239af6c851cfff48d5db5e32511ceae3
68bffd42f91a9978b4c8bf1df1b39f821acbe093
refs/heads/master
2022-01-10T04:40:30.881034
2019-07-05T04:04:48
2019-07-05T04:04:48
106,556,078
0
1
null
2019-07-05T04:04:49
2017-10-11T13:12:58
C
UHC
C++
false
false
2,556
h
/* This file is part of openML, mobile and embedded DBMS. Copyright (C) 2012 Inervit Co., Ltd. support@inervit.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ // QueryTestDlg.h : header file // #if !defined(AFX_QUERYTESTDLG_H__E9B40862_D106_4DB6_833B_65F6C1125DF6__INCLUDED_) #define AFX_QUERYTESTDLG_H__E9B40862_D106_4DB6_833B_65F6C1125DF6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "QueryTest.h" ///////////////////////////////////////////////////////////////////////////// // CQueryTestDlg dialog class CQueryTestDlg : public CDialog { // Construction public: int SelectProcess(char* _cquery); CQueryTestDlg(CWnd* pParent = NULL); // standard constructor CArray<CString, CString&> m_FetchRow; //select 쿼리 수행한 결과 데이터 저장변수 int m_nFetchSize; int m_nField; int m_nSel; iSQL_RES *res; iSQL_ROW row; // Dialog Data //{{AFX_DATA(CQueryTestDlg) enum { IDD = IDD_QUERYTEST_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CQueryTestDlg) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); //}}AFX_VIRTUAL // Implementation protected: HICON m_hIcon; // Generated message map functions //{{AFX_MSG(CQueryTestDlg) virtual BOOL OnInitDialog(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnButtonExit(); afx_msg void OnButtonExe(); afx_msg void OnButtonConnect(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_QUERYTESTDLG_H__E9B40862_D106_4DB6_833B_65F6C1125DF6__INCLUDED_)
[ "skwoo67@gmail.com" ]
skwoo67@gmail.com
85e8ba51fe5b37c0802bd3816d01f95657ab2a9e
ad63d31880514f2cd8b3f49b9a6deaf890a20735
/Fibonacci.cpp
def70a87333343a2c7c5821f7f6d827f381aac37
[]
no_license
geekz93/essemtial_cpp_unit4_to_6
f406fec3025570a31f26fd446d46a94783e169dc
feb6cae26ae0ddd754c634f2ab1492423d0378a7
refs/heads/master
2021-01-17T17:28:56.506055
2016-07-27T08:18:13
2016-07-27T08:18:13
64,292,545
0
0
null
null
null
null
GB18030
C++
false
false
493
cpp
#include "Fibonacci.h" #include "num_seq_base.h" vector<int> Fibonacci::_elems; //是什么使用了const还可以对_elems进行添加数据 void Fibonacci:: gen_elems(int pos) const { if (_elems.empty()) { _elems.push_back(1); _elems.push_back(1); } if (_elems.size() < pos) { int ix = _elems.size(); int n_2 = _elems[ix - 2]; int n_1 = _elems[ix - 1]; for (; ix < pos; ++ix) { int elem = n_2 + n_1; _elems.push_back(elem); n_2 = n_1; n_1 = elem; } } }
[ "imzooo@163.com" ]
imzooo@163.com
c823da62a4156d15ab6611ea1f7fded3533a2c61
8442f074cfeecb4ca552ff0d6e752f939d6326f0
/1294C Product of Three Numbers.cpp
9900d8c2de2cb452d9c10963c2a78160089ebe68
[]
no_license
abufarhad/Codeforces-Problems-Solution
197d3f351fc01231bfefd1c4057be80643472502
b980371e887f62040bee340a8cf4af61a29eac26
refs/heads/master
2021-06-15T16:35:07.327687
2021-03-23T17:29:49
2021-03-23T17:29:49
170,741,904
43
32
null
null
null
null
UTF-8
C++
false
false
1,010
cpp
#include<bits/stdc++.h> #include<stdio.h> using namespace std; #define ll long long #define scl(n) cin>>n; #define scc(c) cin>>c; #define fr(i,n) for (ll i=0;i<n;i++) #define fr1(i,n) for(ll i=1;i<=n;i++) #define pfl(x) printf("%lld\n",x) #define pb push_back #define l(s) s.size() #define asort(a) sort(a,a+n) #define all(x) (x).begin(), (x).end() #define dsort(a) sort(a,a+n,greater<int>()) #define vasort(v) sort(v.begin(), v.end()); #define vdsort(v) sort(v.begin(), v.end(),greater<int>()); int main() { ll t; cin>>t; while(t--) { ll n,i; ll cnt=0,ans=0,sum=0; scl(n); ll f[3]; for(i=2; i*i<n and cnt<2; i++) if(n%i==0)f[cnt++]=i, n/=i; //fr(i, cnt)cout<<f[i]<<" "; cout<<endl; if(cnt!=2)cout<<"NO"<<endl; else printf("YES\n%lld %lld %lld\n", f[0], f[1], n); } return 0; }
[ "abufarhad15@gmail.com" ]
abufarhad15@gmail.com
733d493e3a5321d5c4d41078d0fdedc857dbe62f
9a184dde23113f9cec922719942ff54a0c4a671c
/difficultcharacters.cpp
73abe2f98321d423c2416e7d111eb5cb0bbee371
[]
no_license
shivam2207/HackerRank-Solutions
8f51ee93a42900097f669111a976b6e40a093a68
53da486405c5f97f86d34c9e6188dd28e0dc17b0
refs/heads/master
2020-03-08T00:43:40.898005
2018-04-02T21:09:05
2018-04-02T21:09:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
598
cpp
#include <iostream> #include <string> #include <algorithm> using namespace std; typedef struct data { int count; char ch; int index; }data; bool compare(data a,data b) { return a.count<=b.count; } int main() { int t; cin >> t; while(t--) { string s; cin >> s; int n=s.size(),i,temp; data array[26]; for(i=0;i<26;i++) { array[i].count=0; array[i].index=i; array[i].ch=(char)i+97; } for(i=0;i<n;i++) { temp=s[i]-'a'; array[temp].count++; } sort(array,array+n,compare); for(i=0;i<26;i++) { cout<<array[i].ch<<" "; } cout << "\n"; } return 0; }
[ "shivamkhare2207@gmail.com" ]
shivamkhare2207@gmail.com
21b5e3d4eca8e7259ea84e146ca47e4dd04d9ecf
57c96d0f4fbb3cc844ffe45c06aecea599d5de7a
/include/sdd_protocol/connect/QSerialPortConnection.h
5f6bdbf4c0fabe7ccc51ff9874995c9978d5cf33
[]
no_license
ageev-aleksey/sppu
fd493b857bc64ad1f9865e4723a2d7ecc6a3d295
8a741b6b46752711793b30cf19e174724f86efc2
refs/heads/master
2023-04-26T04:19:54.710052
2021-06-09T09:06:10
2021-06-09T09:06:10
313,399,113
0
0
null
2021-06-13T17:24:21
2020-11-16T18:58:39
Jupyter Notebook
UTF-8
C++
false
false
1,811
h
// // Created by nrx on 14.01.2021. // #ifndef TESTSIMULINKMODEL_QCOMPORT_H #define TESTSIMULINKMODEL_QCOMPORT_H #include "sdd_protocol/connect/QIConnection.h" #include "sdd_protocol/connect/PackageBuffer.h" #include "sdd_protocol/Package.h" #include <QtCore> #include <QtSerialPort> #include <memory> #include <mutex> #include <condition_variable> #include <sdd_protocol/StatePackage.h> // TODO(ageev) Выделить все пакате протокола в отдельный интерфейс, что бы можно было сделать фабрику для // разных видов протокола namespace sdd::conn { class QSerialPortConnection : public QIConnection { Q_OBJECT public: explicit QSerialPortConnection(); void setPort(std::shared_ptr<QSerialPort> port); State recvState() ; void sendLight(Light package) override; void sendMode(Mode package) override; void sendTaskPosition(TaskPosition task) override; void sendPwm(Pwm pwm) override; public slots: void send(Package &package); private slots: void readIsReady(); private: void packageWrite(Package *pack); bool read(StatePackage &package, size_t readSize); bool callbackIsContain(const std::function<Handle> &handler); State statePackageToStruct(sdd::StatePackage &pack); int64_t m_currentIndex; std::shared_ptr<QSerialPort> m_serialPort; QMetaObject::Connection m_qtEventConnection; std::vector<std::function<Handle>> m_callBacks; std::mutex m_mutex; std::condition_variable m_cv; PackageBuffer m_buffer; QFile m_file; }; } #endif //TESTSIMULINKMODEL_QCOMPORT_H
[ "ageevav97@gmail.com" ]
ageevav97@gmail.com
9d999ec24bbeee5059da159d7c6bb8238aa5fbfa
715023da006513f0dd09e5c4267d371b8ba4e4f6
/xray-svn-trunk/xr_3da/xrGame/ui/UICarBodyWnd.h
ecdefa2b9288b2eaeee49767b1dd9271a76bba56
[]
no_license
tsnest/lost-alpha-dc-sources-master
5727d58878b1d4036e8f68df9780f3d078e89f21
fbb61af25da7e722d21492cbaebd6670d84e211c
refs/heads/main
2023-02-11T16:37:16.570856
2021-01-09T17:09:49
2021-01-09T17:09:49
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,801
h
#pragma once #include "UIDialogWnd.h" #include "UIEditBox.h" #include "../inventory_space.h" class CUIDragDropListEx; class CUIItemInfo; class CUITextWnd; class CUICharacterInfo; class CUIPropertiesBox; class CUI3tButton; class CUICellItem; class CInventoryBox; class CInventoryOwner; class CCar; class CUICarBodyWnd: public CUIDialogWnd { private: typedef CUIDialogWnd inherited; bool m_b_need_update; void ColorizeItem(CUICellItem* itm); public: CUICarBodyWnd (); virtual ~CUICarBodyWnd (); virtual void Init (); virtual bool StopAnyMove (){return true;} virtual void SendMessage (CUIWindow *pWnd, s16 msg, void *pData); void InitCarBody (CInventoryOwner* pOurInv, CInventoryOwner* pOthersInv); void InitCarBody (CInventoryOwner* pOur, CInventoryBox* pInvBox); //void InitCarBody (CInventoryOwner* pOur, CInventory* pInv); virtual void Draw (); virtual void Update (); virtual void ShowDialog (bool bDoHideIndicators); virtual void HideDialog (); void DisableAll (); void EnableAll (); virtual bool OnKeyboardAction (int dik, EUIMessages keyboard_action); void UpdateLists_delayed (); protected: CInventoryOwner* m_pOurObject; CInventoryOwner* m_pOthersObject; CInventoryBox* m_pInventoryBox; CInventory* m_pInventory; CCar* m_pCar; CUIDragDropListEx* m_pUIOurBagList; CUIDragDropListEx* m_pUIOthersBagList; CUIStatic* m_pUIStaticTop; CUIStatic* m_pUIStaticBottom; CUIFrameWindow* m_pUIDescWnd; CUIStatic* m_pUIStaticDesc; CUIItemInfo* m_pUIItemInfo; CUIStatic* m_pUIOurBagWnd; CUIStatic* m_pUIOthersBagWnd; //информация о персонажах CUIStatic* m_pUIOurIcon; CUIStatic* m_pUIOthersIcon; CUICharacterInfo* m_pUICharacterInfoLeft; CUICharacterInfo* m_pUICharacterInfoRight; CUIPropertiesBox* m_pUIPropertiesBox; CUI3tButton* m_pUITakeAll; CUICellItem* m_pCurrentCellItem; void UpdateLists (); void ActivatePropertiesBox (); void EatItem (); bool ToOurBag (); bool ToOthersBag (); void SetCurrentItem (CUICellItem* itm); CUICellItem* CurrentItem (); PIItem CurrentIItem (); // Взять все void TakeAll (); bool xr_stdcall OnItemDrop (CUICellItem* itm); bool xr_stdcall OnItemStartDrag (CUICellItem* itm); bool xr_stdcall OnItemDbClick (CUICellItem* itm); bool xr_stdcall OnItemSelected (CUICellItem* itm); bool xr_stdcall OnItemRButtonClick (CUICellItem* itm); bool TransferItem (PIItem itm, CInventoryOwner* owner_from, CInventoryOwner* owner_to, bool b_check); void BindDragDropListEvents (CUIDragDropListEx* lst); };
[ "58656613+NikitaNikson@users.noreply.github.com" ]
58656613+NikitaNikson@users.noreply.github.com
5d3cbee45d31b131084b9cecbb993f9118b1dca0
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
/sstd_boost/sstd/libs/regex/test/regress/test_regex_replace.hpp
416e1148e312961589666eec33598e080257ffae
[ "BSL-1.0" ]
permissive
KqSMea8/sstd_library
9e4e622e1b01bed5de7322c2682539400d13dd58
0fcb815f50d538517e70a788914da7fbbe786ce1
refs/heads/master
2020-05-03T21:07:01.650034
2019-04-01T00:10:47
2019-04-01T00:10:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,475
hpp
/* * * Copyright (c) 2004 * John Maddock * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ /* * LOCATION: see http://www.boost.org for most recent version. * FILE test_regex_replace.hpp * VERSION see <sstd/boost/version.hpp> * DESCRIPTION: Declares tests for regex search and replace. */ #ifndef BOOST_REGEX_REGRESS_REGEX_REPLACE_HPP #define BOOST_REGEX_REGRESS_REGEX_REPLACE_HPP #include "info.hpp" template<class charT, class traits> void test_regex_replace(boost::basic_regex<charT, traits>& r) { typedef std::basic_string<charT> string_type; const string_type& search_text = test_info<charT>::search_text(); boost::regex_constants::match_flag_type opts = test_info<charT>::match_options(); const string_type& format_string = test_info<charT>::format_string(); const string_type& result_string = test_info<charT>::result_string(); string_type result = boost::regex_replace(search_text, r, format_string, opts); if(result != result_string) { BOOST_REGEX_TEST_ERROR("regex_replace generated an incorrect string result", charT); } } struct test_regex_replace_tag{}; template<class charT, class traits> void test(boost::basic_regex<charT, traits>& r, const test_regex_replace_tag&) { const std::basic_string<charT>& expression = test_info<charT>::expression(); boost::regex_constants::syntax_option_type syntax_options = test_info<charT>::syntax_options(); #ifndef BOOST_NO_EXCEPTIONS try #endif { r.assign(expression, syntax_options); if(r.status()) { BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done, error code = " << r.status(), charT); } test_regex_replace(r); } #ifndef BOOST_NO_EXCEPTIONS catch(const boost::bad_expression& e) { BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done: " << e.what(), charT); } catch(const std::runtime_error& e) { BOOST_REGEX_TEST_ERROR("Received an unexpected std::runtime_error: " << e.what(), charT); } catch(const std::exception& e) { BOOST_REGEX_TEST_ERROR("Received an unexpected std::exception: " << e.what(), charT); } catch(...) { BOOST_REGEX_TEST_ERROR("Received an unexpected exception of unknown type", charT); } #endif } #endif
[ "zhaixueqiang@hotmail.com" ]
zhaixueqiang@hotmail.com
2f6f231b0b3343a4f989fcb80d0635e83f3597be
b53748f529df52910b07672c45eda6a7958ff883
/program.cpp
ac15c008469a490756f778009f512ad710be3597
[]
no_license
laguniak16/Tablet
b8c756c719b9ecae6ce4f965b0e8448c39097ea3
734f788e907f86c7c2677c1403405ded28a51476
refs/heads/master
2020-08-04T08:14:17.179197
2020-06-29T10:27:19
2020-06-29T10:27:19
212,069,452
0
0
null
null
null
null
UTF-8
C++
false
false
3,980
cpp
/*#include <iostream> #include <string> #include "tablet.h" #include "przenosne.h" #include "stacjonarne.h" #include "urzadzenie_elektroniczne.h" #include <ctype.h> using namespace std; int opcja; int obiekt = 1; string nazwa; int main() { vector<Urzadzenie_elektroniczne*> urzadzenie; bool pusty = true; cout << "Domyslnie ustawiono obiekt tablet" << endl; do { switch (opcja) { case 0: cout << "MENU PROGRAMU" << endl; cout << "-------------------------------" << endl; cout << "Wybierz opcje:" << endl; cout << "1: Dodaj domyslny wybrany obiekt" << endl; cout << "2: Zapis obiektow do pliku" << endl; cout << "3: Odczyt obiektow z pliku" << endl; cout << "4: Wypisz zawartosc wektora" << endl; cout << "5: Testowanie polimorfizmu" << endl; cout << "6: Zamknij program" << endl; cout << "-------------------------------" << endl; cout << "Opcja: "; cin >> opcja; cin.clear(); cin.ignore(1000, '\n'); break; case 1: do { cout << "Wybierz Obiekt: " << endl; cout << "1-Tablet 2-Przenosne 3-Stacjonarne" << endl << "Obiekt: "; cin >> obiekt; cout << endl; } while (obiekt != 1 && obiekt != 2 && obiekt != 3); if (obiekt == 1) { Tablet *nowyt = new Tablet; urzadzenie.push_back(nowyt); } else if (obiekt == 2) { Przenosne *nowyp = new Przenosne; urzadzenie.push_back(nowyp); } else { Stacjonarne*nowys = new Stacjonarne; urzadzenie.push_back(nowys); } opcja = 0; break; case 2:fstream plik("pliczek.txt", ios::app); if (plik.good()) { if (urzadzenie.empty()) cout << "Nie ma obiektow w wektorze do zapisu" << endl; else { fstream plik("pliczek.txt", ios::app); for (int i = 0; i < urzadzenie.size(); i++) { urzadzenie[i]->zapis(plik); } } } else { cout << "plik nie istnieje"; } plik.close(); { opcja = 0; break; } case 3: { fstream plik("pliczek.txt", ios::in); string linia; Tablet *wczytajtablet; Przenosne *wczytajprzenosne; Stacjonarne *wczytajstacjonarne; if (plik.good()) { while (!plik.eof()) { getline(plik, linia); if (linia == "Tablet") { wczytajtablet = new Tablet; wczytajtablet->wczyt(plik); urzadzenie.push_back(wczytajtablet); pusty = false; } else if (linia == "Przenosne") { wczytajprzenosne = new Przenosne; wczytajprzenosne->wczyt(plik); urzadzenie.push_back(wczytajprzenosne); pusty = false; } else if (linia == "Stacjonarne") { wczytajstacjonarne = new Stacjonarne; wczytajstacjonarne->wczyt(plik); urzadzenie.push_back(wczytajstacjonarne); pusty = false; } else if (pusty == true) { cout << "Pusty plik" << endl; break; } } } else { cout << "plik nie istnieje"; } plik.close(); opcja = 0; break; } case 4: { system("cls"); if (urzadzenie.empty()) cout << "Nie ma obiektow w wektorze do wyswietlenia" << endl; else { cout << "Stan urzadzen: " << endl; for (int i = 0; i <urzadzenie.size(); i++) { urzadzenie[i]->wypisz_stan(); } } opcja = 0; break; } case 5: { Stacjonarne stacjonarne; Przenosne przenosne; Tablet tablet; vector <Urzadzenie_elektroniczne*> urzadzenie2; urzadzenie2.push_back(&tablet); urzadzenie2.push_back(&przenosne); urzadzenie2.push_back(&stacjonarne); cout << "Polimorfizm na podstawie wektora wskaznikow" << endl; for (int i = 0; i < 3; i++) { urzadzenie2[i]->wypisz_stan(); } cout << "Funkcja wypisz jest w kazdej z klas i w kazdej wypisuje inaczej" << endl; cout << "A po usunieci slowa virtual wypisuje jak funkcja klasy urzadzenie elektroniczne" << endl; opcja = 0; break; } default: { cout << "Zla opcja" <<endl; opcja = 0; } } } while (opcja != 6); }*/
[ "mateusz_laguna@o2.pl" ]
mateusz_laguna@o2.pl
2b58d1ff034fcb079535f17eb834c6c0b47c0ed1
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/curl/gumtree/curl_function_3759.cpp
293d591ea5e00a207d8d729e04ddaac565197361
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,431
cpp
void ourWriteOut(CURL *curl, const char *writeinfo) { FILE *stream = stdout; const char *ptr=writeinfo; char *stringp; long longinfo; double doubleinfo; while(*ptr) { if('%' == *ptr) { if('%' == ptr[1]) { /* an escaped %-letter */ fputc('%', stream); ptr+=2; } else { /* this is meant as a variable to output */ char *end; char keepit; int i; if(('{' == ptr[1]) && (end=strchr(ptr, '}'))) { bool match = FALSE; ptr+=2; /* pass the % and the { */ keepit=*end; *end=0; /* zero terminate */ for(i=0; replacements[i].name; i++) { if(curl_strequal(ptr, replacements[i].name)) { match = TRUE; switch(replacements[i].id) { case VAR_EFFECTIVE_URL: if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &stringp)) && stringp) fputs(stringp, stream); break; case VAR_HTTP_CODE: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &longinfo)) fprintf(stream, "%03ld", longinfo); break; case VAR_HTTP_CODE_PROXY: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &longinfo)) fprintf(stream, "%03ld", longinfo); break; case VAR_HEADER_SIZE: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &longinfo)) fprintf(stream, "%ld", longinfo); break; case VAR_REQUEST_SIZE: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo)) fprintf(stream, "%ld", longinfo); break; case VAR_NUM_CONNECTS: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &longinfo)) fprintf(stream, "%ld", longinfo); break; case VAR_REDIRECT_COUNT: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &longinfo)) fprintf(stream, "%ld", longinfo); break; case VAR_REDIRECT_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_TOTAL_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_NAMELOOKUP_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_CONNECT_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_PRETRANSFER_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_STARTTRANSFER_TIME: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_SIZE_UPLOAD: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &doubleinfo)) fprintf(stream, "%.0f", doubleinfo); break; case VAR_SIZE_DOWNLOAD: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &doubleinfo)) fprintf(stream, "%.0f", doubleinfo); break; case VAR_SPEED_DOWNLOAD: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_SPEED_UPLOAD: if(CURLE_OK == curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &doubleinfo)) fprintf(stream, "%.3f", doubleinfo); break; case VAR_CONTENT_TYPE: if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &stringp)) && stringp) fputs(stringp, stream); break; case VAR_FTP_ENTRY_PATH: if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &stringp)) && stringp) fputs(stringp, stream); break; case VAR_REDIRECT_URL: if((CURLE_OK == curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &stringp)) && stringp) fputs(stringp, stream); break; default: break; } break; } } if(!match) { fprintf(stderr, "curl: unknown --write-out variable: '%s'\n", ptr); } ptr=end+1; /* pass the end */ *end = keepit; } else { /* illegal syntax, then just output the characters that are used */ fputc('%', stream); fputc(ptr[1], stream); ptr+=2; } } } else if('\\' == *ptr) { switch(ptr[1]) { case 'r': fputc('\r', stream); break; case 'n': fputc('\n', stream); break; case 't': fputc('\t', stream); break; default: /* unknown, just output this */ fputc(*ptr, stream); fputc(ptr[1], stream); break; } ptr+=2; } else { fputc(*ptr, stream); ptr++; } } }
[ "993273596@qq.com" ]
993273596@qq.com
14cd6f53b1f194d483606c69f238a49adf4f7433
da44dc7263733742408ae87a98c98dc7cc41f163
/Lab_6.3-r/Source.cpp
36b4c3f18d9736e6007ca56f1ed6e0bdf6fce4ca
[]
no_license
YuliiaOsadchukkk/Lab_6.3-r
5f0f45f984d6c667062139973cd9fe40cfd5451b
4d777731cc5ca6b30ad2eecc194929bc87f145de
refs/heads/master
2023-01-20T00:17:46.205950
2020-11-29T20:01:21
2020-11-29T20:01:21
317,028,119
0
0
null
2020-11-29T20:01:23
2020-11-29T19:35:28
C++
WINDOWS-1251
C++
false
false
2,735
cpp
#include <iostream> #include <iomanip> using namespace std; void draw_line(const int& size, const char& c = '-') { cout << c; if (size > 1) { draw_line(size - 1, c); return; } cout << endl; } // 1 int myrand(const int& min, const int& max) { return min > 0 ? rand() % (max - min + 1) + min : rand() % (abs(min) + max + 1) + min; } void full_mass(int* mass, int size, const int* dia) { mass[size - 1] = myrand(dia[0], dia[1]); if (size > 1) full_mass(mass, size - 1, dia); } void draw_mass_recurs(const int* mass, const int& size, const int& c_space) { if (size > 1) draw_mass_recurs(mass, size - 1, c_space); cout << "|" << setw(c_space - 1) << mass[size - 1]; } void draw_mass(const int* mass, const int& size, const int& c_space) { draw_line(size * c_space + 2); draw_mass_recurs(mass, size, c_space); cout << " |" << endl; draw_line(size * c_space + 2); } int Sum(int* mass, const int size, int i) { if (i < size) { if (mass[i] % 2 != 0) return mass[i] + Sum(mass, size, i + 1); else return Sum(mass, size, i + 1); } else return 0; } // 2 template <typename T> T myrand_(const T& min, const T& max) { return (T)(min > 0 ? rand() % (max - min + 1) + min : rand() % (abs(min) + max + 1) + min); } template <typename T> void full_mass_(T* mass, int size, const T* dia) { mass[size - 1] = myrand(dia[0], dia[1]); if (size > 1) full_mass_<T>(mass, size - 1, dia); } template <typename T> void draw_mass_recurs_(const T* mass, const int& size, const int& c_space) { if (size > 1) draw_mass_recurs<T>(mass, size - 1, c_space); cout << "|" << setw(c_space - 1) << mass[size - 1]; } template <typename T> void draw_mass_(const T* mass, const int& size, const int& c_space) { draw_line(size * c_space + 2); draw_mass_recurs(mass, size, c_space); cout << " |" << endl; draw_line(size * c_space + 2); } template < typename T > T Sum(T* mass, int size, int i) { if (i < size) { if (mass[i] % 2 != 0) return mass[i] + Sum(mass, size, i + 1); else return Sum(mass, size, i + 1); } else return 0; } void main() { srand(time(NULL)); const int c_space = 4; // кількість містя яке виділяєьбся на одну комірку массиву, при виводі в консоль int dia[2], n; // діапазон, n cout << "n = "; cin >> n; cout << "dia start = "; cin >> dia[0]; cout << "dia end = "; cin >> dia[1]; int* mass = new int[n]; cout << "1" << endl; full_mass(mass, n, dia); draw_mass(mass, n, c_space); cout << "Sum1 = " << Sum(mass, n, 0) << endl; cout << "2" << endl; full_mass_(mass, n, dia); draw_mass_(mass, n, c_space); cout << "Sum2 = " << Sum<int>(mass, n, 0) << endl; delete[] mass; }
[ "72582368+YuliiaOsadchukkk@users.noreply.github.com" ]
72582368+YuliiaOsadchukkk@users.noreply.github.com
435a07e6fab2d089aa55ee5dcb59e69bc2159bb1
7dc2589f403c4a42310191f7449bc0603fe9d30d
/project-game/GameProject/Sun.h
68f31a88a8fe76f841b5c580bbd3ff75326e64e9
[]
no_license
SuganumaYutaka/city-project
c469eabc429af1e6495be83a081a984c6efce9ee
38269866f3d678fdfb56c6402d3e23281ce1298a
refs/heads/master
2022-12-01T21:40:16.152744
2022-11-25T08:55:44
2022-11-25T08:55:44
109,118,688
3
0
null
2018-02-14T06:11:33
2017-11-01T10:36:48
C++
UTF-8
C++
false
false
1,240
h
/*============================================================================== Sun.h - 太陽 Author : Yutaka Suganuma Date : 2017/8/16 ==============================================================================*/ #ifndef _SUN_H_ #define _SUN_H_ /*------------------------------------------------------------------------------ インクルードファイル ------------------------------------------------------------------------------*/ #include "Manager.h" #include "Component.h" /*------------------------------------------------------------------------------ 前方宣言 ------------------------------------------------------------------------------*/ class Camera; class Light; /*------------------------------------------------------------------------------ クラス定義 ------------------------------------------------------------------------------*/ class Sun : public Component { public: static Component* Create( GameObject* gameObject); Sun( GameObject* pGameObject); void Uninit( void); void SetFieldSize( const Vector3& size); virtual void Save( Text& text); virtual void Load( Text& text); private: void Update(); Camera* m_pCamera; Light* m_pLight; }; #endif
[ "yumetaigachibi@gmail.com" ]
yumetaigachibi@gmail.com
ff8ab998e988148c788ced5e52bf52d17b69a7ce
ec5168f927a2e6e577b1434ff6afb3a6920e919d
/BFS - Shortest Path.cpp
19b279d0ef6b4eda6c43db7c8566d451a887667e
[]
no_license
prabhsimar100/Backup-for-Codes-Competitive-Programming-
3e556e61b429f0b5ef7c0410deae9e3d486617ae
897c02aba520b8b8983bdcd2632103278373292d
refs/heads/master
2022-12-08T14:56:59.396630
2020-09-06T11:35:41
2020-09-06T11:35:41
293,262,987
0
0
null
2020-09-06T11:35:42
2020-09-06T11:32:13
C++
UTF-8
C++
false
false
2,064
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long int #define P pair<int,int> #define pb push_back vector<int> graph[1005]; void bfs(int distance[],int root, int n) { for (int i = 1; i <=n; ++i) { distance[i]=0; } queue<int> Q; Q.push(root); // for (int i = 0; i < graph[root].size(); ++i) // { // Q.push(graph[root][i]); // distance[graph[root][i]]=distance[root]+6; // } while(!Q.empty()) { int cur=Q.front(); Q.pop(); for (int i = 0; i < graph[cur].size(); ++i) { if(distance[graph[cur][i]]==0&&graph[cur][i]!=root) { Q.push(graph[cur][i]); distance[graph[cur][i]]=distance[cur]+6; } } } } int main(){ ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t; cin>>t; while(t--) { int n,m,u,v; cin>>n>>m; int distance[1005]; for (int i = 0; i < m; ++i) { cin>>u>>v; graph[u].pb(v); graph[v].pb(u); } int s; cin>>s; for (int i = 1; i <=n; ++i) { distance[i]=0; } distance[s]=0; bfs(distance,s,n); for (int i = 1; i <=n; ++i) { if(i!=s) if(distance[i]==0) cout<<-1<<" "; else cout<<distance[i]<<" "; } cout<<endl; for (int i = 0; i < n; ++i) graph[i].clear(); } return 0; } // map<int, int> dist; // queue<P>q; // P x; // x.first=root; // x.second=0; // q.push(x); // // dist[x]=0; // dist[x.first]=0; // q.pop(); // for(int i=0;i<graph[x.first].size();i++) // { // P a; // a.first=graph[x.first][i]; // a.second=x.second+6; // q.push(a); // } // while(!q.empty()) // { // P y=q.front(); // q.pop(); // dist[y.first]=y.second; // for(int i=0;i<graph[y.first].size();i++) // { // P a; // a.first=graph[y.first][i]; // a.second=y.second+6; // if(!dist.count(a.first)) // q.push(a); // } // } // for(int i=0;i<dist.size();i++) // { if(dist[i]==0) // dist[i]=-1; // if(i!=root) // cout<<dist[i]<<" ";} // cout<<endl;
[ "prabhsimar100@gmail.com" ]
prabhsimar100@gmail.com
af43b57763de41e93ac89b357789dd1d2abf8870
03ee754445d2dc6abbb3c1f2a57a35519f8acc96
/oporator_overload.cpp
e4d00b227ff25b4865da0f7495d9c78d0b8d14c2
[]
no_license
mizan-cs/Practise-Code
d34a67d1f3ea7a9a81e8096020227b705ca5ec13
74b21d810c242af249a17ec8fef683fdb3c0d1b0
refs/heads/master
2021-01-19T21:19:25.831029
2017-09-09T03:23:47
2017-09-09T03:23:47
101,249,329
0
0
null
null
null
null
UTF-8
C++
false
false
756
cpp
#include<iostream> using namespace std; class Box{ int hight; int wight; public: Box(){ hight=wight=0; } Box(int h, int w){ hight=h; wight=w; } void Show(); Box operator+(int m); Box operator++(); }; void Box::Show(){ cout<<"Hight="<<hight<<" Wight="<<wight<<endl; } Box Box::operator+(int m){ Box temp; temp.hight=hight+m; temp.wight=wight+m; return temp; } Box Box::operator++(){ hight++; wight++; return (*this); } int main(){ Box red(10,20), black; black=red+5; black.Show(); ++red; red.Show(); return 0; }
[ "mysalfe02@gmail.com" ]
mysalfe02@gmail.com
f9424d18dba2a118bd97f258c99f1618bb4b6b6e
ea8aa77c861afdbf2c9b3268ba1ae3f9bfd152fe
/meituan17D/meituan17D/ACMTemplete.cpp
47bd95da4f5a5988b4da704a16c61bb346019e23
[]
no_license
lonelam/SolveSet
987a01e72d92f975703f715e6a7588d097f7f2e5
66a9a984d7270ff03b9c2dfa229d99b922907d57
refs/heads/master
2021-04-03T02:02:03.108669
2018-07-21T14:25:53
2018-07-21T14:25:53
62,948,874
9
3
null
null
null
null
UTF-8
C++
false
false
1,827
cpp
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <cstdio> #include <cmath> #include <map> #include <set> #include <utility> #include <stack> #include <cstring> #include <bitset> #include <deque> #include <string> #include <list> #include <cstdlib> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 100000 + 100; typedef long long ll; typedef long double ld; int n; bool vis[maxn]; bool reach[maxn]; int a[maxn]; int b[maxn]; vector<int> G[maxn]; void rdfs(int cur) { reach[cur] = true; for (int i = 0; i < G[cur].size(); i++) { if (!reach[G[cur][i]]) rdfs(G[cur][i]); } } int dfs(int cur, string & ans) { if (vis[cur]) return -1; vis[cur] = true; if (cur == n - 1) return 1; int ta = cur + a[cur]; int tb = cur + b[cur]; if (0 <= ta && ta < n && reach[ta]) { ans.push_back('a'); int oa = dfs(ta, ans); if (oa == 1) return 1; if (oa == -1) return -1; ans.pop_back(); } if (0 <= tb && tb < n && reach[tb]) { ans.push_back('b'); int ob = dfs(tb, ans); if (ob == 1) return 1; if (ob == -1) return -1; ans.pop_back(); } return 0; } int main() { while (scanf("%d", &n) != EOF) { memset(vis, 0, sizeof(vis)); memset(reach, 0, sizeof(reach)); for (int i = 0; i < n; i++) { G[i].clear(); } for (int i = 0; i < n; i++) { scanf("%d", a + i); int tar = i + a[i]; if (tar >= 0 && tar < n) { G[tar].push_back(i); } } for (int i = 0; i < n; i++) { scanf("%d", b + i); int tar = i + b[i]; if (tar >= 0 && tar < n) { G[tar].push_back(i); } } rdfs(n - 1); if (reach[0]) { string ans; if (dfs(0, ans) == 1) { printf("%s\n", ans.c_str()); } else { printf("Infinity!\n"); } } else { printf("No solution!\n"); } } }
[ "laizenan@gmail.com" ]
laizenan@gmail.com
b1f63a27c898b0b709f65257c512083dd28af4c2
10c5b0f5fb0d21bc162755e6b01903d33bf4a0ca
/CARS/CARS/Source.cpp
8b17e093bd188731f61189b0f5da63361aaf2582
[]
no_license
KillPeopleFast/Daily-Fish
e7a779927e1d5ee60e7e755ca560ba288a83b205
a88273132eacf202e12cd4cf7999f7cd3607135b
refs/heads/master
2021-09-09T21:28:58.778184
2018-03-19T20:07:05
2018-03-19T20:07:05
125,913,968
1
0
null
null
null
null
UTF-8
C++
false
false
880
cpp
#include <allegro5/allegro.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_image.h> int main() { ALLEGRO_BITMAP *face = NULL; ALLEGRO_DISPLAY *display = NULL; al_init(); al_init_image_addon(); display = al_create_display(500, 400); al_init_primitives_addon(); face = al_load_bitmap("prime.png"); al_convert_mask_to_alpha(face, al_map_rgb(255, 0, 255)); al_clear_to_color(al_map_rgb(0, 0, 0)); al_draw_filled_rectangle(30, 30, 359, 200, al_map_rgb(0, 0, 100)); al_draw_filled_rectangle(0, 200, 200, 200, al_map_rgb(0, 0, 100)); al_draw_filled_circle(250, 200, 50, al_map_rgb(210, 105, 30)); al_draw_filled_circle(50, 200, 50, al_map_rgb(210, 105, 30)); al_draw_filled_circle(150, 200, 50, al_map_rgb(210, 105, 30)); al_draw_filled_circle(350, 200, 50, al_map_rgb(210, 105, 30)); al_flip_display(); al_rest(20.0); } //HIIIIIIIIIIIIIIIIIII
[ "sorshadavid1@hotmail.com" ]
sorshadavid1@hotmail.com
a37ed0e5d8a331644df4dc83c4d268c1f80add61
57aad0fc76b28c2bcb4f07dfc3dc96383f33e051
/lightfield-irrlicht/PlaneSimulator.h
fbab453cfc82f2f1f0c50660c5b9c04c335a2665
[]
no_license
lvgeng/lightfield-irrlichtWithShadow
dbf34cf90d1de057d07932c5cb34dcb85af33f20
fd6eb96b667931dd97e996c0d1023c2e45da79ae
refs/heads/master
2021-03-22T04:06:49.388212
2017-06-10T16:35:44
2017-06-10T16:35:44
93,906,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,072
h
#pragma once #include <vector> #include <irrlicht.h> using namespace std; using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; class PlaneSimulator { private: std::vector< std::vector<vector2df> > coordinatesInSubimagesList; std::vector< std::vector<vector2df> > centerCoordinatesOfTargetPixelList; vector3df cameraPosition; int widDisplayzoneByPixel; int heiDisplayzoneByPixel; int widSubimageByPixel; int heiSubimageByPixel; double widSubimageBymm; double heiSubimageBymm; double thickness; double n; public: vector2df getCoorinatesInSubimage(int subimageCountX, int subimageCountY); PlaneSimulator(vector3df cameraPositionInput, int widthOfRenderzoneByPixel, int heightOfRenderzoneByPixel, int widthOfSubimageByPixel, int heightOfSubimageByPixel, double widthOfSubimageBymm, double heightOfSubimageBymm, double thicknessOfTransparentMaterialBetweenDevices, double refractionIndexOfTransparentMaterial, int widthOfHoleByPixel, int HeightOfHoleByPixle); ~PlaneSimulator(); };
[ "lvgengbuaa@gmail.com" ]
lvgengbuaa@gmail.com
7856957dd99a795d44d606a8da2d57b6715eec42
d8fa4162a3c925209d39116d3fd3f7832950ffb6
/WaveWindow.cpp
b9d074841c8a5c887a3f7eb2e8e92af144e158ad
[ "MIT" ]
permissive
mpb-cal/TheAudioLooper
f5ed1287a797f75ebfeb7d3f779eaf2fd1ae6703
ec8a8f13ff8d6a08f8cbdd79954f1d4193dabead
refs/heads/master
2020-12-03T19:44:18.236806
2020-01-02T21:24:52
2020-01-02T21:24:52
231,460,626
0
0
null
null
null
null
UTF-8
C++
false
false
2,242
cpp
#include "WaveWindow.h" #include "InOutSlider.h" #include "main.h" const WORD INOUT_SLIDER = 2; HWND m_hwndInOutSlider = 0; LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_CREATE) { m_hwndInOutSlider = CreateWindow( INOUTSLIDERCLASS, "InOut", WS_VISIBLE | WS_CHILD, 10, 10, 100, 100, hWnd, (HMENU)INOUT_SLIDER, g_hInstance, NULL ); CreateWindow( INOUTSLIDERCLASS, "InOut", WS_VISIBLE | WS_CHILD, 120, 10, 100, 100, hWnd, (HMENU)INOUT_SLIDER, g_hInstance, NULL ); } if (message == WM_PAINT) { HDC hdc = GetDC( hWnd ); PAINTSTRUCT ps; BeginPaint( hWnd, &ps ); RECT rect; GetClientRect( hWnd, &rect ); // SelectObject( hdc, GetStockObject(GRAY_BRUSH) ); char buf[10000] = "Child"; // DrawText( hdc, buf, strlen( buf ), &rect, 0 ); EndPaint( hWnd, &ps ); } else if (message == WM_COMMAND) { if (LOWORD( wParam ) == INOUT_SLIDER) { if (HIWORD( wParam ) == WM_INOUT_MOUSEMOVE) { int x = 0; } else { return DefWindowProc( hWnd, message, wParam, lParam ); } } else { return DefWindowProc( hWnd, message, wParam, lParam ); } } else if (message == WM_INOUT_MOUSEMOVE) { // wParam is child ID // lParam is child hwnd HWND child = (HWND)wParam; short xDrag = lParam; RECT rect; GetWindowRect( child, &rect ); int width = rect.right - rect.left; int height = rect.bottom - rect.top; POINT upperLeft = { rect.left, rect.top }; ScreenToClient( hWnd, &upperLeft ); MoveWindow( child, upperLeft.x + xDrag, upperLeft.y, width, height, TRUE ); } else { return DefWindowProc( hWnd, message, wParam, lParam ); } return 0; } void initWaveWindow() { WNDCLASS wc; ZeroMemory( &wc, sizeof wc ); wc.lpfnWndProc = ChildWndProc; wc.hInstance = g_hInstance; wc.lpszClassName = CHILDCLASSNAME; wc.lpszMenuName = 0; wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wc.hCursor = 0; wc.hIcon = 0; RegisterClass(&wc); initInOutSlider(); }
[ "steelstring@protonmail.com" ]
steelstring@protonmail.com
d63a684db913d1ff92ef4b9623256d49e7020bb5
18f66cb9a08030afab48494b96536e6a80277435
/acm.timus.ru_33735/1098.cpp
b4cec2f7b44ec969a1e97840c9ddc38b4c975e22
[]
no_license
Rassska/acm
aa741075a825080637bebab128d763b64c7f73ae
18aaa37e96b6676334c24476e47cd17d22ca9541
refs/heads/master
2023-03-15T16:57:59.274305
2015-02-24T21:36:34
2015-02-24T21:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
527
cpp
#include <cstdio> #include <cstring> using namespace std; char S[30010]; int g(int x,int n) { return (x%n==0)?n:x%n; } void main() { for(int i =0;scanf("%c",&S[i])>0;) { if(S[i] != '\n') i++; else S[i] = '\0'; } int n=strlen(S),k=1999,prev,next; next = (k%2 == 0)?1:2; if(n==1) next = 1; for(int i = 3; i<=n;i++) { prev=next; next=g((prev+k),i); } switch(S[next-1]) { case '?': printf("Yes"); break; case ' ': printf("No"); break; default: printf("No comments"); break; } }
[ "vadimkantorov@gmail.com" ]
vadimkantorov@gmail.com
bbe54247f976922ff01895d54e1eb0055737ff5b
81fdded2f4a5482e9c00ebb2230a7f8975fc38fd
/ComIOP/Wrapper/ProxyServer/OpcUaComProxyServer.cpp
894c4fd92d29a30e129d80570ec77514cb90b1f9
[ "LicenseRef-scancode-generic-cla" ]
no_license
thephez/UA-.NETStandardLibrary
c38477a95d69387fa37f9eb3cd2056e460b5ae40
759ea05f8d8f990a9aa2354c58dbb846e2ffd88b
refs/heads/master
2021-01-21T07:25:31.968237
2017-01-03T21:01:07
2017-01-03T21:01:07
64,311,762
1
1
null
2016-07-27T13:42:48
2016-07-27T13:42:48
null
UTF-8
C++
false
false
3,620
cpp
/* ======================================================================== * Copyright (c) 2005-2016 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ #include "StdAfx.h" #include "Da/COpcUaDaProxyServer.h" #include "Ae/COpcUaAe2ProxyServer.h" #include "Hda/COpcUaHdaProxyServer.h" #pragma warning(disable:4192) //================================================================================ // COM Module Declarations OPC_DECLARE_APPLICATION(OpcUa, OpcUaComProxyServer, "UA COM Proxy Server", TRUE) OPC_BEGIN_CLASS_TABLE() OPC_CLASS_TABLE_ENTRY(COpcUaDaProxyServer, ComDaProxyServer, 1, "UA COM DA Proxy Server") OPC_CLASS_TABLE_ENTRY(COpcUaAe2ProxyServer, ComAe2ProxyServer, 1, "UA COM AE Proxy Server") // OPC_CLASS_TABLE_ENTRY(COpcUaAeProxyServer, ComAeProxyServer, 1, "UA COM AE Proxy Server") OPC_CLASS_TABLE_ENTRY(COpcUaHdaProxyServer, ComHdaProxyServer, 1, "UA COM HDA Proxy Server") OPC_END_CLASS_TABLE() OPC_BEGIN_CATEGORY_TABLE() OPC_CATEGORY_TABLE_ENTRY(ComDaProxyServer, CATID_OPCDAServer20, OPC_CATEGORY_DESCRIPTION_DA20) #ifndef OPCUA_NO_DA3_SUPPORT OPC_CATEGORY_TABLE_ENTRY(ComDaProxyServer, CATID_OPCDAServer30, OPC_CATEGORY_DESCRIPTION_DA30) #endif // OPC_CATEGORY_TABLE_ENTRY(ComAeProxyServer, CATID_OPCAEServer10, OPC_CATEGORY_DESCRIPTION_AE10) OPC_CATEGORY_TABLE_ENTRY(ComAe2ProxyServer, CATID_OPCAEServer10, OPC_CATEGORY_DESCRIPTION_AE10) OPC_CATEGORY_TABLE_ENTRY(ComHdaProxyServer, CATID_OPCHDAServer10, OPC_CATEGORY_DESCRIPTION_HDA10) OPC_END_CATEGORY_TABLE() #ifndef _USRDLL // {037D6665-27F3-462f-9E8F-F8C146D28669} OPC_IMPLEMENT_LOCAL_SERVER(0x37d6665, 0x27f3, 0x462f, 0x9e, 0x8f, 0xf8, 0xc1, 0x46, 0xd2, 0x86, 0x69); //================================================================================ // WinMain extern "C" int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd ) { OPC_START_LOCAL_SERVER_EX(hInstance, lpCmdLine); return 0; } #else OPC_IMPLEMENT_INPROC_SERVER(); //============================================================================== // DllMain extern "C" BOOL WINAPI DllMain( HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) { OPC_START_INPROC_SERVER(hModule, dwReason); return TRUE; } #endif // _USRDLL
[ "mregen@microsoft.com" ]
mregen@microsoft.com
fe095c6c941658f78f02c1bf0ffa60c4f117687b
a7764174fb0351ea666faa9f3b5dfe304390a011
/inc/Handle_PPoly_HArray1OfTriangle.hxx
84bbc8c656ce1693e38869fe1441597500a8d075
[]
no_license
uel-dataexchange/Opencascade_uel
f7123943e9d8124f4fa67579e3cd3f85cfe52d91
06ec93d238d3e3ea2881ff44ba8c21cf870435cd
refs/heads/master
2022-11-16T07:40:30.837854
2020-07-08T01:56:37
2020-07-08T01:56:37
276,290,778
0
0
null
null
null
null
UTF-8
C++
false
false
916
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _Handle_PPoly_HArray1OfTriangle_HeaderFile #define _Handle_PPoly_HArray1OfTriangle_HeaderFile #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _Standard_DefineHandle_HeaderFile #include <Standard_DefineHandle.hxx> #endif #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Handle_Standard_Persistent_HeaderFile #include <Handle_Standard_Persistent.hxx> #endif class Standard_Persistent; class Handle(Standard_Type); class Handle(Standard_Persistent); class PPoly_HArray1OfTriangle; DEFINE_STANDARD_PHANDLE(PPoly_HArray1OfTriangle,Standard_Persistent) #endif
[ "shoka.sho2@excel.co.jp" ]
shoka.sho2@excel.co.jp
22ab21260f3e221c61d247cf745a6d3be1ecf449
3ae8fb577d6f34bc94c725b3b7140abacc51047d
/gambit/armlib/src/gambit.cpp
0aefce35c56ef326f9f4d43f50ff6d2da382abbf
[]
no_license
mjyc/gambit-lego-pkg
b25b7831e864bba0f126f64a3d40f412a19664c1
d2ae2fa4eb09d5e149c0816eabf9213f75b7283f
refs/heads/master
2022-12-30T17:11:30.768639
2013-09-03T22:02:21
2013-09-03T22:02:21
306,082,007
0
0
null
null
null
null
UTF-8
C++
false
false
3,855
cpp
#include <armlib/gambit.h> #include "ik_gambit.cpp" namespace armlib { Gambit::Gambit() : _spinner(1, &_cb_queue) { _latency_usec = 250000; _n_dofs = 7; _n_arm_dofs = 6; _n_manip_dofs = 1; _data_valid = false; _encoder_position.resize(_n_dofs); _joint_weights.push_back(1.5); _joint_weights.push_back(1.5); _joint_weights.push_back(1.0); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joint_weights.push_back(0.5); _joints_cr.push_back(true); _joints_cr.push_back(true); _joints_cr.push_back(true); _joints_cr.push_back(false); _joints_cr.push_back(false); _joints_cr.push_back(false); _joints_cr.push_back(false); ros::NodeHandle nh; nh.setCallbackQueue(&_cb_queue); _joint_target_pub = nh.advertise<gambit_msgs::JointTargets>("/arm/joint_targets", 1); _joint_encoder_sub = nh.subscribe("/arm/joint_state", 1, &Gambit::joint_encoder_cb, this); _spinner.start(); get_encoder_pos(_commanded_pos); } void Gambit::joint_encoder_cb(const gambit_msgs::JointStateConstPtr &joints) { assert(joints->positions.size() == _n_dofs); lock(); for(unsigned int i=0; i<_n_dofs; i++) _encoder_position[i] = joints->positions[i]; if(_at_target && !_closed_loop_mode) _commanded_pos = _encoder_position; _data_valid = true; unlock(); } bool Gambit::get_encoder_pos(js_vect &position) { _data_valid = false; while(!_data_valid) { if(_should_terminate || !ros::ok()) return false; usleep(1000); } lock(); position = _encoder_position; unlock(); return true; } bool Gambit::set_target_pos(js_vect &position) { assert(position.size() == _n_dofs); gambit_msgs::JointTargets jv; jv.header.stamp = ros::Time::now(); for(unsigned int i=0; i<_n_dofs; i++) { jv.indices.push_back(i); jv.targets.push_back(position[i]); } _joint_target_pub.publish(jv); return true; } bool Gambit::check_joint_limits(js_vect &position) { assert(position.size() >= _n_dofs); return ( position[3] >= -2.618 && position[3] <= 2.618 && position[4] >= -1.571 && position[4] <= 1.571 && position[5] >= -2.618 && position[5] <= 2.618 && position[6] >= -0.530 && position[6] <= 2.618 ); } bool Gambit::check_arm_joint_limits(js_vect &position) { assert(position.size() >= _n_arm_dofs); return ( position[3] >= -2.618 && position[3] <= 2.618 && position[4] >= -1.571 && position[4] <= 1.571 && position[5] >= -2.618 && position[5] <= 2.618 ); } bool Gambit::check_manip_joint_limits(js_vect &position) { assert(position.size() >= _n_manip_dofs); return position[0] >= -0.530 && position[0] <= 2.618; } bool Gambit::inverse_kinematics(double *position, double *orientation, std::vector<js_vect> &solutions) { ik_gambit::IKReal eetrans[3]; ik_gambit::IKReal eerot[9]; ik_gambit::IKReal vfree[1] = {0.0}; solutions.clear(); for(unsigned int i=0; i<3; i++) eetrans[i] = position[i]; for(unsigned int i=0; i<9; i++) eerot[i] = orientation[i]; std::vector<ik_gambit::IKSolution> vsolutions; bool ik_success = ik_gambit::ik(eetrans, eerot, vfree, vsolutions); if(!ik_success) { //printf("debug: ik failed\n"); return false; } std::vector<ik_gambit::IKReal> sol(_n_arm_dofs); //printf("debug: %d solutions\n", vsolutions.size()); for(unsigned int i=0; i<vsolutions.size(); i++) { std::vector<ik_gambit::IKReal> vsolfree(vsolutions[i].GetFree().size()); vsolutions[i].GetSolution(&sol[0], &vsolfree[0]); js_vect js_sol; //printf("debug: solution: "); for(unsigned int j=0; j<_n_arm_dofs; j++) { js_sol.push_back(sol[j]); //printf("%f ", sol[j]); } if(check_arm_joint_limits(js_sol)) { solutions.push_back(js_sol); //printf("(reachable)"); } //printf("\n"); } //printf("debug: &solutions: %p\n", &solutions); //printf("debug: solutions.size(): %d\n", solutions.size()); return !solutions.empty(); } }
[ "mjyc@cs.washington.edu" ]
mjyc@cs.washington.edu
6db78db0707c229277eec3b8c04aa6ac42214554
e38231ec168a4daaec38b3b6ac90c3080acd5204
/src/FaBoMotor_DRV8830.cpp
ec4e0a38831446b2d853cd0cd1b92a605b532736
[ "Artistic-2.0" ]
permissive
gcohen10/FaBoMotor-DRV8830-Library
1f9bc1aeb4db24f49d0e9bc8e70bd5bfeb615877
25817b3c37543b47a03b662d98a7ee97d508f0d6
refs/heads/master
2022-01-07T05:49:09.016233
2019-01-03T16:21:35
2019-01-03T16:21:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,411
cpp
/** @file FaBoMotor_DRV8830.cpp @brief This is a library for the FaBo Temperature I2C Brick. Released under APACHE LICENSE, VERSION 2.0 http://www.apache.org/licenses/ @author FaBo<info@fabo.io> */ #include "FaBoMotor_DRV8830.h" /** @brief Constructor */ FaBoMotor::FaBoMotor(uint8_t addr) { _i2caddr = addr; Wire.begin(); } /** @brief Begin Device */ boolean FaBoMotor::begin() { uint8_t status = 0; return readI2c(DRV8830_FAULT_REG, 1, &status); } /** @brief Configure Device @param [in] config Configure Parameter */ void FaBoMotor::drive(uint8_t direction, uint8_t speed) { uint8_t param = speed << 2 | direction; writeI2c(DRV8830_CONTROL_REG, param); } /** @brief Write I2C @param [in] address register address @param [in] data write data */ void FaBoMotor::writeI2c(uint8_t address, uint8_t data) { Wire.beginTransmission(_i2caddr); Wire.write(address); Wire.write(data); Wire.endTransmission(); } /** @brief Read I2C @param [in] address register address @param [in] num read length @param [out] data read data */ boolean FaBoMotor::readI2c(uint8_t address, uint8_t num, uint8_t * data) { Wire.beginTransmission(_i2caddr); boolean result = Wire.write(address); Serial.print(result); Wire.endTransmission(); uint8_t i = 0; Wire.requestFrom(_i2caddr, num); while( Wire.available() ) { data[i++] = Wire.read(); } return result; }
[ "gclue.akira@gmail.com" ]
gclue.akira@gmail.com
d47b0f911b4f7a4446b6bd5b374700cbe71eacba
04fdfc9d6d1cd2ff13ef7d9e29da988bf2710204
/think_in_c++/chapters02/_17PointerToFunction.cpp
865435f36fb8d4293809a731d71fb30f35f51728
[]
no_license
DongHuaLu/C-plus-plus
29bd872e13e70aef80965c48446d5a5b51134b78
6a3405fd50ed7b23e40a0927267388c4c5f0c45a
refs/heads/master
2020-03-30T05:28:17.467026
2017-02-09T06:05:08
2017-02-09T06:05:08
39,047,161
0
0
null
null
null
null
UTF-8
C++
false
false
215
cpp
#include <iostream> using namespace std; int func(int i){ cout << "i = " << i << endl; return i; } int main(){ int (*fp1)(int); fp1 = func; (*fp1)(2); int (*fp2)(int) = func; (*fp2)(55); }
[ "ctl70000@163.com" ]
ctl70000@163.com
e66c02796f8619bff91d493e7ef2518aa1e078de
781f351347692832c17ebd43bb90accd1036572d
/Sources/Core/Src/KSubWorld.h
5e39d90776a7dee5d86e6a965af39cddab9f4a8e
[]
no_license
fcccode/Jx
71f9a549c7c6bbd1d00df5ad3e074a7c1c665bd1
4b436851508d76dd626779522a080b35cf8edc14
refs/heads/master
2020-04-14T07:59:12.814607
2017-05-23T07:57:15
2017-05-23T07:57:15
null
0
0
null
null
null
null
GB18030
C++
false
false
4,191
h
#ifndef KWorldH #define KWorldH #ifdef _SERVER #define MAX_SUBWORLD 80 #else #define MAX_SUBWORLD 1 #endif #define VOID_REGION -2 //------------------------------------------------------------- #include "KEngine.h" #include "KRegion.h" #include "KWeatherMgr.h" #ifdef _SERVER #include "KMission.h" #include "KMissionArray.h" #define MAX_SUBWORLD_MISSIONCOUNT 10 #define MAX_GLOBAL_MISSIONCOUNT 50 typedef KMissionArray <KMission , MAX_TIMER_PERMISSION> KSubWorldMissionArray; typedef KMissionArray <KMission , MAX_GLOBAL_MISSIONCOUNT> KGlobalMissionArray; extern KGlobalMissionArray g_GlobalMissionArray; #endif //------------------------------------------------------------- #ifndef TOOLVERSION class KSubWorld #else class CORE_API KSubWorld #endif { public: int m_nIndex; int m_SubWorldID; #ifdef _SERVER KSubWorldMissionArray m_MissionArray; #endif KRegion* m_Region; #ifndef _SERVER int m_ClientRegionIdx[MAX_REGION]; char m_szMapPath[FILE_NAME_LENGTH]; //KLittleMap m_cLittleMap; #endif int m_nWorldRegionWidth; // SubWorld里宽几个Region int m_nWorldRegionHeight; // SubWorld里高几个Region int m_nTotalRegion; // SubWorld里Region个数 int m_nRegionWidth; // Region的格子宽度 int m_nRegionHeight; // Region的格子高度 int m_nCellWidth; // Cell的像素宽度 int m_nCellHeight; // Cell的像素高度 int m_nRegionBeginX; int m_nRegionBeginY; int m_nWeather; // 天气变化 DWORD m_dwCurrentTime; // 当前帧 KWorldMsg m_WorldMessage; // 消息 KList m_NoneRegionNpcList; // 不在地图上的NPC #ifdef _SERVER KWeatherMgr *m_pWeatherMgr; #endif private: public: KSubWorld(); ~KSubWorld(); void Activate(); void GetFreeObjPos(POINT& pos); BOOL CanPutObj(POINT pos); void ObjChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); void MissleChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); void AddPlayer(int nRegion, int nIdx); void RemovePlayer(int nRegion, int nIdx); void Close(); int GetDistance(int nRx1, int nRy1, int nRx2, int nRy2); // 像素级坐标 void Map2Mps(int nR, int nX, int nY, int nDx, int nDy, int *nRx, int *nRy); // 格子坐标转像素坐标 static void Map2Mps(int nRx, int nRy, int nX, int nY, int nDx, int nDy, int *pnX, int *pnY); // 格子坐标转像素坐标 void Mps2Map(int Rx, int Ry, int * nR, int * nX, int * nY, int *nDx, int * nDy); // 像素坐标转格子坐标 void GetMps(int *nX, int *nY, int nSpeed, int nDir, int nMaxDir = 64); // 取得某方向某速度下一点的坐标 BYTE TestBarrier(int nMpsX, int nMpsY); BYTE TestBarrier(int nRegion, int nMapX, int nMapY, int nDx, int nDy, int nChangeX, int nChangeY); // 检测下一点是否为障碍 BYTE TestBarrierMin(int nRegion, int nMapX, int nMapY, int nDx, int nDy, int nChangeX, int nChangeY); // 检测下一点是否为障碍 BYTE GetBarrier(int nMpsX, int nMpsY); // 取得某点的障碍信息 DWORD GetTrap(int nMpsX, int nMpsY); void MessageLoop(); int FindRegion(int RegionID); // 找到某ID的Region的索引 int FindFreeRegion(int nX = 0, int nY = 0); #ifdef _SERVER int RevivalAllNpc();//将地图上所有的Npc包括已死亡的Npc全部恢复成原始状态 void BroadCast(const char* pBuffer, size_t uSize); BOOL LoadMap(int nIdx); void LoadObject(char* szPath, char* szFile); void NpcChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nNpcIdx); void PlayerChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nObjIdx); BOOL SendSyncData(int nIdx, int nClient); int GetRegionIndex(int nRegionID); int FindNpcFromName(const char * szName); #endif #ifndef _SERVER BOOL LoadMap(int nIdx, int nRegion); void NpcChangeRegion(int nSrcRegionIdx, int nDesRegionIdx, int nNpcIdx); void Paint(); void Mps2Screen(int *Rx, int *Ry); void Screen2Mps(int *Rx, int *Ry); #endif private: void LoadTrap(); void ProcessMsg(KWorldMsgNode *pMsg); #ifndef _SERVER void LoadCell(); #endif }; #ifndef TOOLVERSION extern KSubWorld SubWorld[MAX_SUBWORLD]; #else extern CORE_API KSubWorld SubWorld[MAX_SUBWORLD]; #endif #endif
[ "tuan.n0s0und@gmail.com" ]
tuan.n0s0und@gmail.com
9dfcc768bcf8e289a771291983ab122165808834
9dc0e27554c5139534087ec2064d2a07ec3b943f
/semestr_1/dynamiczne_zarzadzanie_pamiecia_algorytmy_i_struktury_danych/Kodowanie Huffmana/kodowanie_huffmana.cpp
35b3606b9392256ed8146c93cc85e52834b8c2e8
[]
no_license
rikonek/zut
82d2bc4084d0d17ab8385181386f391446ec35ac
d236b275ffc19524c64369dd21fa711f735605c7
refs/heads/master
2020-12-24T20:00:13.639419
2018-01-25T09:53:29
2018-01-25T09:53:29
86,224,826
1
3
null
2018-01-09T11:40:52
2017-03-26T10:36:59
HTML
UTF-8
C++
false
false
374
cpp
#include <iostream> #include <fstream> #include "huffman.class.h" int main(int argc,char **argv) { std::ifstream plik(argv[1]); if(!plik.is_open()) { std::cout << "Nie mozna otworzyc pliku zrodlowego" << std::endl; return 1; } huffman h; h.debug(true); std::cout << h.encode(plik) << std::endl; plik.close(); return 0; }
[ "radek@madenet.pl" ]
radek@madenet.pl
509a0bb6dd889547c470d03729e808191c894668
188fb8ded33ad7a2f52f69975006bb38917437ef
/Fluid/processor5/0.54/Force
2cdaa9d96d5a6ff1f1921b4cb0b78a0ba171f205
[]
no_license
abarcaortega/Tuto_2
34a4721f14725c20471ff2dc8d22b52638b8a2b3
4a84c22efbb9cd2eaeda92883343b6910e0941e2
refs/heads/master
2020-08-05T16:11:57.674940
2019-10-04T09:56:09
2019-10-04T09:56:09
212,573,883
0
0
null
null
null
null
UTF-8
C++
false
false
1,724
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "0.54"; object Force; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 1 -2 0 0 0 0]; internalField uniform (0 0 0); boundaryField { inlet { type calculated; value nonuniform 0(); } outlet { type calculated; value uniform (0 0 0); } flap { type calculated; value nonuniform 0(); } upperWall { type calculated; value nonuniform 0(); } lowerWall { type calculated; value uniform (0 0 0); } frontAndBack { type empty; } procBoundary5to2 { type processor; value uniform (0 0 0); } procBoundary5to4 { type processor; value uniform (0 0 0); } } // ************************************************************************* //
[ "aldo.abarca.ortega@gmail.com" ]
aldo.abarca.ortega@gmail.com
5cff9c1adda869142180d8859f2dbc854306699b
b7e10af07325fbe34a8f6acb8ad3de090383b845
/edgeRuntime/StandardPlayer.h
eaeacf0bb5b805ee026eb944a8c8fb92b83f3e1e
[ "Apache-2.0" ]
permissive
Joshua0128/mpcToolkit
dabc59d8c1844072fbd92e66eebcd236361e3c3d
67d647488907e6f00575026e5c0b2c26b0b92b25
refs/heads/master
2021-12-29T23:44:16.268521
2016-03-21T15:58:55
2016-03-21T15:58:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,628
h
// // StandardPlayer.h // edgeRuntime // // Created by Abdelrahaman Aly on 06/11/13. // Copyright (c) 2013 Abdelrahaman Aly. All rights reserved. // #ifndef edgeRuntime_StandardPlayer_h #define edgeRuntime_StandardPlayer_h //Generic Headers #include <string.h> namespace Players { /** * @class StandardPlayer * @ingroup Players * @brief * Player Bean class * @details * contains communicational and identification data needed for transmission process * @todo <ul> <li> change player for idPlayer <li> correct address - now reads adress <\ul> * @author Abdelrahaman Aly * @date 2013/11/06 * @version 0.0.1.15 */ class StandardPlayer { private: int * ipAdress_; //ip address of player int port_; //service port int player_; //player id i.e 1, 2, 3, etc. public: /** * @brief Custom class constructor * @details Initialize all estate variables * @param player Represents the player id number * @param port service port * @param ipAddress int vector of size 4 to store service ip address * @exception NA * @todo <ul> <li>Build Exceptions for non compatible data, specially ip Address </ul> */ StandardPlayer(int player, int port, int * ipAdress); /** * @brief Default class constructor * @details Initialize all estate variables with default values * @exception NA * @todo <ul> <li>Build Exceptions for non compatible data, in case of ocupied ports </ul> */ StandardPlayer(); /** @brief Simple Getter @return ipAddress int vector of size 4 to store service ip address */ int * getIpAdress(); /** @brief Simple Setter @param ipAdress int vector of size 4 to store service ip address */ void setIpAdress(int * ipAdress); /** @brief Simple Getter @return player id i.e 1, 2, 3, etc. */ int getPlayer(); /** @brief Simple Setter @param player id i.e 1, 2, 3, etc. */ void setPlayer(int player); /** @brief Simple Getter @return port service port of player. */ int getPort(); /** @brief Simple Setter @param port service port of player. */ void setPort(int port); }; } #endif
[ "abdelrahaman.aly@gmail.com" ]
abdelrahaman.aly@gmail.com
eaf89ae9f32bac205334c7381ad28ccb6f9d402d
50c74a5dd38180e26f0608cb0002585489445555
/Codeforces Solutions/201A.cpp
cfdc91499bfd6ce3a728949417d01b155ff997fe
[]
no_license
ShobhitBehl/Competitive-Programming
1518fe25001cc57095c1643cc8c904523b2ac2ef
7a05897ca0ef5565655350803327f7f23bcf82fe
refs/heads/master
2020-04-17T05:20:52.302129
2019-03-18T10:17:47
2019-03-18T10:17:47
166,265,289
0
0
null
null
null
null
UTF-8
C++
false
false
772
cpp
#include <bits/stdc++.h> using namespace std; typedef long long int lli; #define pi 3.141592653589793238 typedef pair<lli,lli> pll; typedef map<lli,lli> mll; typedef set<lli> sl; //typedef pair<int,int> pii; typedef map<int,int> mii; typedef set<int> si; #define x first #define y second #define mp make_pair #define pb push_back int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); lli x; cin >> x; if(x == 3) { cout << 5 << endl; return 0; } for(int i = 1; i<50; i+=2) { lli num = ((i*i) + 1)/2; if(num >= x) { cout << i << endl; return 0; } } }
[ "shobhitbehl1@gmail.com" ]
shobhitbehl1@gmail.com
390b3e557568277807833847dd196073931a5739
09a353319e8e3f7abe82cdf959254fb8338321dc
/src/runtime/vm/translator/hopt/linearscan.h
4dea13eb48d4162c0e67aff03be0ef2cc2b5f7af
[ "LicenseRef-scancode-unknown-license-reference", "PHP-3.01", "Zend-2.0" ]
permissive
huzhiguang/hiphop-php_20121224_original
37b26487d96707ecb11b1810ff21c69b8f61acd8
029125e8af031cb79fe8e0c2eea9b8f2ad5769a2
refs/heads/master
2020-05-04T17:07:19.378484
2013-08-19T10:06:52
2013-08-19T10:06:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,547
h
/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ #ifndef incl_HPHP_VM_LINEAR_SCAN_H_ #define incl_HPHP_VM_LINEAR_SCAN_H_ #include <boost/noncopyable.hpp> #include "runtime/vm/translator/physreg.h" #include "runtime/vm/translator/abi-x64.h" #include "runtime/vm/translator/hopt/ir.h" #include "runtime/vm/translator/hopt/tracebuilder.h" #include "runtime/vm/translator/hopt/codegen.h" namespace HPHP { namespace VM { namespace JIT { /* * The main entry point for register allocation. Called prior to code * generation. */ void allocRegsForTrace(Trace*, IRFactory*, TraceBuilder*); }}} #endif
[ "huzhiguang@jd.com" ]
huzhiguang@jd.com
8733b71ded70c4ef071f1255b4285d6fd6d247a1
7e79e0be56f612288e9783582c7b65a1a6a53397
/problem-solutions/codeforces/408/D.cpp
7876c3a3644482f6dffb8ca40766a688c55f5fbb
[]
no_license
gcamargo96/Competitive-Programming
a643f492b429989c2d13d7d750c6124e99373771
0325097de60e693009094990d408ee8f3e8bb18a
refs/heads/master
2020-07-14T10:27:26.572439
2019-08-24T15:11:20
2019-08-24T15:11:20
66,391,304
0
0
null
null
null
null
UTF-8
C++
false
false
2,028
cpp
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i)) #define mp make_pair #define pb push_back #define fi first #define se second #define endl "\n" #define PI acos(-1) typedef long long ll; typedef vector<int> vi; typedef vector<bool> vb; typedef pair<int,int> ii; typedef complex<double> base; const int N = 300002; int n, k, d; map<ii, int> road; vi adj[N]; priority_queue<pair<int, ii> > pq; int dist[N], cor[N]; vi res; set<int> police; void dijkstra(){ //memset(dist, INF, sizeof dist); while(!pq.empty()){ int u = pq.top().se.fi; int di = -pq.top().fi; int c = pq.top().se.se; pq.pop(); cor[u] = c; if(di > d) continue; //printf("%d\n", u); For(i,0,adj[u].size()){ int v = adj[u][i]; if(cor[v] != 0 and cor[u] != cor[v] and di+1 >= dist[v]){ if(road.count(ii(u,v))){ res.pb(road[ii(u,v)]); } else{ res.pb(road[ii(v,u)]); } continue; } if(di+1 < dist[v]){ dist[v] = di+1; //cor[v] = cor[u]; pq.push(mp(-dist[v], ii(v, c))); } } } } int main(void){ scanf("%d%d%d", &n, &k, &d); int x; For(i,0,N) dist[i] = INF; For(i,0,k){ scanf("%d", &x); police.insert(x); pq.push(mp(0, ii(x, i+1))); cor[x] = i+1; dist[x] = 0; } int u, v; For(i,0,n-1){ scanf("%d%d", &u, &v); road[ii(u,v)] = i+1; if(police.count(u) and police.count(v)){ if(road.count(ii(u,v))){ res.pb(road[ii(u,v)]); } else{ res.pb(road[ii(v,u)]); } } else{ adj[u].pb(v); adj[v].pb(u); } } if(d == 0){ printf("%d\n", n-1); for(int i = 1; i <= n-1; i++){ printf("%d ", i); } printf("\n"); return 0; } dijkstra(); /*printf("dists = "); for(int i = 1; i <= n; i++){ printf("%d ", dist[i]); } printf("\n"); */ /*sort(res.begin(), res.end()); auto it = unique(res.begin(), res.end()); res.resize(it-res.begin()); */ printf("%d\n", res.size()); For(i,0,res.size()){ printf("%d ", res[i]); } printf("\n"); return 0; }
[ "gacamargo1.000@gmail.com" ]
gacamargo1.000@gmail.com
6133ca93acfccd10156c5b107ddf16c4bd5891f5
b2810745e7d746140b87367f9fa55374cc82b2f2
/Source/BansheeEditor/Source/Win32/BsVSCodeEditor.cpp
ac98bd4c6ee446ec6e04398f8151d7b5fe2352e5
[]
no_license
nemerle/BansheeEngine
7aabb7d2c1af073b1069f313a2192e0152b56e99
10436324afc9327865251169918177a6eabc8506
refs/heads/preview
2020-04-05T18:29:09.657686
2016-05-11T08:19:09
2016-05-11T08:19:09
58,526,181
2
0
null
2016-05-11T08:10:44
2016-05-11T08:10:44
null
UTF-8
C++
false
false
22,469
cpp
//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// #include "Win32/BsVSCodeEditor.h" #include <windows.h> #include <atlbase.h> #include "BsFileSystem.h" #include "BsDataStream.h" // Import EnvDTE #pragma warning(disable: 4278) #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("8.0") lcid("0") raw_interfaces_only named_guids #pragma warning(default: 4278) namespace BansheeEngine { /** * Reads a string value from the specified key in the registry. * * @param[in] key Registry key to read from. * @param[in] name Identifier of the value to read from. * @param[in] value Output value read from the key. * @param[in] defaultValue Default value to return if the key or identifier doesn't exist. */ LONG getRegistryStringValue(HKEY hKey, const WString& name, WString& value, const WString& defaultValue) { value = defaultValue; wchar_t strBuffer[512]; DWORD strBufferSize = sizeof(strBuffer); ULONG result = RegQueryValueExW(hKey, name.c_str(), 0, nullptr, (LPBYTE)strBuffer, &strBufferSize); if (result == ERROR_SUCCESS) value = strBuffer; return result; } /** Contains data about a Visual Studio project. */ struct VSProjectInfo { WString GUID; WString name; Path path; }; /** * Handles retrying of calls that fail to access Visual Studio. This is due to the weird nature of VS when calling its * methods from external code. If this message filter isn't registered some calls will just fail silently. */ class VSMessageFilter : public IMessageFilter { DWORD __stdcall HandleInComingCall(DWORD dwCallType, HTASK htaskCaller, DWORD dwTickCount, LPINTERFACEINFO lpInterfaceInfo) override { return SERVERCALL_ISHANDLED; } DWORD __stdcall RetryRejectedCall(HTASK htaskCallee, DWORD dwTickCount, DWORD dwRejectType) override { if (dwRejectType == SERVERCALL_RETRYLATER) { // Retry immediatey return 99; } // Cancel the call return -1; } DWORD __stdcall MessagePending(HTASK htaskCallee, DWORD dwTickCount, DWORD dwPendingType) override { return PENDINGMSG_WAITDEFPROCESS; } /** COM requirement. Returns instance of an interface of provided type. */ HRESULT __stdcall QueryInterface(REFIID iid, void** ppvObject) override { if(iid == IID_IDropTarget || iid == IID_IUnknown) { AddRef(); *ppvObject = this; return S_OK; } else { *ppvObject = nullptr; return E_NOINTERFACE; } } /** COM requirement. Increments objects reference count. */ ULONG __stdcall AddRef() override { return InterlockedIncrement(&mRefCount); } /** COM requirement. Decreases the objects reference count and deletes the object if its zero. */ ULONG __stdcall Release() override { LONG count = InterlockedDecrement(&mRefCount); if(count == 0) { bs_delete(this); return 0; } else { return count; } } private: LONG mRefCount; }; /** Contains various helper classes for interacting with a Visual Studio instance running on this machine. */ class VisualStudio { private: static const String SLN_TEMPLATE; /**< Template text used for a solution file. */ static const String PROJ_ENTRY_TEMPLATE; /**< Template text used for a project entry in a solution file. */ static const String PROJ_PLATFORM_TEMPLATE; /**< Template text used for platform specific information for a project entry in a solution file. */ static const String PROJ_TEMPLATE; /**< Template XML used for a project file. */ static const String REFERENCE_ENTRY_TEMPLATE; /**< Template XML used for a reference to another assembly entry by name. */ static const String REFERENCE_PROJECT_ENTRY_TEMPLATE; /**< Template XML used for a reference to another project entry. */ static const String REFERENCE_PATH_ENTRY_TEMPLATE; /**< Template XML used for a reference to another assembly entry by name and path. */ static const String CODE_ENTRY_TEMPLATE; /**< Template XML used for a single code file entry in a project. */ static const String NON_CODE_ENTRY_TEMPLATE; /**< Template XML used for a single non-code file entry in a project. */ public: /** * Scans the running processes to find a running Visual Studio instance with the specified version and open solution. * * @param[in] clsID Class ID of the specific Visual Studio version we are looking for. * @param[in] solutionPath Path to the solution the instance needs to have open. * @return DTE object that may be used to interact with the Visual Studio instance, or null if * not found. */ static CComPtr<EnvDTE::_DTE> findRunningInstance(const CLSID& clsID, const Path& solutionPath) { CComPtr<IRunningObjectTable> runningObjectTable = nullptr; if (FAILED(GetRunningObjectTable(0, &runningObjectTable))) return nullptr; CComPtr<IEnumMoniker> enumMoniker = nullptr; if (FAILED(runningObjectTable->EnumRunning(&enumMoniker))) return nullptr; CComPtr<IMoniker> dteMoniker = nullptr; if (FAILED(CreateClassMoniker(clsID, &dteMoniker))) return nullptr; CComBSTR bstrSolution(solutionPath.toWString(Path::PathType::Windows).c_str()); CComPtr<IMoniker> moniker; ULONG count = 0; while (enumMoniker->Next(1, &moniker, &count) == S_OK) { if (moniker->IsEqual(dteMoniker)) { CComPtr<IUnknown> curObject = nullptr; HRESULT result = runningObjectTable->GetObject(moniker, &curObject); moniker = nullptr; if (result != S_OK) continue; CComPtr<EnvDTE::_DTE> dte; curObject->QueryInterface(__uuidof(EnvDTE::_DTE), (void**)&dte); if (dte == nullptr) continue; CComPtr<EnvDTE::_Solution> solution; if (FAILED(dte->get_Solution(&solution))) continue; CComBSTR fullName; if (FAILED(solution->get_FullName(&fullName))) continue; if (fullName == bstrSolution) return dte; } } return nullptr; } /** * Opens a new Visual Studio instance of the specified version with the provided solution. * * @param[in] clsID Class ID of the specific Visual Studio version to start. * @param[in] solutionPath Path to the solution the instance needs to open. */ static CComPtr<EnvDTE::_DTE> openInstance(const CLSID& clsid, const Path& solutionPath) { CComPtr<IUnknown> newInstance = nullptr; if (FAILED(::CoCreateInstance(clsid, nullptr, CLSCTX_LOCAL_SERVER, EnvDTE::IID__DTE, (LPVOID*)&newInstance))) return nullptr; CComPtr<EnvDTE::_DTE> dte; newInstance->QueryInterface(__uuidof(EnvDTE::_DTE), (void**)&dte); if (dte == nullptr) return nullptr; dte->put_UserControl(TRUE); CComPtr<EnvDTE::_Solution> solution; if (FAILED(dte->get_Solution(&solution))) return nullptr; CComBSTR bstrSolution(solutionPath.toWString(Path::PathType::Windows).c_str()); if (FAILED(solution->Open(bstrSolution))) return nullptr; // Wait until VS opens UINT32 elapsed = 0; while (elapsed < 10000) { EnvDTE::Window* window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) return dte; Sleep(100); elapsed += 100; } return nullptr; } /** * Opens a file on a specific line in a running Visual Studio instance. * * @param[in] dte DTE object retrieved from findRunningInstance() or openInstance(). * @param[in] filePath Path of the file to open. File should be a part of the VS solution. * @param[in] line Line on which to focus Visual Studio after the file is open. */ static bool openFile(CComPtr<EnvDTE::_DTE> dte, const Path& filePath, UINT32 line) { // Open file CComPtr<EnvDTE::ItemOperations> itemOperations; if (FAILED(dte->get_ItemOperations(&itemOperations))) return false; CComBSTR bstrFilePath(filePath.toWString(Path::PathType::Windows).c_str()); CComBSTR bstrKind(EnvDTE::vsViewKindPrimary); CComPtr<EnvDTE::Window> window = nullptr; if (FAILED(itemOperations->OpenFile(bstrFilePath, bstrKind, &window))) return false; // Scroll to line CComPtr<EnvDTE::Document> activeDocument; if (SUCCEEDED(dte->get_ActiveDocument(&activeDocument))) { CComPtr<IDispatch> selection; if (SUCCEEDED(activeDocument->get_Selection(&selection))) { CComPtr<EnvDTE::TextSelection> textSelection; if (SUCCEEDED(selection->QueryInterface(&textSelection))) { textSelection->GotoLine(line, TRUE); } } } // Bring the window in focus window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) { window->Activate(); HWND hWnd; window->get_HWnd((LONG*)&hWnd); SetForegroundWindow(hWnd); } return true; } /** Generates a Visual Studio project GUID from the project name. */ static String getProjectGUID(const WString& projectName) { static const String guidTemplate = "{0}-{1}-{2}-{3}-{4}"; String hash = md5(projectName); String output = StringUtil::format(guidTemplate, hash.substr(0, 8), hash.substr(8, 4), hash.substr(12, 4), hash.substr(16, 4), hash.substr(20, 12)); StringUtil::toUpperCase(output); return output; } /** * Builds the Visual Studio solution text (.sln) for the provided version, using the provided solution data. * * @param[in] version Visual Studio version for which we're generating the solution file. * @param[in] data Data containing a list of projects and other information required to build the solution text. * @return Generated text of the solution file. */ static String writeSolution(VisualStudioVersion version, const CodeSolutionData& data) { struct VersionData { String formatVersion; }; Map<VisualStudioVersion, VersionData> versionData = { { VisualStudioVersion::VS2008, { "10.00" } }, { VisualStudioVersion::VS2010, { "11.00" } }, { VisualStudioVersion::VS2012, { "12.00" } }, { VisualStudioVersion::VS2013, { "12.00" } }, { VisualStudioVersion::VS2015, { "12.00" } } }; StringStream projectEntriesStream; StringStream projectPlatformsStream; for (auto& project : data.projects) { String guid = getProjectGUID(project.name); String projectName = toString(project.name); projectEntriesStream << StringUtil::format(PROJ_ENTRY_TEMPLATE, projectName, projectName + ".csproj", guid); projectPlatformsStream << StringUtil::format(PROJ_PLATFORM_TEMPLATE, guid); } String projectEntries = projectEntriesStream.str(); String projectPlatforms = projectPlatformsStream.str(); return StringUtil::format(SLN_TEMPLATE, versionData[version].formatVersion, projectEntries, projectPlatforms); } /** * Builds the Visual Studio project text (.csproj) for the provided version, using the provided project data. * * @param[in] version Visual Studio version for which we're generating the project file. * @param[in] projectData Data containing a list of files, references and other information required to * build the project text. * @return Generated text of the project file. */ static String writeProject(VisualStudioVersion version, const CodeProjectData& projectData) { struct VersionData { String toolsVersion; }; Map<VisualStudioVersion, VersionData> versionData = { { VisualStudioVersion::VS2008, { "3.5" } }, { VisualStudioVersion::VS2010, { "4.0" } }, { VisualStudioVersion::VS2012, { "4.0" } }, { VisualStudioVersion::VS2013, { "12.0" } }, { VisualStudioVersion::VS2015, { "13.0" } } }; StringStream tempStream; for (auto& codeEntry : projectData.codeFiles) tempStream << StringUtil::format(CODE_ENTRY_TEMPLATE, codeEntry.toString()); String codeEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& nonCodeEntry : projectData.nonCodeFiles) tempStream << StringUtil::format(NON_CODE_ENTRY_TEMPLATE, nonCodeEntry.toString()); String nonCodeEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& referenceEntry : projectData.assemblyReferences) { String referenceName = toString(referenceEntry.name); if (referenceEntry.path.isEmpty()) tempStream << StringUtil::format(REFERENCE_ENTRY_TEMPLATE, referenceName); else tempStream << StringUtil::format(REFERENCE_PATH_ENTRY_TEMPLATE, referenceName, referenceEntry.path.toString()); } String referenceEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); for (auto& referenceEntry : projectData.projectReferences) { String referenceName = toString(referenceEntry.name); String projectGUID = getProjectGUID(referenceEntry.name); tempStream << StringUtil::format(REFERENCE_PROJECT_ENTRY_TEMPLATE, referenceName, projectGUID); } String projectReferenceEntries = tempStream.str(); tempStream.str(""); tempStream.clear(); tempStream << toString(projectData.defines); String defines = tempStream.str(); String projectGUID = getProjectGUID(projectData.name); return StringUtil::format(PROJ_TEMPLATE, versionData[version].toolsVersion, projectGUID, toString(projectData.name), defines, referenceEntries, projectReferenceEntries, codeEntries, nonCodeEntries); } }; const String VisualStudio::SLN_TEMPLATE = R"(Microsoft Visual Studio Solution File, Format Version {0} # Visual Studio 2013 VisualStudioVersion = 12.0.30723.0 MinimumVisualStudioVersion = 10.0.40219.1{1} Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution{2} EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal )"; const String VisualStudio::PROJ_ENTRY_TEMPLATE = R"( Project("\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\}") = "{0}", "{1}", "\{{2}\}" EndProject)"; const String VisualStudio::PROJ_PLATFORM_TEMPLATE = R"( \{{0}\}.Debug|Any CPU.ActiveCfg = Debug|Any CPU \{{0}\}.Debug|Any CPU.Build.0 = Debug|Any CPU \{{0}\}.Release|Any CPU.ActiveCfg = Release|Any CPU \{{0}\}.Release|Any CPU.Build.0 = Release|Any CPU)"; const String VisualStudio::PROJ_TEMPLATE = R"literal(<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="{0}" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition = " '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition = " '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>\{{1}\}</ProjectGuid> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace></RootNamespace> <AssemblyName>{2}</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <BaseDirectory>Resources</BaseDirectory> <SchemaVersion>2.0</SchemaVersion> </PropertyGroup> <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>Internal\\Temp\\Assemblies\\Debug\\</OutputPath> <BaseIntermediateOutputPath>Internal\\Temp\\Assemblies\\</BaseIntermediateOutputPath> <DefineConstants>DEBUG;TRACE;{3}</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel > </PropertyGroup> <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>Internal\\Temp\\Assemblies\\Release\\</OutputPath> <BaseIntermediateOutputPath>Internal\\Temp\\Assemblies\\</BaseIntermediateOutputPath> <DefineConstants>TRACE;{3}</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup>{4} </ItemGroup> <ItemGroup>{5} </ItemGroup> <ItemGroup>{6} </ItemGroup> <ItemGroup>{7} </ItemGroup> <Import Project = "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"/> </Project>)literal"; const String VisualStudio::REFERENCE_ENTRY_TEMPLATE = R"( <Reference Include="{0}"/>)"; const String VisualStudio::REFERENCE_PATH_ENTRY_TEMPLATE = R"( <Reference Include="{0}"> <HintPath>{1}</HintPath> </Reference>)"; const String VisualStudio::REFERENCE_PROJECT_ENTRY_TEMPLATE = R"( <ProjectReference Include="{0}.csproj"> <Project>\{{1}\}</Project> <Name>{0}</Name> </ProjectReference>)"; const String VisualStudio::CODE_ENTRY_TEMPLATE = R"( <Compile Include="{0}"/>)"; const String VisualStudio::NON_CODE_ENTRY_TEMPLATE = R"( <None Include="{0}"/>)"; VSCodeEditor::VSCodeEditor(VisualStudioVersion version, const Path& execPath, const WString& CLSID) :mVersion(version), mExecPath(execPath), mCLSID(CLSID) { } void VSCodeEditor::openFile(const Path& solutionPath, const Path& filePath, UINT32 lineNumber) const { CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); CLSID clsID; if (FAILED(CLSIDFromString(mCLSID.c_str(), &clsID))) { CoUninitialize(); return; } CComPtr<EnvDTE::_DTE> dte = VisualStudio::findRunningInstance(clsID, solutionPath); if (dte == nullptr) dte = VisualStudio::openInstance(clsID, solutionPath); if (dte == nullptr) { CoUninitialize(); return; } VSMessageFilter* newFilter = new VSMessageFilter(); IMessageFilter* oldFilter; CoRegisterMessageFilter(newFilter, &oldFilter); EnvDTE::Window* window = nullptr; if (SUCCEEDED(dte->get_MainWindow(&window))) window->Activate(); VisualStudio::openFile(dte, filePath, lineNumber); CoRegisterMessageFilter(oldFilter, nullptr); CoUninitialize(); } void VSCodeEditor::syncSolution(const CodeSolutionData& data, const Path& outputPath) const { String solutionString = VisualStudio::writeSolution(mVersion, data); solutionString = StringUtil::replaceAll(solutionString, "\n", "\r\n"); Path solutionPath = outputPath; solutionPath.append(data.name + L".sln"); for (auto& project : data.projects) { String projectString = VisualStudio::writeProject(mVersion, project); projectString = StringUtil::replaceAll(projectString, "\n", "\r\n"); Path projectPath = outputPath; projectPath.append(project.name + L".csproj"); SPtr<DataStream> projectStream = FileSystem::createAndOpenFile(projectPath); projectStream->write(projectString.c_str(), projectString.size() * sizeof(String::value_type)); projectStream->close(); } SPtr<DataStream> solutionStream = FileSystem::createAndOpenFile(solutionPath); solutionStream->write(solutionString.c_str(), solutionString.size() * sizeof(String::value_type)); solutionStream->close(); } VSCodeEditorFactory::VSCodeEditorFactory() :mAvailableVersions(getAvailableVersions()) { for (auto& version : mAvailableVersions) mAvailableEditors.push_back(version.first); } Map<CodeEditorType, VSCodeEditorFactory::VSVersionInfo> VSCodeEditorFactory::getAvailableVersions() const { #if BS_ARCH_TYPE == BS_ARCHITECTURE_x86_64 bool is64bit = true; #else bool is64bit = false; IsWow64Process(GetCurrentProcess(), (PBOOL)&is64bit); #endif WString registryKeyRoot; if (is64bit) registryKeyRoot = L"SOFTWARE\\Wow6432Node\\Microsoft"; else registryKeyRoot = L"SOFTWARE\\Microsoft"; struct VersionData { CodeEditorType type; WString registryKey; WString name; WString executable; }; Map<VisualStudioVersion, VersionData> versionToVersionNumber = { { VisualStudioVersion::VS2008, { CodeEditorType::VS2008, L"VisualStudio\\9.0", L"Visual Studio 2008", L"devenv.exe" } }, { VisualStudioVersion::VS2010, { CodeEditorType::VS2010, L"VisualStudio\\10.0", L"Visual Studio 2010", L"devenv.exe" } }, { VisualStudioVersion::VS2012, { CodeEditorType::VS2012, L"VisualStudio\\11.0", L"Visual Studio 2012", L"devenv.exe" } }, { VisualStudioVersion::VS2013, { CodeEditorType::VS2013, L"VisualStudio\\12.0", L"Visual Studio 2013", L"devenv.exe" } }, { VisualStudioVersion::VS2015, { CodeEditorType::VS2015, L"VisualStudio\\14.0", L"Visual Studio 2015", L"devenv.exe" } } }; Map<CodeEditorType, VSVersionInfo> versionInfo; for(auto version : versionToVersionNumber) { WString registryKey = registryKeyRoot + L"\\" + version.second.registryKey; HKEY regKey; LONG result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryKey.c_str(), 0, KEY_READ, &regKey); if (result != ERROR_SUCCESS) continue; WString installPath; getRegistryStringValue(regKey, L"InstallDir", installPath, StringUtil::WBLANK); if (installPath.empty()) continue; WString clsID; getRegistryStringValue(regKey, L"ThisVersionDTECLSID", clsID, StringUtil::WBLANK); VSVersionInfo info; info.name = version.second.name; info.execPath = installPath.append(version.second.executable); info.CLSID = clsID; info.version = version.first; versionInfo[version.second.type] = info; } return versionInfo; } CodeEditor* VSCodeEditorFactory::create(CodeEditorType type) const { auto findIter = mAvailableVersions.find(type); if (findIter == mAvailableVersions.end()) return nullptr; // TODO - Also create VSExpress and VSCommunity editors return bs_new<VSCodeEditor>(findIter->second.version, findIter->second.execPath, findIter->second.CLSID); } }
[ "bearishsun@gmail.com" ]
bearishsun@gmail.com
31a4cdecf1c61a27f8d1246d81cc2872e57ae982
ad20ec70814c8e3992e14c8e78ef1830d7c73597
/TripleX/main.cpp
c45e529e76be9924d25f61e139a55aa784b234c0
[]
no_license
koerriva/UnrealEngine4Course
eab6ea63d00777a53476f750528257563891cea0
c575fe211e034e405e34f524ebe0f1ac498be0d7
refs/heads/master
2022-10-13T15:16:09.067684
2020-06-02T14:26:52
2020-06-02T14:26:52
265,832,276
0
0
null
null
null
null
UTF-8
C++
false
false
1,931
cpp
#include <iostream> #include <ctime> void PrintIntroduction(int Difficulty) { std::cout << "\033[1;33mYou are a secret agent breaking into a level "; std::cout << "\033[1;32m" << Difficulty << "\033[0m"; std::cout << "\033[1;33m" << " secure server room...\033[0m\n"; std::cout << "\033[1;31mEnter the correct code to continue...\033[0m\n\n"; } bool PlayGame(int Difficulty) { PrintIntroduction(Difficulty); const int CodeA = rand() % Difficulty + 1; const int CodeB = rand() % Difficulty + 1; const int CodeC = rand() % Difficulty + 1; const int CodeSum = CodeA + CodeB + CodeC; const int CodeProduct = CodeA * CodeB * CodeC; std::cout << "+ There are 3 numbers in the code"; std::cout << "\n+ The codes add-up to:\033[1;32m" << CodeSum; std::cout << "\033[0m\n+ The codes multiply to give:\033[1;32m" << CodeProduct << "\033[0m" << std::endl; int GuessA, GuessB, GuessC; std::cin >> GuessA >> GuessB >> GuessC; const int GuessSum = GuessA + GuessB + GuessC; const int GuessProduct = GuessA * GuessB * GuessC; if (GuessSum == CodeSum && GuessProduct == CodeProduct) { std::cout << "\033[1;32m" << "Well done!You have extracted a file!" << "\033[0m\n\n"; return true; } else { std::cout << "\033[1;31m" << "You entered wrong code!Be carefully!Try again!" << "\033[0m\n\n"; return false; } } int main() { srand(time(NULL)); int LevelDifficulty = 1; const int MaxLevelDifficulty = 5; while (LevelDifficulty <= MaxLevelDifficulty) { bool bLevelComplete = PlayGame(LevelDifficulty); std::cin.clear(); std::cin.ignore(); if (bLevelComplete) { ++LevelDifficulty; } } std::cout << "\n*** Great work agent! ***\n"; return 0; }
[ "504097978@qq.com" ]
504097978@qq.com
f9d054b276bb474ba401ed6614b848a43fce7142
03b20afd312ba32e375d8a2619a070971f3e31f5
/Coursera/Data Structures and Algorithms Specialization/Algorithmic Toolbox/Week2/last_digit_of_a_large_fibonacci_number.cpp
87330ec8ee5bce10f11044d63577426135a55425
[]
no_license
AndrewShkrob/Courses
9c368e107786ba7c19a1744072d6f50bc332efbb
c5d95e468ac8ee0d38a6af7119c1d9c1962c4941
refs/heads/master
2022-10-05T02:48:38.388577
2020-06-06T14:25:27
2020-06-06T14:25:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
402
cpp
#include <bits/stdc++.h> using namespace std; uint64_t FibonacciLastDigit(uint64_t n) { if (n <= 1) return n; uint64_t a = 0; uint64_t b = 1; uint64_t ans = 0; for (size_t i = 2; i <= n; i++) { ans = (a + b) % 10; a = b; b = ans; } return ans; } int main() { uint64_t n; cin >> n; cout << FibonacciLastDigit(n); return 0; }
[ "andrei5709978@gmail.com" ]
andrei5709978@gmail.com
6955ad08326f1cf2d1c0aaf749566ed6ba6ce3f0
5012f1a7f9d746c117f04ff56f7ebe6d5fc9128f
/1.Server/2.Midware/KFPlugin/KFRobot/KFQueryFriendRankState.cpp
3f23e0ad284c1c1cae7bddbb58bde3f1bb49e3c8
[ "Apache-2.0" ]
permissive
hw233/KFrame
c9badd576ab7c75f4e5aea2cfb3b20f6f102177f
a7e300c301225d0ba3241abcf81e871d8932f326
refs/heads/master
2023-05-11T07:50:30.349114
2019-01-25T08:20:11
2019-01-25T08:20:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
961
cpp
#include "KFQueryFriendRankState.h" #include "KFRobot.h" namespace KFrame { void KFQueryFriendRankState::EnterState( KFRobot* kfrobot ) { // 启动定时器, 10秒认证一次 kfrobot->StartTimer( _kf_robot_config->_state_rep_time ); } void KFQueryFriendRankState::LeaveState( KFRobot* kfrobot ) { kfrobot->StopTimer(); } void KFQueryFriendRankState::CheckState( KFRobot* kfrobot ) { } void KFQueryFriendRankState::RunState( KFRobot* kfrobot ) { if ( !kfrobot->DoneTimer() ) { return; } if ( kfrobot->_loop_wait_times >= _kf_robot_config->_next_state_cryl_time ) { kfrobot->ChangeStateProxy(); //kfrobot->ChangeState( RobotStateEnum::EnterChat ); kfrobot->_loop_wait_times = 0; return; } kfrobot->QueryFriendRankList(); ++kfrobot->_loop_wait_times; } }
[ "lori227@qq.com" ]
lori227@qq.com
addc5b1c12b7b43b61875450b13d0454d7d12f71
e73ca94a87c263b0e7622a850a576d526fc22d82
/D3DX_Doyun_Engine/ConsoleLogger.h
d3d286b16c8a1110bdbab2c9cf8e3671418a6877
[]
no_license
Sicarim/D3DX_Project
de3805bb1bf08b66396ab815c1abc6ffad68ba64
5679aa80a7aac9e8cd05f77567eb4bc279657257
refs/heads/main
2023-03-26T22:25:52.857187
2021-03-15T15:05:04
2021-03-15T15:05:04
348,013,258
0
0
null
null
null
null
UTF-8
C++
false
false
6,611
h
// ConsoleLogger.h: interface for the CConsoleLogger class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_CONSOLELOGGER_H__294FDF9B_F91E_4F6A_A953_700181DD1996__INCLUDED_) #define AFX_CONSOLELOGGER_H__294FDF9B_F91E_4F6A_A953_700181DD1996__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "windows.h" #include <time.h> #include <stdio.h> #include "stdlib.h" #include <fcntl.h> #include "io.h" #include "direct.h" #include "ntverp.h" #if !defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD<3790 #pragma message ("********************************************************************************************") #pragma message ("Notice (performance-warning): you are not using the Microsoft Platform SDK,") #pragma message (" we'll use CRITICAL_SECTION instead of InterLocked operation") #pragma message ("********************************************************************************************") #else #define CONSOLE_LOGGER_USING_MS_SDK #endif // If no "helper_executable" location was specify - // search for the DEFAULT_HELPER_EXE #define DEFAULT_HELPER_EXE "ConsoleLoggerHelper.exe" class CConsoleLogger { public: // ctor,dtor CConsoleLogger(); virtual ~CConsoleLogger(); // create a logger: starts a pipe+create the child process long Create(const char *lpszWindowTitle=NULL, int buffer_size_x=-1,int buffer_size_y=-1, const char *logger_name=NULL, const char *helper_executable=NULL); // close everything long Close(void); // output functions inline int print(const char *lpszText,int iSize=-1); int printf(const char *format,...); // play with the CRT output functions int SetAsDefaultOutput(void); static int ResetDefaultOutput(void); protected: char m_name[64]; HANDLE m_hPipe; #ifdef CONSOLE_LOGGER_USING_MS_SDK // we'll use this DWORD as VERY fast critical-section . for more info: // * "Understand the Impact of Low-Lock Techniques in Multithreaded Apps" // Vance Morrison , MSDN Magazine October 2005 // * "Performance-Conscious Thread Synchronization" , Jeffrey Richter , MSDN Magazine October 2005 volatile long m_fast_critical_section; inline void InitializeCriticalSection(void) { m_fast_critical_section=0; } inline void DeleteCriticalSection(void) { m_fast_critical_section=0; } // our own LOCK function inline void EnterCriticalSection(void) { while ( InterlockedCompareExchange(&m_fast_critical_section,1,0)!=0) Sleep(0); } // our own UNLOCK function inline void LeaveCriticalSection(void) { m_fast_critical_section=0; } #else CRITICAL_SECTION m_cs; inline void InitializeCriticalSection(void) { ::InitializeCriticalSection(&m_cs); } inline void DeleteCriticalSection(void) { ::DeleteCriticalSection(&m_cs); } // our own LOCK function inline void EnterCriticalSection(void) { ::EnterCriticalSection(&m_cs); } // our own UNLOCK function inline void LeaveCriticalSection(void) { ::LeaveCriticalSection(&m_cs); } #endif // you can extend this class by overriding the function virtual long AddHeaders(void) { return 0;} // the _print() helper function virtual int _print(const char *lpszText,int iSize); // SafeWriteFile : write safely to the pipe inline BOOL SafeWriteFile( /*__in*/ HANDLE hFile, /*__in_bcount(nNumberOfBytesToWrite)*/ LPCVOID lpBuffer, /*__in */ DWORD nNumberOfBytesToWrite, /*__out_opt */ LPDWORD lpNumberOfBytesWritten, /*__inout_opt */ LPOVERLAPPED lpOverlapped ) { EnterCriticalSection(); BOOL bRet = ::WriteFile(hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped); LeaveCriticalSection(); return bRet; } }; /////////////////////////////////////////////////////////////////////////// // CConsoleLoggerEx: same as CConsoleLogger, // but with COLORS and more functionality (cls,gotoxy,...) // // the drawback - we first send the "command" and than the data, // so it's little bit slower . (i don't believe that anyone // is going to notice the differences , it's not measurable) // ////////////////////////////////////////////////////////////////////////// class CConsoleLoggerEx : public CConsoleLogger { DWORD m_dwCurrentAttributes; enum enumCommands { COMMAND_PRINT, COMMAND_CPRINT, COMMAND_CLEAR_SCREEN, COMMAND_COLORED_CLEAR_SCREEN, COMMAND_GOTOXY, COMMAND_CLEAR_EOL, COMMAND_COLORED_CLEAR_EOL }; public: CConsoleLoggerEx(); enum enumColors { COLOR_BLACK=0, COLOR_BLUE=FOREGROUND_BLUE, COLOR_GREEN=FOREGROUND_GREEN , COLOR_RED =FOREGROUND_RED , COLOR_WHITE=COLOR_RED|COLOR_GREEN|COLOR_BLUE, COLOR_INTENSITY =FOREGROUND_INTENSITY , COLOR_BACKGROUND_BLACK=0, COLOR_BACKGROUND_BLUE =BACKGROUND_BLUE , COLOR_BACKGROUND_GREEN =BACKGROUND_GREEN , COLOR_BACKGROUND_RED =BACKGROUND_RED , COLOR_BACKGROUND_WHITE =COLOR_BACKGROUND_RED|COLOR_BACKGROUND_GREEN|COLOR_BACKGROUND_BLUE , COLOR_BACKGROUND_INTENSITY =BACKGROUND_INTENSITY , COLOR_COMMON_LVB_LEADING_BYTE =COMMON_LVB_LEADING_BYTE , COLOR_COMMON_LVB_TRAILING_BYTE =COMMON_LVB_TRAILING_BYTE , COLOR_COMMON_LVB_GRID_HORIZONTAL =COMMON_LVB_GRID_HORIZONTAL , COLOR_COMMON_LVB_GRID_LVERTICAL =COMMON_LVB_GRID_LVERTICAL , COLOR_COMMON_LVB_GRID_RVERTICAL =COMMON_LVB_GRID_RVERTICAL , COLOR_COMMON_LVB_REVERSE_VIDEO =COMMON_LVB_REVERSE_VIDEO , COLOR_COMMON_LVB_UNDERSCORE=COMMON_LVB_UNDERSCORE }; // Clear screen , use default color (black&white) void cls(void); // Clear screen use specific color void cls(DWORD color); // Clear till End Of Line , use default color (black&white) void clear_eol(void); // Clear till End Of Line , use specified color void clear_eol(DWORD color); // write string , use specified color int cprintf(int attributes,const char *format,...); // write string , use current color int cprintf(const char *format,...); // goto(x,y) void gotoxy(int x,int y); DWORD GetCurrentColor(void) { return m_dwCurrentAttributes; } void SetCurrentColor(DWORD dwColor) { m_dwCurrentAttributes=dwColor; } protected: virtual long AddHeaders(void) { // Thnx to this function, the "Helper" can see that we are "extended" logger !!! // (so we can use the same helper-child-application for both loggers DWORD cbWritten=0; const char *ptr= "Extended-Console: TRUE\r\n"; WriteFile(m_hPipe,ptr,strlen(ptr),&cbWritten,NULL); return (cbWritten==strlen(ptr)) ? 0 : -1; } virtual int _print(const char *lpszText,int iSize); virtual int _cprint(int attributes,const char *lpszText,int iSize); }; #endif
[ "djawleh@naver.com" ]
djawleh@naver.com
eb1d76fa137b7b7e67ed56e4748d7ec0059b3eb1
2665b0d8ab0ba8584721b6dcd50f404952921900
/src/interpreter.hh
576835201010c4237152a77cefa7d19026ae1874
[ "MIT" ]
permissive
hxdaze/Epilog
2f9d938828e5f3e5e356d2695867fca78221650f
48cd45be6003f7968e5ed9ad69d2907fed9f435e
refs/heads/master
2021-12-14T09:34:22.457568
2017-04-22T11:38:05
2017-04-22T11:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,172
hh
#include "runtime.hh" namespace Epilog { namespace Interpreter { struct FunctorClause { // A structure entailing a block of instructions containing the definition for each clause with a certain functor. std::vector<Instruction::instructionReference> startAddresses; Instruction::instructionReference endAddress; FunctorClause(Instruction::instructionReference startAddress, Instruction::instructionReference endAddress) : endAddress(endAddress) { startAddresses.push_back(startAddress); } }; class Context { public: std::unordered_map<std::string, FunctorClause> functorClauses; Instruction::instructionReference insertionAddress = 0; }; } // These functions are made visible to external classes so that dynamic instruction generation is possible. namespace AST { void executeInstructions(Instruction::instructionReference startAddress, Instruction::instructionReference endAddress, std::unordered_map<std::string, HeapReference>* allocations); } Instruction::instructionReference pushInstruction(Interpreter::Context& context, Instruction* instruction); void initialiseBuiltins(Interpreter::Context& context); }
[ "github@varkor.com" ]
github@varkor.com
76a61ab4d8a8fbf46b6ae5b33f89a7d5f83c9fe3
80ed2d804f11a90013b95d51f838513f1e42ef1c
/src/SimpleVariantCallTool.cpp
e2a6a5c5288f517339c61edd211d7fedfbd0e1bc
[]
no_license
ZengFLab/PyroTools
dc80b4cd44b830fd9efe0d16632a8c51650b6e48
81ece81d1947100edbecb807755a01a472d348ad
refs/heads/master
2021-12-05T01:35:57.751050
2015-05-26T03:39:35
2015-05-26T03:39:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,328
cpp
#include "SimpleVariantCallTool.h" #include "GenericRegionTools.h" #include "GenericVariant.h" #include "GenericBamAlignmentTools.h" #include "GenericSequenceGlobal.h" using namespace GenericSequenceTools; #include <getopt.h> #include <time.h> #include <tuple> #include <utility> #include <iomanip> #include <iostream> #include <fstream> #include <sstream> #include <sys/stat.h> #include <algorithm> #include <forward_list> #include <unordered_map> #include <parallel/algorithm> #include <omp.h> using namespace std; #include "api/BamReader.h" #include "api/BamMultiReader.h" #include "api/BamAux.h" #include "api/BamAlignment.h" using namespace BamTools; SimpleVariantCallTool::SimpleVariantCallTool() :mapQualThres(5) ,readLenThres(100) ,alnIdentityThres(0.9) ,numAmbiguousThres(2) ,alnFlagMarker(0) ,baseQualThres(10) ,snpHitThres(2) ,indelHitThres(2) ,ignoreSnp(false) ,ignoreIndel(false) ,outputFormat("bed") ,numThreads(1) ,windowSize(1e+5) ,verbose(0) { } // verbose inline void Verbose(string MSG) { cerr << "[" << CurrentTime() << " PyroTools-SimpleVarCall] " << MSG << endl; } // check the existence of a file // reference: http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c inline bool file_exist(const string& filename) { struct stat buffer; return (stat (filename.c_str(), &buffer) == 0); } // help message int SimpleVariantCallTool::Help() { cerr << "SYNOPSIS" << endl; cerr << " PyroTools SimpleVarCall [OPTIONS] <GENOME> <BAM> [<BAM>...]" << endl; cerr << "" << endl; cerr << "DESCRIPTION" << endl; cerr << " SimpleVarCall is to simply profile all suspect variants in the genome given sequencing data." << endl; cerr << "" << endl; cerr << "OPTIONS" << endl; cerr << "Read Filtration" << endl; cerr << " --roi filter reads not hit the region of interest" << endl; cerr << " --roi-list filter reads not hit the regions of interest" << endl; cerr << " --mq filter reads with mapping quality less than the value (default:5) [INT]" << endl; cerr << " --len filter reads with length less than the value (default:100) [INT]" << endl; cerr << " --iden filter reads with the identity less than the value (default:0.9) [FLT]" << endl; cerr << " --na filter reads with many ambiguous base (default:2) [INT]" << endl; cerr << " --ff filter reads with the specified flags, flag info could be found in SAM manual [INT]" << endl; cerr << "Variant Filtration" << endl; cerr << " --bq filter read alleles with base quality less than the value (default:10) [INT]" << endl; cerr << " --snp-hit filter SNPs with the hits less than the value (default:2) [INT]" << endl; cerr << " --indel-hit filter INDELs with the hits less than the value (default:2) [INT]" << endl; cerr << "Variant Output" << endl; cerr << " --disable-snp ignore SNPs" << endl; cerr << " --disable-indel ignore INDELs" << endl; cerr << " --out-format specify the format of output, valid arguments: bed or vcf (default:bed) [STR]" << endl; cerr << "Miscellaneous" << endl; cerr << " --window specify the size of the scanning window (default:1e+5) [INT]" << endl; cerr << " --num-cores specify the number of cpu cores being used (default:1) [INT]" << endl; cerr << " -v,--verbose specify the level of verbosity, valid arguments: 0 for quiet, 1 for debug (default:0) [INT]" << endl; cerr << " -h,--help print help message" << endl; return 0; } int SimpleVariantCallTool::commandLineParser(int argc, char *argv[]) { auto isHexString = [](string s) { for (auto c : s) { if (c=='x') return true; if (c=='X') return true; } return false; }; int c; while (1) { static struct option long_options[] = { {"roi", required_argument, 0, 0}, {"roi-list", required_argument, 0, 0}, {"mq", required_argument, 0, 0}, {"len", required_argument, 0, 0}, {"iden", required_argument, 0, 0}, {"na", required_argument, 0, 0}, {"ff", required_argument, 0, 0}, {"bq", required_argument, 0, 0}, {"snp-hit", required_argument, 0, 0}, {"indel-hit", required_argument, 0, 0}, {"disable-snp", no_argument, 0, 0}, {"disable-indel", no_argument, 0, 0}, {"out-format", required_argument, 0, 0}, {"num-cores", required_argument, 0, 0}, {"window", required_argument, 0, 0}, {"verbose", required_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {0,0,0,0} }; // getopt_long stores the option index here int option_index = 0; c = getopt_long(argc, argv, "v:h", long_options, &option_index); // detect the end of the options if (c==-1) break; switch(c) { case 0: switch(option_index) { case 0: regionStringsOfInterest.emplace_back(optarg); break; case 1: { ifstream infile(optarg); string line; while (getline(infile,line)) { if (!line.empty()) regionStringsOfInterest.emplace_back(optarg); } infile.close(); } break; case 2: mapQualThres=stoi(optarg); break; case 3: readLenThres=stoi(optarg); break; case 4: alnIdentityThres=stod(optarg); break; case 5: numAmbiguousThres=stoi(optarg); break; case 6: if (isHexString(optarg)){ alnFlagMarker |= stoul(optarg,nullptr,16); }else{ alnFlagMarker |= stoi(optarg); } break; case 7: baseQualThres=stoi(optarg); break; case 8: snpHitThres=stoi(optarg); break; case 9: indelHitThres=stoi(optarg); break; case 10: ignoreSnp=true; break; case 11: ignoreIndel=true; break; case 12: outputFormat=optarg; break; case 13: numThreads=stoi(optarg); break; case 14: windowSize=stod(optarg); break; default: abort(); } break; case 'v': verbose=stoi(optarg); break; case 'h': Help(); exit(EXIT_SUCCESS); break; case '?': exit(EXIT_FAILURE); break; default: abort(); } } // genome file if (optind<argc) { genomeFile=argv[optind++]; // check the existence of the genome file if (!file_exist(genomeFile)) { cerr << "[PyroTools-SimpleVarCall] error: " << genomeFile << " not existed" << endl; exit(EXIT_FAILURE); } // check the existence of the genome index file if (!file_exist(genomeFile+".fai")) { cerr << "[PyroTools-SimpleVarCall] error: " << (genomeFile+".fai") << " not existed" << endl; exit(EXIT_FAILURE); } } // bam file for (; optind<argc;) { bamFiles.emplace_back(argv[optind++]); // check the existence of the bam file auto f=*bamFiles.rbegin(); BamReader bamReader; if (!bamReader.Open(f)) { cerr << "[PyroTools-ConsensusGraph] error: " << f << " not existed or invalid" << endl; exit(EXIT_FAILURE); } } // canonicalize the regions if (regionStringsOfInterest.empty()) { BamMultiReader bamReader; bamReader.Open(bamFiles); RefVector genomeDict = bamReader.GetReferenceData(); for (auto g : genomeDict) { regionStringsOfInterest.emplace_back(g.RefName); } } return 0; } // interface int SimpleVariantCallTool::Run(int argc, char *argv[]) { // print help message if no arguments provided if (argc==2) { Help(); exit(EXIT_SUCCESS); } // parse command line options commandLineParser(argc-1,argv+1); // run the simple variant call if (SimpleVariantCall()!=0) return 1; return 0; } // region sorting function inline bool isValidAlignment(BamAlignment& al, int minReadLen, int minMapQual, int flag) { // check read length if (!GenericBamAlignmentTools::validReadLength(al,minReadLen)) return false; // check map quality if (!GenericBamAlignmentTools::validMapQuality(al,minMapQual)) return false; // check the alignment flag if (GenericBamAlignmentTools::isFilteredByFlag(al,flag)) return false; return true; } // workhorse int SimpleVariantCallTool::SimpleVariantCall() { // open bam file BamMultiReader bamReader; bamReader.Open(bamFiles); // the dictionary of the chromosomes RefVector genomeDict = bamReader.GetReferenceData(); // define the scanning window if (verbose>=1) Verbose(string("define the scanning window")); vector<tuple<int,int,int>> scanWindowSet; int numWindow = GenericRegionTools::toScanWindow(genomeDict, regionStringsOfInterest, windowSize, scanWindowSet); // compute the width for cout int wc1=3,wc2=3,wc3=3,wc4=1,wc5=1; for_each(genomeDict.begin(),genomeDict.end(),[&](RefData& a){ if (wc1<a.RefName.length()) wc1 = a.RefName.length(); if (wc2<to_string(a.RefLength).length()) wc2 = to_string(a.RefLength).length(); if (wc3<to_string(a.RefLength).length()) wc3 = to_string(a.RefLength).length(); }); // lambda funtion for output auto repoVar = [&](GenericAllele& allele) { // to avoid cout interleaving error in parallel mode stringstream buffer; string info = "snp"; if (allele.m_allele=="-" && allele.m_reference!="-") info = "del"; if (allele.m_allele!="-" && allele.m_reference=="-") info = "ins"; buffer << setw(wc1) << left << genomeDict[allele.m_chrID].RefName << "\t" << setw(wc2) << left << (allele.m_chrPosition+1) << "\t" << setw(wc3) << left << (allele.m_chrPosition+1+1) << "\t" << setw(wc4) << left << allele.m_reference << "\t" << setw(wc5) << left << allele.m_allele << "\t" << setw(3) << left << allele.m_alleleDepth << "\t" << setw(3) << left << allele.m_globalDepth << "\t" << setw(3) << left << info << "\n"; std::cout << buffer.str() << std::flush; }; clock_t allTime = 0; // loop over windows if (verbose>=1) Verbose(string("looping over the windows")); omp_set_dynamic(0); omp_set_num_threads(numThreads); #pragma omp parallel for shared(genomeDict,repoVar) reduction(+:allTime) for (int i=0; i<numWindow; i++) { BamMultiReader bamReader; bamReader.Open(bamFiles); clock_t tStart = clock(); // define an alignment BamAlignment aln; // alleles in the window unordered_map<string,GenericAllele> alleles; // define a lambda function auto depoVar = [&](int tId, int tPos, char tRef, char tAlt, double tBq, int tDep) { string tKey = GenericAllele::key(tId, tPos, tRef, tAlt); auto tPtr = alleles.find(tKey); if (tPtr==alleles.end()) { GenericAllele allele; allele.m_chrID = tId; allele.m_chrPosition = tPos; allele.m_reference = tRef; allele.m_globalDepth = tDep; allele.m_allele = tAlt; allele.m_alleleDepth = 1; allele.m_alleleMapAvgQual = aln.MapQuality; allele.m_alleleStrandPos = (aln.IsReverseStrand()?0:1); allele.m_alleleStrandNeg = (aln.IsReverseStrand()?1:0); allele.m_bamData.emplace_back(tuple<char,int,int,int>(tAlt,tBq,aln.MapQuality,((aln.IsReverseStrand()?-1:1)))); alleles.emplace(make_pair(tKey, allele)); }else { tPtr->second.m_alleleDepth += 1; tPtr->second.m_alleleMapAvgQual += aln.MapQuality; tPtr->second.m_alleleStrandPos += (aln.IsReverseStrand()?0:1); tPtr->second.m_alleleStrandNeg += (aln.IsReverseStrand()?1:0); tPtr->second.m_bamData.emplace_back(tuple<char,int,int,int>(tAlt,tBq,aln.MapQuality,((aln.IsReverseStrand()?-1:1)))); } }; // window position tuple<int,int,int> w = scanWindowSet[i]; int wId = get<0>(w); int wLp = get<1>(w); int wRp = get<2>(w); // get sequencing depth if (verbose>=1) Verbose("retrieve the depths in "+genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp)); map<long,long> genomeDepth; string CMD, DepthResult; stringstream ssCMD; ssCMD << "samtools depth "; ssCMD << "-r " << genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp) << " "; ssCMD << "-q " << baseQualThres << " "; ssCMD << "-Q " << mapQualThres << " "; ssCMD << "-l " << readLenThres << " "; for (auto bf : bamFiles) ssCMD << " " << bf; CMD = ssCMD.str(); // run the command RunCmdGetReturn(CMD, DepthResult); // parse the result { string tId; int tPos, tDep; string result; stringstream ssResult; stringstream ssDepthResult(DepthResult); while(getline(ssDepthResult, result)){ ssResult << result; ssResult >> tId >> tPos >> tDep; ssResult.clear(); ssResult.str(""); genomeDepth[tPos-1] = tDep; } } // get variants if (verbose>=1) Verbose("retrieve the variants in "+genomeDict[wId].RefName+":"+to_string(wLp+1)+"-"+to_string(wRp)); // rewind the reader bamReader.Rewind(); // set the window region bamReader.SetRegion(wId, wLp, wId, wRp); // retrieve an alignment in the window while (bamReader.GetNextAlignment(aln)) { // skip the alignment if it doesn't overlap the window if (aln.Position>=wRp || aln.GetEndPosition()<=wLp) continue; // skip the invalid alignment if (!isValidAlignment(aln, readLenThres, mapQualThres, alnFlagMarker)) continue; // skip the alignment harboring too many mismatches if (!GenericBamAlignmentTools::validReadIdentity(aln, 1-alnIdentityThres)) continue; if (!ignoreSnp) { // retrieve the SNPs on the read vector<long> readSnpPos; vector<char> readSnpRef; vector<char> readSnpAlt; vector<double> readSnpBq; GenericBamAlignmentTools::getBamAlignmentMismatches(aln, readSnpPos, readSnpRef, readSnpAlt, readSnpBq); for (size_t j=0; j<readSnpAlt.size(); j++) { if (readSnpBq[j]<baseQualThres) continue; if (readSnpPos[j]<wLp || readSnpPos[j]>=wRp) continue; depoVar(wId, readSnpPos[j], readSnpRef[j], readSnpAlt[j], readSnpBq[j], genomeDepth[readSnpPos[j]]); } } if (!ignoreIndel) { // retrieve the inserts on the read vector<long> readInsPos; vector<string> readInsSeq; vector<vector<double>> readInsBq; GenericBamAlignmentTools::getBamAlignmentInserts(aln, readInsPos, readInsSeq, readInsBq); for (size_t j=0; j<readInsPos.size(); j++) { int ip = readInsPos[j]; string iseq = readInsSeq[j]; vector<double> ibq = readInsBq[j]; for (size_t k=0; k<iseq.length(); k++, ip++) { if (ip<wLp || ip>=wRp) continue; depoVar(wId, ip, '-', iseq[k], ibq[k], genomeDepth[ip]); } } } if (!ignoreIndel) { // retrieve the deletes on the read vector<long> readDelPos; vector<string> readDelSeq; GenericBamAlignmentTools::getBamAlignmentDeletes(aln, readDelPos, readDelSeq); for (size_t j=0; j<readDelPos.size(); j++) { int dp = readDelPos[j]; string dseq = readDelSeq[j]; for (size_t k=0; k<dseq.length(); k++, dp++) { if (dp<wLp || dp>=wRp) continue; depoVar(wId, dp, dseq[k], '-', 0, genomeDepth[dp]); } } } } if (verbose>=1) Verbose("output the variants"); // filter and output for (auto ptr : alleles) { GenericAllele allele = get<1>(ptr); if (ignoreSnp && allele.m_reference!="-" && allele.m_allele!="-") continue; if (ignoreIndel && (allele.m_reference=="-" || allele.m_allele=="-")) continue; if (allele.m_reference!="-" && allele.m_allele!="-") { if (allele.m_alleleDepth>snpHitThres) { repoVar(allele); } }else { if (allele.m_alleleDepth>indelHitThres) { repoVar(allele); } } } clock_t tEnd = clock(); allTime += tEnd - tStart; if (verbose>=1) Verbose("time elapsed "+to_string((double)(tEnd-tStart)/CLOCKS_PER_SEC)+" seconds"); } if (verbose>=1) Verbose("total time elapsed "+to_string((double)allTime/CLOCKS_PER_SEC)+" seconds"); bamReader.Close(); return 0; }
[ "zeng.bupt@gmail.com" ]
zeng.bupt@gmail.com
2f30b0feb79c37a7639798b04b76f63b8bdb5d4b
812125f1d67ab7cb468a06171fb6ef86c8ef1483
/buff/b.cpp
310642ffc8ccd0bd78875e732dbdcdf68523ef1f
[]
no_license
sxw106106/cpp-learning
861e8d67ed29ce0ceac78acb900e4756667adad6
7cd2817699e816acd6725137e6f7254b9fcbe1a0
refs/heads/master
2021-01-21T06:46:47.779675
2014-03-24T16:20:28
2014-03-24T16:20:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
983
cpp
#include <string.h> #include <stdio.h> #include <stdlib.h> int main(void) { char buff2[4 * 16000 * 16 /8]; printf("################## sizeof(buff2)= %d#################\n",sizeof(buff2)); char buff[3][4 * 16000 * 16 /8]; memset(buff,0,sizeof(buff)); printf("################## sizeof(buff)= %d#################\n",sizeof(buff)); printf("################## sizeof(buff)0= %d#################\n",sizeof(buff[0])); printf("################## sizeof(buff)1= %d#################\n",sizeof(buff[1])); printf("################## sizeof(buff)2= %d#################\n",sizeof(buff[2])); printf("################## address(buff)0= %x#################\n",&buff[0]); printf("################## address(buff)1= %x#################\n",&buff[1]); printf("################## address(buff)2= %x#################\n",&buff[2]); printf("################## len(buff)= %d#################\n",sizeof(buff)/sizeof(buff[0])); return 1; }
[ "no7david@gmail.com" ]
no7david@gmail.com
b2d480d42ad7290ca3f5c828db7722bfd4e55e46
341c6ea936988af9e24379f5cf08a62be1d9d811
/ccursor.cpp
9ade2e2634292e71272a114441865681674a7f6f
[]
no_license
mextier/Patience
3fad4544ccc123782756f4de411527a43a047bc6
bad1f104f82d3c895e4565499137acaf27da3f20
refs/heads/master
2021-10-24T05:04:45.991183
2019-03-22T05:17:40
2019-03-22T05:17:40
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,369
cpp
//==================================================================================================== //подключаемые библиотеки //==================================================================================================== #include "ccursor.h" //==================================================================================================== //конструктор и деструктор класса //==================================================================================================== //---------------------------------------------------------------------------------------------------- //конструктор //---------------------------------------------------------------------------------------------------- CCursor::CCursor(void) { Init(); } //---------------------------------------------------------------------------------------------------- //деструктор //---------------------------------------------------------------------------------------------------- CCursor::~CCursor() { } //==================================================================================================== //закрытые функции класса //==================================================================================================== //==================================================================================================== //открытые функции класса //==================================================================================================== //---------------------------------------------------------------------------------------------------- //инициализировать //---------------------------------------------------------------------------------------------------- void CCursor::Init(void) { cCoord_Position.X=0; cCoord_Position.Y=0; MoveMode=false; for(int32_t n=0;n<NConsts::PATIENCE_NUMBER_AMOUNT;n++) PatienceNumber[n]=0; ResetSelected(); } //---------------------------------------------------------------------------------------------------- //сбросить выбор //---------------------------------------------------------------------------------------------------- void CCursor::ResetSelected(void) { SelectedBoxIndex=-1; SelectedPositionIndexInBox=-1; cCoord_OffsetWithSelectedPosition.X=-1; cCoord_OffsetWithSelectedPosition.Y=-1; } //---------------------------------------------------------------------------------------------------- //сохранить состояние //---------------------------------------------------------------------------------------------------- bool CCursor::SaveState(std::ofstream &file) { if (file.write(reinterpret_cast<char*>(&PatienceNumber),sizeof(uint8_t)*NConsts::PATIENCE_NUMBER_AMOUNT).fail()==true) return(false); return(true); } //---------------------------------------------------------------------------------------------------- //загрузить состояние //---------------------------------------------------------------------------------------------------- bool CCursor::LoadState(std::ifstream &file) { if (file.read(reinterpret_cast<char*>(&PatienceNumber),sizeof(uint8_t)*NConsts::PATIENCE_NUMBER_AMOUNT).fail()==true) return(false); return(true); }
[ "da-nie@yandex.ru" ]
da-nie@yandex.ru