blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
91e125143a3a20f80ec509516e86b81db752ef9b
1228f8cce666e58647a322170f3b252590b37c4d
/stan_test/test.cc
c156db773e493acc007b8840e5e12a3383b556f1
[]
no_license
andersdot/shoderivz
c8e23c86b3ac763f976824a8a38bdd01a9083cc2
36647d8d61583ac5d675dfdfdfdaab1d97dd4985
refs/heads/master
2021-06-17T15:42:10.278731
2021-01-15T20:17:28
2021-01-15T20:17:28
143,882,756
0
1
null
2018-10-01T20:58:37
2018-08-07T14:11:14
Jupyter Notebook
UTF-8
C++
false
false
1,503
cc
test.cc
#include <iostream> #include <stan/math.hpp> #include <stdexcept> #include <vector> struct sho_ode { template <typename T0, typename T1, typename T2> inline std::vector<typename stan::return_type<T1, T2>::type> // initial time // initial positions // parameters // double data // integer data operator()(const T0& t_in, const std::vector<T1>& y_in, const std::vector<T2>& theta, const std::vector<double>& x, const std::vector<int>& x_int, std::ostream* msgs) const { if (y_in.size() != 2) throw std::domain_error( "this function was called with inconsistent state"); std::vector<typename stan::return_type<T1, T2>::type> res; res.push_back(y_in.at(1)); res.push_back(-y_in.at(0) - theta.at(0) * y_in.at(1)); return res; } }; int main () { typedef stan::math::var grad_type; double t0 = 0.0; sho_ode harm_osc; std::vector<grad_type> theta; theta.push_back(grad_type(0.15)); std::vector<double> y0; y0.push_back(1.0); y0.push_back(0.0); std::vector<double> ts; for (int i = 0; i < 100; i++) ts.push_back(t0 + 0.1 * (i + 1)); std::vector<double> x; std::vector<int> x_int; //std::vector<std::vector<double> > ode_res_vd auto ode_res_vd = stan::math::integrate_ode_rk45(harm_osc, y0, t0, ts, theta, x, x_int); std::vector<grad_type> params; params.push_back(theta[0]); std::vector<double> g; ode_res_vd[99][0].grad(params, g); std::cout << g[0] << "\n"; return 0; }
ba6dc7bd1398dcc4442ac52e744c94fb392cb91d
2955547cad5ffa9c386a77aa4901d0a00efeef5a
/ClientServer/build-Client-Desktop_Qt_5_12_3_MinGW_32_bit-Debug/ui_mainwindow.h
34f9ba4f5f024478a5921cc67aa6e9f5761e4156
[]
no_license
Facassanxt/QT
50be6a647b4ea69b56d590b69ffcc96ce4179117
2d267506e5a4ab26c2d059bf6d0d0a18b64f6fe7
refs/heads/master
2022-11-23T04:15:21.576438
2020-07-21T08:35:56
2020-07-21T08:35:56
281,335,965
0
0
null
null
null
null
UTF-8
C++
false
false
41,741
h
ui_mainwindow.h
/******************************************************************************** ** Form generated from reading UI file 'mainwindow.ui' ** ** Created by: Qt User Interface Compiler version 5.12.3 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_MAINWINDOW_H #define UI_MAINWINDOW_H #include <QtCore/QLocale> #include <QtCore/QVariant> #include <QtWidgets/QApplication> #include <QtWidgets/QFormLayout> #include <QtWidgets/QGridLayout> #include <QtWidgets/QGroupBox> #include <QtWidgets/QHBoxLayout> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QMainWindow> #include <QtWidgets/QPushButton> #include <QtWidgets/QRadioButton> #include <QtWidgets/QSpacerItem> #include <QtWidgets/QTableView> #include <QtWidgets/QVBoxLayout> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_MainWindow { public: QWidget *centralWidget; QGroupBox *groupBoxLog; QGridLayout *gridLayout; QVBoxLayout *verticalLayout_5; QHBoxLayout *horizontalLayout_3; QVBoxLayout *verticalLayout; QLabel *Label; QLabel *Label_2; QVBoxLayout *verticalLayout_4; QLineEdit *Login; QLineEdit *Password; QPushButton *LoginB; QTableView *tableView; QGroupBox *groupBox; QVBoxLayout *verticalLayout_3; QVBoxLayout *verticalLayout_6; QLabel *label_5; QLineEdit *id; QPushButton *Delete; QGroupBox *groupBoxAdd; QVBoxLayout *verticalLayout_2; QVBoxLayout *verticalLayout_7; QHBoxLayout *horizontalLayout; QLabel *label; QLineEdit *Name; QHBoxLayout *horizontalLayout_2; QLabel *label_2; QLineEdit *Year; QHBoxLayout *horizontalLayout_4; QLabel *label_3; QLineEdit *Address; QHBoxLayout *horizontalLayout_5; QLabel *label_4; QLineEdit *Tel; QHBoxLayout *horizontalLayout_6; QSpacerItem *horizontalSpacer_3; QRadioButton *Admin; QRadioButton *Worker; QPushButton *Add; QGroupBox *groupBoxEd; QVBoxLayout *verticalLayout_10; QVBoxLayout *verticalLayout_11; QHBoxLayout *horizontalLayout_12; QLabel *label_10; QLineEdit *id_2; QHBoxLayout *horizontalLayout_13; QLabel *label_11; QLineEdit *Name_3; QHBoxLayout *horizontalLayout_14; QLabel *label_12; QLineEdit *Year_3; QHBoxLayout *horizontalLayout_15; QLabel *label_13; QLineEdit *Address_3; QHBoxLayout *horizontalLayout_16; QLabel *label_14; QLineEdit *Tel_3; QHBoxLayout *horizontalLayout_17; QLabel *label_15; QLineEdit *login; QHBoxLayout *horizontalLayout_18; QLabel *label_16; QLineEdit *password; QHBoxLayout *horizontalLayout_19; QSpacerItem *horizontalSpacer_5; QRadioButton *Admin_3; QRadioButton *Worker_3; QHBoxLayout *horizontalLayout_7; QPushButton *Cancel; QPushButton *Edit; QPushButton *pushButtonBD; QGroupBox *groupBoxButton; QVBoxLayout *verticalLayout_12; QPushButton *pushButton_2; QPushButton *pushButton_3; QPushButton *pushButton_4; QPushButton *filter; QGroupBox *groupBoxCom; QVBoxLayout *verticalLayout_13; QLineEdit *lineEdit; QPushButton *pushButtonCom; QPushButton *up; QPushButton *down; QGroupBox *Filter; QFormLayout *formLayout; QVBoxLayout *verticalLayout_8; QLabel *label_17; QLabel *label_18; QLabel *label_19; QLabel *label_20; QLabel *label_22; QLabel *label_21; QVBoxLayout *verticalLayout_9; QLineEdit *id_4; QLineEdit *Name_4; QLineEdit *Year_4; QLineEdit *Address_4; QLineEdit *Tel_4; QLineEdit *login_4; QPushButton *pushButton; void setupUi(QMainWindow *MainWindow) { if (MainWindow->objectName().isEmpty()) MainWindow->setObjectName(QString::fromUtf8("MainWindow")); MainWindow->setEnabled(true); MainWindow->resize(800, 600); MainWindow->setMinimumSize(QSize(800, 600)); MainWindow->setMaximumSize(QSize(800, 600)); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QString::fromUtf8("centralWidget")); groupBoxLog = new QGroupBox(centralWidget); groupBoxLog->setObjectName(QString::fromUtf8("groupBoxLog")); groupBoxLog->setGeometry(QRect(247, 219, 306, 162)); groupBoxLog->setMinimumSize(QSize(300, 150)); groupBoxLog->setStyleSheet(QString::fromUtf8("font: 75 16pt \"impact\";\n" "background-color: rgba(255, 205, 206,0.5);")); gridLayout = new QGridLayout(groupBoxLog); gridLayout->setSpacing(6); gridLayout->setContentsMargins(11, 11, 11, 11); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); verticalLayout_5 = new QVBoxLayout(); verticalLayout_5->setSpacing(6); verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5")); horizontalLayout_3 = new QHBoxLayout(); horizontalLayout_3->setSpacing(6); horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); verticalLayout = new QVBoxLayout(); verticalLayout->setSpacing(6); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); Label = new QLabel(groupBoxLog); Label->setObjectName(QString::fromUtf8("Label")); Label->setMinimumSize(QSize(0, 0)); Label->setStyleSheet(QString::fromUtf8("")); verticalLayout->addWidget(Label); Label_2 = new QLabel(groupBoxLog); Label_2->setObjectName(QString::fromUtf8("Label_2")); Label_2->setStyleSheet(QString::fromUtf8("")); verticalLayout->addWidget(Label_2); horizontalLayout_3->addLayout(verticalLayout); verticalLayout_4 = new QVBoxLayout(); verticalLayout_4->setSpacing(6); verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4")); Login = new QLineEdit(groupBoxLog); Login->setObjectName(QString::fromUtf8("Login")); Login->setStyleSheet(QString::fromUtf8("color:black;")); verticalLayout_4->addWidget(Login); Password = new QLineEdit(groupBoxLog); Password->setObjectName(QString::fromUtf8("Password")); Password->setStyleSheet(QString::fromUtf8("color:black;")); Password->setEchoMode(QLineEdit::Password); verticalLayout_4->addWidget(Password); horizontalLayout_3->addLayout(verticalLayout_4); verticalLayout_5->addLayout(horizontalLayout_3); LoginB = new QPushButton(groupBoxLog); LoginB->setObjectName(QString::fromUtf8("LoginB")); LoginB->setStyleSheet(QString::fromUtf8("color: black;")); verticalLayout_5->addWidget(LoginB); gridLayout->addLayout(verticalLayout_5, 0, 1, 1, 1); tableView = new QTableView(centralWidget); tableView->setObjectName(QString::fromUtf8("tableView")); tableView->setEnabled(true); tableView->setGeometry(QRect(0, 0, 800, 331)); tableView->setMinimumSize(QSize(800, 0)); QFont font; font.setPointSize(1); tableView->setFont(font); tableView->setStyleSheet(QString::fromUtf8("background-color: rgb(255, 242, 249);")); groupBox = new QGroupBox(centralWidget); groupBox->setObjectName(QString::fromUtf8("groupBox")); groupBox->setGeometry(QRect(500, 450, 301, 151)); groupBox->setStyleSheet(QString::fromUtf8("font: 8pt \"MS Shell Dlg 2\";")); verticalLayout_3 = new QVBoxLayout(groupBox); verticalLayout_3->setSpacing(6); verticalLayout_3->setContentsMargins(11, 11, 11, 11); verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3")); verticalLayout_6 = new QVBoxLayout(); verticalLayout_6->setSpacing(6); verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6")); label_5 = new QLabel(groupBox); label_5->setObjectName(QString::fromUtf8("label_5")); label_5->setMinimumSize(QSize(300, 50)); label_5->setMaximumSize(QSize(300, 50)); QFont font1; font1.setFamily(QString::fromUtf8("MS Shell Dlg 2")); font1.setPointSize(8); font1.setBold(false); font1.setItalic(false); font1.setWeight(50); label_5->setFont(font1); label_5->setAlignment(Qt::AlignCenter); verticalLayout_6->addWidget(label_5); id = new QLineEdit(groupBox); id->setObjectName(QString::fromUtf8("id")); id->setMinimumSize(QSize(0, 0)); id->setMaximumSize(QSize(999999, 9999)); id->setFont(font1); id->setAlignment(Qt::AlignCenter); verticalLayout_6->addWidget(id); verticalLayout_3->addLayout(verticalLayout_6); Delete = new QPushButton(groupBox); Delete->setObjectName(QString::fromUtf8("Delete")); Delete->setFont(font1); verticalLayout_3->addWidget(Delete); groupBoxAdd = new QGroupBox(centralWidget); groupBoxAdd->setObjectName(QString::fromUtf8("groupBoxAdd")); groupBoxAdd->setGeometry(QRect(0, 330, 361, 271)); verticalLayout_2 = new QVBoxLayout(groupBoxAdd); verticalLayout_2->setSpacing(6); verticalLayout_2->setContentsMargins(11, 11, 11, 11); verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); verticalLayout_7 = new QVBoxLayout(); verticalLayout_7->setSpacing(6); verticalLayout_7->setObjectName(QString::fromUtf8("verticalLayout_7")); horizontalLayout = new QHBoxLayout(); horizontalLayout->setSpacing(6); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); label = new QLabel(groupBoxAdd); label->setObjectName(QString::fromUtf8("label")); label->setAlignment(Qt::AlignCenter); horizontalLayout->addWidget(label); Name = new QLineEdit(groupBoxAdd); Name->setObjectName(QString::fromUtf8("Name")); Name->setEnabled(true); Name->setMinimumSize(QSize(0, 50)); Name->setMaximumSize(QSize(250, 50)); QFont font2; font2.setItalic(false); Name->setFont(font2); Name->setCursor(QCursor(Qt::IBeamCursor)); Name->setTabletTracking(false); Name->setContextMenuPolicy(Qt::DefaultContextMenu); Name->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Name->setMaxLength(50); Name->setEchoMode(QLineEdit::Normal); Name->setAlignment(Qt::AlignCenter); Name->setDragEnabled(false); horizontalLayout->addWidget(Name); verticalLayout_7->addLayout(horizontalLayout); horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setSpacing(6); horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); label_2 = new QLabel(groupBoxAdd); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setAlignment(Qt::AlignCenter); horizontalLayout_2->addWidget(label_2); Year = new QLineEdit(groupBoxAdd); Year->setObjectName(QString::fromUtf8("Year")); Year->setMinimumSize(QSize(0, 50)); Year->setMaximumSize(QSize(250, 50)); Year->setFont(font2); Year->setContextMenuPolicy(Qt::DefaultContextMenu); Year->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Year->setMaxLength(50); Year->setEchoMode(QLineEdit::Normal); Year->setAlignment(Qt::AlignCenter); Year->setDragEnabled(false); horizontalLayout_2->addWidget(Year); verticalLayout_7->addLayout(horizontalLayout_2); horizontalLayout_4 = new QHBoxLayout(); horizontalLayout_4->setSpacing(6); horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4")); label_3 = new QLabel(groupBoxAdd); label_3->setObjectName(QString::fromUtf8("label_3")); label_3->setAlignment(Qt::AlignCenter); horizontalLayout_4->addWidget(label_3); Address = new QLineEdit(groupBoxAdd); Address->setObjectName(QString::fromUtf8("Address")); Address->setMinimumSize(QSize(0, 50)); Address->setMaximumSize(QSize(250, 50)); Address->setFont(font2); Address->setContextMenuPolicy(Qt::DefaultContextMenu); Address->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Address->setMaxLength(50); Address->setEchoMode(QLineEdit::Normal); Address->setAlignment(Qt::AlignCenter); Address->setDragEnabled(false); horizontalLayout_4->addWidget(Address); verticalLayout_7->addLayout(horizontalLayout_4); horizontalLayout_5 = new QHBoxLayout(); horizontalLayout_5->setSpacing(6); horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); label_4 = new QLabel(groupBoxAdd); label_4->setObjectName(QString::fromUtf8("label_4")); label_4->setAlignment(Qt::AlignCenter); horizontalLayout_5->addWidget(label_4); Tel = new QLineEdit(groupBoxAdd); Tel->setObjectName(QString::fromUtf8("Tel")); Tel->setMinimumSize(QSize(0, 50)); Tel->setMaximumSize(QSize(250, 50)); Tel->setFont(font2); Tel->setContextMenuPolicy(Qt::DefaultContextMenu); Tel->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Tel->setMaxLength(50); Tel->setEchoMode(QLineEdit::Normal); Tel->setAlignment(Qt::AlignCenter); Tel->setDragEnabled(false); horizontalLayout_5->addWidget(Tel); verticalLayout_7->addLayout(horizontalLayout_5); verticalLayout_2->addLayout(verticalLayout_7); horizontalLayout_6 = new QHBoxLayout(); horizontalLayout_6->setSpacing(6); horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6")); horizontalSpacer_3 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout_6->addItem(horizontalSpacer_3); Admin = new QRadioButton(groupBoxAdd); Admin->setObjectName(QString::fromUtf8("Admin")); Admin->setMinimumSize(QSize(147, 0)); Admin->setMaximumSize(QSize(147, 16777215)); horizontalLayout_6->addWidget(Admin); Worker = new QRadioButton(groupBoxAdd); Worker->setObjectName(QString::fromUtf8("Worker")); Worker->setMinimumSize(QSize(147, 0)); Worker->setMaximumSize(QSize(147, 16777215)); Worker->setCheckable(true); Worker->setChecked(true); horizontalLayout_6->addWidget(Worker); verticalLayout_2->addLayout(horizontalLayout_6); Add = new QPushButton(groupBoxAdd); Add->setObjectName(QString::fromUtf8("Add")); verticalLayout_2->addWidget(Add); groupBoxEd = new QGroupBox(centralWidget); groupBoxEd->setObjectName(QString::fromUtf8("groupBoxEd")); groupBoxEd->setEnabled(true); groupBoxEd->setGeometry(QRect(0, 327, 501, 281)); groupBoxEd->setStyleSheet(QString::fromUtf8("font: 8pt \"MS Shell Dlg 2\";")); verticalLayout_10 = new QVBoxLayout(groupBoxEd); verticalLayout_10->setSpacing(6); verticalLayout_10->setContentsMargins(11, 11, 11, 11); verticalLayout_10->setObjectName(QString::fromUtf8("verticalLayout_10")); verticalLayout_11 = new QVBoxLayout(); verticalLayout_11->setSpacing(6); verticalLayout_11->setObjectName(QString::fromUtf8("verticalLayout_11")); horizontalLayout_12 = new QHBoxLayout(); horizontalLayout_12->setSpacing(6); horizontalLayout_12->setObjectName(QString::fromUtf8("horizontalLayout_12")); label_10 = new QLabel(groupBoxEd); label_10->setObjectName(QString::fromUtf8("label_10")); label_10->setFont(font1); label_10->setAlignment(Qt::AlignCenter); horizontalLayout_12->addWidget(label_10); id_2 = new QLineEdit(groupBoxEd); id_2->setObjectName(QString::fromUtf8("id_2")); id_2->setMinimumSize(QSize(100, 0)); id_2->setMaximumSize(QSize(400, 99999)); id_2->setFont(font1); id_2->setContextMenuPolicy(Qt::DefaultContextMenu); id_2->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); id_2->setMaxLength(50); id_2->setEchoMode(QLineEdit::Normal); id_2->setAlignment(Qt::AlignCenter); id_2->setDragEnabled(false); horizontalLayout_12->addWidget(id_2); verticalLayout_11->addLayout(horizontalLayout_12); horizontalLayout_13 = new QHBoxLayout(); horizontalLayout_13->setSpacing(6); horizontalLayout_13->setObjectName(QString::fromUtf8("horizontalLayout_13")); label_11 = new QLabel(groupBoxEd); label_11->setObjectName(QString::fromUtf8("label_11")); label_11->setFont(font1); label_11->setAlignment(Qt::AlignCenter); horizontalLayout_13->addWidget(label_11); Name_3 = new QLineEdit(groupBoxEd); Name_3->setObjectName(QString::fromUtf8("Name_3")); Name_3->setEnabled(true); Name_3->setMinimumSize(QSize(100, 0)); Name_3->setMaximumSize(QSize(400, 99999)); Name_3->setFont(font1); Name_3->setCursor(QCursor(Qt::IBeamCursor)); Name_3->setTabletTracking(false); Name_3->setContextMenuPolicy(Qt::DefaultContextMenu); Name_3->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Name_3->setMaxLength(50); Name_3->setEchoMode(QLineEdit::Normal); Name_3->setAlignment(Qt::AlignCenter); Name_3->setDragEnabled(false); horizontalLayout_13->addWidget(Name_3); verticalLayout_11->addLayout(horizontalLayout_13); horizontalLayout_14 = new QHBoxLayout(); horizontalLayout_14->setSpacing(6); horizontalLayout_14->setObjectName(QString::fromUtf8("horizontalLayout_14")); label_12 = new QLabel(groupBoxEd); label_12->setObjectName(QString::fromUtf8("label_12")); label_12->setFont(font1); label_12->setAlignment(Qt::AlignCenter); horizontalLayout_14->addWidget(label_12); Year_3 = new QLineEdit(groupBoxEd); Year_3->setObjectName(QString::fromUtf8("Year_3")); Year_3->setMinimumSize(QSize(100, 0)); Year_3->setMaximumSize(QSize(400, 99999)); Year_3->setFont(font1); Year_3->setContextMenuPolicy(Qt::DefaultContextMenu); Year_3->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Year_3->setMaxLength(50); Year_3->setEchoMode(QLineEdit::Normal); Year_3->setAlignment(Qt::AlignCenter); Year_3->setDragEnabled(false); horizontalLayout_14->addWidget(Year_3); verticalLayout_11->addLayout(horizontalLayout_14); horizontalLayout_15 = new QHBoxLayout(); horizontalLayout_15->setSpacing(6); horizontalLayout_15->setObjectName(QString::fromUtf8("horizontalLayout_15")); label_13 = new QLabel(groupBoxEd); label_13->setObjectName(QString::fromUtf8("label_13")); label_13->setFont(font1); label_13->setAlignment(Qt::AlignCenter); horizontalLayout_15->addWidget(label_13); Address_3 = new QLineEdit(groupBoxEd); Address_3->setObjectName(QString::fromUtf8("Address_3")); Address_3->setMinimumSize(QSize(100, 0)); Address_3->setMaximumSize(QSize(400, 99999)); Address_3->setFont(font1); Address_3->setContextMenuPolicy(Qt::DefaultContextMenu); Address_3->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Address_3->setMaxLength(50); Address_3->setEchoMode(QLineEdit::Normal); Address_3->setAlignment(Qt::AlignCenter); Address_3->setDragEnabled(false); horizontalLayout_15->addWidget(Address_3); verticalLayout_11->addLayout(horizontalLayout_15); horizontalLayout_16 = new QHBoxLayout(); horizontalLayout_16->setSpacing(6); horizontalLayout_16->setObjectName(QString::fromUtf8("horizontalLayout_16")); label_14 = new QLabel(groupBoxEd); label_14->setObjectName(QString::fromUtf8("label_14")); label_14->setFont(font1); label_14->setAlignment(Qt::AlignCenter); horizontalLayout_16->addWidget(label_14); Tel_3 = new QLineEdit(groupBoxEd); Tel_3->setObjectName(QString::fromUtf8("Tel_3")); Tel_3->setMinimumSize(QSize(100, 0)); Tel_3->setMaximumSize(QSize(400, 99999)); Tel_3->setFont(font1); Tel_3->setContextMenuPolicy(Qt::DefaultContextMenu); Tel_3->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Tel_3->setMaxLength(50); Tel_3->setEchoMode(QLineEdit::Normal); Tel_3->setAlignment(Qt::AlignCenter); Tel_3->setDragEnabled(false); horizontalLayout_16->addWidget(Tel_3); verticalLayout_11->addLayout(horizontalLayout_16); horizontalLayout_17 = new QHBoxLayout(); horizontalLayout_17->setSpacing(6); horizontalLayout_17->setObjectName(QString::fromUtf8("horizontalLayout_17")); label_15 = new QLabel(groupBoxEd); label_15->setObjectName(QString::fromUtf8("label_15")); label_15->setFont(font1); label_15->setAlignment(Qt::AlignCenter); horizontalLayout_17->addWidget(label_15); login = new QLineEdit(groupBoxEd); login->setObjectName(QString::fromUtf8("login")); login->setMinimumSize(QSize(100, 0)); login->setMaximumSize(QSize(400, 99999)); login->setFont(font1); login->setContextMenuPolicy(Qt::DefaultContextMenu); login->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); login->setMaxLength(50); login->setEchoMode(QLineEdit::Normal); login->setAlignment(Qt::AlignCenter); login->setDragEnabled(false); horizontalLayout_17->addWidget(login); verticalLayout_11->addLayout(horizontalLayout_17); horizontalLayout_18 = new QHBoxLayout(); horizontalLayout_18->setSpacing(6); horizontalLayout_18->setObjectName(QString::fromUtf8("horizontalLayout_18")); label_16 = new QLabel(groupBoxEd); label_16->setObjectName(QString::fromUtf8("label_16")); label_16->setFont(font1); label_16->setAlignment(Qt::AlignCenter); horizontalLayout_18->addWidget(label_16); password = new QLineEdit(groupBoxEd); password->setObjectName(QString::fromUtf8("password")); password->setMinimumSize(QSize(100, 0)); password->setMaximumSize(QSize(400, 99999)); password->setFont(font1); password->setContextMenuPolicy(Qt::DefaultContextMenu); password->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); password->setMaxLength(50); password->setEchoMode(QLineEdit::Normal); password->setAlignment(Qt::AlignCenter); password->setDragEnabled(false); horizontalLayout_18->addWidget(password); verticalLayout_11->addLayout(horizontalLayout_18); verticalLayout_10->addLayout(verticalLayout_11); horizontalLayout_19 = new QHBoxLayout(); horizontalLayout_19->setSpacing(6); horizontalLayout_19->setObjectName(QString::fromUtf8("horizontalLayout_19")); horizontalSpacer_5 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout_19->addItem(horizontalSpacer_5); Admin_3 = new QRadioButton(groupBoxEd); Admin_3->setObjectName(QString::fromUtf8("Admin_3")); Admin_3->setMinimumSize(QSize(147, 0)); Admin_3->setMaximumSize(QSize(147, 16777215)); Admin_3->setFont(font1); Admin_3->setAcceptDrops(false); Admin_3->setCheckable(true); Admin_3->setChecked(false); Admin_3->setAutoExclusive(true); horizontalLayout_19->addWidget(Admin_3); Worker_3 = new QRadioButton(groupBoxEd); Worker_3->setObjectName(QString::fromUtf8("Worker_3")); Worker_3->setMinimumSize(QSize(147, 0)); Worker_3->setMaximumSize(QSize(147, 16777215)); Worker_3->setFont(font1); Worker_3->setCheckable(true); Worker_3->setChecked(false); horizontalLayout_19->addWidget(Worker_3); verticalLayout_10->addLayout(horizontalLayout_19); horizontalLayout_7 = new QHBoxLayout(); horizontalLayout_7->setSpacing(6); horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7")); Cancel = new QPushButton(groupBoxEd); Cancel->setObjectName(QString::fromUtf8("Cancel")); horizontalLayout_7->addWidget(Cancel); Edit = new QPushButton(groupBoxEd); Edit->setObjectName(QString::fromUtf8("Edit")); Edit->setFont(font1); horizontalLayout_7->addWidget(Edit); verticalLayout_10->addLayout(horizontalLayout_7); pushButtonBD = new QPushButton(centralWidget); pushButtonBD->setObjectName(QString::fromUtf8("pushButtonBD")); pushButtonBD->setGeometry(QRect(500, 330, 301, 121)); groupBoxButton = new QGroupBox(centralWidget); groupBoxButton->setObjectName(QString::fromUtf8("groupBoxButton")); groupBoxButton->setGeometry(QRect(360, 340, 141, 261)); verticalLayout_12 = new QVBoxLayout(groupBoxButton); verticalLayout_12->setSpacing(6); verticalLayout_12->setContentsMargins(11, 11, 11, 11); verticalLayout_12->setObjectName(QString::fromUtf8("verticalLayout_12")); pushButton_2 = new QPushButton(groupBoxButton); pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); verticalLayout_12->addWidget(pushButton_2); pushButton_3 = new QPushButton(groupBoxButton); pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); verticalLayout_12->addWidget(pushButton_3); pushButton_4 = new QPushButton(groupBoxButton); pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); pushButton_4->setEnabled(true); pushButton_4->setMinimumSize(QSize(0, 0)); pushButton_4->setMouseTracking(false); pushButton_4->setTabletTracking(false); pushButton_4->setFocusPolicy(Qt::StrongFocus); pushButton_4->setContextMenuPolicy(Qt::DefaultContextMenu); pushButton_4->setAcceptDrops(false); pushButton_4->setLayoutDirection(Qt::LeftToRight); pushButton_4->setAutoFillBackground(false); pushButton_4->setCheckable(false); pushButton_4->setAutoRepeat(false); pushButton_4->setAutoExclusive(false); pushButton_4->setAutoDefault(false); pushButton_4->setFlat(false); verticalLayout_12->addWidget(pushButton_4); filter = new QPushButton(groupBoxButton); filter->setObjectName(QString::fromUtf8("filter")); verticalLayout_12->addWidget(filter); groupBoxCom = new QGroupBox(centralWidget); groupBoxCom->setObjectName(QString::fromUtf8("groupBoxCom")); groupBoxCom->setGeometry(QRect(0, 330, 361, 271)); verticalLayout_13 = new QVBoxLayout(groupBoxCom); verticalLayout_13->setSpacing(6); verticalLayout_13->setContentsMargins(11, 11, 11, 11); verticalLayout_13->setObjectName(QString::fromUtf8("verticalLayout_13")); lineEdit = new QLineEdit(groupBoxCom); lineEdit->setObjectName(QString::fromUtf8("lineEdit")); lineEdit->setMinimumSize(QSize(0, 245)); verticalLayout_13->addWidget(lineEdit); pushButtonCom = new QPushButton(groupBoxCom); pushButtonCom->setObjectName(QString::fromUtf8("pushButtonCom")); verticalLayout_13->addWidget(pushButtonCom); up = new QPushButton(centralWidget); up->setObjectName(QString::fromUtf8("up")); up->setGeometry(QRect(710, 16, 75, 23)); down = new QPushButton(centralWidget); down->setObjectName(QString::fromUtf8("down")); down->setGeometry(QRect(710, 40, 75, 23)); Filter = new QGroupBox(centralWidget); Filter->setObjectName(QString::fromUtf8("Filter")); Filter->setGeometry(QRect(0, 370, 361, 231)); formLayout = new QFormLayout(Filter); formLayout->setSpacing(6); formLayout->setContentsMargins(11, 11, 11, 11); formLayout->setObjectName(QString::fromUtf8("formLayout")); verticalLayout_8 = new QVBoxLayout(); verticalLayout_8->setSpacing(6); verticalLayout_8->setObjectName(QString::fromUtf8("verticalLayout_8")); label_17 = new QLabel(Filter); label_17->setObjectName(QString::fromUtf8("label_17")); label_17->setFont(font1); label_17->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_17); label_18 = new QLabel(Filter); label_18->setObjectName(QString::fromUtf8("label_18")); label_18->setFont(font1); label_18->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_18); label_19 = new QLabel(Filter); label_19->setObjectName(QString::fromUtf8("label_19")); label_19->setFont(font1); label_19->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_19); label_20 = new QLabel(Filter); label_20->setObjectName(QString::fromUtf8("label_20")); label_20->setFont(font1); label_20->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_20); label_22 = new QLabel(Filter); label_22->setObjectName(QString::fromUtf8("label_22")); label_22->setFont(font1); label_22->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_22); label_21 = new QLabel(Filter); label_21->setObjectName(QString::fromUtf8("label_21")); label_21->setFont(font1); label_21->setAlignment(Qt::AlignCenter); verticalLayout_8->addWidget(label_21); formLayout->setLayout(0, QFormLayout::LabelRole, verticalLayout_8); verticalLayout_9 = new QVBoxLayout(); verticalLayout_9->setSpacing(6); verticalLayout_9->setObjectName(QString::fromUtf8("verticalLayout_9")); id_4 = new QLineEdit(Filter); id_4->setObjectName(QString::fromUtf8("id_4")); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(id_4->sizePolicy().hasHeightForWidth()); id_4->setSizePolicy(sizePolicy); id_4->setMinimumSize(QSize(100, 0)); id_4->setMaximumSize(QSize(400, 99999)); id_4->setFont(font1); id_4->setContextMenuPolicy(Qt::DefaultContextMenu); id_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); id_4->setMaxLength(50); id_4->setEchoMode(QLineEdit::Normal); id_4->setAlignment(Qt::AlignCenter); id_4->setDragEnabled(false); verticalLayout_9->addWidget(id_4); Name_4 = new QLineEdit(Filter); Name_4->setObjectName(QString::fromUtf8("Name_4")); Name_4->setEnabled(true); sizePolicy.setHeightForWidth(Name_4->sizePolicy().hasHeightForWidth()); Name_4->setSizePolicy(sizePolicy); Name_4->setMinimumSize(QSize(100, 0)); Name_4->setMaximumSize(QSize(400, 99999)); Name_4->setFont(font1); Name_4->setCursor(QCursor(Qt::IBeamCursor)); Name_4->setTabletTracking(false); Name_4->setContextMenuPolicy(Qt::DefaultContextMenu); Name_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Name_4->setMaxLength(50); Name_4->setEchoMode(QLineEdit::Normal); Name_4->setAlignment(Qt::AlignCenter); Name_4->setDragEnabled(false); verticalLayout_9->addWidget(Name_4); Year_4 = new QLineEdit(Filter); Year_4->setObjectName(QString::fromUtf8("Year_4")); Year_4->setMinimumSize(QSize(100, 0)); Year_4->setMaximumSize(QSize(400, 99999)); Year_4->setFont(font1); Year_4->setContextMenuPolicy(Qt::DefaultContextMenu); Year_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Year_4->setMaxLength(50); Year_4->setEchoMode(QLineEdit::Normal); Year_4->setAlignment(Qt::AlignCenter); Year_4->setDragEnabled(false); verticalLayout_9->addWidget(Year_4); Address_4 = new QLineEdit(Filter); Address_4->setObjectName(QString::fromUtf8("Address_4")); Address_4->setMinimumSize(QSize(100, 0)); Address_4->setMaximumSize(QSize(400, 99999)); Address_4->setFont(font1); Address_4->setContextMenuPolicy(Qt::DefaultContextMenu); Address_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Address_4->setMaxLength(50); Address_4->setEchoMode(QLineEdit::Normal); Address_4->setAlignment(Qt::AlignCenter); Address_4->setDragEnabled(false); verticalLayout_9->addWidget(Address_4); Tel_4 = new QLineEdit(Filter); Tel_4->setObjectName(QString::fromUtf8("Tel_4")); Tel_4->setMinimumSize(QSize(100, 0)); Tel_4->setMaximumSize(QSize(400, 99999)); Tel_4->setFont(font1); Tel_4->setContextMenuPolicy(Qt::DefaultContextMenu); Tel_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); Tel_4->setMaxLength(50); Tel_4->setEchoMode(QLineEdit::Normal); Tel_4->setAlignment(Qt::AlignCenter); Tel_4->setDragEnabled(false); verticalLayout_9->addWidget(Tel_4); login_4 = new QLineEdit(Filter); login_4->setObjectName(QString::fromUtf8("login_4")); login_4->setMinimumSize(QSize(100, 0)); login_4->setMaximumSize(QSize(400, 99999)); login_4->setFont(font1); login_4->setContextMenuPolicy(Qt::DefaultContextMenu); login_4->setLocale(QLocale(QLocale::Russian, QLocale::Russia)); login_4->setMaxLength(50); login_4->setEchoMode(QLineEdit::Normal); login_4->setAlignment(Qt::AlignCenter); login_4->setDragEnabled(false); verticalLayout_9->addWidget(login_4); formLayout->setLayout(0, QFormLayout::FieldRole, verticalLayout_9); pushButton = new QPushButton(Filter); pushButton->setObjectName(QString::fromUtf8("pushButton")); formLayout->setWidget(1, QFormLayout::FieldRole, pushButton); MainWindow->setCentralWidget(centralWidget); tableView->raise(); groupBoxCom->raise(); groupBoxAdd->raise(); pushButtonBD->raise(); groupBox->raise(); up->raise(); down->raise(); Cancel->raise(); groupBoxEd->raise(); Edit->raise(); groupBoxLog->raise(); groupBoxButton->raise(); label_17->raise(); id_4->raise(); Name_4->raise(); label_18->raise(); label_19->raise(); Year_4->raise(); label_20->raise(); Address_4->raise(); label_21->raise(); login_4->raise(); label_22->raise(); Tel_4->raise(); Filter->raise(); retranslateUi(MainWindow); pushButton_4->setDefault(false); QMetaObject::connectSlotsByName(MainWindow); } // setupUi void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", nullptr)); groupBoxLog->setTitle(QApplication::translate("MainWindow", "\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217", nullptr)); Label->setText(QApplication::translate("MainWindow", "Username", nullptr)); Label_2->setText(QApplication::translate("MainWindow", "Password", nullptr)); LoginB->setText(QApplication::translate("MainWindow", "Login", nullptr)); label_5->setText(QApplication::translate("MainWindow", "ID \320\240\320\260\320\261\320\276\321\202\320\275\320\270\320\272\320\260", nullptr)); Delete->setText(QApplication::translate("MainWindow", "Delete", nullptr)); label->setText(QApplication::translate("MainWindow", "Name:", nullptr)); #ifndef QT_NO_STATUSTIP Name->setStatusTip(QString()); #endif // QT_NO_STATUSTIP Name->setText(QString()); label_2->setText(QApplication::translate("MainWindow", "Year:", nullptr)); Year->setText(QString()); label_3->setText(QApplication::translate("MainWindow", "Address:", nullptr)); Address->setText(QString()); label_4->setText(QApplication::translate("MainWindow", "Tel:", nullptr)); Tel->setText(QString()); Admin->setText(QApplication::translate("MainWindow", "Admin", nullptr)); Worker->setText(QApplication::translate("MainWindow", "Worker", nullptr)); Add->setText(QApplication::translate("MainWindow", "Add", nullptr)); label_10->setText(QApplication::translate("MainWindow", "Id", nullptr)); id_2->setText(QString()); label_11->setText(QApplication::translate("MainWindow", "Name:", nullptr)); #ifndef QT_NO_STATUSTIP Name_3->setStatusTip(QString()); #endif // QT_NO_STATUSTIP Name_3->setText(QString()); label_12->setText(QApplication::translate("MainWindow", "Year:", nullptr)); Year_3->setText(QString()); label_13->setText(QApplication::translate("MainWindow", "Address:", nullptr)); Address_3->setText(QString()); label_14->setText(QApplication::translate("MainWindow", "Tel:", nullptr)); Tel_3->setText(QString()); label_15->setText(QApplication::translate("MainWindow", "Login", nullptr)); login->setText(QString()); label_16->setText(QApplication::translate("MainWindow", "Password", nullptr)); password->setText(QString()); Admin_3->setText(QApplication::translate("MainWindow", "Admin", nullptr)); Worker_3->setText(QApplication::translate("MainWindow", "Worker", nullptr)); Cancel->setText(QApplication::translate("MainWindow", "Cancel", nullptr)); Edit->setText(QApplication::translate("MainWindow", "Edit", nullptr)); pushButtonBD->setText(QApplication::translate("MainWindow", "\320\222\321\213\320\262\320\276\320\264 \320\221\320\224", nullptr)); pushButton_2->setText(QApplication::translate("MainWindow", "\320\224\320\276\320\261\320\260\320\262\320\270\321\202\321\214", nullptr)); pushButton_3->setText(QApplication::translate("MainWindow", "\320\230\320\267\320\274\320\265\320\275\320\270\321\202\321\214", nullptr)); pushButton_4->setText(QApplication::translate("MainWindow", "\320\240\321\203\321\207\320\275\320\276\320\271 \320\262\320\262\320\276\320\264 \320\272\320\276\320\274\320\260\320\275\320\264", nullptr)); filter->setText(QApplication::translate("MainWindow", "\320\244\320\270\320\273\321\214\321\202\321\200", nullptr)); pushButtonCom->setText(QApplication::translate("MainWindow", "\320\236\321\202\320\277\321\200\320\260\320\262\320\270\321\202\321\214", nullptr)); up->setText(QApplication::translate("MainWindow", "\342\206\221", nullptr)); down->setText(QApplication::translate("MainWindow", "\342\206\223", nullptr)); label_17->setText(QApplication::translate("MainWindow", "Id", nullptr)); label_18->setText(QApplication::translate("MainWindow", "Name:", nullptr)); label_19->setText(QApplication::translate("MainWindow", "Year:", nullptr)); label_20->setText(QApplication::translate("MainWindow", "Address:", nullptr)); label_22->setText(QApplication::translate("MainWindow", "Tel:", nullptr)); label_21->setText(QApplication::translate("MainWindow", "Login", nullptr)); id_4->setText(QString()); #ifndef QT_NO_STATUSTIP Name_4->setStatusTip(QString()); #endif // QT_NO_STATUSTIP Name_4->setText(QString()); Year_4->setText(QString()); Address_4->setText(QString()); Tel_4->setText(QString()); login_4->setText(QString()); pushButton->setText(QApplication::translate("MainWindow", "\320\222\321\213\320\277\320\276\320\273\320\275\320\270\321\202\321\214", nullptr)); } // retranslateUi }; namespace Ui { class MainWindow: public Ui_MainWindow {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_MAINWINDOW_H
f7283dc440f05d92bacfdfed6e1a35d7077d11f4
dec93ac0f633a804362fc2429678ba9c0251712f
/HW10/Point.h
518c3f12759c2bea3cf4507cfe2b044f2afbcf9c
[]
no_license
viktoria2506/cpp-itmo
9353ee4ec9f2e0c903ab850293e77fe0f9d7a770
184bda74d85cd2a49db236968729433907862508
refs/heads/master
2021-10-24T12:00:12.578769
2019-03-25T23:13:36
2019-03-25T23:13:36
177,664,605
1
0
null
null
null
null
UTF-8
C++
false
false
498
h
Point.h
// // Created by vikac on 20.01.2019. // #ifndef HW10_POINT_H #define HW10_POINT_H class Point { public: explicit Point(double x = 0, double y = 0) : x(x), y(y) {}; double getX() const { return x; } double getY() const { return y; } bool operator<(const Point& p) const { return getX() < p.getX() || (getX() == p.getX() && getY() < p.getY()); } private: double x, y; }; double distance(const Point& q,const Point& p); #endif //HW10_POINT_H
cf5ae5d3705033556395189e88d1c760cd648478
2ebdb85fdd3160d31fe19e6644b5c8bd0a72f49e
/test/SphericalCoordinateTest.cpp
61e3e7f70549237f93eac1cf66d448dfbfb57510
[]
no_license
XuRongYan/ModelGeneratorBasedOnSketch
af8726173b6a57661acbe16001292dd2edb77a25
b828935137e37b3fd1b423eb7bae0b03075d5537
refs/heads/master
2022-03-04T18:59:58.828836
2019-11-14T08:02:48
2019-11-14T08:02:48
214,182,331
0
0
null
null
null
null
UTF-8
C++
false
false
2,936
cpp
SphericalCoordinateTest.cpp
// // Created by 徐溶延 on 2019/9/9. // #include <Eigen/Core> #include <Eigen/Dense> #include <gtest/gtest.h> #include "../spherical_harmonic/ContourSphericalCoordinate.h" #include "../spherical_harmonic/MeshSphericalCoordinate.h" #include "../spherical_harmonic/TriangulationSpericalCoordinate.h" #include "../io/MeshIO.h" #include "../contour/ContourCollection.h" #include "../triangulation/TriangulationUtil.h" using namespace std; using namespace Eigen; class SphericalCoordinateTest : public ::testing::Test { public: Matrix3Xf m1, m2, m3, m4; void generate_data() { m1.resize(3, 6); m2.resize(3, 4); m1 << 0, 1, 2, 3, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0; m2 << 1, 2, 2, 1, 1, 1, 2, 2, 0, 0, 0, 0; } ContourCollection prepare_collection() { m3.resize(3, 4); m3 << 0, 3, 3, 0, 0, 0, 3, 3, 0, 0, 0, 0; m4.resize(3, 4); m4 << 1, 2, 2, 1, 1, 1, 2, 2, 0, 0, 0, 0; vector<Contour> vecContour = {Contour(m3, IS_OUTSKIRT), Contour(m4)}; return ContourCollection(vecContour); } }; TEST_F(SphericalCoordinateTest, SphericalCoordinateOutskirtTest) { generate_data(); ContourSphericalCoordinate sph1(m1, 12, true); //SphericalCoordinate sph2(m2, 12, false); EXPECT_FLOAT_EQ(sph1.getPhi(0), pi / 2); EXPECT_FLOAT_EQ(sph1.getPhi(m1.cols() - 1), pi * 2); EXPECT_FLOAT_EQ(sph1.getTheta(0), pi / 2); EXPECT_FLOAT_EQ(sph1.getTheta(2), pi / 2); } TEST_F(SphericalCoordinateTest, SphericalCoordinateNotOutskirtTest) { generate_data(); ContourSphericalCoordinate sph2(m2, 12, false); EXPECT_FLOAT_EQ(sph2.getPhi(0), pi / 4); EXPECT_FLOAT_EQ(sph2.getPhi(m1.cols() - 1), atan2(2, 1)); EXPECT_FLOAT_EQ(sph2.getTheta(0), asin(sqrt(2) / 6 * pi)); } TEST_F(SphericalCoordinateTest, MeshSphericalCoordinateTest) { SurfaceMesh mesh; MeshIO::read_mesh(mesh, "ball.obj"); MeshSphericalCoordinate sphericalCoordinate(mesh); ASSERT_EQ(sphericalCoordinate.size(), mesh.n_vertices()); } TEST_F(SphericalCoordinateTest, TriangulationCoordinateTest) { ContourCollection contours = prepare_collection(); SurfaceMesh mesh = xry_mesh::triangulate(contours); Contour contour = contours.getContours().at(0); ContourSphericalCoordinate contourSphericalCoordinate(contour, contours.getSphereCircumference()); TriangulationSpericalCoordinate spericalCoordinate(mesh, contourSphericalCoordinate.getCircumference()); EXPECT_EQ(spericalCoordinate.size(), mesh.n_vertices()); for(size_t i = 0; i < contour.rows(); i++) { EXPECT_FLOAT_EQ(spericalCoordinate.getTheta(i), pi / 2); } for(size_t i = contour.rows(); i < contours.getMergedContour().rows(); i += 2) { EXPECT_FLOAT_EQ(spericalCoordinate.getPhi(i), pi / 4); } }
8a2795c342e14bb0a439a40257f9adf0232ef3d8
eafae6e88ae9c25a11a218414e4e80a73de8deed
/Dependencies/Header/mysql/server/private/sql_show.h
3d7a4d1146cedd6bc209ec6de5b2bb57d26385d3
[ "GPL-2.0-only", "Apache-2.0" ]
permissive
GabrielLins64/SimpleERP
12fdc969a8bf1a211cc48b62fac10ec601eec8c1
8a25bdab32bd58a866f429b7f541e0e0617ef2e1
refs/heads/main
2023-05-14T11:55:15.623120
2021-06-02T18:41:58
2021-06-02T18:41:58
373,289,684
0
0
Apache-2.0
2021-06-02T20:05:27
2021-06-02T20:05:26
null
UTF-8
C++
false
false
9,607
h
sql_show.h
/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. Copyright (c) 2012, 2016, MariaDB 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; version 2 of the 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 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_SHOW_H #define SQL_SHOW_H #include "sql_list.h" /* List */ #include "handler.h" /* enum_schema_tables */ #include "table.h" /* enum_schema_table_state */ #include "my_apc.h" /* Forward declarations */ class JOIN; class String; class THD; class sp_name; struct TABLE_LIST; typedef class st_select_lex SELECT_LEX; struct LEX; typedef struct st_mysql_show_var SHOW_VAR; typedef struct st_schema_table ST_SCHEMA_TABLE; struct TABLE; typedef struct system_status_var STATUS_VAR; /* Used by handlers to store things in schema tables */ #define IS_FILES_FILE_ID 0 #define IS_FILES_FILE_NAME 1 #define IS_FILES_FILE_TYPE 2 #define IS_FILES_TABLESPACE_NAME 3 #define IS_FILES_TABLE_CATALOG 4 #define IS_FILES_TABLE_SCHEMA 5 #define IS_FILES_TABLE_NAME 6 #define IS_FILES_LOGFILE_GROUP_NAME 7 #define IS_FILES_LOGFILE_GROUP_NUMBER 8 #define IS_FILES_ENGINE 9 #define IS_FILES_FULLTEXT_KEYS 10 #define IS_FILES_DELETED_ROWS 11 #define IS_FILES_UPDATE_COUNT 12 #define IS_FILES_FREE_EXTENTS 13 #define IS_FILES_TOTAL_EXTENTS 14 #define IS_FILES_EXTENT_SIZE 15 #define IS_FILES_INITIAL_SIZE 16 #define IS_FILES_MAXIMUM_SIZE 17 #define IS_FILES_AUTOEXTEND_SIZE 18 #define IS_FILES_CREATION_TIME 19 #define IS_FILES_LAST_UPDATE_TIME 20 #define IS_FILES_LAST_ACCESS_TIME 21 #define IS_FILES_RECOVER_TIME 22 #define IS_FILES_TRANSACTION_COUNTER 23 #define IS_FILES_VERSION 24 #define IS_FILES_ROW_FORMAT 25 #define IS_FILES_TABLE_ROWS 26 #define IS_FILES_AVG_ROW_LENGTH 27 #define IS_FILES_DATA_LENGTH 28 #define IS_FILES_MAX_DATA_LENGTH 29 #define IS_FILES_INDEX_LENGTH 30 #define IS_FILES_DATA_FREE 31 #define IS_FILES_CREATE_TIME 32 #define IS_FILES_UPDATE_TIME 33 #define IS_FILES_CHECK_TIME 34 #define IS_FILES_CHECKSUM 35 #define IS_FILES_STATUS 36 #define IS_FILES_EXTRA 37 typedef enum { WITHOUT_DB_NAME, WITH_DB_NAME } enum_with_db_name; int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond); int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, Table_specification_st *create_info_arg, enum_with_db_name with_db_name); int show_create_table_ex(THD *thd, TABLE_LIST *table_list, const char * forced_db, const char *forced_name, String *packet, Table_specification_st *create_info_arg, enum_with_db_name with_db_name); int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table); bool append_identifier(THD *thd, String *packet, const char *name, size_t length); static inline bool append_identifier(THD *thd, String *packet, const LEX_CSTRING *name) { return append_identifier(thd, packet, name->str, name->length); } void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd); bool mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list, List<Item> *field_list, String *buffer); bool mysqld_show_create(THD *thd, TABLE_LIST *table_list); void mysqld_show_create_db_get_fields(THD *thd, List<Item> *field_list); bool mysqld_show_create_db(THD *thd, LEX_CSTRING *db_name, LEX_CSTRING *orig_db_name, const DDL_options_st &options); void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); int mysqld_show_variables(THD *thd,const char *wild); bool mysqld_show_storage_engines(THD *thd); bool mysqld_show_authors(THD *thd); bool mysqld_show_contributors(THD *thd); bool mysqld_show_privileges(THD *thd); char *make_backup_log_name(char *buff, const char *name, const char* log_ext); uint calc_sum_of_all_status(STATUS_VAR *to); bool append_definer(THD *thd, String *buffer, const LEX_CSTRING *definer_user, const LEX_CSTRING *definer_host); int add_status_vars(SHOW_VAR *list); void remove_status_vars(SHOW_VAR *list); ulonglong get_status_vars_version(void); void init_status_vars(); void free_status_vars(); void reset_status_vars(); bool show_create_trigger(THD *thd, const sp_name *trg_name); void view_store_options(THD *thd, TABLE_LIST *table, String *buff); void init_fill_schema_files_row(TABLE* table); void initialize_information_schema_acl(); ST_SCHEMA_TABLE *find_schema_table(THD *thd, const LEX_CSTRING *table_name, bool *in_plugin); static inline ST_SCHEMA_TABLE *find_schema_table(THD *thd, const LEX_CSTRING *table_name) { bool unused; return find_schema_table(thd, table_name, &unused); } ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); int make_schema_select(THD *thd, SELECT_LEX *sel, ST_SCHEMA_TABLE *schema_table); int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list); bool get_schema_tables_result(JOIN *join, enum enum_schema_table_state executed_place); enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list); const char* get_one_variable(THD *thd, const SHOW_VAR *variable, enum_var_type value_type, SHOW_TYPE show_type, system_status_var *status_var, const CHARSET_INFO **charset, char *buff, size_t *length); /* These functions were under INNODB_COMPATIBILITY_HOOKS */ int get_quote_char_for_identifier(THD *thd, const char *name, size_t length); THD *find_thread_by_id(longlong id, bool query_id= false); class select_result_explain_buffer; /* SHOW EXPLAIN request object. */ class Show_explain_request : public Apc_target::Apc_call { public: THD *target_thd; /* thd that we're running SHOW EXPLAIN for */ THD *request_thd; /* thd that run SHOW EXPLAIN command */ /* If true, there was some error when producing EXPLAIN output. */ bool failed_to_produce; /* SHOW EXPLAIN will be stored here */ select_result_explain_buffer *explain_buf; /* Query that we've got SHOW EXPLAIN for */ String query_str; /* Overloaded virtual function */ void call_in_target_thread(); }; /** Condition pushdown used for INFORMATION_SCHEMA / SHOW queries. This structure is to implement an optimization when accessing data dictionary data in the INFORMATION_SCHEMA or SHOW commands. When the query contain a TABLE_SCHEMA or TABLE_NAME clause, narrow the search for data based on the constraints given. */ typedef struct st_lookup_field_values { /** Value of a TABLE_SCHEMA clause. Note that this value length may exceed @c NAME_LEN. @sa wild_db_value */ LEX_CSTRING db_value; /** Value of a TABLE_NAME clause. Note that this value length may exceed @c NAME_LEN. @sa wild_table_value */ LEX_CSTRING table_value; /** True when @c db_value is a LIKE clause, false when @c db_value is an '=' clause. */ bool wild_db_value; /** True when @c table_value is a LIKE clause, false when @c table_value is an '=' clause. */ bool wild_table_value; } LOOKUP_FIELD_VALUES; /* INFORMATION_SCHEMA: Execution plan for get_all_tables() call */ class IS_table_read_plan : public Sql_alloc { public: IS_table_read_plan() : no_rows(false), trivial_show_command(FALSE) {} bool no_rows; /* For EXPLAIN only: For SHOW KEYS and SHOW COLUMNS, we know which db_name.table_name will be read, however for some reason we don't set the fields in this->lookup_field_vals. In order to not have JOIN::save_explain_data() walking over uninitialized data, we set trivial_show_command=true. */ bool trivial_show_command; LOOKUP_FIELD_VALUES lookup_field_vals; Item *partial_cond; bool has_db_lookup_value() { return (lookup_field_vals.db_value.length && !lookup_field_vals.wild_db_value); } bool has_table_lookup_value() { return (lookup_field_vals.table_value.length && !lookup_field_vals.wild_table_value); } }; bool optimize_schema_tables_reads(JOIN *join); bool optimize_schema_tables_memory_usage(List<TABLE_LIST> &tables); /* Handle the ignored database directories list for SHOW/I_S. */ bool ignore_db_dirs_init(); void ignore_db_dirs_free(); void ignore_db_dirs_reset(); bool ignore_db_dirs_process_additions(); bool push_ignored_db_dir(const char *path); extern char *opt_ignore_db_dirs; #endif /* SQL_SHOW_H */
6c0cbe6d57cf1ba38a8f4728f7c5b8168ea6b295
27b6db2b06406e8c03b68e3e21734dbb5352205c
/c18/src/Cuboid.cpp
d00fa4500197719175199ac24e78504234867e1c
[]
no_license
kuniyoshi/chapter18
53144e1c23aec9b92b85319f454917ac704ea35f
f04b3ed65bfca33760b40362e360cfa33dddf67d
refs/heads/master
2021-01-01T05:24:32.442360
2016-04-15T06:32:11
2016-04-15T06:32:11
56,276,902
0
0
null
null
null
null
UTF-8
C++
false
false
2,259
cpp
Cuboid.cpp
#include "Cuboid.h" #include "GraphicsDatabase/Vector3.h" using GraphicsDatabase::Vector3; namespace { const int InternalRange = 1000; } // namespace - Cuboid::Cuboid() : balance_x_(0), balance_y_(0), balance_z_(0), half_x_(0), half_y_(0), half_z_(0) {} Cuboid::Cuboid(const Cuboid& base) : balance_x_(base.balance_x_), balance_y_(base.balance_y_), balance_z_(base.balance_z_), half_x_(base.half_x_), half_y_(base.half_y_), half_z_(base.half_z_) {} Cuboid::Cuboid(const Vector3& balance, const Vector3& half_size) { balance_x_ = static_cast< int >(balance.x * InternalRange); balance_y_ = static_cast< int >(balance.y * InternalRange); balance_z_ = static_cast< int >(balance.z * InternalRange); half_x_ = static_cast< int >(half_size.x * InternalRange); half_y_ = static_cast< int >(half_size.y * InternalRange); half_z_ = static_cast< int >(half_size.z * InternalRange); } Cuboid::~Cuboid() {} void Cuboid::set_balance(const Vector3& balance) { balance_x_ = static_cast< int >(balance.x * InternalRange); balance_y_ = static_cast< int >(balance.y * InternalRange); balance_z_ = static_cast< int >(balance.z * InternalRange); } void Cuboid::set_half_size(const Vector3& half_size) { half_x_ = static_cast< int >(half_size.x * InternalRange); half_y_ = static_cast< int >(half_size.y * InternalRange); half_z_ = static_cast< int >(half_size.z * InternalRange); } bool Cuboid::does_intersect(const Cuboid& that) const { const Cuboid& b = that; int ax0 = balance_x_ - half_x_; int ax1 = balance_x_ + half_x_; int bx0 = b.balance_x_ - b.half_x_; int bx1 = b.balance_x_ + b.half_x_; if (ax0 < bx1 && ax1 > bx0) { int ay0 = balance_y_ - half_y_; int ay1 = balance_y_ + half_y_; int by0 = b.balance_y_ - b.half_y_; int by1 = b.balance_y_ + b.half_y_; if (ay0 < by1 && ay1 > by0) { int az0 = balance_z_ - half_z_; int az1 = balance_z_ + half_z_; int bz0 = b.balance_z_ - b.half_z_; int bz1 = b.balance_z_ + b.half_z_; if (az0 < bz1 && az1 > bz0) { return true; } } } return false; }
3a5409444674803a67564f27cb82d224f53cf33a
de1b9e5ebf35324b501add2c7f01b36a7246e6ea
/CPP/sqrt_rounded_to_nearest_int.cpp
2646d9fbf8dd56e360f9fe2425381bce06dc2208
[]
no_license
ishanmazhar/prog-prob-solving
f0993703ade0f91d875e94ae905505eab28e713e
eda361854a9bccd577cd16502a4d08577b0938c9
refs/heads/master
2023-06-27T23:44:46.196283
2021-07-30T08:29:30
2021-07-30T08:29:30
390,990,442
0
0
null
null
null
null
UTF-8
C++
false
false
184
cpp
sqrt_rounded_to_nearest_int.cpp
#include <iostream> #include <cmath> using namespace std; int main() { double x; cin >> x; cout << "The nearest int of the square root is " << round(sqrt(x)) << endl; return 0; }
be59f38dec819887edb6dd3a239eb7191e2ddf79
2b282fb3219251277c5a84e43b5d9827680ab200
/2840.cpp
465d96a0f0c50f794d8c44afc3a4631d53c031a6
[]
no_license
MatheusMilan/URI-Online-Judge
4cdc658737c6eea2d5f30fc557deae903adab366
ef440044c3dd5435c80a6c45cc6f27ea1dcc44a0
refs/heads/main
2023-01-12T15:11:59.971428
2020-11-21T12:32:57
2020-11-21T12:32:57
314,798,562
0
0
null
null
null
null
UTF-8
C++
false
false
213
cpp
2840.cpp
#include <stdio.h> #include <math.h> int main() { int R,L; double v; scanf("%d %d",&R,&L); v=(4.0/3.0)*(3.1415*(pow(R,3))); v=floor(L/v); printf("%.0f\n",v); return 0; }
aa74b40ee38cb42c87c53f03ec12fbe0058e9311
586d140f0102c1961f3c86045f5750b6f244b055
/Source/SideOp/Classes/HUD/SideOpHUD.h
b01fae35c355ef0d670f6592558d56ff8d68e5b1
[]
no_license
DaedalusProspect/SideOp
0e879d5a691716cb84edf1acd3e22185cc8a13bd
7d5dc2f7aece86284bb2c418e21bf61955197585
refs/heads/master
2021-01-02T08:52:25.657512
2015-07-29T02:05:08
2015-07-29T02:05:08
33,493,968
1
0
null
null
null
null
UTF-8
C++
false
false
271
h
SideOpHUD.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/HUD.h" #include "SideOpHUD.generated.h" /** * */ UCLASS() class SIDEOP_API ASideOpHUD : public AHUD { GENERATED_BODY() };
7a26b0ea017d67e133a5a8e5d9f0af780416ee48
ae31542273a142210a1ff30fb76ed9d45d38eba9
/src/backend/gporca/libnaucrates/src/operators/CDXLScalarSubqueryQuantified.cpp
06b552e64e0856b04dfac3dd6b8981b2072788f3
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "PostgreSQL", "OpenSSL", "LicenseRef-scancode-stream-benchmark", "ISC", "LicenseRef-scancode-openssl", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-ssleay-windows", "BSD-2-Clause", "Python-2.0" ]
permissive
greenplum-db/gpdb
8334837bceb2d5d51a684500793d11b190117c6a
2c0f8f0fb24a2d7a7da114dc80f5f5a2712fca50
refs/heads/main
2023-08-22T02:03:03.806269
2023-08-21T22:59:53
2023-08-22T01:17:10
44,781,140
6,417
2,082
Apache-2.0
2023-09-14T20:33:42
2015-10-23T00:25:17
C
UTF-8
C++
false
false
3,563
cpp
CDXLScalarSubqueryQuantified.cpp
//--------------------------------------------------------------------------- // Greenplum Database // Copyright (C) 2012 EMC, Corp. // // @filename: // CDXLScalarSubqueryQuantified.cpp // // @doc: // Implementation of quantified subquery operator //--------------------------------------------------------------------------- #include "naucrates/dxl/operators/CDXLScalarSubqueryQuantified.h" #include "gpos/string/CWStringDynamic.h" #include "naucrates/dxl/operators/CDXLNode.h" #include "naucrates/dxl/xml/CXMLSerializer.h" using namespace gpos; using namespace gpdxl; using namespace gpmd; //--------------------------------------------------------------------------- // @function: // CDXLScalarSubqueryQuantified::CDXLScalarSubqueryQuantified // // @doc: // Constructor // //--------------------------------------------------------------------------- CDXLScalarSubqueryQuantified::CDXLScalarSubqueryQuantified( CMemoryPool *mp, IMDId *scalar_op_mdid, CMDName *scalar_op_mdname, ULONG colid) : CDXLScalar(mp), m_scalar_op_mdid(scalar_op_mdid), m_scalar_op_mdname(scalar_op_mdname), m_colid(colid) { GPOS_ASSERT(scalar_op_mdid->IsValid()); GPOS_ASSERT(nullptr != scalar_op_mdname); } //--------------------------------------------------------------------------- // @function: // CDXLScalarSubqueryQuantified::~CDXLScalarSubqueryQuantified // // @doc: // Destructor // //--------------------------------------------------------------------------- CDXLScalarSubqueryQuantified::~CDXLScalarSubqueryQuantified() { m_scalar_op_mdid->Release(); GPOS_DELETE(m_scalar_op_mdname); } //--------------------------------------------------------------------------- // @function: // CDXLScalarSubqueryQuantified::SerializeToDXL // // @doc: // Serialize operator in DXL format // //--------------------------------------------------------------------------- void CDXLScalarSubqueryQuantified::SerializeToDXL(CXMLSerializer *xml_serializer, const CDXLNode *dxlnode) const { const CWStringConst *element_name = GetOpNameStr(); xml_serializer->OpenElement( CDXLTokens::GetDXLTokenStr(EdxltokenNamespacePrefix), element_name); // serialize operator id and name xml_serializer->AddAttribute(CDXLTokens::GetDXLTokenStr(EdxltokenOpName), m_scalar_op_mdname->GetMDName()); m_scalar_op_mdid->Serialize(xml_serializer, CDXLTokens::GetDXLTokenStr(EdxltokenOpNo)); // serialize computed column id xml_serializer->AddAttribute(CDXLTokens::GetDXLTokenStr(EdxltokenColId), m_colid); dxlnode->SerializeChildrenToDXL(xml_serializer); xml_serializer->CloseElement( CDXLTokens::GetDXLTokenStr(EdxltokenNamespacePrefix), element_name); } #ifdef GPOS_DEBUG //--------------------------------------------------------------------------- // @function: // CDXLScalarSubqueryQuantified::AssertValid // // @doc: // Checks whether operator node is well-structured // //--------------------------------------------------------------------------- void CDXLScalarSubqueryQuantified::AssertValid(const CDXLNode *dxlnode, BOOL validate_children) const { GPOS_ASSERT(2 == dxlnode->Arity()); CDXLNode *pdxlnScalarChild = (*dxlnode)[EdxlsqquantifiedIndexScalar]; CDXLNode *pdxlnRelationalChild = (*dxlnode)[EdxlsqquantifiedIndexRelational]; GPOS_ASSERT(EdxloptypeScalar == pdxlnScalarChild->GetOperator()->GetDXLOperatorType()); GPOS_ASSERT(EdxloptypeLogical == pdxlnRelationalChild->GetOperator()->GetDXLOperatorType()); dxlnode->AssertValid(validate_children); } #endif // GPOS_DEBUG // EOF
6b18b472a3649bfdcc7c7bc8a8b517516f862f20
f7fa487f1872352781372611e3322d494de569da
/linux ADO 数据库代码/MyDB.cpp
d34375bc5bc3c3956f2c6c388a606a7af7c7f458
[]
no_license
rainhenry/CodeNote
151494aa5069d49ccf27112c8fc791a1c355bc5c
ba55ca15ee003aa2a02ffae7563629907a831333
refs/heads/master
2023-07-02T03:51:23.163637
2021-08-07T17:16:32
2021-08-07T17:16:32
393,670,260
1
0
null
null
null
null
GB18030
C++
false
false
2,053
cpp
MyDB.cpp
/************************************************************************* > File Name: MyDB.cpp > Author: SongLee > E-mail: lisong.shine@qq.com > Created Time: 2014年05月04日 星期日 23时37分08秒 > Personal Blog: http://songlee24.github.io ************************************************************************/ #include<iostream> #include<cstdlib> #include "MyDB.h" using namespace std; MyDB::MyDB() { connection = mysql_init(NULL); // 初始化数据库连接变量 if(connection == NULL) { cout << "Error:" << mysql_error(connection); exit(1); } } MyDB::~MyDB() { if(connection != NULL) // 关闭数据库连接 { mysql_close(connection); } } bool MyDB::initDB(string host, string user, string pwd, string db_name) { // 函数mysql_real_connect建立一个数据库连接 // 成功返回MYSQL*连接句柄,失败返回NULL connection = mysql_real_connect(connection, host.c_str(), user.c_str(), pwd.c_str(), db_name.c_str(), 0, NULL, 0); if(connection == NULL) { cout << "Error:" << mysql_error(connection); exit(1); } return true; } bool MyDB::exeSQL(string sql) { // mysql_query()执行成功返回0,失败返回非0值。与PHP中不一样 if(mysql_query(connection, sql.c_str())) { cout << "Query Error:" << mysql_error(connection); exit(1); } else { result = mysql_use_result(connection); // 获取结果集 // mysql_field_count()返回connection查询的列数 for(int i=0; i < mysql_field_count(connection); ++i) { // 获取下一行 row = mysql_fetch_row(result); if(row <= 0) { break; } // mysql_num_fields()返回结果集中的字段数 for(int j=0; j < mysql_num_fields(result); ++j) { cout << row[j] << " "; } cout << endl; } // 释放结果集的内存 mysql_free_result(result); } return true; }
13f4c1c47665b4c7abbb6ac4ab15495b6b333d5f
9de32079256a0a052087c60baa4f23c7387ef249
/src/networkinterfacefrontendbase.cpp
425ccf274b899c2ab90e1157877f750ade28b4a3
[ "MIT" ]
permissive
drcfts/SystemC_RISC-V
69710dfc3e4a1fa7bbae8c1759fabebe0d76dd6a
3d35d752d57405d5a0b55e09d1143e0f43a90887
refs/heads/master
2021-01-25T09:32:25.572964
2017-07-08T14:40:15
2017-07-08T14:40:15
93,849,004
2
0
null
null
null
null
UTF-8
C++
false
false
1,698
cpp
networkinterfacefrontendbase.cpp
#include "networkinterfacefrontendbase.h" NetworkInterfaceFrontEndBase::NetworkInterfaceFrontEndBase() : _payloadDst(0), _payloadSrc(0), _ack((std::string(SC_KERNEL_EVENT_PREFIX)+"NIShellBase_ack").c_str()), _valid((std::string(SC_KERNEL_EVENT_PREFIX)+"NIShellBase_valid").c_str()), _ackFlag(false), _validFlag(false), _writing((std::string(SC_KERNEL_EVENT_PREFIX)+"NIShellBase_writing").c_str()), _reading((std::string(SC_KERNEL_EVENT_PREFIX)+"NIShellBase_reading").c_str()), _writingFlag(false), _readingFlag(false) { } void NetworkInterfaceFrontEndBase::sendPayload(const std::vector<uint32_t> &payload, int dst) { _payloadDst = dst; _payload = payload; _writing.notify(SC_ZERO_TIME); _writingFlag = true; for (;!_ackFlag;) { wait(_ack); } _ackFlag = false; } void NetworkInterfaceFrontEndBase::receivePayload(std::vector<uint32_t> &payload, int *src) { _reading.notify(SC_ZERO_TIME); _readingFlag = true; for (;!_validFlag;) { wait(_valid); } _validFlag = false; payload = _payload; *src = _payloadSrc; } void NetworkInterfaceFrontEndBase::kernelReceivePayload(std::vector<uint32_t> &payload, int *dst) { for (;!_writingFlag;) { wait(_writing); } _writingFlag = false; payload = _payload; *dst = _payloadDst; _ack.notify(SC_ZERO_TIME); _ackFlag = true; } void NetworkInterfaceFrontEndBase::kernelSendPayload(const std::vector<uint32_t> &payload, int *src) { for (;!_readingFlag;) { wait(_reading); } _readingFlag = false; _valid.notify(); _validFlag = true; _payload = payload; _payloadSrc = *src; }
7460fe13d2837fa2e1e5e054add4953e814139f7
7d558e68292c1b6345e6f0af1f14927a60367718
/IDPUI/CZToolBar.h
5a48ee5633cc1497a59e18cb86f69223faa0df1a
[]
no_license
veinyyxy/IDP_OLD2
e8c15c8cc0d0be62ea7c359b46b5285616ba2da1
4dbd439f5d01a78eb10a3da5792d609d0950ae2b
refs/heads/master
2022-12-19T19:19:31.823314
2020-09-28T05:24:17
2020-09-28T05:24:17
299,151,464
0
0
null
null
null
null
UTF-8
C++
false
false
503
h
CZToolBar.h
#ifndef CZTOOLBAR_H #define CZTOOLBAR_H #include <QtGui> #include "ui_CZToolBar.h" #include "idpui_global.h" #include "IDPdb.h" class MainWindow; class IDPUI_EXPORT CZToolBar : public QToolBar { Q_OBJECT public: CZToolBar(QWidget *parent = 0); ~CZToolBar(); public: void LoadData(QString fileName); private: void InitSlots(); public Q_SLOTS: void Slots_ActionTriggered( QAction* action ); private: Ui::CZToolBar ui; QActionGroup m_CZActionGroup; MainWindow* _mw; }; #endif // CZTOOLBAR_H
3c87b00f2583999075a779c51868ec90e6a7ba54
29beae3644979feda8969c63ceefdd0ac586ca2d
/spanner/polygon.h
ece0c41792f6d68fef078788a3f54ae6cf459cd6
[]
no_license
luccasiau/cpsc448
a956654f7637526069a9e050dcb8ac79ceb80eb1
6283dc80be97225f1e634dc47d961de59a06659d
refs/heads/master
2020-12-14T18:22:25.421327
2020-04-21T00:34:12
2020-04-21T00:34:12
234,837,910
0
0
null
null
null
null
UTF-8
C++
false
false
977
h
polygon.h
#include <cmath> #include <vector> using namespace std; typedef long double ld; class Point { public: ld x, y; Point(ld x_=0, ld y_=0): x(x_), y(y_) {} static ld dist(Point p, Point q); }; class SpannerGraph { public: int n; int numEdges; SpannerGraph(vector<Point> p); void addEdge(int a, int b); void removeEdge(int a, int b); int getTriangulations(); ld getBestSpannerRatio(); vector<vector<bool>> getBestSpannerGraph(); void printSegments(); int getDegree(int a); bool hasEdge(int a, int b); void clearEdges(); ld getPointsDistance(int a, int b); private: vector<Point> points; vector<vector<bool>> adj; vector<vector<ld>> dist; vector<int> degree; // best information ld bestSpanner; vector<vector<bool>> bestGraph; int numTriangulations; void measureAndUpdateSpanner(); ld measureSpanner(); void buildGraph(); void floydWarshall(); };
7da95985654b0159fff5dcb7c10d35d6e60540d0
4fdd91f9c7bd4d61eaa65b48ecedb3faafd4ee9a
/Volatile Database/Volatile Database/Game.cpp
37c6f2cff2ac10b1414ae0b179d85df71e6fc29a
[]
no_license
jobtolmop/Volatile-Database
76c864f89380071ad358e7ec730dc25be017c82c
f4db7200f661cc2d8116f37bcb4f38d61e84dac6
refs/heads/master
2020-08-31T02:09:10.944021
2019-10-30T15:04:59
2019-10-30T15:04:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
99
cpp
Game.cpp
#include <iostream> #include "Game.h" void Game::StartGame() { std::cout << "it works"; }
6d2c80aae97c5aca5040643b9a9ed7613c3de225
01a42b69633daf62a2eb3bb70c5b1b6e2639aa5f
/SCUM_Skewer_Vegetables_functions.cpp
fc09ee7e5a9373f11c36bed45f81d5617fced00e
[]
no_license
Kehczar/scum_sdk
45db80e46dac736cc7370912ed671fa77fcb95cf
8d1770b44321a9d0b277e4029551f39b11f15111
refs/heads/master
2022-07-25T10:06:20.892750
2020-05-21T11:45:36
2020-05-21T11:45:36
265,826,541
1
0
null
null
null
null
UTF-8
C++
false
false
4,919
cpp
SCUM_Skewer_Vegetables_functions.cpp
// Scum 3.79.22573 (UE 4.24) #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace Classes { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function ConZ.FoodItem.OnRep_Temperature // () void ASkewer_Vegetables_C::OnRep_Temperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_Temperature"); ASkewer_Vegetables_C_OnRep_Temperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnRep_ItemOpened // () void ASkewer_Vegetables_C::OnRep_ItemOpened() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_ItemOpened"); ASkewer_Vegetables_C_OnRep_ItemOpened_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnRep_IsCooking // () void ASkewer_Vegetables_C::OnRep_IsCooking() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnRep_IsCooking"); ASkewer_Vegetables_C_OnRep_IsCooking_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.OnAudioComponentExpired // () void ASkewer_Vegetables_C::OnAudioComponentExpired() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.OnAudioComponentExpired"); ASkewer_Vegetables_C_OnAudioComponentExpired_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function ConZ.FoodItem.IsCooking // () // Parameters: // bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) bool ASkewer_Vegetables_C::IsCooking() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.IsCooking"); ASkewer_Vegetables_C_IsCooking_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetVolume // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ASkewer_Vegetables_C::GetVolume() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetVolume"); ASkewer_Vegetables_C_GetVolume_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetThermalConductivityFactor // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ASkewer_Vegetables_C::GetThermalConductivityFactor() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetThermalConductivityFactor"); ASkewer_Vegetables_C_GetThermalConductivityFactor_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetTemperature // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ASkewer_Vegetables_C::GetTemperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetTemperature"); ASkewer_Vegetables_C_GetTemperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetEnvironmentTemperature // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ASkewer_Vegetables_C::GetEnvironmentTemperature() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetEnvironmentTemperature"); ASkewer_Vegetables_C_GetEnvironmentTemperature_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } // Function ConZ.FoodItem.GetCookingAmount // () // Parameters: // float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData) float ASkewer_Vegetables_C::GetCookingAmount() { static auto fn = UObject::FindObject<UFunction>("Function ConZ.FoodItem.GetCookingAmount"); ASkewer_Vegetables_C_GetCookingAmount_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; return params.ReturnValue; } } #ifdef _MSC_VER #pragma pack(pop) #endif
2c45d299ef6592317cc103d99064c383bec137ef
b380d77a3fbf00404f6bdd28bd605e0df255ac56
/My_Solid_Proj/EngineInclude/EngineGenerated/rigidBody.sld.hpp
e3192cf766ea60dc4bfe2401015f5b71b9dc223b
[ "MIT" ]
permissive
SolidTeamDev/SolidEngine
6fc3074c4a83a140698617edb864d1e67fbbdad3
63f61a34db7604081ed82894a5eac4c33607d94f
refs/heads/master
2023-05-27T09:48:05.073017
2021-06-14T09:22:42
2021-06-14T09:22:42
270,995,069
0
0
null
null
null
null
UTF-8
C++
false
false
7,728
hpp
rigidBody.sld.hpp
#pragma once /** * Source file: D:\Project\SolidEngine\SolidEngine\Include\ECS\Components\rigidBody.hpp */ #include "EntityMacros.h" #include <Refureku/Misc/DisableWarningMacros.h> #include <Refureku/TypeInfo/Namespaces/Namespace.h> #include <Refureku/TypeInfo/Namespaces/NamespaceFragment.h> #include <Refureku/TypeInfo/Namespaces/NamespaceFragmentRegisterer.h> #include <Refureku/TypeInfo/Archetypes/Class.h> #include <Refureku/TypeInfo/Archetypes/Enum.h> #include <Refureku/TypeInfo/Archetypes/ArchetypeRegisterer.h> #include <Refureku/TypeInfo/Entity/DefaultEntityRegisterer.h> #ifdef __RFK3698706698196451833u_DeclareGetNamespaceFragment #undef __RFK3698706698196451833u_DeclareGetNamespaceFragment #endif #define __RFK3698706698196451833u_DeclareGetNamespaceFragment inline rfk::NamespaceFragment const& getNamespaceFragment3698706698196451833u_16729104821330039792() noexcept; #ifdef __RFK3698706698196451833u_DefineGetNamespaceFragment #undef __RFK3698706698196451833u_DefineGetNamespaceFragment #endif #define __RFK3698706698196451833u_DefineGetNamespaceFragment \ inline rfk::NamespaceFragment const& getNamespaceFragment3698706698196451833u_16729104821330039792() noexcept \ { \ static rfk::NamespaceFragment fragment("Solid", 3698706698196451833u); \ static bool initialized = false; \ if (!initialized) \ { \ initialized = true; \ fragment.nestedEntities.reserve(1u); rfk::NamespaceFragment* fragmentPtr = &fragment; fragmentPtr->addNestedEntity(&Solid::RigidBody::staticGetArchetype()); \ } \ return fragment; \ } #ifdef __RFK3698706698196451833u_RegisterNamespace #undef __RFK3698706698196451833u_RegisterNamespace #endif #define __RFK3698706698196451833u_RegisterNamespace \ inline rfk::NamespaceFragmentRegisterer namespaceFragmentRegisterer3698706698196451833u_16729104821330039792 = rfk::NamespaceFragmentRegisterer("Solid", 3698706698196451833u, &getNamespaceFragment3698706698196451833u_16729104821330039792(), true); #ifdef __RFK3698706698196451833u_GENERATED #undef __RFK3698706698196451833u_GENERATED #endif #ifdef KODGEN_PARSING #define __RFK3698706698196451833u_GENERATED #else #define __RFK3698706698196451833u_GENERATED \ namespace rfk::generated { \ __RFK3698706698196451833u_DeclareGetNamespaceFragment \ __RFK3698706698196451833u_RegisterNamespace \ __RFK3698706698196451833u_DefineGetNamespaceFragment \ } #endif #define __RFK9721541611162158115u_GenerateParentsMetadata \ type.directParents.reserve(1); \ type.addToParents<Solid::Components>(static_cast<rfk::EAccessSpecifier>(1)); \ #define __RFK9721541611162158115u_GenerateFieldsMetadata \ registerChild<RigidBody>(&type); \ #define __RFK9721541611162158115u_GenerateFieldHelperMethods \ private: \ template <typename ParentType, typename ChildType> \ static constexpr void recurseRegisterChild([[maybe_unused]] rfk::Struct* childArchetype) \ { \ if constexpr (rfk::isReflectedClass<ParentType>) \ { \ ParentType::template registerChild<ChildType>(childArchetype); \ } \ } \ public: \ template <typename ChildType> \ static void registerChild(rfk::Struct* childArchetype) noexcept \ { \ recurseRegisterChild<Solid::Components, ChildType>(childArchetype); \ rfk::Struct const& thisArchetype = staticGetArchetype(); \ if (childArchetype != &thisArchetype) \ { \ const_cast<rfk::Struct&>(thisArchetype).children.insert(childArchetype); \ } \ [[maybe_unused]] rfk::Field* field = nullptr; \ [[maybe_unused]] rfk::StaticField* staticField = nullptr; \ __RFK_DISABLE_WARNING_PUSH \ __RFK_DISABLE_WARNING_OFFSETOF \ field = childArchetype->addField("gravity", 15862074580564247938u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, gravity)); \ field = childArchetype->addField("isKinematic", 2476124050480900145u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, isKinematic)); \ field = childArchetype->addField("mass", 4790624427714371020u, rfk::Type::getType<float>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, mass)); \ field = childArchetype->addField("drag", 11318751206634570742u, rfk::Type::getType<float>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, drag)); \ field = childArchetype->addField("angularDrag", 15619724461819505796u, rfk::Type::getType<float>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, angularDrag)); \ field = childArchetype->addField("freezePosX", 15257040038834533861u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezePosX)); \ field = childArchetype->addField("freezePosY", 15257038939322905650u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezePosY)); \ field = childArchetype->addField("freezePosZ", 15257037839811277439u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezePosZ)); \ field = childArchetype->addField("freezeRotX", 15181879547109669988u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezeRotX)); \ field = childArchetype->addField("freezeRotY", 15181880646621298199u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezeRotY)); \ field = childArchetype->addField("freezeRotZ", 15181881746132926410u, rfk::Type::getType<bool>(), static_cast<rfk::EFieldFlags>(4), &thisArchetype, offsetof(ChildType, freezeRotZ)); \ __RFK_DISABLE_WARNING_POP \ } #define __RFK9721541611162158115u_GenerateMethodsMetadata \ #define __RFK9721541611162158115u_GenerateArchetypeProperties \ #define __RFK9721541611162158115u_GenerateDefaultInstantiatorSetup \ type.setDefaultInstantiator(&rfk::defaultInstantiator<RigidBody>); #define __RFK9721541611162158115u_GetTypeDeclaration \ __RFK9721541611162158115u_GenerateFieldHelperMethods \ public: \ inline static rfk::Class const& staticGetArchetype() noexcept; \ rfk::Class const& getArchetype() const noexcept override { return RigidBody::staticGetArchetype(); } #ifdef KODGEN_PARSING #define __RFK9721541611162158115u_GetTypeDefinition #else #define __RFK9721541611162158115u_GetTypeDefinition \ inline rfk::Class const& Solid::RigidBody::staticGetArchetype() noexcept \ { \ static bool initialized = false; \ static rfk::Class type("RigidBody", 9721541611162158115u, sizeof(RigidBody)); \ \ if (!initialized) \ { \ initialized = true; \ \ __RFK9721541611162158115u_GenerateArchetypeProperties \ __RFK9721541611162158115u_GenerateParentsMetadata \ \ __RFK9721541611162158115u_GenerateFieldsMetadata \ __RFK9721541611162158115u_GenerateDefaultInstantiatorSetup \ __RFK9721541611162158115u_GenerateMethodsMetadata \ } \ \ return type; \ } #endif #define __RFK9721541611162158115u_RegisterArchetype \ private: \ static inline rfk::ArchetypeRegisterer __rfkArchetypeRegisterer; #ifdef KODGEN_PARSING #define RigidBody_GENERATED #else #define RigidBody_GENERATED \ friend rfk::Struct; \ friend rfk::hasField___rfkArchetypeRegisterer<RigidBody, rfk::ArchetypeRegisterer>; \ __RFK9721541611162158115u_GetTypeDeclaration \ __RFK9721541611162158115u_RegisterArchetype \ \ private: #endif #ifdef __RFKNativeProperties_GENERATED #undef __RFKNativeProperties_GENERATED #endif #define __RFKNativeProperties_GENERATED \ #ifdef File_GENERATED #undef File_GENERATED #endif #define File_GENERATED \ __RFK9721541611162158115u_GetTypeDefinition \ __RFK3698706698196451833u_GENERATED \ __RFKNativeProperties_GENERATED \
f409e0abef074d83701172a9708fe10eb5677aff
2ddfba5d2ad9c28e99d5c55ebf529cf70bced034
/buylow/buylow.cpp
00dd4d39ae7fe37143939826e06cf118b11f9524
[]
no_license
SanD94/USACO
9b59dc17ac7cf4ed60a300c3af3d34dc679207b6
42cec4a11e7ac1837c39c951fde1c0f6b8e5a03c
refs/heads/master
2021-01-21T04:37:19.248925
2019-10-01T12:18:10
2019-10-01T12:18:10
37,533,047
0
2
null
null
null
null
UTF-8
C++
false
false
1,470
cpp
buylow.cpp
/* ID: safaand1 PROG: buylow LANG: C++11 */ #include <iostream> #include <string> #include <fstream> using namespace std; #define max(a,b) a>b?a:b #define min(a,b) a<b?a:b ifstream fin("buylow.in"); ofstream fout("buylow.out"); string sum(string a, string b){ string res = ""; int a_len = a.length(); int b_len = b.length(); int mx = max(a_len, b_len); char ext = 0; for(int i=0;i<mx;i++){ char x = (min(i, a_len)) < a_len ? (a[i]-'0') : 0; char y = (min(i, b_len)) < b_len ? (b[i]-'0') : 0; res += ((x+y+ext) % 10) + '0'; ext = (x+y+ext)/10; } if(ext == 1) res += ext + '0'; return res; } string inv(string a){ string res; for(int i = a.length() - 1; i>=0; i--) res += a[i]; return res; } int N; int prices[5000]; int seq[5000]; string num[5000]; int main(){ fin >> N; for(int i=0;i<N;i++){ fin >> prices[i]; seq[i] = 1; num[i] += "1"; } for(int i=1;i<N;i++) for(int j=0;j<i;j++){ if(prices[i] == prices[j]){ seq[j] = -1; num[j] = ""; } else if(prices[i] < prices[j]){ if (seq[j] >= seq[i]){ seq[i] = seq[j] + 1; num[i] = num[j]; } else if(seq[j] + 1 == seq[i]) num[i] = sum(num[i], num[j]); } } int len=0; string sq=""; for(int i=0;i<N;i++){ if(len < seq[i]) { len = seq[i]; sq = num[i]; } else if (len == seq[i]) sq = sum(sq, num[i]); } fout << len << " " << inv(sq) << endl; return 0; }
d97a16ddcbe67e721e9914d59be684d81ca0a1af
2952219d4db6d181e815b5a58344e19428d6b745
/src/main.cpp
04852358b7ca01a221b21202654c8fc47386387b
[]
no_license
BuzzVII/PointViewer
df82c589bc18262196f8aa4e15206a8e65982e2f
a79193876b2ad8405beec2b922427510b8563242
refs/heads/master
2020-05-13T18:47:34.583175
2018-10-14T11:07:11
2018-10-14T11:07:11
12,083,854
1
0
null
null
null
null
UTF-8
C++
false
false
7,879
cpp
main.cpp
#include <math.h> #include <time.h> #include <iostream> #include <string> #include <vector> #include <fstream> #include <algorithm> #include "load_points.h" // open gl includes #include <GL/glfw.h> //PointViewer version 0.2 void resetPoints(Points *pPset, double *pDims); void resetPoints(Points *pPset, double *pDims, int maxid){ glBegin(GL_POINTS); for(int count=0;count < (*pPset).size();count++){ if(pDims[4]==1) glColor3ub((*pPset)[count].r, (*pPset)[count].g, (*pPset)[count].b); else if(pDims[4]==0) glColor3ub((*pPset)[count].I, (*pPset)[count].I, (*pPset)[count].I); else glColor3ub( ((((*pPset)[count].id * 450) % 500 ) * 3 ) % 256, (*pPset)[count].id * 255 / maxid, maxid - ( ( ( 72 * (*pPset)[count].id ) % 13 ) * 900 ) % 256 ); glVertex3f( ( (*pPset)[count].x - pDims[1] ) / pDims[0] * 2.f -1.f , ((*pPset)[count].z - pDims[3]) / pDims[0] * 2.f - 1.f, ( (*pPset)[count].y - pDims[2]) / pDims[0] * 2.f - 1.f ); } glEnd(); } void drawaxes(float *pxax, float *pyax, float *pzax); void drawaxes(float *pxax, float *pyax, float *pzax){ glBegin(GL_LINES); glColor3ub(255,0,0); glVertex3f(0.f * pzax[0], 0.f * pzax[1],0.f * pzax[2]); glVertex3f(0.1f * pzax[0], 0.1f * pzax[1], 0.1f * pzax[2]); glEnd(); glBegin(GL_LINES); glColor3ub(0,255,0); glVertex3f(0.f * pyax[0], 0.f * pyax[1], 0.f * pyax[2]); glVertex3f(0.1f * pyax[0], 0.1f * pyax[1], 0.1f * pyax[2]); glEnd(); glBegin(GL_LINES); glColor3ub(0,0,255); glVertex3f(0.0f * pxax[0], 0.0f * pxax[1], 0.0f * pxax[2]); glVertex3f(0.1f * pxax[0], 0.1f * pxax[1], 0.1f * pxax[2]); glEnd(); } int main( int argc, char** argv ){ int input,maxid,speed=1; float sign=1.0f; float xaxis[3]={1.f, 0.f, 0.f}, yaxis[3]={0.f, 1.f, 0.f}, zaxis[3]={0.f, 0.f, 1.f}; float cos1=cos( 1.f/180 * 3.141592 ), sin1=sin( 1.f/180 * 3.141592); double dims[5]; bool cdown=false; GLfloat currentModelMatrix[16]; std::string userCommand; dims[4]=1; Points P; load_points(&P , dims); for( int n = 0; n < P.size(); n++) maxid = std::max(maxid,P[n].id); std::cout << "max id = " << maxid << std::endl; input = time( NULL ); std::cout << "Initializing Graphics Window" << std::endl; if ( !glfwInit() ){ std::cerr << "Failed to start GLFW" << std::endl; return -1; } if (!glfwOpenWindow(800, 800, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)){ glfwTerminate(); return -1; } glfwSetWindowTitle("PointViewer"); glfwEnable(GLFW_STICKY_KEYS); glEnable( GL_POINT_SMOOTH ); // glEnable( GL_LIGHTING ); // glEnable( GL_LIGHT0 ); // glEnable( GL_LIGHT1 ); glPointSize( 1.0f ); glOrtho(-100,100,-100,100,-1000,1000); while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED) ){ //glClearColor( 0.160f, 0.0f, 0.120f, 0.0f); glClearColor( 0.1f, 0.1f, 0.1f, 0.1f); glClear( GL_COLOR_BUFFER_BIT ); resetPoints(&P, dims, maxid); drawaxes(xaxis, yaxis, zaxis); glDrawArrays(GL_POINTS, 0, 3); glDrawArrays(GL_LINES,0,3); glfwSwapBuffers(); glfwPollEvents(); //manipulate transforms to current view axes /*glGetFloatv(GL_MODELVIEW_MATRIX, currentModelViewMatrix); glRotatef(xRotation, currentModelViewMatrix[1], currentModelViewMatrix[5], currentModelViewMatrix[9]); glGetFloatv(GL_MODELVIEW_MATRIX, currentModelViewMatrix); glRotatef(yRotation, currentModelViewMatrix[0], currentModelViewMatrix[4], currentModelViewMatrix[8]);*/ /* Need to calculate the current axis based on the previous key presses then update each rotate etc to be around the appropriate axis*/ if( glfwGetKey( GLFW_KEY_UP ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef( 0.1 * yaxis[0], 0.1 * yaxis[1], 0.1 * yaxis[2]); else { glRotatef(-1.f * float( speed ), xaxis[0], xaxis[1], xaxis[2]); } } else if( glfwGetKey( GLFW_KEY_DOWN ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef(-0.1 * yaxis[0],-0.1 * yaxis[1],-0.1 * yaxis[2]); else { glRotatef(1.f * float( speed ), xaxis[0], xaxis[1], xaxis[2]); } } else if( glfwGetKey( GLFW_KEY_LEFT ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef(-0.1 * xaxis[0],-0.1 * xaxis[1],-0.1 * xaxis[2]); else { glRotatef(-1.f * float( speed ), yaxis[0], yaxis[1], yaxis[2]); } } else if( glfwGetKey( GLFW_KEY_RIGHT ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef(0.1 * xaxis[0],0.1 * xaxis[1],0.1 * xaxis[2]); else { glRotatef(1.f * float( speed ), yaxis[0], yaxis[1], yaxis[2]); } } else if( glfwGetKey( 'A' ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef(0.1 * zaxis[0],0.1 * zaxis[1],0.1 * zaxis[2]); else { glRotatef(1.f * float( speed ), zaxis[0], zaxis[1], zaxis[2]); } } else if( glfwGetKey( 'Z' ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glTranslatef(-0.1 * zaxis[0],-0.1 * zaxis[1],-0.1 * zaxis[2]); else { glRotatef(-1.f * float( speed ), zaxis[0], zaxis[1], zaxis[2]); } } else if( glfwGetKey( GLFW_KEY_SPACE ) == GLFW_PRESS ){ if( glfwGetKey( GLFW_KEY_RCTRL ) == GLFW_PRESS ) glScalef( pow(1.1f * float( speed ),1) , pow(1.1f * float( speed ),1) , pow(1.1f * float( speed ),1) ); else { glScalef( pow(0.9f / float( speed ),1) , pow(0.9f / float( speed ),1) , pow(0.9f / float( speed ),1) ); } } else if( glfwGetKey( 'R' ) == GLFW_PRESS ){ glLoadIdentity();//reset view glGetFloatv(GL_MODELVIEW_MATRIX, currentModelMatrix);//reset vectors xaxis[0]=currentModelMatrix[0]; xaxis[1]=currentModelMatrix[4]; xaxis[2]=currentModelMatrix[8]; yaxis[0]=currentModelMatrix[1]; yaxis[1]=currentModelMatrix[5]; yaxis[2]=currentModelMatrix[9]; zaxis[0]=currentModelMatrix[2]; zaxis[1]=currentModelMatrix[6]; zaxis[2]=currentModelMatrix[10]; } else if( glfwGetKey( 'G' ) == GLFW_PRESS ){ glGetFloatv(GL_MODELVIEW_MATRIX, currentModelMatrix);//reset vectors xaxis[0]=currentModelMatrix[0]; xaxis[1]=currentModelMatrix[4]; xaxis[2]=currentModelMatrix[8]; yaxis[0]=currentModelMatrix[1]; yaxis[1]=currentModelMatrix[5]; yaxis[2]=currentModelMatrix[9]; zaxis[0]=currentModelMatrix[2]; zaxis[1]=currentModelMatrix[6]; zaxis[2]=currentModelMatrix[10]; } else if( glfwGetKey( 'C' ) == GLFW_PRESS & !cdown ){ dims[4] = float(int( dims[4] + 1 ) % 3); cdown=true; } else if( glfwGetKey( 'C' ) == GLFW_RELEASE ){ cdown=false; } else if( glfwGetKey( '1' ) == GLFW_RELEASE ){ speed=1; } else if( glfwGetKey( '2' ) == GLFW_RELEASE ){ speed=10; } else if( glfwGetKey( '3' ) == GLFW_RELEASE ){ speed=100; } else if( glfwGetKey( '/' ) == GLFW_RELEASE ){ //bring up user terminal } } std::cout << "terminating GLFW" << std::endl; glfwTerminate(); std::cout << "program complete" << std::endl; return 0; }
3421a208f7c47836a2474ee112b8554f7ef18633
715b6e5edbd097ced1354f8d385a053ab412de4f
/S01602AW-test.ino
8425fced33b21b201cce23c6103c08e2519a697b
[ "MIT" ]
permissive
yoggy/S01602AW-test
4ab0cdc4233bf0ec593028dfeeaf767944cec38a
099ebcf539b36670e010f0741e7d0866f8e44524
refs/heads/master
2021-01-12T05:00:28.451504
2017-01-03T07:48:30
2017-01-03T07:48:30
77,827,112
0
0
null
null
null
null
UTF-8
C++
false
false
688
ino
S01602AW-test.ino
// // S01602AW-test.ino - a sample sketch for for SO1602AWWB, SO1602AWGB, SO1602AWYB // // OLED Character Display Module 16x2 // http://akizukidenshi.com/catalog/g/gP-08277/ (White) // http://akizukidenshi.com/catalog/g/gP-08276/ (Green) // http://akizukidenshi.com/catalog/g/gP-08278/ (Yellow) // // license: // Copyright (c) 2017 yoggy <yoggy0@gmail.com> // Released under the MIT license // http://opensource.org/licenses/mit-license.php;// // #include <Wire.h> #include "WioNode.h" void setup() { INIT_WIO_NODE(); Wire.begin(PORT1_D1, PORT1_D0); //SDA (White), SCL(Yellow) so1602aw_init(); so1602aw_print("hello SO1602AWGB!!!!12345678"); } void loop() { }
3ba2a62074119ceaf1c9f2801bd0b2f84a59b013
e5c753ab5204897919a934c4184e874b39f14530
/Undergrad/Second Year/Compilers/Project/parser/symbol.cpp
e81dfb0bac9caa13b92791484c82c0fd2c024ff4
[]
no_license
adechan/School
bcb7a50ec0c21c4362495c0e0746ab4a6e79cba8
975da492704111a47f50f9f75ccaf2a023f9e8fc
refs/heads/master
2021-06-09T16:00:21.764181
2021-05-11T06:58:07
2021-05-11T06:58:07
106,673,346
1
1
null
null
null
null
UTF-8
C++
false
false
216
cpp
symbol.cpp
#include "symbol.hpp" namespace parser { symbol::symbol(const lexer::token& token, parser::type type) : token_(token) , type_(type) {} const std::string& symbol::text() const { return token_.text(); } }
902dba01010cc154f7db9f3b93006aa6486837b2
a7f3bd7e33edd82c41d8bc5b0d81f66777ef2a6f
/tile.h
636f1524b683cc03b1f6c2e19a3f74b6d5d0e6d7
[]
no_license
joemac875/cursed-realms
385ebc852b1ce6a7372dcf7d89f8d59a980abcaf
c7cb455714efcf937bbb089c1e3525cf3d7c07a4
refs/heads/master
2020-05-25T01:36:15.873236
2019-05-30T16:02:20
2019-05-30T16:02:20
187,559,980
2
0
null
null
null
null
UTF-8
C++
false
false
4,348
h
tile.h
#ifndef TERRAIN_H // include guard #define TERRAIN_H #include "FastNoise.h" #include <curses.h> #include <vector> #include <time.h> #include "settings.h" #include "resource.h" #include <string> /* used to use the same noise generator to get different values at the "same" spot */ #define NOISE_GEN_OFFSET 9000 using namespace std; class TileManager; class Tile; class TerrainTile; class PlainsTile; class BarrenTile; class BuildingTile; enum BuildingType {BT_None = 0, BT_LumberMill = 1, BT_Farm = 2, BT_Road = 4, BT_Keep = 8, BT_Bridge = 16, BT_House = 32}; inline BuildingType operator|(BuildingType A, BuildingType B){ return static_cast<BuildingType>(static_cast<int>(A) | static_cast<int>(B)); } // Abstract class for tiles class Tile { public: Tile(); virtual chtype render(); void setCharacter(chtype target); virtual string getToolText(); void setText(string target); virtual void step(); virtual double getHeight() const; virtual void setHeight(double target); virtual ~Tile(); int getX() const; int getY() const; void setX(int x); void setY(int y); protected: double height; chtype character; string description; int y_coord = 0; int x_coord = 0; }; //////////////////////////////////////////////////////// class TerrainTile: public Tile { public: TerrainTile(int y, int x); int getUsability(); bool hasBuilding(); void removeBuilding(); BuildingType getAcceptedBuildings(); chtype render(); int isRoute(); string getToolText(); virtual void step(); void setBuilding(BuildingTile * tile); protected: int usability = 0; BuildingType acceptedBuildings; BuildingTile * building = nullptr; }; class BuildingTile: public Tile { public: BuildingTile(int y, int x); chtype render(); virtual void step(); virtual int isRoute(); virtual bool canAfford(); virtual void subtractCosts(); protected: int buildTime = 0; int turnsToBuild =0; int woodCost = 0; int familyCost = 0; }; //////////////////////////////////////////////////////// class BarrenTile: public TerrainTile { public: BarrenTile(int y, int x); }; class PlainsTile: public TerrainTile { public: PlainsTile(int y, int x); }; class ForestTile: public TerrainTile { public: ForestTile(int y, int x); }; class RiverTile: public TerrainTile { public: RiverTile(int y, int x); }; //////////////////////////////////////////// class LumberMill: public BuildingTile { public: LumberMill(int y, int x); ~LumberMill(); int calculateProduction(int acceptedUsage); string getToolText() ; virtual void step(); void setProduction(int target); private: int production; }; class Farm: public BuildingTile { public: Farm(int y, int x); ~Farm(); int calculateProduction(int acceptedUsage); string getToolText() ; virtual void step(); void setProduction(int target); private: int production; }; class Road: public BuildingTile { public: Road(int y, int x); int isRoute(); }; class Bridge: public BuildingTile { public: Bridge(int y, int x); int isRoute(); }; class Keep: public BuildingTile { public: Keep(int y, int x); string getToolText() ; void step(); int isRoute(); }; class House: public BuildingTile { public: House(int y, int x); ~House(); void step(); private: }; //////////////////////////////////////////////// class TileManager { public: TileManager(); void stepAll(); void dumpRenders(vector<vector<chtype> > &storage, int y_offset, int x_offset); void createRivers(int chunkSize); void fillRiver(int y, int x); bool static pathToKeep(int y, int x); bool static pathToKeepHelper(vector<vector<bool> > &visited, int y, int x); string getToolText(int y, int x); static void createBuilding(BuildingType bt, int y, int x); static void removeBuilding(int y, int x); static bool canRemoveBuilding(int y, int x); static Keep * keep; static vector<vector<TerrainTile* > > tileVector; private: FastNoise noiseGen; double baseRiverProb = 3; }; #endif
87a04babfab68d6519dce6729d54e0d12dd4e9ca
31a00f317d9d3fdb80ee70256ab00191652d166f
/BuyuSources/ServerCore/SourceCode/GameServer/FishLogic/FishScene/FishMap.cpp
8ac127be8e4e14ca5eb792c85957833370c20aab
[]
no_license
guojia2017/Fish
17aa7438004197a797f3ff95253540ab2896f1c4
1bc98d96fb1f1685e041ee4a4b76de2f9c0331a3
refs/heads/master
2021-01-19T09:48:34.011324
2017-04-11T03:42:03
2017-04-11T03:42:03
87,787,390
4
4
null
null
null
null
GB18030
C++
false
false
14,058
cpp
FishMap.cpp
#include "stdafx.h" #include "FishMap.h" #include "Crc32.h" #include "tinyxml2.h" #include "Random.h" #include <algorithm> #include "FishResManager.h" FISHMAP FishMap::ms_AllMapList; #include <vector> #include <string> using namespace tinyxml2; #define LAST_COUNT 5 struct FindXMLData { wstring fileName; wstring path; }; typedef vector<FindXMLData> StrMapList; bool IsEqualStr(const char *pc, const char *pc2, bool ignor) { if (ignor) return _stricmp(pc, pc2) == 0; else return strcmp(pc, pc2) == 0; } void FindFile(wstring &dir, StrMapList &fileList) { wstring root = dir; if (*root.rbegin() != L'\\' && *root.rbegin() != L'/') root += L"/"; wstring fidstr = root + L"*.*"; WIN32_FIND_DATA fd; ZeroMemory(&fd, sizeof(WIN32_FIND_DATA)); HANDLE hFile = FindFirstFile(fidstr.c_str(), &fd); while (hFile != INVALID_HANDLE_VALUE) { if (fd.cFileName[0] == L'.') { } else if(fd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) { wstring subdir = root + fd.cFileName; FindFile(subdir, fileList); } else { wstring file = fd.cFileName; UINT size = file.size(); if (file.c_str()[size - 4] == L'.' && ::towlower(file.c_str()[size - 3]) == L'x' && ::towlower(file.c_str()[size - 2]) == L'm' && ::towlower(file.c_str()[size - 1]) == L'l') { FindXMLData dl; dl.path = root + file; dl.fileName = file.erase(file.size() - 4, 4); fileList.push_back(dl); } } if (!FindNextFile(hFile, &fd)) break; } } FishMap::FishMap() { m_pMap = NULL; } FishMap::~FishMap() { m_pMap = NULL; ReleaseMap(); } bool SortPackageData(const FishPackageData &f1, const FishPackageData &f2) { if (f1.StartSeconds < f2.StartSeconds) return true; if (f1.StartSeconds == f2.StartSeconds) return f1.EndSeconds < f2.EndSeconds; return false; } bool LoadRandFlow(XMLElement *pFlow, FishMapData *pFishMapData, wstring &file) { XMLElement *pEle = pFlow->FirstChildElement(); while (pEle) { if (pEle->FirstChild() == NULL) { InnerFishLog(L"配置文件未包含FLow属性:%s", file.c_str()); return false; } int idx = atoi(pEle->FirstChild()->Value()); pFishMapData->FLowList.push_back(ConvertIntToWORD(idx)); pEle = pEle->NextSiblingElement(); } return true; } bool LoadFixedFlow(XMLElement *pFixedFlow, FishMapData *pFishMapData, wstring &file) { XMLElement *pOrder = pFixedFlow->FirstChildElement(); XMLElement *pFlow = pFixedFlow->LastChildElement(); if (pOrder == NULL || pFlow == NULL) { InnerFishLog(L"配置文件缺少固定或顺序节点:%s", file.c_str()); return false; } if (IsEqualStr(pOrder->Name(), "flows", true)) { XMLElement *temp = pOrder; pOrder = pFlow; pFlow = pOrder; } XMLElement *pEle = pOrder->FirstChildElement(); while (pEle) { int idx = atoi(pEle->FirstChild()->Value()); pFishMapData->FlowOrderData.OrderIndex.push_back(ConvertIntToWORD(idx)); pEle = pEle->NextSiblingElement(); } pEle = pFlow->FirstChildElement(); while (pEle) { int idx = atoi(pEle->FirstChild()->Value()); pFishMapData->FlowOrderData.FlowIndex.push_back(ConvertIntToWORD(idx)); pEle = pEle->NextSiblingElement(); } return true; } bool LoadPackage(XMLElement *pPackage, FishMapData *pFishMapData, wstring &file) { XMLElement *pEle = pPackage->FirstChildElement(); const char *pcAtt; while (pEle) { FishPackageData pd; pcAtt = pEle->Attribute("StartSeconds"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含StartSeconds属性:%s", file.c_str()); return false; } pd.StartSeconds = (float)atoi(pcAtt); pcAtt = pEle->Attribute("EndSeconds"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含EndSeconds属性:%s", file.c_str()); return false; } pd.EndSeconds = (float)atoi(pcAtt); pcAtt = pEle->Attribute("IntervalSeconds"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含IntervalSeconds属性:%s", file.c_str()); return false; } pd.IntervalSeconds = (float)atoi(pcAtt); pcAtt = pEle->Attribute("Chance"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含Chance属性:%s", file.c_str()); return false; } pd.Chance = ConvertIntToWORD(atoi(pcAtt)); pcAtt = pEle->Attribute("MaxCount"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含MaxCount属性:%s", file.c_str()); return false; } pd.MaxCount = ConvertIntToWORD(atoi(pcAtt)); pcAtt = pEle->Attribute("PackageType"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含PackageType属性:%s", file.c_str()); return false; } XMLElement *pc = pEle->FirstChildElement(); while (pc) { pd.FishGroup.push_back(ConvertIntToBYTE(atoi(pc->FirstChild()->Value()))); pc = pc->NextSiblingElement(); } pd.PackageType = ConvertIntToBYTE(atoi(pcAtt)); pFishMapData->PackageList.push_back(pd); pEle = pEle->NextSiblingElement(); } return true; } bool FishMap::LoadAllMap(const WCHAR *pcDir) { wstring dir = pcDir; StrMapList fileList; FindFile(dir, fileList); tinyxml2::XMLDocument doc; char path[MAX_PATH]; for (UINT i = 0; i < fileList.size(); ++i) { wstring &file = fileList[i].path; int namecount = fileList[i].fileName.size(); if (namecount > MAX_MAP_NAME) { InnerFishLog(L"地图名称长度超过指定数量(%d):%s", fileList[i].fileName.size(), file.c_str()); return false; } ::WideCharToMultiByte(CP_ACP, 0, file.c_str(), -1, path, sizeof(path), NULL, 0); if (doc.LoadFile(path) != XML_NO_ERROR) { InnerFishLog(L"加载地图文件出错:%s", file.c_str()); return false; } XMLElement *pFirstElement = doc.FirstChildElement(); if (IsEqualStr(pFirstElement->Name(), "map", true) == false) { InnerFishLog(L"配置文件不正确:%s", file.c_str()); return false; } FishMapData *pFishMapData = new FishMapData; const char *pcAtt = pFirstElement->Attribute("BackgroundImage"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含BackgroundImage属性:%s", file.c_str()); return false; } pFishMapData->BackgroudImage = ConvertIntToBYTE(atoi(pcAtt)); pcAtt = pFirstElement->Attribute("Repeat"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含Repeat属性:%s", file.c_str()); return false; } pFishMapData->Repeat = IsEqualStr(pcAtt, "true", true); pcAtt = pFirstElement->Attribute("Name"); if (pcAtt == NULL) { InnerFishLog(L"配置文件未包含Name属性:%s", file.c_str()); return false; } ::MultiByteToWideChar(CP_UTF8, 0, pcAtt, -1, pFishMapData->MapName, MAX_MAP_NAME); XMLElement *pEle = pFirstElement->FirstChildElement(); bool bHasFixedFlow = false; bool bHasPackage = false; bool bHasRandFlow = false; while (pEle) { if (IsEqualStr(pEle->Name(), "packages", true)) { if (!LoadPackage(pEle, pFishMapData, file)) return false; bHasPackage = true; } else if (IsEqualStr(pEle->Name(), "random_flows", true)) { if (!LoadRandFlow(pEle, pFishMapData, file)) return false; bHasRandFlow = true; } else if (IsEqualStr(pEle->Name(), "fixed_flows", true)) { if (!LoadFixedFlow(pEle, pFishMapData, file)) return false; bHasFixedFlow = true; } pEle = pEle->NextSiblingElement(); } if (!bHasFixedFlow || !bHasPackage || !bHasRandFlow) { InnerFishLog(L"配置文件不正确,缺少固定、随机或者红包节点:%s", file.c_str()); return false; } if (pFishMapData->FLowList.size() == 0) { InnerFishLog(L"配置文件流程数量为0:%s", file.c_str()); return false; } UINT crc = AECrc32(fileList[i].fileName.c_str(), fileList[i].fileName.size() * sizeof(WCHAR), 0); if (ms_AllMapList.find(crc) != ms_AllMapList.end()) { InnerFishLog(L"存在相同的地图名称:%s", file.c_str()); return false; } //验证 for (UINT j = 0; j < pFishMapData->FlowOrderData.FlowIndex.size(); ++j) { int idx = pFishMapData->FlowOrderData.FlowIndex[j]; FlowData *pFlow = FishResManager::Inst()->GetFlow(idx); if (pFlow == NULL) { InnerFishLog(L"地图中的固定流程为NUMM:%s :%d", file.c_str(), j); return false; } } for (UINT j = 0; j < pFishMapData->FlowOrderData.OrderIndex.size(); ++j) { USHORT idx = pFishMapData->FlowOrderData.OrderIndex[j]; if (idx < 0 || idx > pFishMapData->FLowList.size()) { InnerFishLog(L"地图中的固定流程顺序不正确:%s :%d", file.c_str(), idx); return false; } } if (pFishMapData->FlowOrderData.OrderIndex.size() > 0 && pFishMapData->FlowOrderData.FlowIndex.size() == 0) { InnerFishLog(L"地图中的固定流程为0,但有顺序设置:%s :%d", file.c_str(), pFishMapData->FlowOrderData.OrderIndex.size()); return false; } ::sort(pFishMapData->FlowOrderData.OrderIndex.begin(), pFishMapData->FlowOrderData.OrderIndex.end()); ::sort(pFishMapData->PackageList.begin(), pFishMapData->PackageList.end(), SortPackageData); for (UINT j = 1; j < pFishMapData->PackageList.size(); ++j) { if (pFishMapData->PackageList[j].StartSeconds < pFishMapData->PackageList[j - 1].EndSeconds) { InnerFishLog(L"红包发射时间重叠:%s", file.c_str()); return false; } if (pFishMapData->PackageList[j].EndSeconds < pFishMapData->PackageList[j].StartSeconds) { InnerFishLog(L"红包发射结束时间小于起始时间:%s", file.c_str()); return false; } } float maxtime = 0; for (UINT j = 0; j < pFishMapData->FLowList.size(); ++j) { int idx = pFishMapData->FLowList[j]; FlowData *pFlow = FishResManager::Inst()->GetFlow(idx); if (pFlow == NULL) { InnerFishLog(L"地图中的流程为NUMM:%s :%d", file.c_str(), j); return false; } maxtime += pFlow->GetMaxTimeSeconds(); } pFishMapData->MaxTime = maxtime; wcscpy_s(pFishMapData->FileName, MAX_MAP_NAME, fileList[i].fileName.c_str()); ms_AllMapList[crc] = pFishMapData; doc.Clear(); } InnerFishLog(L"加载地图:%d", ms_AllMapList.size()); return true; } void FishMap::ReleaseAllMap() { for (FISHMAP::iterator it = ms_AllMapList.begin(); it != ms_AllMapList.end(); ++it) { delete(it->second); } ms_AllMapList.clear(); } bool FishMap::LoadMap(const WCHAR *mapName) { UINT crc = AECrc32(mapName, wcslen(mapName) * sizeof(WCHAR), 0); FISHMAP::iterator it = ms_AllMapList.find(crc); if (it == ms_AllMapList.end()) { InnerFishLog(L"场景加载地图失败:%s", mapName); return false; } m_Interval = FLT_MAX; m_pMap = it->second; ReleaseMap(); for (UINT i = 0; i < m_pMap->FLowList.size(); ++i) { FlowIndexData *pfd = new FlowIndexData; pfd->FlowIdx = m_pMap->FLowList[i]; pfd->LastIdx = false; m_FlowData.push_back(pfd); } Reset(); return true; } void FishMap::Reset() { m_LastPackageGroupID = 255; m_nIndex = 0; m_Time = 0; //m_Interval = FLT_MAX; m_FlowList.clear(); m_PackageCount.clear(); FlowDataList flowList; FlowDataList lastFlowList; for (UINT i = 0; i < m_pMap->PackageList.size(); ++i) { m_PackageCount.push_back(m_pMap->PackageList[i].MaxCount); } for (UINT i = 0; i < m_FlowData.size(); ++i) { if (m_FlowData[i]->LastIdx) lastFlowList.push_back(m_FlowData[i]); else flowList.push_back(m_FlowData[i]); } while(flowList.size() > 0) { UINT idx = RandRange(0, flowList.size()); m_FlowList.push_back(flowList[idx]); flowList[idx] = flowList.back(); flowList.pop_back(); } int count = (int)m_FlowList.size(); for (UINT i = 0; i < lastFlowList.size(); ++i) { UINT idx = RandRange(0, count); m_FlowList.insert(m_FlowList.begin() + idx, lastFlowList[i]); lastFlowList[i]->LastIdx = false; } UINT lastCount = min(LAST_COUNT, m_FlowList.size() / 2); UINT startIdx = m_FlowList.size() - lastCount; for (UINT i = startIdx; i < m_FlowList.size(); ++i) m_FlowList[i]->LastIdx = true; } void FishMap::ReleaseMap() { for (UINT i = 0; i < m_FlowData.size(); ++i) { delete(m_FlowData[i]); } m_FlowData.clear(); m_FlowList.clear(); } USHORT FishMap::GetFlowIndex(bool &bFixedGroup) { bFixedGroup = false; int idx = -1; for (UINT i = 0; i < m_pMap->FlowOrderData.OrderIndex.size(); ++i) { int orderidx = m_pMap->FlowOrderData.OrderIndex[i]; if (orderidx == m_nIndex) { //发射固定的流程 idx = RandRange(0, m_pMap->FlowOrderData.FlowIndex.size()); idx = m_pMap->FlowOrderData.FlowIndex[idx]; bFixedGroup = true; } else if (orderidx > m_nIndex) break; } if (idx == -1) { idx = m_FlowList.back()->FlowIdx; m_FlowList.pop_back(); } ++m_nIndex; return (USHORT)idx; } byte FishMap::GetPackageGroupID(FishPackageData &fpd) { //保证不重复两次出现相同的路径 if (fpd.FishGroup.size() == 1) return fpd.FishGroup[0]; byte groupid = ConvertDWORDToBYTE(RandRange(0, fpd.FishGroup.size())); while (groupid == m_LastPackageGroupID) groupid = ConvertDWORDToBYTE(RandRange(0, fpd.FishGroup.size())); m_LastPackageGroupID = groupid; return groupid; } //返回-1表示不出红包 UINT FishMap::Update(float deltaTime) { if (m_pMap == NULL) return 0xffffffff; UINT ret = 0xffffffff; //时段生成的方式 for (UINT i = 0; i < m_pMap->PackageList.size(); ++i) { FishPackageData &fpd = m_pMap->PackageList[i]; USHORT &maxCount = m_PackageCount[i]; if (m_Time <= fpd.StartSeconds && m_Time + deltaTime > fpd.EndSeconds) { if (maxCount <= 0 || m_Interval < fpd.IntervalSeconds || fpd.FishGroup.size() == 0) continue; --maxCount; int rnd = RandRange(0, 100); if (rnd < fpd.Chance) { //出红包 m_Interval = 0; ret = fpd.PackageType; ret = (ret << 16) | GetPackageGroupID(fpd); break; } } else if (m_Time >= fpd.StartSeconds) { if (maxCount <= 0 || m_Interval < fpd.IntervalSeconds || m_Time > fpd.EndSeconds || fpd.FishGroup.size() == 0) continue; int rnd = RandRange(0, 100); --maxCount; if (rnd < fpd.Chance) { //生成鱼群 m_Interval = 0; ret = fpd.PackageType; ret = (ret << 16) | GetPackageGroupID(fpd); break; } } else break; } m_Time += deltaTime; if (ret == -1) m_Interval += deltaTime; return ret; }
ec578503da31e2cf2b5b19e015b65a7319b92544
2dbfc4dd5e03abae36c170484299654f79f7f580
/Surrounded Regions.cpp
e349c7a9054b4d16e8c749df97e830bc0dddc952
[]
no_license
MarcosFelipeBC/LeetCode-Solutions
aab03f9a02ce7983ac4b0538c87d2407bdddfce9
67602af597997fe11fb5afbf6fc7ec5f8f8cd2aa
refs/heads/master
2020-07-07T04:46:56.410148
2020-04-18T17:43:39
2020-04-18T17:43:39
203,253,746
1
1
null
2020-04-18T17:51:14
2019-08-19T21:36:42
C++
UTF-8
C++
false
false
1,412
cpp
Surrounded Regions.cpp
//https://leetcode.com/problems/surrounded-regions/ class Solution { public: vector < vector < bool > > vist; int n, m, dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; bool check(int x, int y){ return (x >= 0 && x < n && y >= 0 && y < m && !vist[x][y]); } void propagate(vector < vector < char > >&mat, int x, int y){ vist[x][y] = true; for (int i=0; i<4; i++){ int a = x + dx[i], b = y + dy[i]; if(check(a, b) && mat[x][y] == 'O'){ propagate(mat, a, b); } } } void solve(vector<vector<char>>& board) { if(board.size() == 0) return ; n = board.size(); m = board[0].size(); vist.assign(n, vector < bool >(m, false)); for (int i=0; i<n; i++) for (int j=0; j<m; j++) vist[i][j] = false; for (int i=0; i<m; i++){ if(!vist[0][i]) propagate(board, 0, i); if(!vist[n-1][i]) propagate(board, n-1, i); } for (int i=0; i<n; i++){ if(!vist[i][0]) propagate(board, i, 0); if(!vist[i][m-1]) propagate(board, i, m-1); } for (int i=0; i<n; i++){ for (int j=0; j<m; j++){ if(!vist[i][j]) board[i][j] = 'X'; } } } };
ea06bb3e32510fe8ff443701bb491192fc8bf25f
0d4d9fbd57e4ca666bd8eb7923aba08d5f669121
/src/downToZero2.cpp
c356c33fcab742a602ec7fafde399f0743582cf6
[]
no_license
TMBear/prep
e8c0aac78aa75dfb1da13cb67953d03406903d7d
b4690fe80558f03d370af6b8c7c8c43b6320beb2
refs/heads/master
2020-07-31T15:15:54.778274
2020-03-03T03:15:25
2020-03-03T03:15:25
210,650,033
0
0
null
null
null
null
UTF-8
C++
false
false
1,670
cpp
downToZero2.cpp
////////////////////////////////////////////////////////////////////////////////////////////////////// // https://www.hackerrank.com/challenges/down-to-zero-ii/problem // #include <iostream> #include <vector> class DownZero { const int c_maxVal; public: DownZero(const std::size_t maxVal); void initialize(); std::size_t getSteps(std::size_t val); private: void tryNewStep(const std::size_t indx, const std::size_t steps); void tryMul(const std::size_t i); void tryAdd(const std::size_t i); private: std::vector<std::size_t> m_steps; }; DownZero::DownZero(const std::size_t maxVal) : c_maxVal(maxVal) {} void DownZero::initialize() { m_steps.resize(c_maxVal); std::fill(m_steps.begin(), m_steps.end(), c_maxVal); m_steps[0] = 0; for (std::size_t i = 0; i < c_maxVal; ++i) { tryMul(i); tryAdd(i); } } void DownZero::tryAdd(std::size_t i) { tryNewStep(i + 1, m_steps[i] + 1); } void DownZero::tryMul(std::size_t i) { if (i == 0) return; const auto nextStep = m_steps[i] + 1; const auto maxMul = std::min(i, c_maxVal / i); for (std::size_t mul = 1; mul <= maxMul; mul++) { tryNewStep(mul * i, nextStep); } } void DownZero::tryNewStep(const std::size_t indx, const std::size_t steps){ if (indx >= m_steps.size()) return; m_steps[indx] = std::min(m_steps[indx], steps); } std::size_t DownZero::getSteps(std::size_t val) { if (val >= m_steps.size()) return std::numeric_limits<std::size_t>::max(); return m_steps[val]; } void downToZero2() { const std::size_t maxVal = 1000001; DownZero dz(maxVal); dz.initialize(); std::cout << dz.getSteps(94) << std::endl; }
399d1650a1c0cc1df0858867ad5990a65c672ba8
0deeaaed18f11b60908135964758dd715434e92c
/ctp2_code/ui/slic_debug/sourcelist.cpp
7486b0c7e2e270c797d79b71dd6920347fc729a5
[]
no_license
civctp2/civctp2
0a8deaf7f525cfff2ec5bab99f015b0ba52cf11b
67532c1338ad8c0f8e943a6e04633782543fa06a
refs/heads/master
2023-09-04T12:44:38.436220
2020-09-27T15:05:43
2023-03-02T02:31:57
152,506,474
66
22
null
2023-09-03T21:20:51
2018-10-11T00:20:01
C++
ISO-8859-3
C++
false
false
13,350
cpp
sourcelist.cpp
//---------------------------------------------------------------------------- // // Project : Call To Power 2 // File type : C++ source // Description : Slic source list // Id : $Id$ // //---------------------------------------------------------------------------- // // Disclaimer // // THIS FILE IS NOT GENERATED OR SUPPORTED BY ACTIVISION. // // This material has been developed at apolyton.net by the Apolyton CtP2 // Source Code Project. Contact the authors at ctp2source@apolyton.net. // //---------------------------------------------------------------------------- // // Compiler flags // // - None // //---------------------------------------------------------------------------- // // Modifications from the original Activision code: // // - Initialized local variables. (Sep 9th 2005 Martin Gühmann) // //---------------------------------------------------------------------------- #include "c3.h" #ifdef CTP2_ENABLE_SLICDEBUG #include "aui.h" #include "aui_uniqueid.h" #include "c3ui.h" #include "aui_ldl.h" #include "aui_uniqueid.h" #include "aui_static.h" #include "aui_hypertextbox.h" #include "c3_static.h" #include "thermometer.h" #include "textbutton.h" #include "c3_button.h" #include "c3textfield.h" #include "c3listbox.h" #include "c3_listbox.h" #include "aui_listbox.h" #include "c3window.h" #include "c3windows.h" #include "c3_popupwindow.h" #include "c3_utilitydialogbox.h" #include "keypress.h" #include "sourcelist.h" #include "SlicEngine.h" #include "SlicSegment.h" #include "SlicConditional.h" #include "pixelutils.h" #include "colorset.h" // g_colorSet extern C3UI *g_c3ui; SourceList *g_sourceList = NULL; class SourceListItemContinueAction : public aui_Action { public: SourceListItemContinueAction(SourceListItem *item) : aui_Action (), m_item (item) { ; }; virtual ~SourceListItemContinueAction(void) { ; }; virtual void Execute ( aui_Control * control, uint32 action, uint32 data ) { if (m_item) { m_item->Continue(); } } private: SourceListItem * m_item; }; void sourcelist_Callback(sint32 arg) { } void sourcelist_Display(SlicSegment *segment) { if(!g_sourceList) { g_sourceList = new SourceList(sourcelist_Callback); } g_sourceList->DisplayWindow(segment); } void sourcelist_Remove() { if(g_sourceList) { g_sourceList->RemoveWindow(); } } void sourcelist_RegisterBreak(SlicSegment *segment, sint32 offset) { sourcelist_Display(segment); g_sourceList->ShowBreak(offset); } SourceList::SourceList(SourceListCallback *callback, MBCHAR *ldlBlock) { AUI_ERRCODE errcode = AUI_ERRCODE_OK; MBCHAR windowBlock[ k_AUI_LDL_MAXBLOCK + 1 ]; m_continue = NULL; m_list = NULL; m_exit = NULL; if (ldlBlock) strcpy(windowBlock,ldlBlock); else strcpy(windowBlock,"SourceListPopup"); { m_window = new c3_PopupWindow( &errcode, aui_UniqueId(), windowBlock, 16, AUI_WINDOW_TYPE_FLOATING, false); Assert( AUI_NEWOK(m_window, errcode) ); if ( !AUI_NEWOK(m_window, errcode) ) return; m_window->Resize(m_window->Width(),m_window->Height()); m_window->GrabRegion()->Resize(m_window->Width(),m_window->Height()); m_window->SetStronglyModal(FALSE); m_window->SetDraggable(TRUE); } m_callback = callback; Initialize( windowBlock ); } SourceList::~SourceList(void) { if (g_c3ui && m_window) { g_c3ui->RemoveWindow(m_window->Id()); } delete m_continue; delete m_list; delete m_window; delete m_exit; delete m_step; delete m_stepInto; delete m_status; // m_callback : reference only // m_segment : reference only } void SourceListActionCallback(aui_Control *control, uint32 action, uint32 data, void *cookie) { if((action != (uint32)AUI_LISTBOX_ACTION_SELECT) && (action != (uint32)AUI_LISTBOX_ACTION_RMOUSESELECT) && (action != (uint32)AUI_LISTBOX_ACTION_DOUBLECLICKSELECT)) return; SourceList *list = (SourceList *)cookie; SourceListItem *item = (SourceListItem *)list->GetList()->GetSelectedItem(); if(action == AUI_LISTBOX_ACTION_DOUBLECLICKSELECT) { } if(!item) return; if(action == AUI_LISTBOX_ACTION_RMOUSESELECT) { return; } return; } void SourceListButtonCallback(aui_Control *control, uint32 action, uint32 data, void *cookie) { if(action == AUI_BUTTON_ACTION_EXECUTE) { if(control == g_sourceList->m_continue) { g_sourceList->Continue(); } if(control == g_sourceList->m_exit) { sourcelist_Remove(); } if(control == g_sourceList->m_step) { g_sourceList->StepInto(); } if(control == g_sourceList->m_stepInto) { g_sourceList->StepInto(); } } } sint32 SourceList::Initialize(MBCHAR *windowBlock) { AUI_ERRCODE errcode = AUI_ERRCODE_OK; MBCHAR controlBlock[ k_AUI_LDL_MAXBLOCK + 1 ]; sprintf( controlBlock, "%s.%s", windowBlock, "SourceList" ); m_list = new c3_ListBox(&errcode, aui_UniqueId(), controlBlock, SourceListActionCallback, this); m_list->SetAbsorbancy(FALSE); Assert( AUI_NEWOK(m_list, errcode) ); if ( !AUI_NEWOK(m_list, errcode) ) return -1; sprintf(controlBlock, "%s.%s", windowBlock, "ContinueButton"); m_continue = new c3_Button(&errcode, aui_UniqueId(), controlBlock, SourceListButtonCallback, this); Assert(AUI_NEWOK(m_continue, errcode)); if( !AUI_NEWOK(m_continue, errcode)) return -1; sprintf(controlBlock, "%s.%s", windowBlock, "ExitButton"); m_exit = new c3_Button(&errcode, aui_UniqueId(), controlBlock, SourceListButtonCallback, this); Assert(AUI_NEWOK(m_exit, errcode)); if( !AUI_NEWOK(m_exit, errcode)) return -1; sprintf(controlBlock, "%s.%s", windowBlock, "StepButton"); m_step = new c3_Button(&errcode, aui_UniqueId(), controlBlock, SourceListButtonCallback, this); Assert(AUI_NEWOK(m_step, errcode)); if( !AUI_NEWOK(m_step, errcode)) return -1; sprintf(controlBlock, "%s.%s", windowBlock, "StepIntoButton"); m_stepInto = new c3_Button(&errcode, aui_UniqueId(), controlBlock, SourceListButtonCallback, this); Assert(AUI_NEWOK(m_stepInto, errcode)); if( !AUI_NEWOK(m_stepInto, errcode)) return -1; sprintf(controlBlock, "%s.%s", windowBlock, "Status"); m_status = new c3_Static(&errcode, aui_UniqueId(), controlBlock); Assert(AUI_NEWOK(m_status, errcode)); if(!AUI_NEWOK(m_status, errcode)) return -1; errcode = aui_Ldl::SetupHeirarchyFromRoot( windowBlock ); Assert( AUI_SUCCESS(errcode) ); return 0; } void SourceList::Cleanup(void) { if (g_c3ui && m_window) { g_c3ui->RemoveWindow(m_window->Id()); } #define mycleanup(mypointer) delete mypointer; mypointer = NULL; mycleanup(m_continue); mycleanup(m_list); mycleanup(m_window); #undef mycleanup m_callback = NULL; } void SourceList::DisplayWindow(SlicSegment *segment) { AUI_ERRCODE auiErr; m_segment = segment; UpdateData(); auiErr = g_c3ui->AddWindow(m_window); Assert(auiErr == AUI_ERRCODE_OK); keypress_RegisterHandler(this); } void SourceList::RemoveWindow(void) { AUI_ERRCODE auiErr; auiErr = g_c3ui->RemoveWindow(m_window->Id()); Assert(auiErr == AUI_ERRCODE_OK); keypress_RemoveHandler(this); } void SourceList::kh_Close() { RemoveWindow(); } sint32 SourceList::UpdateData(void) { MBCHAR ldlBlock[k_AUI_LDL_MAXBLOCK + 1]; AUI_ERRCODE retval; strcpy(ldlBlock, "SourceListItem"); m_list->Clear(); sint32 i; sint32 firstLineNum, firstLineOffset, lastLineNum; bool res = m_segment->GetSourceLines(firstLineNum, firstLineOffset, lastLineNum); Assert(res); if(!res) return 1; FILE *f = fopen(m_segment->GetFilename(), "r"); Assert(f); if(!f) return 1; fseek(f, firstLineOffset, SEEK_SET); MBCHAR line[k_MAX_SOURCE_LINE]; SourceListItem *item; for(i = firstLineNum; i <= lastLineNum; i++) { fgets(line, 1024, f); item = new SourceListItem(&retval, i - firstLineNum, m_segment, line, i, ldlBlock); m_list->AddItem((c3_ListItem *)item); } fclose(f); return 0; } void SourceList::ShowBreak(sint32 offset) { sint32 lineNumber; lineNumber = m_segment->FindLineNumber(offset); sint32 i; char statusBuf[1024]; sprintf(statusBuf, "Break at %s:%d", m_segment->GetName(), lineNumber); for(i = 0; i < m_list->NumItems(); i++) { SourceListItem *item = (SourceListItem *)m_list->GetItemByIndex(i); if(item->m_lineNumber == lineNumber) { item->ShowBreak(); SlicConditional *cond = item->GetSegment()->GetConditional(lineNumber); if(cond) { strcat(statusBuf, " when "); strcat(statusBuf, cond->GetExpression()); } break; } } m_status->SetText(statusBuf); } void SourceList::Continue() { sint32 i; m_status->SetText("--"); for(i = 0; i < m_list->NumItems(); i++) { SourceListItem *item = (SourceListItem *)m_list->GetItemByIndex(i); if(item->m_activeBreak) { g_c3ui->AddAction(new SourceListItemContinueAction(item)); return; } } if(g_slicEngine->AtBreak()) { g_slicEngine->Continue(); } } void SourceList::StepInto() { g_slicEngine->RequestBreak(); Continue(); } SourceListItem::SourceListItem(AUI_ERRCODE *retval, sint32 index, SlicSegment *segment, MBCHAR *line, sint32 lineNumber, MBCHAR *ldlBlock) : aui_ImageBase(ldlBlock), aui_TextBase(ldlBlock, (MBCHAR *)NULL), c3_ListItem(retval, ldlBlock) { m_index = index; m_segment = segment; strncpy(m_line, line, k_MAX_SOURCE_LINE); m_lineNumber = lineNumber; m_break = m_segment->LineHasBreak(m_lineNumber, m_conditional); m_activeBreak = false; Assert(AUI_SUCCESS(*retval)); if(!AUI_SUCCESS(*retval)) return; *retval = InitCommonLdl(segment, ldlBlock); Assert(AUI_SUCCESS(*retval)); if(!AUI_SUCCESS(*retval)) return; } void SourceBreakItemCallback(aui_Control *control, uint32 action, uint32 data, void *cookie) { if(action == k_C3_STATIC_ACTION_LMOUSE) { SourceListItem *item = (SourceListItem *)cookie; item->ToggleBreak(); } else if(action == k_C3_STATIC_ACTION_RMOUSE) { SourceListItem *item = (SourceListItem *)cookie; item->EditConditional(); } } AUI_ERRCODE SourceListItem::InitCommonLdl(SlicSegment *segment, MBCHAR *ldlBlock) { MBCHAR block[ k_AUI_LDL_MAXBLOCK + 1 ]; AUI_ERRCODE retval; c3_Static *breakItem; c3_Static *textItem; sprintf(block, "%s.%s", ldlBlock, "Break"); breakItem = new c3_Static(&retval, aui_UniqueId(), block); breakItem->SetActionFuncAndCookie(SourceBreakItemCallback, this); AddChild(breakItem); sprintf(block, "%s.%s", ldlBlock, "Line"); textItem = new c3_Static(&retval, aui_UniqueId(), block); AddChild(textItem); Update(); return AUI_ERRCODE_OK; } void SourceListItem::Update(void) { c3_Static *codeItem; codeItem = (c3_Static *)GetChildByIndex(1); codeItem->SetText(m_line); m_break = m_segment->LineHasBreak(m_lineNumber, m_conditional); c3_Static *breakItem = (c3_Static *)GetChildByIndex(0); char breakChars[3]; if(!m_break) { breakChars[0] = '-'; } else { if(m_conditional) { breakChars[0] = 'C'; } else { breakChars[0] = '+'; } } if(m_activeBreak) { breakChars[1] = '>'; breakChars[2] = 0; breakItem->SetText(breakChars); codeItem->SetTextColor(g_colorSet->GetColorRef(COLOR_RED)); } else { breakChars[1] = 0; breakItem->SetText(breakChars); codeItem->SetTextColor(g_colorSet->GetColorRef(COLOR_BLACK)); } } sint32 SourceListItem::Compare(c3_ListItem *item2, uint32 column) { return 0; } void SourceListItem::Open() { return; } void SourceListItem::Continue() { m_activeBreak = false; Update(); g_slicEngine->Continue(); } void SourceListItem::ToggleBreak() { m_break = !m_break; if(m_break) { m_segment->SetBreak(m_lineNumber, true); } else { m_segment->SetBreak(m_lineNumber, false); } Update(); } void SourceListItem::SetBreak() { m_break = true; m_segment->SetBreak(m_lineNumber, true); Update(); } void SourceListItem::ClearBreak() { m_break = false; m_segment->SetBreak(m_lineNumber, false); Update(); } void SourceListItem::ShowBreak() { m_activeBreak = TRUE; Update(); } static c3_UtilityTextFieldPopup *s_conditionalPopup = NULL; class KillConditionalPopupAction : public aui_Action { public: virtual void Execute(aui_Control* control, uint32 action, uint32 data) { delete s_conditionalPopup; s_conditionalPopup = NULL; }; }; void SourceListItemConditionalCallback(MBCHAR const *text, sint32 val2, void *data) { if(!val2) return; SourceListItem *item = (SourceListItem *)data; if(!text || strlen(text) < 1) { item->GetSegment()->RemoveConditional(item->GetLineNumber()); item->ClearBreak(); return; } SlicConditional *cond = item->GetSegment()->GetConditional(item->GetLineNumber()); if (cond) { cond->SetExpression(text); } else { cond = item->GetSegment()->NewConditional(item->GetLineNumber(), text); Assert(cond); } item->SetBreak(); g_c3ui->AddAction(new KillConditionalPopupAction); } void SourceListItem::EditConditional() { SlicConditional *cond = m_segment->GetConditional(m_lineNumber); if(!s_conditionalPopup) s_conditionalPopup = new c3_UtilityTextFieldPopup(SourceListItemConditionalCallback, NULL, cond ? cond->GetExpression() : "", NULL, "SourceListConditionalPopup", this, true); s_conditionalPopup->DisplayWindow(); } #endif // CTP2_ENABLE_SLICDEBUG
fba4c2690c9d7f6581dacdf1b8aac7c6feeff3e3
bb90ad20468f9fe2039b8c16858bd8eae8bbc050
/src/endpoints/authentication/cose_auth.cpp
acd9a755d7526af45164e66226980855412d3867
[ "Apache-2.0" ]
permissive
microsoft/CCF
0997fd81a924d36d775b219720b26b4ff196b18a
2fbf87840b9e8334c141f4a9c9b25aae979b0540
refs/heads/main
2023-09-05T15:39:37.265089
2023-09-05T15:27:25
2023-09-05T15:27:25
180,112,558
687
229
Apache-2.0
2023-09-14T14:28:39
2019-04-08T09:13:04
C++
UTF-8
C++
false
false
15,487
cpp
cose_auth.cpp
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the Apache 2.0 License. #include "ccf/endpoints/authentication/cose_auth.h" #include "ccf/crypto/cose_verifier.h" #include "ccf/crypto/public_key.h" #include "ccf/http_consts.h" #include "ccf/rpc_context.h" #include "ccf/service/tables/members.h" #include "ccf/service/tables/users.h" #include "node/cose_common.h" #include <qcbor/qcbor.h> #include <qcbor/qcbor_spiffy_decode.h> #include <t_cose/t_cose_sign1_verify.h> namespace ccf { namespace cose { static constexpr auto HEADER_PARAM_MSG_TYPE = "ccf.gov.msg.type"; static constexpr auto HEADER_PARAM_MSG_PROPOSAL_ID = "ccf.gov.msg.proposal_id"; static constexpr auto HEADER_PARAM_MSG_CREATED_AT = "ccf.gov.msg.created_at"; std::pair<ccf::GovernanceProtectedHeader, Signature> extract_governance_protected_header_and_signature( const std::vector<uint8_t>& cose_sign1) { ccf::GovernanceProtectedHeader parsed; // Adapted from parse_cose_header_parameters in t_cose_parameters.c. // t_cose doesn't support custom header parameters yet. UsefulBufC msg{cose_sign1.data(), cose_sign1.size()}; QCBORError qcbor_result; QCBORDecodeContext ctx; QCBORDecode_Init(&ctx, msg, QCBOR_DECODE_MODE_NORMAL); QCBORDecode_EnterArray(&ctx, nullptr); qcbor_result = QCBORDecode_GetError(&ctx); if (qcbor_result != QCBOR_SUCCESS) { throw COSEDecodeError("Failed to parse COSE_Sign1 outer array"); } uint64_t tag = QCBORDecode_GetNthTagOfLast(&ctx, 0); if (tag != CBOR_TAG_COSE_SIGN1) { throw COSEDecodeError("COSE_Sign1 is not tagged"); } struct q_useful_buf_c protected_parameters; QCBORDecode_EnterBstrWrapped( &ctx, QCBOR_TAG_REQUIREMENT_NOT_A_TAG, &protected_parameters); QCBORDecode_EnterMap(&ctx, NULL); enum { ALG_INDEX, KID_INDEX, GOV_MSG_TYPE, GOV_MSG_PROPOSAL_ID, GOV_MSG_CREATED_AT, END_INDEX, }; QCBORItem header_items[END_INDEX + 1]; header_items[ALG_INDEX].label.int64 = headers::PARAM_ALG; header_items[ALG_INDEX].uLabelType = QCBOR_TYPE_INT64; header_items[ALG_INDEX].uDataType = QCBOR_TYPE_INT64; header_items[KID_INDEX].label.int64 = headers::PARAM_KID; header_items[KID_INDEX].uLabelType = QCBOR_TYPE_INT64; header_items[KID_INDEX].uDataType = QCBOR_TYPE_BYTE_STRING; auto gov_msg_type_label = HEADER_PARAM_MSG_TYPE; header_items[GOV_MSG_TYPE].label.string = UsefulBuf_FromSZ(gov_msg_type_label); header_items[GOV_MSG_TYPE].uLabelType = QCBOR_TYPE_TEXT_STRING; header_items[GOV_MSG_TYPE].uDataType = QCBOR_TYPE_TEXT_STRING; auto gov_msg_proposal_id = HEADER_PARAM_MSG_PROPOSAL_ID; header_items[GOV_MSG_PROPOSAL_ID].label.string = UsefulBuf_FromSZ(gov_msg_proposal_id); header_items[GOV_MSG_PROPOSAL_ID].uLabelType = QCBOR_TYPE_TEXT_STRING; header_items[GOV_MSG_PROPOSAL_ID].uDataType = QCBOR_TYPE_TEXT_STRING; auto gov_msg_proposal_created_at = HEADER_PARAM_MSG_CREATED_AT; header_items[GOV_MSG_CREATED_AT].label.string = UsefulBuf_FromSZ(gov_msg_proposal_created_at); header_items[GOV_MSG_CREATED_AT].uLabelType = QCBOR_TYPE_TEXT_STRING; // Although this is really uint, specify QCBOR_TYPE_INT64 // QCBOR_TYPE_UINT64 only matches uint values that are greater than // INT64_MAX header_items[GOV_MSG_CREATED_AT].uDataType = QCBOR_TYPE_INT64; header_items[END_INDEX].uLabelType = QCBOR_TYPE_NONE; QCBORDecode_GetItemsInMap(&ctx, header_items); qcbor_result = QCBORDecode_GetError(&ctx); if (qcbor_result != QCBOR_SUCCESS) { throw COSEDecodeError( fmt::format("Failed to decode protected header: {}", qcbor_result)); } if (header_items[ALG_INDEX].uDataType == QCBOR_TYPE_NONE) { throw COSEDecodeError("Missing algorithm in protected header"); } parsed.alg = header_items[ALG_INDEX].val.int64; if (header_items[KID_INDEX].uDataType == QCBOR_TYPE_NONE) { throw COSEDecodeError("Missing kid in protected header"); } parsed.kid = qcbor_buf_to_string(header_items[KID_INDEX].val.string); if (header_items[GOV_MSG_CREATED_AT].uDataType == QCBOR_TYPE_NONE) { throw COSEDecodeError("Missing created_at in protected header"); } if (header_items[GOV_MSG_TYPE].uDataType != QCBOR_TYPE_NONE) { parsed.gov_msg_type = qcbor_buf_to_string(header_items[GOV_MSG_TYPE].val.string); } if (header_items[GOV_MSG_PROPOSAL_ID].uDataType != QCBOR_TYPE_NONE) { parsed.gov_msg_proposal_id = qcbor_buf_to_string(header_items[GOV_MSG_PROPOSAL_ID].val.string); } // Really uint, but the parser doesn't enforce that, so we must check if (header_items[GOV_MSG_CREATED_AT].val.int64 < 0) { throw COSEDecodeError("Header parameter created_at must be positive"); } parsed.gov_msg_created_at = header_items[GOV_MSG_CREATED_AT].val.int64; QCBORDecode_ExitMap(&ctx); QCBORDecode_ExitBstrWrapped(&ctx); QCBORItem item; // skip unprotected header QCBORDecode_VGetNextConsume(&ctx, &item); // payload QCBORDecode_GetNext(&ctx, &item); // signature QCBORDecode_GetNext(&ctx, &item); auto signature = item.val.string; QCBORDecode_ExitArray(&ctx); auto error = QCBORDecode_Finish(&ctx); if (error) { throw COSEDecodeError("Failed to decode COSE_Sign1"); } Signature sig{static_cast<const uint8_t*>(signature.ptr), signature.len}; return {parsed, sig}; } std::pair<ccf::ProtectedHeader, Signature> extract_protected_header_and_signature( const std::vector<uint8_t>& cose_sign1) { ccf::ProtectedHeader parsed; // Adapted from parse_cose_header_parameters in t_cose_parameters.c. // t_cose doesn't support custom header parameters yet. UsefulBufC msg{cose_sign1.data(), cose_sign1.size()}; QCBORError qcbor_result; QCBORDecodeContext ctx; QCBORDecode_Init(&ctx, msg, QCBOR_DECODE_MODE_NORMAL); QCBORDecode_EnterArray(&ctx, nullptr); qcbor_result = QCBORDecode_GetError(&ctx); if (qcbor_result != QCBOR_SUCCESS) { throw COSEDecodeError("Failed to parse COSE_Sign1 outer array"); } uint64_t tag = QCBORDecode_GetNthTagOfLast(&ctx, 0); if (tag != CBOR_TAG_COSE_SIGN1) { throw COSEDecodeError("COSE_Sign1 is not tagged"); } struct q_useful_buf_c protected_parameters; QCBORDecode_EnterBstrWrapped( &ctx, QCBOR_TAG_REQUIREMENT_NOT_A_TAG, &protected_parameters); QCBORDecode_EnterMap(&ctx, NULL); enum { ALG_INDEX, KID_INDEX, END_INDEX, }; QCBORItem header_items[END_INDEX + 1]; header_items[ALG_INDEX].label.int64 = headers::PARAM_ALG; header_items[ALG_INDEX].uLabelType = QCBOR_TYPE_INT64; header_items[ALG_INDEX].uDataType = QCBOR_TYPE_INT64; header_items[KID_INDEX].label.int64 = headers::PARAM_KID; header_items[KID_INDEX].uLabelType = QCBOR_TYPE_INT64; header_items[KID_INDEX].uDataType = QCBOR_TYPE_BYTE_STRING; header_items[END_INDEX].uLabelType = QCBOR_TYPE_NONE; QCBORDecode_GetItemsInMap(&ctx, header_items); qcbor_result = QCBORDecode_GetError(&ctx); if (qcbor_result != QCBOR_SUCCESS) { throw COSEDecodeError( fmt::format("Failed to decode protected header: {}", qcbor_result)); } if (header_items[ALG_INDEX].uDataType == QCBOR_TYPE_NONE) { throw COSEDecodeError("Missing algorithm in protected header"); } parsed.alg = header_items[ALG_INDEX].val.int64; if (header_items[KID_INDEX].uDataType == QCBOR_TYPE_NONE) { throw COSEDecodeError("Missing kid in protected header"); } parsed.kid = qcbor_buf_to_string(header_items[KID_INDEX].val.string); QCBORDecode_ExitMap(&ctx); QCBORDecode_ExitBstrWrapped(&ctx); QCBORItem item; // skip unprotected header QCBORDecode_VGetNextConsume(&ctx, &item); // payload QCBORDecode_GetNext(&ctx, &item); // signature QCBORDecode_GetNext(&ctx, &item); auto signature = item.val.string; QCBORDecode_ExitArray(&ctx); auto error = QCBORDecode_Finish(&ctx); if (error) { throw COSEDecodeError("Failed to decode COSE_Sign1"); } Signature sig{static_cast<const uint8_t*>(signature.ptr), signature.len}; return {parsed, sig}; } } MemberCOSESign1AuthnPolicy::MemberCOSESign1AuthnPolicy( std::optional<std::string> gov_msg_type_) : gov_msg_type(gov_msg_type_){}; MemberCOSESign1AuthnPolicy::~MemberCOSESign1AuthnPolicy() = default; std::unique_ptr<AuthnIdentity> MemberCOSESign1AuthnPolicy::authenticate( kv::ReadOnlyTx& tx, const std::shared_ptr<ccf::RpcContext>& ctx, std::string& error_reason) { const auto& headers = ctx->get_request_headers(); const auto content_type_it = headers.find(http::headers::CONTENT_TYPE); if (content_type_it == headers.end()) { error_reason = fmt::format("Missing {} header", http::headers::CONTENT_TYPE); return nullptr; } if (content_type_it->second != http::headervalues::contenttype::COSE) { error_reason = fmt::format( "Content type is not set to {}", http::headervalues::contenttype::COSE); return nullptr; } auto [phdr, cose_signature] = cose::extract_governance_protected_header_and_signature( ctx->get_request_body()); if (!cose::is_ecdsa_alg(phdr.alg)) { error_reason = fmt::format("Unsupported algorithm: {}", phdr.alg); return nullptr; } MemberCerts members_certs_table(Tables::MEMBER_CERTS); auto member_certs = tx.ro(members_certs_table); auto member_cert = member_certs->get(phdr.kid); if (member_cert.has_value()) { auto verifier = crypto::make_cose_verifier(member_cert->raw()); std::span<const uint8_t> body = { ctx->get_request_body().data(), ctx->get_request_body().size()}; std::span<uint8_t> authned_content; if (!verifier->verify(body, authned_content)) { error_reason = fmt::format("Failed to validate COSE Sign1"); return nullptr; } if (gov_msg_type.has_value()) { if (!phdr.gov_msg_type.has_value()) { error_reason = fmt::format( "Missing ccf.gov.msg.type, expected ccf.gov.msg.type to be {}", gov_msg_type.value()); return nullptr; } if (phdr.gov_msg_type.value() != gov_msg_type.value()) { error_reason = fmt::format( "Found ccf.gov.msg.type set to {}, expected ccf.gov.msg.type to be " "{}", phdr.gov_msg_type.value(), gov_msg_type.value()); return nullptr; } } auto identity = std::make_unique<MemberCOSESign1AuthnIdentity>(); identity->member_id = phdr.kid; identity->member_cert = member_cert.value(); identity->protected_header = phdr; identity->envelope = body; identity->content = authned_content; identity->signature = cose_signature; return identity; } else { error_reason = fmt::format("Signer is not a known member"); return nullptr; } } void MemberCOSESign1AuthnPolicy::set_unauthenticated_error( std::shared_ptr<ccf::RpcContext> ctx, std::string&& error_reason) { ctx->set_error( HTTP_STATUS_UNAUTHORIZED, ccf::errors::InvalidAuthenticationInfo, std::move(error_reason)); ctx->set_response_header( http::headers::WWW_AUTHENTICATE, "COSE-SIGN1 realm=\"Signed request access\""); } const OpenAPISecuritySchema MemberCOSESign1AuthnPolicy::security_schema = std::make_pair( MemberCOSESign1AuthnPolicy::SECURITY_SCHEME_NAME, nlohmann::json{ {"type", "http"}, {"scheme", "cose_sign1"}, {"description", "Request payload must be a COSE Sign1 document, with expected " "protected headers. " "Signer must be a member identity registered with this service."}}); UserCOSESign1AuthnPolicy::UserCOSESign1AuthnPolicy() = default; UserCOSESign1AuthnPolicy::~UserCOSESign1AuthnPolicy() = default; std::unique_ptr<AuthnIdentity> UserCOSESign1AuthnPolicy::authenticate( kv::ReadOnlyTx& tx, const std::shared_ptr<ccf::RpcContext>& ctx, std::string& error_reason) { const auto& headers = ctx->get_request_headers(); const auto content_type_it = headers.find(http::headers::CONTENT_TYPE); if (content_type_it == headers.end()) { error_reason = fmt::format("Missing {} header", http::headers::CONTENT_TYPE); return nullptr; } if (content_type_it->second != http::headervalues::contenttype::COSE) { error_reason = fmt::format( "Content type is not set to {}", http::headervalues::contenttype::COSE); return nullptr; } auto [phdr, cose_signature] = cose::extract_protected_header_and_signature(ctx->get_request_body()); if (!cose::is_ecdsa_alg(phdr.alg)) { error_reason = fmt::format("Unsupported algorithm: {}", phdr.alg); return nullptr; } UserCerts users_certs_table(Tables::USER_CERTS); auto user_certs = tx.ro(users_certs_table); auto user_cert = user_certs->get(phdr.kid); if (user_cert.has_value()) { auto verifier = crypto::make_cose_verifier(user_cert->raw()); std::span<const uint8_t> body = { ctx->get_request_body().data(), ctx->get_request_body().size()}; std::span<uint8_t> authned_content; if (!verifier->verify(body, authned_content)) { error_reason = fmt::format("Failed to validate COSE Sign1"); return nullptr; } auto identity = std::make_unique<UserCOSESign1AuthnIdentity>(); identity->user_id = phdr.kid; identity->user_cert = user_cert.value(); identity->protected_header = phdr; identity->envelope = body; identity->content = authned_content; identity->signature = cose_signature; return identity; } else { error_reason = fmt::format("Signer is not a known user"); return nullptr; } } void UserCOSESign1AuthnPolicy::set_unauthenticated_error( std::shared_ptr<ccf::RpcContext> ctx, std::string&& error_reason) { ctx->set_error( HTTP_STATUS_UNAUTHORIZED, ccf::errors::InvalidAuthenticationInfo, std::move(error_reason)); ctx->set_response_header( http::headers::WWW_AUTHENTICATE, "COSE-SIGN1 realm=\"Signed request access\""); } const OpenAPISecuritySchema UserCOSESign1AuthnPolicy::security_schema = std::make_pair( UserCOSESign1AuthnPolicy::SECURITY_SCHEME_NAME, nlohmann::json{ {"type", "http"}, {"scheme", "cose_sign1"}, {"description", "Request payload must be a COSE Sign1 document, with expected " "protected headers. " "Signer must be a user identity registered with this service."}}); }
44b9532ab331860c6c5216ff3d3f95cf9b37dbdf
ae089e025211d289a99ca2acab9f9aa77d0908ce
/include/couchdb/export.hpp
81adc718775d319dbf5445ea8f8b0d59353eaae9
[ "BSL-1.0", "Apache-2.0" ]
permissive
greenjava/couchdbpp
aeab479ba4f46b68e40bca1131ef498c93e9e8e2
69743a1bbef2c7630b8ce4dc65d005f1e688dfb5
refs/heads/master
2020-07-02T02:35:51.384272
2013-03-07T09:05:23
2013-03-07T09:05:23
8,608,157
1
0
null
null
null
null
UTF-8
C++
false
false
767
hpp
export.hpp
#ifndef __COUCH_DB_CONFIG_HPP__ #define __COUCH_DB_CONFIG_HPP__ #ifdef _WIN32 #ifdef COUCHDB_EXPORTS #define COUCHDB_API __declspec(dllexport) #else #define COUCHDB_API __declspec(dllimport) #endif #define COUCHDB_CLASS_API #elif defined(__GNUC__) && (__GNUC__>=4) && defined(__USE_DYLIB_VISIBILITY__) #ifdef COUCHDB_EXPORTS #define COUCHDB_API __attribute__ ((visibility("default"))) #define COUCHDB_CLASS_API __attribute__ ((visibility("default"))) #else #define COUCHDB_API __attribute__ ((visibility("hidden"))) #define COUCHDB_CLASS_API __attribute__ ((visibility("hidden"))) #endif #else #define COUCHDB_API #define COUCHDB_CLASS_API #endif #endif //__COUCH_DB_CONFIG_HPP__
e9650b3a6a5019a10bff3991cd3a373304892d72
ca602ac81a00ad82d539519502d764180ae57ba9
/Num17_std_invoke.cpp
21d984f77ee931fc909e1f92508f7fa379d85b78
[]
no_license
jpiccoli/Cpp_Weekly
8b6251b367fe2399754cddf443c29c86204f0116
d640ab43c18c4ecdd81eb494d5daf75d886a9b0e
refs/heads/master
2021-09-17T09:29:14.602062
2018-06-30T01:40:52
2018-06-30T01:40:52
110,934,144
0
0
null
null
null
null
UTF-8
C++
false
false
811
cpp
Num17_std_invoke.cpp
#include <iostream> #include <functional> int do_something(const int i) { return 5 + i; } struct S { int j = 5; int do_something(const int i) { return j + i; } int do_something_2(const int i) { return j * i; } }; int main() { std::cout << std::invoke(&do_something, 5) << "\n"; S s; std::cout << s.do_something(3) << "\n"; auto fp = &S::do_something; int (S::*fp2)(int) = nullptr; if (true ) { fp2 = &S::do_something_2; } else { fp2 = &S::do_something; } std::cout << (s.*fp)(2) << "\n"; std::cout << (s.*fp2)(1) << "\n"; // Alternative std::cout << std::invoke(&S::do_something , s, 11) << "\n"; std::cout << std::invoke(&S::do_something_2, s, 11) << "\n"; // Can use to access member data std::cout << std::invoke(&S::j, s) << "\n"; }
6da3efedbce0303b3fc1edcf196e870fb5284fb1
3a4762368701494deabe35407dee73880dd09c0b
/dht_temp_sensor/dht_temp_sensor.ino
81d0751abc5c24318ae5ef7d7db62a12f654fa91
[ "Unlicense" ]
permissive
Pohjois-Tapiolan-lukio/arduino-projects
1843e5ce8128fa22e9e86f5144c74a643fb55b54
410942e0b08989635481c85d009df141f30994b2
refs/heads/master
2022-01-07T13:01:23.327230
2019-06-05T03:26:25
2019-06-05T03:26:25
106,404,874
3
2
null
2018-02-27T18:24:57
2017-10-10T10:52:51
C++
UTF-8
C++
false
false
2,929
ino
dht_temp_sensor.ino
/* Tässä on erikseen ladattavat kirjastot: * - FirebaseArduino: https://github.com/firebase/firebase-arduino * - Adafruit BMP085: https://github.com/adafruit/Adafruit-BMP085-Library * - DHT: https://github.com/adafruit/DHT-sensor-library * - Adafruit Unified Sensor: https://github.com/adafruit/Adafruit_Sensor * - ArduinoJSON */ #include <DHT.h> #include <WiFi101.h> #include <Adafruit_BMP085.h> #include <FirebaseArduino.h> #define FIREBASE_HOST "FIREBASE PROJEKTIN OSOITE" //Muodossa "testi123.firebaseio.com" #define FIREBASE_AUTH "FIREBASE PROJEKTIN AVAIN" #define WIFI_SSID "WIFIN SSID" #define WIFI_PASSWORD "WIFIN SALASANA" #define DHTPIN 4 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); Adafruit_BMP085 bmp; int n = 0; long AloitusAika = 0; long Aika = 0; long KulunutAika = 0; void setup() { Serial.begin(9600); Serial.println(); Serial.println(); Serial.println(); Serial.println(); Serial.println(); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Yhdistetaan"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(); Serial.print("Yhdistetty: "); Serial.println(WiFi.localIP()); Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); delay(500); if (!bmp.begin()) { Serial.println("BMP Sensoria ei löytynyt!"); while (1) {} } dht.begin(); long AloitusAika = millis(); } void loop() { float kosteus_Data = dht.readHumidity(); float C_Data = dht.readTemperature(); float C2_Data = bmp.readTemperature(); float Paine_Data = bmp.readPressure(); float korkeus_Data = bmp.readAltitude(); long Aika = millis(); long KulunutAika = ( Aika - AloitusAika) / 1000; if (isnan(kosteus_Data) || isnan(C_Data)) { Serial.println(); Serial.println("Lukeminen DHT anturista epaonnistui!"); } else { Firebase.setInt("Mittaukset/" + String(n) + "/Aika", KulunutAika); Firebase.setInt("Mittaukset/" + String(n) + "/Kosteus", kosteus_Data); Firebase.setInt("Mittaukset/" + String(n) + "/Lampotila", C_Data); Firebase.setInt("Mittaukset/" + String(n) + "/LampotilaBMP", C2_Data); Firebase.setInt("Mittaukset/" + String(n) + "/Paine", Paine_Data); Firebase.setInt("Mittaukset/" + String(n) + "/Korkeus", korkeus_Data); delay(10); n++; } if (Firebase.failed()) { Serial.print("Firebase lahetys epaonnistui:"); Serial.println(Firebase.error()); return; } Serial.println(); Serial.print("Aika: "); Serial.println(KulunutAika); Serial.print("Kosteus: "); Serial.print(kosteus_Data); Serial.println("%"); Serial.print("Lampotila: "); Serial.print(C_Data); Serial.println("*C"); Serial.print("Lampotila 2: "); Serial.print(C2_Data); Serial.println("*C"); Serial.print("Paine: "); Serial.print(Paine_Data); Serial.println("Pa"); Serial.print("Korkeus: "); Serial.print(korkeus_Data); Serial.println("m"); delay(5000); }
f13e4f2bd2bc6c794c6c630b3f7d860069045a11
69d41528d52112e4681322a793015768c27a29d1
/IcaroLib/Matrix.cpp
aa20cc4bff885556d3c812d2ff5e17905a246c67
[]
no_license
icaromanfrinni/Convex_Hull_and_Delaunay_Triangulation
079d7245b7018437879821894f830f2fc51602b5
c5f079880ccfff4e290bbc9537f363850fee311d
refs/heads/master
2020-07-12T08:37:52.370884
2019-08-29T06:40:44
2019-08-29T06:40:44
204,767,606
0
0
null
null
null
null
UTF-8
C++
false
false
2,008
cpp
Matrix.cpp
#include <iostream> #include <stdlib.h> #include <iomanip> #include <cmath> #include "Matrix.h" using namespace std; //DEFAULT CONSTRUCTOR Matrix::Matrix() { sizeR = 0; sizeC = 0; for (int i = 0; i < MAX; i++) for (int j = 0; j < MAX; j++) e[i][j] = 0.0; } //OVERLOAD CONSTRUCTOR Matrix::Matrix(int nR, int nC) { sizeR = nR; sizeC = nC; for (int i = 0; i < MAX; i++) for (int j = 0; j < MAX; j++) e[i][j] = 0.0; } //DESTRUCTOR Matrix::~Matrix() { } //------------------------------------------------------------------------------ //THE DETERMINANT OF A MATRIX //------------------------------------------------------------------------------ float Matrix::det() const { if (sizeR != sizeC) //verifica se a matrix é quadrada { cout << "\n!!! MATRIX MUST BE SQUARE !!!\n" << endl; exit(EXIT_FAILURE); } else { int n = sizeR; //pega a dimensão da matrix float det = 0.0; if (n == 1) { det = e[0][0]; return det; } else if (n == 2) //se for 2x2, calcula o determinante direto { det = e[0][0] * e[1][1] - e[0][1] * e[1][0]; return det; } else { for (int k = 0; k < n; k++) { Matrix subM(n - 1, n - 1); //Inicializa uma SubMatriz com DIM = n-1 da matriz corrente for (int i = 1; i < n; i++) //cada submatriz é formada pelos elementos abaixo da primeira linha for (int j = 0; j < n; j++) { if (j < k) //não pega os elementos da coluna do coeficiente subM.e[i - 1][j] = e[i][j]; else if (j > k) subM.e[i - 1][j - 1] = e[i][j]; } det += pow(-1, k) * e[0][k] * subM.det(); //calcula o determinante de cada submatriz e acumula } return det; } } }
741f06d08dd28277ade650f0e935603c1f2b01d8
793c8848753f530aab28076a4077deac815af5ac
/src/dskphone/ui/t48/talkui/src/ctalkframetopbar.cpp
7f3b213a23a5e4dc92dc06395abbebed3ee49599
[]
no_license
Parantido/sipphone
4c1b9b18a7a6e478514fe0aadb79335e734bc016
f402efb088bb42900867608cc9ccf15d9b946d7d
refs/heads/master
2021-09-10T20:12:36.553640
2018-03-30T12:44:13
2018-03-30T12:44:13
263,628,242
1
0
null
2020-05-13T12:49:19
2020-05-13T12:49:18
null
UTF-8
C++
false
false
3,511
cpp
ctalkframetopbar.cpp
//mod-this(TalkUI) #include "ctalkframetopbar.h" //mod-UIKernel #include "qtcommon/qmisc.h" #include "baseui/fontcolor.h" #include "customtheme/modcustomtheme.h" #include "uikernel/languagehelper.h" #include "uikernel/qwidgetlist.h" #include "uikernel/qwidgetutility.h" #include "uikernel/qdatetimelabel.h" // mod-MainWnd #include "mainwnd/accountmenuselector.h" //mod-ImageManager #include "imagemanager/modimagemanager.h" // #include "account/accountmanager.h" #include "account/include/modaccount.h" // PicPath #ifdef _T3X #include "T3XStyleUI/T3XPicPath.h" #endif #ifdef _T4X #include "baseui/t4xpicpath.h" #endif // 控件位置定义 const QRect LAB_CHANNEL_ICON_GEOMETRY(4, 4, 34, 34); const QRect LAB_TITLE_GEOMETRY(300, 0, 200, 43); CTalkFrameTopbar::CTalkFrameTopbar(QWidget * parent/* = 0*/) : QFrame(parent) , m_iAccountID(-1) , m_strChannelIconPath("") , m_pDateTime(NULL) , m_pLineBtn(NULL) { InitData(); } CTalkFrameTopbar::~CTalkFrameTopbar() { } // 初始化数据 void CTalkFrameTopbar::InitData() { m_labChannelIcon.setParent(this); m_labChannelIcon.setGeometry(LAB_CHANNEL_ICON_GEOMETRY); /*QFont font; font.setPointSize(18); font.setWeight(75); font.setBold(true); m_labTitle.setFont(font);*/ CustomTheme_SetWidgetFontProperty(&m_labTitle, CUSTOM_FONT_ID_TITLEBAR_NORMAL, true, QFont::Bold); m_labTitle.setParent(this); m_labTitle.setGeometry(LAB_TITLE_GEOMETRY); m_labTitle.setAlignment(Qt::AlignCenter); m_pDateTime = new qDateTimeLabel(this); if (NULL != m_pDateTime) { m_pDateTime->setGeometry(568, 0, 224, 43); m_pDateTime->setAlignment(Qt::AlignRight | Qt::AlignVCenter); // 设置lab上的字的颜色 CustomTheme_SetWidgetFontProperty(m_pDateTime, CUSTOM_FONT_ID_TITLEBAR_TIME, true, QFont::Bold); } m_pLineBtn = new qUIPushButton(this); if (NULL != m_pLineBtn) { m_pLineBtn->setGeometry(41, 0, 115, 43); m_pLineBtn->setTextColor(Qt::white); m_pLineBtn->setTextAlign(Qt::AlignLeft | Qt::AlignVCenter); connect(m_pLineBtn, SIGNAL(clicked()), this, SLOT(OnLineBtnClick())); } } void CTalkFrameTopbar::SetChannelIcon(const QString & strPath) { if (m_strChannelIconPath != strPath) { m_strChannelIconPath = strPath; m_labChannelIcon.setPixmap(THEME_GET_BMP(m_strChannelIconPath.toUtf8().data())); } } void CTalkFrameTopbar::SetTitle(const yl::string & strTitle) { m_labTitle.setText(LANG_TRANSLATE(strTitle.c_str())); } void CTalkFrameTopbar::SetLineBtnText(const QString & strText) { if (NULL != m_pLineBtn) { m_pLineBtn->setText(strText); } } void CTalkFrameTopbar::SetLineBtnActive(bool bActive) { if (NULL == m_pLineBtn) { return; } (bActive) ? m_pLineBtn->show() : m_pLineBtn->hide(); } void CTalkFrameTopbar::SetAccountID(int iAccountID) { m_iAccountID = iAccountID; } void CTalkFrameTopbar::OnLineBtnClick() { m_accountSelector.Init(); // 设置Index m_accountSelector.SetSelectIndexByAccountID(m_iAccountID); if (m_accountSelector.GetAccountSize() <= 0) { return; } QPoint ptMenu(0, 0); MessageBox_ShowTitleMenuBox(this, &m_accountSelector, ptMenu); } void CTalkFrameTopbar::MessageBoxCallBack(CMessageBoxBase * pMessageBox) { int nAccountId = m_accountSelector.GetAccountId(); if (-1 != nAccountId) { emit SelectUserLine(nAccountId); } }
bfbe12cc840fa0319fd0e961a76f1f6c0e958582
6887ae9cae51dc646e0e51ef81a8fec6a7addbc0
/libstacker/src/focas.cpp
aa537b41a698a3fbda0f6e84adfb743feacee994
[ "MIT" ]
permissive
JoeAndrew/OpenSkyStacker
d93c6131aeea10c47eeb6ae2bb3c2dd4a2282510
d55b4b5bbfdffa893410f3ddc594848847f6d0e5
refs/heads/master
2022-11-05T04:54:19.776152
2020-06-20T16:40:42
2020-06-20T16:40:42
273,366,286
0
0
MIT
2020-06-19T00:15:36
2020-06-19T00:15:35
null
UTF-8
C++
false
false
11,572
cpp
focas.cpp
#include "focas.h" using namespace openskystacker; std::vector<Triangle> openskystacker::generateTriangleList(std::vector<Star> List) { int nobjs = NOBJS; if (List.size() < NOBJS) nobjs = static_cast<int>(List.size()); //ntriang = (nobjs - 2) * (nobjs - 1) * nobjs / 6; std::vector<Triangle> List_triang; //(ntriang); int i, j, k, p=0; float di, dj, dk, a, b, c, h1, h2; std::vector<float> sides(nobjs * (nobjs - 1)/2 + 1); /* Minimize the number of triangle sides to compute */ for (i = 0; i < nobjs; i++) { for (j = i + 1; j < nobjs; j++) { h1 = (List[i].x - List[j].x); h2 = (List[i].y - List[j].y); k = sidesPos(i, j, nobjs); sides[k] = sqrt(h1*h1 + h2*h2); } } /* Order the triangle sides and compute the triangle space coords */ for (i = 0; i < (nobjs-2); i++) { for (j = i+1; j < (nobjs-1); j++) { for (k = j+1; k < nobjs; k++) { di = sides [sidesPos(i, j, nobjs)] ; dj = sides [sidesPos(j, k, nobjs)] ; dk = sides [sidesPos(k, i, nobjs)] ; if (dk > dj) { if (dk > di) { if (dj > di) { /* kji */ a = dk; b = dj; c = di; List_triang.push_back(Triangle(k,i,j)); } else { /* kij */ a = dk; b = di; c = dj; List_triang.push_back(Triangle(i,k,j)); } } else { /* ikj */ a = di; b = dk; c = dj; List_triang.push_back(Triangle(i,j,k)); } } else if (dj > di) { if (di > dk) { /* jik */ a = dj; b = di; c = dk; List_triang.push_back(Triangle(j,k,i)); } else { /* jki */ a = dj; b = dk; c = di; List_triang.push_back(Triangle(k,j,i)); } } else { /* ijk */ a = di; b = dj; c = dk; List_triang.push_back(Triangle(j,i,k)); } /* Include only triangles with b/a < 0.9 */ if ( b/a < 0.9 ) { List_triang[p].x = b/a; List_triang[p].y = c/a; p++; } else { List_triang.pop_back(); } } } } return List_triang; } int openskystacker::sidesPos(int i, int j, int n) { if (i < j) return(i*(2*n-i-3)/2 + j); else return(j*(2*n-j-3)/2 + i); } std::vector<std::vector<int> > openskystacker::findMatches(int nobjs, int *k_, std::vector<Triangle> List_triangA, std::vector<Triangle> List_triangB) { std::vector<std::vector<int> > matches(3, std::vector<int>(MAX_MATCH, 0)); int i, j, l, n, first, last; int &k = *k_; k = 0; int *Table_match = new int[nobjs * nobjs]; for (int i = 0; i < nobjs * nobjs; i++) { Table_match[i] = 0; } /* Sort List_triangB by x coordinate. */ sortTriangles(&List_triangB, 0, static_cast<int>(List_triangB.size()) - 1); /* Find objects within tolerance distance in triangle space. */ for (Triangle tri : List_triangA) { binSearchTriangles(tri.x, &List_triangB, &first, &last); checkTolerance(nobjs, tri, &List_triangB, first, last, Table_match); } /* Find the nobjs points with the most matches. */ k = 0; for (i = 0; i < nobjs; i++) { for (j = 0; j < nobjs; j++) { n = Table_match[i*nobjs+j]; if (n > 0) { if (k < nobjs) { for (l=k; l>0 && n>matches[2][l-1]; l--) { matches[0][l] = matches[0][l-1]; matches[1][l] = matches[1][l-1]; matches[2][l] = matches[2][l-1]; } matches[0][l] = i; matches[1][l] = j; matches[2][l] = n; k++; } else if (n >= matches[2][nobjs-1]) { for (l=k; l>0 && n>matches[2][l-1]; l--) { matches[0][l] = matches[0][l-1]; matches[1][l] = matches[1][l-1]; matches[2][l] = matches[2][l-1]; } matches[0][l] = i; matches[1][l] = j; matches[2][l] = n; l = k < MAX_MATCH ? k + 1: k; n = matches[2][nobjs-1]; for (k=nobjs; k<l && n==matches[2][k]; k++); } } } } delete [] Table_match; return matches; } void openskystacker::sortTriangles(std::vector<Triangle> *List_Triang_, int l, int r) { // make index operator easier std::vector<Triangle> &List_Triang = *List_Triang_; Triangle v; Triangle t; int i, j; if( r > l ) { v.x = List_Triang[r].x; i = l-1; j = r; for(;;) { while(List_Triang[++i].x < v.x ); while((j > 1) && (List_Triang[--j].x > v.x)); if(i >= j) break; t.x = List_Triang[i].x; List_Triang[i].x = List_Triang[j].x; List_Triang[j].x = t.x; t.y = List_Triang[i].y; List_Triang[i].y = List_Triang[j].y; List_Triang[j].y = t.y; t.s1 = List_Triang[i].s1; List_Triang[i].s1 = List_Triang[j].s1; List_Triang[j].s1 = t.s1; t.s2 = List_Triang[i].s2; List_Triang[i].s2 = List_Triang[j].s2; List_Triang[j].s2 = t.s2; t.s3 = List_Triang[i].s3; List_Triang[i].s3 = List_Triang[j].s3; List_Triang[j].s3 = t.s3; } t.x = List_Triang[i].x; List_Triang[i].x = List_Triang[r].x; List_Triang[r].x = t.x; t.y = List_Triang[i].y; List_Triang[i].y = List_Triang[r].y; List_Triang[r].y = t.y; t.s1= List_Triang[i].s1; List_Triang[i].s1 = List_Triang[r].s1; List_Triang[r].s1 = t.s1; t.s2 = List_Triang[i].s2; List_Triang[i].s2 = List_Triang[r].s2; List_Triang[r].s2 = t.s2; t.s3 = List_Triang[i].s3; List_Triang[i].s3 = List_Triang[r].s3; List_Triang[r].s3 = t.s3; sortTriangles(&List_Triang, l, i-1); sortTriangles(&List_Triang, i+1, r); } } void openskystacker::binSearchTriangles(float key, std::vector<Triangle> *List_triang_, int *first, int *last) { std::vector<Triangle> &List_triang = *List_triang_; int ntriang = static_cast<int>(List_triang.size()); int min = 0, max = ntriang - 1, middle ; int found = 0, i; double tolerance = TOL; while ((!found) && (max - min > 1)) { middle = (min + max ) / 2; if (fabs(List_triang[middle].x - key) < tolerance) found = 1; else if ( key < ( List_triang[middle ].x - tolerance)) max = middle ; else if ( key > (List_triang[middle ].x + tolerance)) min = middle; } /* Not found */ if (!found) { *first = 2; *last = 1; return; } for (i = middle; i > 0; i--) { if (fabs (List_triang[i].x - key) > tolerance) break; } *first = i; for (i = middle; i < ntriang-1; i++) { if (fabs (List_triang[i].x - key) > tolerance) break; } *last = i; } void openskystacker::checkTolerance(int nobjs, Triangle List_triangA, std::vector<Triangle> *List_triangB_, int first, int last, int Table_match[]) { std::vector<Triangle> &List_triangB = *List_triangB_; double tolerance = TOL; double tolerance2 = TOL * TOL; float temp1, temp2, distance; int i, h1, h2; for (i = first ; i <= last; i++) { temp2 = (List_triangA.y - List_triangB[i].y); if (temp2 < tolerance) { temp1 = (List_triangA.x - List_triangB[i].x); distance = temp1 * temp1 + temp2 * temp2; if (distance < tolerance2) { h1 = List_triangA.s1; h2 = List_triangB[i].s1; Table_match[h1*nobjs+h2]++; h1 = List_triangA.s2; h2 = List_triangB[i].s2; Table_match[h1*nobjs+h2]++; h1 = List_triangA.s3; h2 = List_triangB[i].s3; Table_match[h1*nobjs+h2]++; } } } } std::vector<std::vector<float> > openskystacker::findTransform(std::vector<std::vector<int> > matches, int m, std::vector<Star> List1, std::vector<Star> List2, int *ok) { //float xfrm[2][3]; std::vector<std::vector<float> > xfrm(2, std::vector<float>(3,0)); int i, j, i1, i2; int mda = MAX_MATCH, mdb = MAX_MATCH, n = 3, nb = 2; int krank, ip[3]; float tau = 0.1f, rnorm[2], h[3], g[3]; float a[3][MAX_MATCH], b[2][MAX_MATCH]; float x, y, r2, sum, rms; /* Require a minimum number of points. */ if (m < MIN_MATCH) { if (ok) *ok = -1; return xfrm; } /* Compute the initial transformation with the 12 best matches. */ j = (m < 12) ? m : 12; for (i=0; i<j; i++) { a[0][i] = List1[matches[0][i]].x; a[1][i] = List1[matches[0][i]].y; a[2][i] = 1.; b[0][i] = List2[matches[1][i]].x; b[1][i] = List2[matches[1][i]].y; } hfti_(a, &mda, &j, &n, b, &mdb, &nb, &tau, &krank, rnorm, h, g, ip); for (i=0; i<2; i++) for (j=0; j<3; j++) xfrm[i][j] = b[i][j]; /* Start with all matches compute RMS and reject outliers. */ /* The outliers are found from the 60% point in the sorted residuals. */ for (;;) { sum = 0.; for (i=0; i<m; i++) { i1 = matches[0][i]; i2 = matches[1][i]; r2 = List1[i1].x; y = List1[i1].y; x = xfrm[0][0] * r2 + xfrm[0][1] * y + xfrm[0][2]; y = xfrm[1][0] * r2 + xfrm[1][1] * y + xfrm[1][2]; x -= List2[i2].x; y -= List2[i2].y; r2 = x * x + y * y; for (j=i; j>0 && r2<a[1][j-1]; j--) a[1][j] = a[1][j-1]; a[0][i] = r2; a[1][j] = r2; sum += r2; } /* Set clipping limit and quit when no points are clipped. */ i = 0.6 * m; r2 = CLIP * a[1][i]; if (r2 >= a[1][m-1]) { rms = sqrt(sum / m); break; } Q_UNUSED(rms); /* Clip outliers and redo the fit. */ j = 0; for (i=0; i<m; i++) { if (a[0][i] < r2) { i1 = matches[0][i]; i2 = matches[1][i]; matches[0][j] = i1; matches[1][j] = i2; a[0][j] = List1[i1].x; a[1][j] = List1[i1].y; a[2][j] = 1.; b[0][j] = List2[i2].x; b[1][j] = List2[i2].y; j++; } } m = j; if (m < MIN_MATCH) { if (ok) *ok = -1; return xfrm; } hfti_(a, &mda, &m, &n, b, &mdb, &nb, &tau, &krank, rnorm, h, g,ip); for (i=0; i<2; i++) for (j=0; j<3; j++) xfrm[i][j] = b[i][j]; } return xfrm; }
223f5757b28fcdef9bb200b72894d7994a5d536f
9d61448272b9eafd5765357c3cd6d4162d297acd
/src/cube.cpp
391cfb06ae5f6a5b92ae83a19c6ddd78a55b7a2d
[]
no_license
pandeyjames/RobotArm
9af41bf846bbe7ab2dd758e56164fb2d22d294a0
82eb17f141eb7427682d44484ba92b047b989f4c
refs/heads/master
2021-08-30T21:00:46.741007
2017-12-19T12:29:20
2017-12-19T12:29:20
113,297,980
1
0
null
null
null
null
UTF-8
C++
false
false
2,889
cpp
cube.cpp
#include "../include/cube.h" Cube::Cube(){ width = 1.0f; breadth = 1.0f; height = 1.0f; pos = GMlib::Point<float,3>(0.0f,0.0f,0.0f); makeCube(); } Cube::Cube(GMlib::Point<float,3>pos , float width, float breadth, float height){ this->width = width; this->breadth = breadth; this->height =height; this->pos = pos; makeCube(); } Cube::Cube(const Cube& copy){ width = copy.width; breadth = copy.breadth; height = copy.height; pos = copy.pos; planes = copy.planes; } void Cube::setWidth(float w){ width = w; } void Cube::setBreadth(float b){ breadth =b; } void Cube::setHeight(float h){ height =h; } void Cube::makeCube(){ planes.push_back(std::make_unique<Plane>( pos + GMlib::Vector<float,3>(0.5*breadth, 0.5*width, -0.5*height), GMlib::Vector<float,3>(0.0f, -width, 0.0f), GMlib::Vector<float,3>(-breadth, 0.0f, 0.0f))); planes.push_back(std::make_shared<Plane>( pos + GMlib::Vector<float,3>(0.5*breadth, 0.5*width, 0.5*height), GMlib::Vector<float,3>(0.0f, -width, 0.0f), GMlib::Vector<float,3>(-breadth, 0.0f, 0.0f))); planes.push_back(std::make_shared<Plane>( pos + GMlib::Vector<float,3>(0.5*breadth, 0.5*width, -0.5*height), GMlib::Vector<float,3>(0.0f, -width, 0.0f), GMlib::Vector<float,3>(0.0, 0.0f, height))); planes.push_back(std::make_shared<Plane>( pos + GMlib::Vector<float,3>(0.5*breadth, 0.5*width, -0.5*height), GMlib::Vector<float,3>(-breadth, 0.0f, 0.0f), GMlib::Vector<float,3>(0.0f, 0.0f, height))); planes.push_back(std::make_shared<Plane>( pos + GMlib::Vector<float,3>(-0.5*breadth, -0.5*width, -0.5*height), GMlib::Vector<float,3>(0.0f,width, 0.0f), GMlib::Vector<float,3>(0.0f, 0.0f, height))); planes.push_back(std::make_shared<Plane>( pos +GMlib::Vector<float,3>(-0.5*breadth, -0.5*width, -0.5*height), GMlib::Vector<float,3>(breadth, 0.0f, 0.0f), GMlib::Vector<float,3>(0.0f, 0.0f, height))); } void Cube::setMaterial(const GMlib::Material& m){ for(auto& it:planes){ it->setMaterial(m); } } void Cube::replot(int m1, int m2, int d1, int d2){ for(auto& it:planes){ it->replot(m1,m2,d1,d2); } } void Cube::toggleDefaultVisualizer(){ for(auto& it:planes){ it->toggleDefaultVisualizer(); } } void Cube::insertToScene(const std::shared_ptr<GMlib::Scene>& scene) { for(auto& it:planes){ scene->insert(it.get()); } }
7f62ea014fb5b6f71d54f00e2089fb49b25d7c3a
9b3b3ffc842c038a296fd57ebb167269a96faf0e
/1102.cpp
b45910b6315b3c6f0085e94904ab6727fd554ee9
[]
no_license
ee-lynn/PAT_test
577cce79e482da60aab8e88fe167a4eff01d17f8
21a2576b7b9ee738ca0a0cbde18a5edffdc9f03e
refs/heads/master
2021-06-30T03:02:01.937954
2017-09-18T02:22:14
2017-09-18T02:22:14
103,836,895
0
0
null
null
null
null
UTF-8
C++
false
false
1,682
cpp
1102.cpp
#include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; typedef struct node { int key; int left; int right; }node; int NUM = 0; void invert(vector<node>& BTree, int root) { if (BTree[root].left != -1) invert(BTree, BTree[root].left); if (BTree[root].right != -1) invert(BTree, BTree[root].right); int tmp; tmp = BTree[root].left; BTree[root].left = BTree[root].right; BTree[root].right = tmp; } void display_inorder(vector<node>& BTree, int root) { if (BTree[root].left != -1) display_inorder(BTree, BTree[root].left); if (NUM == 0) { cout << root; NUM++; } else cout << " " << root; if (BTree[root].right != -1) display_inorder(BTree, BTree[root].right); } int main() { int N; cin >> N; vector<node> BTree(N); vector<bool> Exits(N, false); for (int i = 0; i < N; i++) { char c; int key, left, right; cin >> c; if (c != '-') { left = c - '0'; Exits[left] = true; } else left = -1; cin >> c; if (c != '-') { right = c - '0'; Exits[right] = true; } else right = -1; BTree[i] = { i, left, right }; } int root; for (int i = 0; i < N; i++) if (!Exits[i]) { root = i; break; } invert(BTree, root); queue<node> myQueue; cout << root; myQueue.push(BTree[root]); while (!myQueue.empty()) { int index = myQueue.front().left; if (index != -1) { node t = BTree[index]; cout << " " << t.key; myQueue.push(t); } index = myQueue.front().right; if (index != -1) { node t = BTree[index]; cout << " " << t.key; myQueue.push(t); } myQueue.pop(); } cout << endl; display_inorder(BTree, root); cout << endl; return 0; }
0dfe1d462c888a4384620d68dc84a7a421e36c4a
4db3777336ee57e24138eaae027d58e264939cba
/chapter5/exercises/exercise_5_3.cpp
8c8af076dbd05791935a429bc2cb3f73fe93bb26
[]
no_license
Canciller/tlpi
e502a5921d2a4df67213da22c98fb81e5265cdb9
fe39494698648113feeb94eee1e2529a04142322
refs/heads/master
2020-09-24T10:51:58.882863
2019-12-28T01:06:13
2019-12-28T01:06:13
225,743,454
0
0
null
null
null
null
UTF-8
C++
false
false
823
cpp
exercise_5_3.cpp
#include <sys/stat.h> #include <fcntl.h> #include "tlpi_hdr.h" int main(int argc, char *argv[]) { if(argc < 2 || strcmp(argv[1], "--help") == 0) usageErr("%s filename num-bytes [x]\n", argv[0]); bool x = argc > 3; size_t bytes = atoi(argv[2]); int flags = O_CREAT | O_WRONLY | O_TRUNC; if(!x) flags |= O_APPEND; int fd = open(argv[1], flags, S_IRUSR | S_IWUSR); if(fd == -1) errExit("open"); if(x && lseek(fd, 0, SEEK_END) == -1) errExit("lseek"); for(size_t i = 0; i < bytes; ++i) { ssize_t status = write(fd, "x", 1); if(status == -1) errExit("write"); } if(close(fd) == -1) errExit("close"); printf("%zu bytes written %s append\n", bytes, x ? "without" : "with"); return EXIT_SUCCESS; }
41b6084db8aad51e4eca399c1281fa6734d718ad
1854667e41610358399e95fc326e0d308f79f9df
/GameClient/include/GameClient/main.cpp
d56796243ac24cbb304ae446c20171d6e9cb3071
[]
no_license
1aam2am1/RTS_GAME
c84e8a102635bdccbd91bc3b23b6b5663b162151
d8df7df5949738f248d948ff49dd9703b726d9fd
refs/heads/master
2023-03-24T06:38:55.735177
2021-03-26T13:59:07
2021-03-26T13:59:07
296,715,523
0
0
null
null
null
null
UTF-8
C++
false
false
1,409
cpp
main.cpp
#include <GameClient/Argv_options.h> #include <GameApi/GlobalLogSource.h> #include <Version/version.h> #include <GameClient/Unity/Editor/Menu.h> #include "MainWindow.h" #include "FontLoader.h" #include "GlobalStaticVariables.h" #include <filesystem> #include <GameClient/Windows/AssetWindow.h> #include <GameClient/Unity/Editor/AssetDatabase.h> #include <GameClient/Initializer.h> namespace fs = std::filesystem; int main(int argc, char **argv) { try { Argv_options options; options.process(argc, argv); if (options.getOptions().version) { GameApi::log(INFO.fmt("Version: %s %s %s %i bit\n", Version::GIT_TAG.data(), Version::GIT_SHA.data(), Version::DATE.data(), static_cast<int>(sizeof(void *) * 8))); } global.settings.Load(); MainWindow window(options); FontLoader{options}; Initializer::initialize(); #if UNITY_EDITOR fs::create_directory("Assets"); Menu::Init(); AssetWindow::Init(); //=>To Coroutine #else if (!std::filesystem::exists("Assets")) { throw std::runtime_error("Assets folder don't exists"); } #endif AssetDatabase::Refresh(); window.run(); Initializer::uninitialize(); } EXCEPTION_PRINT GameApi::log(INFO << "Bye"); return 0; }
19db33973d46cfbbaddfcce725c1cac4742cdaa6
dafbd21f473ecfc176f42e03bb5c2b302811ebd3
/Mathlab/MathLabAddWidget.h
03dd0187b8c55b553224b67872708ca9fafdd644
[]
no_license
tsbraw/Mathlab
811f50716eed32a14c7030bcf9c6e26d351290e0
e1cf2a06edce1c621e728a6f1b8c72f3b157cf86
refs/heads/master
2023-06-04T14:27:24.668382
2021-06-14T12:41:15
2021-06-14T12:41:15
339,039,245
0
0
null
null
null
null
UTF-8
C++
false
false
494
h
MathLabAddWidget.h
#ifndef MATHLABADDWIDGET_H #define MATHLABADDWIDGET_H #include <QDialog> #include "MathLabTypes.h" namespace Ui {class MathLabAddWidget;}; class MathLabAddWidget : public QDialog { Q_OBJECT public: MathLabAddWidget(QWidget *parent = 0); ~MathLabAddWidget(); CourseInfoPtr GetCourseInfo(); void SetCourseInfo(CourseInfoPtr courseInfo); private slots: void On_pushButton_Ok_clicked(); private: Ui::MathLabAddWidget *ui; CourseInfoPtr _newCourse; }; #endif // MATHLABADDWIDGET_H
dcb8e08f0830d2d20f66ffe4fd82a6c3d4554de5
cb48413932dd202b7f2ac53542779b5732b22234
/src/graphics/animation/blendop.h
b8bd97c6eb473d037b1449b6bacda0033c8a8dd7
[]
no_license
mkkellogg/GTE
b80e119366b69303e48e1aadee9c06c60f133f09
5ddaca3b9ab6e7231775f2d0ac31840542d81724
refs/heads/master
2021-01-13T17:27:38.790833
2018-06-12T00:22:41
2018-06-12T00:22:41
22,696,044
12
0
null
2017-05-02T17:25:16
2014-08-06T19:53:58
C++
UTF-8
C++
false
false
1,220
h
blendop.h
/********************************************* * * class: BlendOp * * author: Mark Kellogg * * This class is the base class for animation blending operations. * ***********************************************/ #ifndef _GTE_BLENDOP_H_ #define _GTE_BLENDOP_H_ #include <vector> #include <string> #include "engine.h" #include "global/global.h" namespace GTE { //forward declarations class Transform; class SkeletonNode; class BlendOp { friend class AnimationPlayer; protected: Real duration; Real progress; Bool complete; Bool started; std::vector<Real> initialWeights; BlendOp(Real duration); virtual ~BlendOp(); void SetComplete(Bool complete); void SetStarted(Bool started); public: void Reset(); Bool Init(const std::vector<Real>& initialWeights); virtual void Update(std::vector<Real>& weights); virtual void OnStart() = 0; virtual void OnComplete() = 0; virtual void OnStoppedEarly() = 0; Bool HasCompleted() const; Bool HasStarted() const; Real GetNormalizedProgress() const; Real GetProgress() const; }; } #endif
51e08b3f8817ef2e222ff5dfb0454fc711b4a7bd
3d1b69ca81cb16cda4db6dafc3769f30c3f2535a
/TME3/exo4.cpp
4ed396ada4d25d30382f9f576853fb91df42730d
[]
no_license
KatiaAMICHI/CPA-Projet
a5b3d2bd164dbd33c483cb11abadf064290c2d7f
e1359e63566399ef2415ea5de6697019630bd978
refs/heads/master
2020-05-23T23:12:46.778397
2019-04-07T10:43:41
2019-04-07T10:48:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,647
cpp
exo4.cpp
#include <stdio.h> #include "structs.h" #include "algs.h" #include <set> #include <cmath> int nbTriangles(adjArray *arr) { int nb = 0; int i, j, k; for(i = 0; i < arr->n; i++) { std::set<unsigned int> unei; // Tous les voisins de u for(j = arr->cd[i]; j < arr->cd[i+1]; j++) unei.insert(arr->adj[j]); for(j = arr->cd[i]; j < arr->cd[i+1]; j++) { unsigned int nj = arr->adj[j]; for(k = arr->cd[nj]; k < arr->cd[nj+1]; k++) { if(unei.find(arr->adj[k]) != unei.end()) nb++; } } } return nb; } int nbTriplets(adjArray *arr) { int nb = 0; int i, j, k; for(i = 0; i < arr->n; i++) { for(j = arr->cd[i]; j < arr->cd[i+1]; j++) { unsigned int nj = arr->adj[j]; for(k = arr->cd[nj]; k < arr->cd[nj+1]; k++) nb++; } } return nb; } double transitivity(adjArray *arr, int nbTrip) { int nb = nbTriangles(arr); return (double) (3 * nb) / (double) nbTrip; } double clustering(adjArray *arr) { int i, j, k; int *degs = (int *)malloc(arr->n*sizeof(int)); for(i = 0; i < arr->n; i++) degs[i] = arr->cd[i+1]-arr->cd[i]; for(i = 0; i < arr->m; i++) degs[arr->adj[i]]++; double *cc = (double *)malloc(arr->n*sizeof(double)); for(i = 0; i < arr->n; i++) { int nb = 0; std::set<unsigned int> unei; // Tous les voisins de u for(j = arr->cd[i]; j < arr->cd[i+1]; j++) unei.insert(arr->adj[j]); for(j = arr->cd[i]; j < arr->cd[i+1]; j++) { unsigned int nj = arr->adj[j]; for(k = arr->cd[nj]; k < arr->cd[nj+1]; k++) { if(unei.find(arr->adj[k]) != unei.end()) nb++; } } if(nb == 0) cc[i] = 0; else cc[i] = (double)nb / (double) ((degs[i]*(degs[i]-1))/2); } double c = 0; for(i = 0; i < arr->n; i++) { c += cc[i]; } free(cc); free(degs); return c / (double) arr->n; } int main(int argc, char **argv) { if(argc != 2) { printf("usage : ./exo4 <input_file>\n"); return 1; } char *inputName = argv[1]; unsigned int nbNodes = 0; unsigned int nbEdges = 0; std::map<unsigned int, unsigned int> *map = size(inputName, &nbNodes, &nbEdges); adjArray *arr = loadAsAdjArray(inputName, nbNodes, nbEdges, map); delete map; printf("Loaded the graph as adj array\n"); int nbTri = nbTriplets(arr); sortDescendingDegrees(arr, nbNodes); printf("Sorted by descending degrees\n"); long startTime = clock(); printf("Nb de triangles: %d\n", nbTriangles(arr)); printf("Execution time: %ldms\n", (1000*(clock()-startTime))/CLOCKS_PER_SEC); printf("Ratio de transitivité: %f\n", transitivity(arr, nbTri)); printf("Clustering: %f\n", clustering(arr)); freeAdjArray(arr); return 0; }
19cb1fb9dfed6612a71ff027607c0dd1b7d0e8a5
363b26d5e929f651349a5a8c4f735bdb9a0b20eb
/CIS350/main.cpp
0dfd0ce7e01b2966a3df22543e47c1e68c4afc1b
[]
no_license
habeshawit/convertInfixOperation
f24e297275f29bd1e1e747bf6b608a9634cf5dad
d52651a4e3c259ecf31abd8b7047bb0502dbce5c
refs/heads/master
2023-08-24T00:32:21.619849
2021-10-02T03:58:09
2021-10-02T03:58:09
410,217,044
0
0
null
2021-09-30T09:02:52
2021-09-25T08:22:51
C++
UTF-8
C++
false
false
16,376
cpp
main.cpp
//Program Name: EvaluateInfixOperations //Programmer Name: Shalom Kebede //Description: Given a file with infix expressions, the program will create and traverse trees in prefix, infix and postfix order. It will evaluate the expression from the prefix notation and print to the screen the result of the traversal or print error messages as appropriate. //Date Created: Sep 18, 2021 #include <iostream> #include <fstream> #include <stack> #include <string> #include <vector> using namespace std; bool isOperand(char); bool isOperator(char); bool isParenthesis(char); int precedent(char); void constructTree(string, ofstream&); void printOperations(string, ofstream&); void prefixEvaluation(string, ofstream&); string validate(string); string convertToPostFix(string, ofstream&); string prefix; int convertToDigit(char); //struct to create node for binary tree struct Node { char data; Node* left, * right; }; //stack to store pointers to node stack<Node*> s; void preorder(Node*, ofstream&); void inorder(Node*, ofstream&); void postorder(Node*, ofstream&); int height(Node*); void printTree(Node*, ofstream&); void printCurrentLevel(Node*, int, ofstream&); int main() { string postFix; string scannedExpression; string inputFileName; string outputFileName; cout << "Welcome! Enter the name of the file you would like to open: "; cin >> inputFileName; cout << "\nEnter the name of the output file: "; cin >> outputFileName; //Read from input file & check for file errors ifstream inputFile(inputFileName); ofstream outputFile(outputFileName); if (inputFile.fail()) { outputFile << "\n ERROR: Cannot read input from file." << endl; cout << "\n ERROR: Cannot read input from file." << endl; return 0; } else if (inputFile.peek() == EOF) { outputFile << "\n ERROR: Input file is empty" << endl; cout << "\n ERROR: Input file is empty" << endl; return 0; } cout << "\nSuccessfully opened input file: '" << inputFileName << "'" << endl; outputFile << "\nSuccessfully opened input file: '" << inputFileName << "'" << endl; while (!inputFile.eof()) { string scannedExpression; string validationResult; getline(inputFile, scannedExpression); outputFile << "\n---------------------------------------------------------------------\n\n"; cout << "\n---------------------------------------------------------------------\n\n" ; outputFile << "Input Line: #" << scannedExpression << "#" << endl; cout << "Input Line: #" << scannedExpression << "#" << endl; validationResult = validate(scannedExpression); if (validationResult == "Valid Statement") { outputFile << validationResult << endl; cout << validationResult << endl; postFix = convertToPostFix(scannedExpression, outputFile); printOperations(postFix, outputFile); constructTree(postFix, outputFile); } else { outputFile << validationResult; cout << validationResult; } } cout << "\nProgram completed.\n"; outputFile << "\nProgram completed.\n"; return 0; } //Description: Function to validate if scanned expression is valid //Pre-condition: infix expression (string) //Post-condition: Returns result of validation string validate(string expression) { string result = "Invalid Statement: \n"; int countOpening = count(expression.begin(), expression.end(), '('); int countClosing = count(expression.begin(), expression.end(), ')'); vector<int> errors; //check for mismatched parenthesis error if (countOpening != countClosing) { //if not already in error vector, push error 1 (parenthesis mismatched) to errors vector if (!(find(errors.begin(), errors.end(), 1) != errors.end())) { result += "\tMismatched parenthesis\n"; errors.push_back(1); } } for (int i = 0; i < expression.length(); i++) { //check for invalid operand or operator if (isOperand(expression[i]) == false && isOperator(expression[i]) == false && isParenthesis(expression[i]) == false && !isblank(expression[i])) { //add error 2 (invalid operand/operator) to results with piece of data causing error result += "\tInvalid operator/operand '" + string(1, expression[i]) + "'\n"; errors.push_back(2); } //check for spacing error //if every even spot is not an empty space, return error 3 (spacing error) if (i % 2 == 0) { if (!isblank(expression[i])) { if (!(find(errors.begin(), errors.end(), 3) != errors.end())) { result += "\tSpacing error\n"; errors.push_back(3); } } } //check for inaccurate use of parenthesis if (isOperator(expression[i])) { if ((expression[i + 2] && expression[i + 2] == ')') || (expression[i - 2] && expression[i - 2] == '(')) { if (!(find(errors.begin(), errors.end(), 4) != errors.end())) { result += "\tInaccurate use of parenthesis\n"; errors.push_back(4); } } } } //check errors vector for all errors detected //if no error detected return 'Valid Statement' if (errors.size() == 0) { result = "Valid Statement"; } return result; } //Description: Function to convert infix expression to postfix //Pre-condition: infix expression (string), output file //Post-condition: Returns post fix expression (string) string convertToPostFix(string scannedExpression, ofstream& outputFile) { stack <char> myStack; string postFix; for (int i = 0; i < scannedExpression.length(); i++) { char charRead = scannedExpression[i]; //if read character is operand, add to postFix string if (isOperand(charRead)) { postFix += charRead; } //if read character is operator, add to stack else if (isOperator(charRead)) { //pop all Stack operators if scanned operand has lower precendent than existing precedence operator in stack //add popped operator to postFix string while (!myStack.empty() && precedent(charRead) < precedent(myStack.top())) { postFix += myStack.top(); myStack.pop(); } //push operand into stack myStack.push(charRead); } else if(isParenthesis(charRead)) { if (charRead == '(') myStack.push(charRead); else { while (!myStack.empty() && myStack.top() != '(') { postFix += myStack.top(); myStack.pop(); } if (!myStack.empty()) myStack.pop(); } } }; //Pop remaining items in the stack while (!myStack.empty()) { postFix += myStack.top(); myStack.pop(); } outputFile << "Postfix Expresssion: " << postFix << endl; cout << "Postfix Expresssion: " << postFix << endl; return postFix; } //Description: Function to check if scanned character is an operand //Pre-condition: input is char //Post-condition: returns true if char is operand, false otherwise bool isOperand(char charRead) { if ((charRead >= 'A' && charRead <= 'Z') || (charRead >= '0' && charRead <= '9')) { return true; } else { return false; } } //Description: Function to check if scanned character is an operator //Pre-condition: input is char //Post-condition: returns true if char is operand, false otherwise bool isOperator(char charRead) { if ((charRead == '*') || (charRead == '/') || (charRead == '+') || (charRead == '-')) { return true; } else { return false; } } //Description: Function to check if scanned character is an parenthesis //Pre-condition: input is char //Post-condition: returns true if char is operand, false otherwise bool isParenthesis(char charRead) { if (charRead == '(' || charRead == ')') return true; else return false; } //Description: Function to check the precendence of scanned character //Pre-condition: input is char //Post-condition: returns higher precedent if char red is * or / int precedent(char charRead) { if (charRead == '*' || charRead == '/') { return 2; } else if (charRead == '+' || charRead == '-') { return 1; } else { return 0; } } //Description: Function to print operations from postfix expression //Pre-condition: post fix expression (string), output file //Post-condition: prints all individual operation in postfix expression & logs to output file void printOperations(string expression, ofstream& outputFile) { stack<string> newStack; string operand1; string operand2; outputFile << "Operations: " << endl; cout << "Operations: " << endl; for (int i = 0; i < expression.length(); i++) { char charRead = expression[i]; if (isOperand(charRead)) { newStack.push(string(1, charRead)); } else if (isOperator(charRead)) { operand1 = newStack.top(); newStack.pop(); operand2 = newStack.top(); newStack.pop(); newStack.push(operand2 + operand1 + charRead); outputFile << "\t " << operand2 + operand1 + charRead << endl; cout << "\t " << operand2 + operand1 + charRead << endl; } } } //Description: Function to construct tree from postfix expression //Pre-condition: post fix expression (string), output file //Post-condition: constructs and prints tree, prints prefix, infix and postfix notation, initiates evaluation using prefix void constructTree(string expression, ofstream& outputFile) { for (int i = 0; i < expression.length(); i++) { char charRead = expression[i]; //if operand, turn into leaf node and push to stack if (isOperand(charRead)) { Node* node = new Node(); node ->data = charRead; node->left = node->right = nullptr; s.push(node); } //if operator else { //create node with operator as node Node *node = new Node(); node->data = charRead; //Pop item from stack and set as 1st child Node *child1 = s.top(); s.pop(); //Pop item from stack and set as 2nd child Node *child2 = s.top(); s.pop(); //set right and left children node->right = child1; node->left = child2; //add subtree to stack s.push(node); } } printTree(s.top(), outputFile); outputFile << "\nPrefix: "; cout << "\nPrefix: "; preorder(s.top(), outputFile); outputFile << "\nInfix: "; cout << "\nInfix: "; inorder(s.top(), outputFile); outputFile << "\nPostfix: "; cout << "\nPostfix: "; postorder(s.top(), outputFile); prefixEvaluation(prefix, outputFile); //reset prefix to empty string prefix = ""; } /* preordertree traversal */ void preorder(Node* ptr, ofstream& outputFile) { //print visit, left, right if (ptr) { outputFile << ptr->data; cout << ptr->data; prefix += ptr->data; preorder(ptr->left, outputFile); preorder(ptr->right, outputFile); } } /* inordertree traversal */ void inorder(Node* ptr, ofstream& outputFile){ //print left, visit, right if (ptr) { inorder(ptr->left, outputFile); outputFile << ptr->data; cout << ptr->data; inorder(ptr->right, outputFile); } } /* postordertree traversal */ void postorder(Node* ptr, ofstream& outputFile){ //print left, right, visit if (ptr) { postorder(ptr->left, outputFile); postorder(ptr->right, outputFile); outputFile << ptr->data; cout << ptr->data; } } //Description: Print tree in level order //Pre-condition: root node as input //Post-condition: prints tree void printTree(Node* node, ofstream& outputFile) { outputFile << "\nTree: " << endl; cout << "\nTree: " << endl; int treeHeight = height(node); for (int i = 0; i < treeHeight; i++){ outputFile << "\t"; cout << "\t"; printCurrentLevel(node, i, outputFile); outputFile << endl; cout << endl; } } //Description: Print node at current level //Pre-condition: root node as input, level (int), output file //Post-condition: prints tree void printCurrentLevel(Node* node, int level, ofstream& outputFile) { if (node != NULL) { if (level == 0) { outputFile << node->data << " "; cout << node->data << " "; } else if (level > 0) { //recursively print left and right node, decrementing level to 0 printCurrentLevel(node->left, level-1, outputFile); printCurrentLevel(node->right, level-1, outputFile); } } else { return; } } //Description: function to get height of tree //Pre-condition: root node as input //Post-condition: returns height of tree int height(Node* node) { if (!node) { return 0; } //get the max height between right and left subtrees, add 1 for current node int treeHeight = max(height(node->left), height(node->right)) + 1; return treeHeight; } //Description: Function to convert char to int //Pre-condition: char read //Post-condition: returns converted int int convertToDigit(char charRead) { //Convert numbers in expression to int by subtracting '0' if (isdigit(charRead)) { return charRead - '0'; } //Convert alphabets in expression to int by subtracting 'A' and adding 1 else { return charRead - 'A' + 1; } } //Description: Function to evaluate prefix expression //Pre-condition: prefix expression (string), output file //Post-condition: prints evaluation operations and result void prefixEvaluation(string expression, ofstream& outputFile) { stack<string> stringStack; stack<double> resultStack; string operand1; string operand2; double oper1; double oper2; outputFile << "\nEvaluation: " << endl; cout << "\nEvaluation: " << endl; for (int i = expression.length() -1; i >= 0; i--) { char charRead = expression[i]; if (isOperand(charRead)) { stringStack.push(string(1, charRead)); int digit = convertToDigit(charRead); resultStack.push(digit); } else if (isOperator(charRead)) { operand1 = stringStack.top(); stringStack.pop(); oper1 = resultStack.top(); resultStack.pop(); operand2 = stringStack.top(); stringStack.pop(); oper2 = resultStack.top(); resultStack.pop(); stringStack.push(charRead + operand1 + operand2); outputFile << "\t " << charRead + operand1 + operand2; cout << "\t " << charRead + operand1 + operand2; //Evaluate expression if (charRead == '+') { resultStack.push(oper1 + oper2); } if (charRead == '-') { resultStack.push(oper1 - oper2); }if (charRead == '*') { resultStack.push(oper1 * oper2); } if (charRead == '/') { if (oper2 == 0) { cout << " = ERROR (Division by zero not allowed)" << endl; outputFile << " = ERROR (Division by zero not allowed)" << endl; return; } resultStack.push(oper1 / oper2); } outputFile << " = " << resultStack.top() << endl; cout << " = " << resultStack.top() << endl; } } //prints result of evaluation outputFile << "Final Result: " << resultStack.top() << endl; cout << "Final Result: " << resultStack.top() << endl; }
4fd54dde223a8ee8e04ca05c37bf14eec33d0e8a
dbb31defecc286f88d69082f0710d47c2fbce74f
/common/Point3D.hh
e4d7fbbe4c0eda394cc89178ea0b6eaf9bbc9db8
[]
no_license
gRiverOS/2DSimulationRefactoring
dffbce0592d4fb0742f4a0f1a7f7cad299d2e68c
fa7b7b2d51b2cf6e2dd162117776b6926743291f
refs/heads/master
2020-05-19T08:03:11.282683
2015-08-07T03:00:17
2015-08-07T03:00:17
39,927,226
0
0
null
null
null
null
UTF-8
C++
false
false
1,479
hh
Point3D.hh
#ifndef POINT3D_HH_ #define POINT3D_HH_ #include <stdlib.h> #include <iostream> #include "Point.hh" class Point3D : public Point{ private: double x; double y; double z; public: Point3D(); Point3D(double n_x, double n_y, double n_z); Point3D(Point3D * v); double getX() const; void setX(double x); double getY() const; void setY(double y); double getZ() const; void setZ(double z); double length(); virtual ~Point3D() { }; virtual Point3D * operator+(const Point * v) { return new Point3D( (x + dynamic_cast<const Point3D*>(v)->getX()), (y + dynamic_cast<const Point3D*>(v)->getY()), (z + dynamic_cast<const Point3D*>(v)->getZ()) ); }; virtual Point3D * operator-(const Point * v) { return new Point3D( (x - dynamic_cast<const Point3D*>(v)->getX()), (y - dynamic_cast<const Point3D*>(v)->getY()), (z - dynamic_cast<const Point3D*>(v)->getZ()) ); }; virtual Point3D * operator*(double w) { return new Point3D((x * w), (y * w), (z * w)); }; virtual Point3D * operator/(double w) { return new Point3D((x / w), (y / w), (z / w)); }; virtual Point3D * operator=(const Point * v) { x = dynamic_cast<const Point3D*>(v)->getX(); y = dynamic_cast<const Point3D*>(v)->getY(); z = dynamic_cast<const Point3D*>(v)->getZ(); return this; }; virtual string toString() { stringstream s; s << x << " " << y << " " << z; return s.str(); }; }; #endif /* POINT3D_HH_ */
62b816d8a863a4ab3d54681e48322c3abd358778
703cc1b788895b98331f52dc6e87ac6ec1910e35
/src/psi/pat.cpp
ef64710f6531221375be64314255b7b99a75c887
[]
no_license
ioxuy/dvb_si_psi_parser
1509942fb116ec23cb0ded94fffa24788864526b
75f8fb87734ff6211e895356d4e1f8087c6fbf54
refs/heads/master
2021-06-04T22:13:06.628804
2016-09-08T05:17:47
2016-09-08T05:17:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,367
cpp
pat.cpp
/* *Original Author: shko */ #include <pat.h> PAT::Program::Program(const int program_number, const int program_map_PID) { InitInternalData(); this->program_number = program_number; this->program_map_PID = program_map_PID; } int PAT::Program::getProgram_map_PID() { return program_map_PID; } int PAT::Program::getProgram_number() { return program_number; } void PAT::Program::InitInternalData() { program_number = 0; program_map_PID = 0; } PAT::PAT(const char *raw_data) : TableSectionExtendedSyntax(raw_data, 0) { InitInternalData(); SetInternalData(raw_data); } PAT::PAT(const char *raw_data, const int siSpec) : TableSectionExtendedSyntax(raw_data, siSpec) { InitInternalData(); SetInternalData(raw_data); } PAT::~PAT() { for(PATProgramIterator i = programVector.begin(); i != programVector.end(); ++i) delete *i; } std::vector<PAT::Program*> PAT::buildProgramVector(const char* data, const int i, const int programInfoLength) { std::vector<Program*> r = std::vector<Program*>(); int t = 0; while (t < programInfoLength) { Program* p = new Program(Utils::getInt(data, i + t, 2, MASK_16BITS), Utils::getInt(data, i + t + 2, 2, MASK_13BITS)); t += 4; r.push_back(p); } return r; } int PAT::getTransportStreamId() { return getTableIdExtension(); } int PAT::getNumberOfPrograms() { return programVector.size(); } int PAT::getProgramNumber(const int i) { #if 1 if(i >= programVector.size()) return 0; Program *p = programVector.at(i); return p->getProgram_number(); #else return (Utils::getUnsignedByte(rawData[8 + (i*4)]) *256) + Utils::getUnsignedByte(rawData[9 + (i*4)]); #endif } int PAT::getProgramMapPID(const int i) { #if 1 if(i >= programVector.size()) return 0; Program *p = programVector.at(i); return p->getProgram_map_PID(); #else return ((Utils::getUnsignedByte(rawData[10 + (i*4)])& 0x1F)*256) + Utils::getUnsignedByte(rawData[11 + (i*4)]); #endif } std::vector<PAT::Program*>* PAT::getProgramVector() { return &programVector; } void PAT::InitInternalData() { programVector.clear(); } void PAT::SetInternalData(const char* raw_data) { const int programsLength = sectionLength - 9; programVector = buildProgramVector(raw_data, 8, programsLength); }
ab6a97e197b2862e2e1ebae8713da2fcd3124957
f93a873c48905f0f9559e376ff9f74ca78bb5058
/koopa.h
0f4f05fa37ad6043f17f5fdcff3ed278bd19566a
[]
no_license
Flirre/game-engine
eed1b5a109f5f03219900f0b1427b0ed48e9e203
15ad824c90d74f96bb211a3220c998d234ebf55e
refs/heads/master
2020-03-27T09:16:40.817782
2019-05-19T16:29:00
2019-05-19T16:29:00
146,327,193
0
0
null
null
null
null
UTF-8
C++
false
false
3,367
h
koopa.h
#pragma once class KoopaInputComponent : public InputComponent { public: void Create(AvancezLib* system, GameObject * go, std::set<GameObject*> * game_objects, Direction direction) { InputComponent::Create(system, go, game_objects, KOOPA_SPEED, direction); go->direction = direction; } virtual void Receive(Message m) { if (m == IDLE) { Stop(); } } void Turn_Around() { Stop(); if (go->direction == RIGHT) { WalkLeft(); } else { WalkRight(); } } void Update(float dt) { if (go->direction == RIGHT) { WalkRight(); } else { WalkLeft(); } } }; class KoopaCollideComponent : public CollideComponent { public: void Create(AvancezLib* system, GameObject * go, std::set<GameObject*> * game_objects, ObjectPool<GameObject> * coll_objects) { CollideComponent::Create(system, go, game_objects, coll_objects); } void Update(float dt) { { for (auto i = 0; i < coll_objects->pool.size(); i++) { GameObject * go0 = coll_objects->pool[i]; if (go0->enabled && go != go0) { if (boundingBoxCollision(go, go0)) // check for any AABB collision { ResolveCollision(go, go0, dt); if (!go0->map_object && (abs(go->verticalPosition - go0->verticalPosition) < 2)) { go->Receive(TURN_AROUND); go0->Receive(TURN_AROUND); } } } } } } }; class KoopaPhysicsComponent : public PhysicsComponent { public: void CheckBounds(unsigned int WORLD_WIDTH, GameObject* go) { if (go->horizontalPosition > (WORLD_WIDTH - go->spriteWidth / 2)) go->horizontalPosition = 0; if (go->horizontalPosition < -(go->spriteWidth / 2)) go->horizontalPosition = WORLD_WIDTH - go->spriteWidth / 2; // check if koopa is at same height as pipe if (go->verticalPosition > 190) { // teleport to corresponding top pipe if (go->horizontalPosition < 16) { go->horizontalPosition = 32; go->verticalPosition = 10; go->Receive(TURN_AROUND); } if (go->horizontalPosition > (WORLD_WIDTH - 32)) { go->horizontalPosition = (WORLD_WIDTH - 48); go->verticalPosition = 10; go->Receive(TURN_AROUND); } } } void Update(float dt) { PhysicsComponent::UpdatePosition(dt, go, this->GetGravity()); CheckBounds(this->GetWorldWidth(), go); } }; class Koopa : public GameObject { public: int lives; virtual ~Koopa() { SDL_Log("Koopa::~Koopa"); } virtual void Init() { SDL_Log("Koopa::Init"); GameObject::Init(); lives = 3; } virtual void Receive(Message m) { onGround = false; if (m == HIT) { verticalVelocity = -100.f; RemoveLife(); if (lives < 0) { Send(HIT); this->enabled = false; } } if (m == ON_MAP) { verticalVelocity = 0; onGround = true; SetSprites(GetSpriteSet(0)); } if (m == NOT_ON_MAP) { onGround = false; } if (m == JUMP) { SetSprites(GetSpriteSet(1)); } if (m == RUNNING) { if (onGround) { SetSprites(GetSpriteSet(2)); } } if (m == IDLE) { SetSprites(GetSpriteSet(0)); } if (m == TURN_AROUND) { KoopaInputComponent *koopa_input = (KoopaInputComponent*)(InputComponent*)this->components.at(0); //InputComponent is added at place 0 in the list of Components. koopa_input->Turn_Around(); } } void RemoveLife() { lives--; //SDL_Log("remaining lives %d", lives); } };
f0e0e8051c909449f0eec7a8d7a4c00202903d7f
29ac0c9c6b5863d71b986dd3ec7cb19b4cfde1ef
/utilsCtrl/editDistanceProc/EditDistanceProc.h
2fbdd4fddd14eccf6d0e17a6cab2cd93728d3396
[]
no_license
mayurou/caiss
92dcdf1077bef4928763261cb2415805f1534401
aab39d7b7844a68b9c194f09b3aaef7ab695616b
refs/heads/master
2023-07-18T16:07:38.297135
2021-09-11T01:54:35
2021-09-11T01:54:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,009
h
EditDistanceProc.h
// // Created by Chunel on 2020/7/4. // 计算两个字符串的编译距离,用于去重 // #ifndef CAISS_EDITDISTANCEPROC_H #define CAISS_EDITDISTANCEPROC_H #include <vector> #include "../UtilsProc.h" using namespace std; class EditDistanceProc : public UtilsProc { public: /** * 是否超过编辑距离 * @param fst * @param snd * @param dist * @return */ static bool BeyondEditDistance(const string &fst, const string &snd, const unsigned int dist) { return (EditDistanceProc::calc(fst, snd) > dist); } /** * 计算两个数据之间的编辑距离 * @param fst * @param snd * @return */ static unsigned int calc(const string &fst, const string &snd) { string longStr = fst; string shortStr = snd; if (longStr.length() < shortStr.length()) { swap(longStr, shortStr); // 确保长的在第一个 } int longLen = (int)longStr.size() + 1; // 用于初始化的值,均加一操作 int shortLen = (int)shortStr.size() + 1; vector<int> vecBefore(shortLen, 0); vector<int> vecCur(shortLen, 0); for (int i = 0; i < longLen; i++) { for (int j = 0; j < shortLen; j++) { if (i == 0) { vecCur[j] = j; } else if (j == 0) { vecCur[j] = i; } else { if (longStr[i-1] == shortStr[j-1]) { vecCur[j] = vecBefore[j-1]; } else { vecCur[j] = std::min(std::min(vecBefore[j], vecCur[j-1]), vecBefore[j-1]) + 1; } } } vecBefore = vecCur; // 记录上一条信息 } return (unsigned int)vecCur.back(); // 返回最后一个数据 } private: explicit EditDistanceProc() = default; ~EditDistanceProc() override = default; }; #endif //CAISS_EDITDISTANCEPROC_H
d27e2d7a7a108c079eeb878d5db938e0570c5c85
3fc28213605b14ed9970e1834fe5064a97a213b9
/dataloaders/new_MBD/cpp/wrap_py2.cpp
3d671a39624d64a96bd34115ef50cedfeba52d41
[]
no_license
onvungocminh/Dahu_CNN_IOG
fc670f1bfc4134b1abf58ab165276bccf7ce1476
8c7640133edfe0f4cb25cbff81af4f4c2985e860
refs/heads/master
2023-02-01T19:28:46.549365
2020-12-18T11:59:26
2020-12-18T11:59:26
322,581,698
0
0
null
null
null
null
UTF-8
C++
false
false
124
cpp
wrap_py2.cpp
#include "MBD_distance.cpp" PyMODINIT_FUNC initMBD(void) { (void) Py_InitModule("MBD", Methods); import_array(); }
d56b8b2d88c63d901bb7a9cea9436423531d4b32
a3f664e0b17c1b7cf718c75e0f7300d3485d724f
/engine/GZJTextureManager.cpp
83c4bf1ec109fc0e353dc375f104057311afc3b5
[]
no_license
DarkTong/engine
7842eeddb216983a62f5a376e4ddf77cb7e8e45b
f15aa4f4ce180bf224c0f57a0d8a233589231867
refs/heads/master
2021-04-12T08:46:32.666706
2018-05-04T03:09:20
2018-05-04T03:09:20
126,551,732
0
0
null
null
null
null
GB18030
C++
false
false
1,113
cpp
GZJTextureManager.cpp
#include "GZJTextureManager.h" namespace GZJ_ENGINE { GZJTextureManagerPtr GZJTextureManager::_instance = nullptr; GZJTextureManager::GZJTextureManager() { assert(_instance == nullptr); } GZJTextureManager::~GZJTextureManager() { } void GZJTextureManager::StartUp() { resMap.clear(); resHandleMap.clear(); resHandle = 0; _resRoot = ENGINE_SRC_ROOT_PATH + "\\texture"; } void GZJTextureManager::ShutDown() { resMap.clear(); resHandleMap.clear(); resHandle = 1; } void GZJTextureManager::PrepareAll() { // 外部不调用这个函数 cout << ("Can't use this funciotn in Texture Manager!") << endl; return; } void GZJTextureManager::LoadAll() { // 外部不调用次方法 cout << ("Can't use this funciotn in Texture Manager!") << endl; return; } void GZJTextureManager::UnLoadAll() { cout << ("Can't use this funciotn in Texture Manager!") << endl; return; } GZJResource* GZJTextureManager::createImp(const String & name) { GZJResourceManager* mgr = static_cast<GZJResourceManager*>(this); return (new GZJTexture(mgr, name, resHandle)); } }
34e3bb435d921eb334de9a2c8d380af94e11c934
568ac7b7cd7d2befaceecdf2496855c19c31c900
/welcomedialog.cpp
6e41ad67a8ff3a113e3a8378fa57c4497c0babf3
[ "MIT" ]
permissive
HarukiMoriarty/QtMall
86c70fcb19c2b4f5f153d56d89b837958b33782c
e135ab0f766ffa9cd595d3332f642c72aac121ee
refs/heads/master
2022-01-16T02:52:54.008192
2019-03-11T18:42:12
2019-03-11T18:42:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,069
cpp
welcomedialog.cpp
#include "welcomedialog.h" WelcomeDialog::WelcomeDialog(QWidget *parent) : QWidget(parent) { nameLabel = new QLabel(tr("name:")); nameLineText = new QLineEdit(); passwordLabel = new QLabel(tr("password:")); passwordLineText = new QLineEdit(); passwordLineText->setEchoMode(QLineEdit::Password); logBtn = new QPushButton(tr("Log in")); boxVH1 = new QHBoxLayout; boxVH1->addWidget(nameLabel); boxVH1->addWidget(nameLineText); boxVH1->addWidget(passwordLabel); boxVH1->addWidget(passwordLineText); boxVH1->addWidget(logBtn); passwordConfirmLabel = new QLabel(tr("confirm your password:")); QLineEdit *passwordConfirm = new QLineEdit(); QPushButton *regBtn = new QPushButton(tr("Register")); QHBoxLayout *boxVH2 = new QHBoxLayout; boxVH2->addWidget(passwordConfirmLabel); boxVH2->addWidget(passwordConfirm); boxVH2->addWidget(regBtn); QVBoxLayout *boxV = new QVBoxLayout; boxV->addLayout(boxVH1); boxV->addLayout(boxVH2); setLayout(boxV); }
56bb566ac278f53081b55890ad8d3e5d97db28cf
e85338f6d8666eb476698de5025c742b9b838a50
/ojs/cf/663C.cpp
b3595f8580301b279f00d26a8657cbc0a9dc2171
[]
no_license
yancouto/competitive-programming
8104bb3c45e0b385c2abb4cfcac14c35cce0619e
ac849e3aa858eea56b0aa6b7eb93e9a9e70f9475
refs/heads/master
2022-10-19T11:29:46.932829
2022-10-07T00:16:43
2022-10-07T00:16:43
66,641,933
7
0
null
null
null
null
UTF-8
C++
false
false
1,688
cpp
663C.cpp
#include <bits/stdc++.h> using namespace std; #define fst first #define snd second typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; #define pb push_back const ll modn = 1000000007; inline ll mod(ll x) { return x % modn; } #ifdef ONLINE_JUDGE # define lld I64d # define debug(args...) {} #else # define debug(args...) fprintf(stderr, args) #endif const int N = 112345; int S[N], sz[N]; int find(int i) { if(S[S[i]] != S[i]) S[i] = find(S[i]); return S[i]; } void join(int a, int b) { if((a = find(a)) == (b = find(b))) return; if(sz[a] < sz[b]) swap(a, b); sz[a] += sz[b]; S[b] = a; } int a[N], b[N], c[N], r[N]; vector<pii> adj[N]; int seen[N], n, m, t; void dfs(int u, int flip, int want) { r[u] = flip; seen[u] = t; for(pii a : adj[u]) { int v = a.fst, e = a.snd; if(seen[v] == t) continue; dfs(v, (c[e] ^ flip) != want, want); } } bool ok(int u, int want) { if(seen[u] == t) return true; seen[u] = t; for(pii a : adj[u]) { int v = a.fst, e = a.snd; if((c[e] ^ r[::a[e]] ^ r[b[e]]) != want) return false; if(!ok(v, want)) return false; } return true; } bool go(int u, int flip, int want) { t++; dfs(u, flip, want); t++; return ok(u, want); } int main() { int i, j; char c; scanf("%d %d", &n, &m); for(i = 0; i < n; i++) S[i] = i, sz[i] = 1; for(i = 0; i < m; i++) { scanf("%d %d %c", &a[i], &b[i], &c); a[i]--; b[i]--; ::c[i] = c == 'R'; join(a[i], b[i]); adj[a[i]].pb(pii(b[i], i)); adj[b[i]].pb(pii(a[i], i)); } for(j = 0; j < 2; j++) { for(i = 0; i < n; i++) if(i == find(i)) { if(go(i, 0, j) || go(i, 1, j)) continue; } if(i == n) break; } if(j == 2) puts("-1"); // fazer menor }
9771798be6f75c479c3f12c73db94a005ba58c8d
328f58958dee676e04f7754172251b62b93b77b9
/Downloads-Genesis/Cpp-Assessment/99002539/trip.h
0328a4a40802c1567623d61d091de2079cf7642d
[]
no_license
99002500/Desktop-Genesis
957e6ed41b694757b2ecd74416a3c177078a71c9
da3ccf82d7844932a3f66a3f4710c9ac2d149ea2
refs/heads/main
2023-01-09T15:51:26.077219
2020-11-12T11:22:34
2020-11-12T11:22:34
312,192,379
0
0
null
null
null
null
UTF-8
C++
false
false
464
h
trip.h
#ifndef TRIP_H_INCLUDED #define TRIP_H_INCLUDED #include<iostream> const int speed = 500; // 500 miles per hour const int price = 10; // 10 rupees per mile class Trip { std::string m_SourceCity; std::string m_DestinationCity; public: Trip(); Trip(std::string,std::string); std::string getOrigin(); std::string getDestination(); virtual double computeFare()=0; virtual double computeTravelTime()=0; }; #endif // TRIP_H_INCLUDED
c02075cde99697bf1fa56fb11a18fe62ec5d634b
b2955406769855ab42617d59805ef643d860db38
/OOP-Projects/ATM/include/Conta/ContaPoupanca.h
842307f7742b8e1d12f51de188ed79c85d217100
[]
no_license
lucasbivar/object-oriented-programming
46ded50a73b92abb7f2d34136499f27a84269769
11a6367404985cd4c384ab1997d07db64c455e78
refs/heads/main
2023-08-18T14:10:28.503755
2021-10-15T00:24:30
2021-10-15T00:24:30
380,388,577
0
1
null
null
null
null
UTF-8
C++
false
false
617
h
ContaPoupanca.h
#ifndef CONTA_POUPANCA_H #define CONTA_POUPANCA_H #include <string> using std::string; #include "Conta.h" #include "../Pessoa/Pessoa.h" class ContaPoupanca : public Conta { public: ContaPoupanca(Pessoa* p=nullptr, string prefixoConta="", string prefixoPessoa="", int dataDeAniversario=10 , double saldo=0, string numeroDaConta="", list<Transacao> transacoes=list<Transacao>()); virtual void imprimirExtrato() const; virtual void mostrarConta() const; void setDiaDeAniversario(int dia); int getDiaDeAniversario() const; private: int diaDeAniversario; }; #endif
74d8940ee9f826f0f0a9241f34b9417db62faccd
ca2e65ad96ce8022d423c3e83cfef79b2ce53a7f
/src/transport/IBTransport.cpp
28089548731567cce29204118f777a1553da605f
[]
no_license
bharurn/MiMiC_CommLib_Test
8196054960aaa04a6f9452504f4b708c3ac053b8
7c75a8210c87db8bccc203bd168543666ce957f2
refs/heads/master
2022-11-09T17:55:22.632369
2020-06-18T10:46:26
2020-06-18T10:46:26
272,648,350
0
0
null
null
null
null
UTF-8
C++
false
false
66
cpp
IBTransport.cpp
// // Created by vbolnykh on 6/4/18. // #include "IBTransport.h"
5be42a5cc2aef3ab871f4a71fbfa02f0adf2df6a
7c82cb038616b804274af51fd7f9521e9195daaa
/Cylinder.cpp
dd0d63bd992437e9b4c0ebed3e9f390e7e6a0b35
[]
no_license
ahmetYilmaz88/C-plus-plus
b63bb7813dbdd3bd421720f70100a34095fd60ce
93163e053dd60d5dcd53884f9bd5fc548821fd3b
refs/heads/main
2023-01-18T19:37:08.363441
2020-12-03T04:27:54
2020-12-03T04:27:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,164
cpp
Cylinder.cpp
/// @author Ahmet Yilmaz /// I pledge my word of honor that I have abided /// by the CSN Academic Integrity Policy while completing /// this assignment. /// @file AhmetYilmazCit133_pa11.cpp /// @version The date is: 2020-06-13 /// @brief The program uses various number of functions /// and two class /// class names are Circle and Cylinder /// it has 2 constructors without parameter, 1 for each class /// Circle class: /// first function sets the value for radius according to the parameter /// second function returns the radius value to the parameter /// third function returns the diameter /// fourth function calculates and returns the area of a circle /// fifth function calculate and return perimeter /// Cylinder class: /// first function sets the value for height according to the parameter /// second function returns the height value to the parameter /// third function calculates and returns the area of a cylinder /// fourth function calculates and returns the volume of a cylinder /// @note Time taken to develop, write, test and debug /// is less than 4 hour. // include the necessary headers #include <iostream> #include <string> #include <time.h> #include <cmath> #include <iomanip> #include "Circle.h" #include "Cylinder.h" using namespace std; Cylinder::Cylinder() //default - no arguments { height = 0;// Sets height = 0 in default constructor }//end of default constructor // constructor with no parameter void Cylinder:: set_height(double h)//function to set height { if(h <= 0) { height = 1; } else { height = h; }//end of set_height() } /// sets the values of attribute based on its parameter /// parameters /// @ return - none double Cylinder:: area() const// function area { return (perimeter() * (get_radius() + height)) / 144; }//end of area() /// sets the values of attribute based on its parameter /// parameters /// @return - area double Cylinder:: volume() const// function volume { return (Circle::area() * height) / 1728 * 28.31685; }//end of volume() /// sets the values of attribute based on its parameter /// parameters /// @return - volume
4375e34241c081322b35dcacc1a583a79a535dd3
02c855e1c35fa756b01d3c857307b3b695b54de8
/MicroChat/gen-cpp/UserService_server.skeleton.cpp
7ede973fbb9aed44a45fa414f251444809c8fc69
[]
no_license
KeithStoke/ECE578_Final_Project_MicroChat
538633a5ba1a561e01a4caf0c0a7264cbc74e7d3
176c246c6d9aec26727ee981f3d56a10a56ef134
refs/heads/master
2023-04-14T16:59:06.284402
2021-04-23T01:55:22
2021-04-23T01:55:22
343,955,735
1
1
null
2021-04-23T01:55:22
2021-03-03T00:47:08
Lua
UTF-8
C++
false
false
2,005
cpp
UserService_server.skeleton.cpp
// This autogenerated skeleton file illustrates how to build a server. // You should copy it to another filename to avoid overwriting it. #include "UserService.h" #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/server/TSimpleServer.h> #include <thrift/transport/TServerSocket.h> #include <thrift/transport/TBufferTransports.h> using namespace ::apache::thrift; using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::server; using namespace ::microchat; class UserServiceHandler : virtual public UserServiceIf { public: UserServiceHandler() { // Your initialization goes here } void ping(std::string& _return, const int32_t id) { // Your implementation goes here printf("ping\n"); } void Login(std::string& _return, const std::string& username, const std::string& password) { // Your implementation goes here printf("Login\n"); } void CreateUser(std::string& _return, const std::string& username, const std::string& name, const std::string& password) { // Your implementation goes here printf("CreateUser\n"); } void GetUserID(std::string& _return, const std::string& username) { // Your implementation goes here printf("GetUserID\n"); } void Logout(std::string& _return, const std::string& username) { // Your implementation goes here printf("Logout\n"); } }; int main(int argc, char **argv) { int port = 9090; ::std::shared_ptr<UserServiceHandler> handler(new UserServiceHandler()); ::std::shared_ptr<TProcessor> processor(new UserServiceProcessor(handler)); ::std::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port)); ::std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); ::std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); server.serve(); return 0; }
2f181c82bdd2641e6595d03d3347ad7ce2b502d1
80a83faaf11d8755d9963b0f805fe1688c1ad08d
/boj/11062.cpp
d3976babfa484fd51d96b58890bc7b48cf4efa88
[]
no_license
0913vision/Study
c594bf13176f95218235e914184a670e4a77647d
7c1fe1f5b40815b658e79784ae4fc95a2659cf46
refs/heads/master
2022-07-06T10:48:23.867310
2022-06-30T21:46:21
2022-06-30T21:46:21
224,319,553
0
0
null
null
null
null
UTF-8
C++
false
false
2,421
cpp
11062.cpp
//interesting card game! #include <iostream> #include <algorithm> #include <memory.h> #define LEFT 0 #define RIGHT 1 using namespace std; int *card; int table[1010][1010]; int ctable[1010][1010]; int n; int dp(int L, int R) { int cl, cr, el, er, ecl, ecr; if(table[L][R] > -1) return table[L][R]; if(L>R) table[L][R] = 0; else if(L==R) { table[L][L] = card[L]; ctable[L][L] = LEFT; } else if(R-L==1) { if(card[L]<card[R]) { ctable[L][R] = RIGHT; table[L][R] = card[R]; } else { ctable[L][R] = LEFT; table[L][R] = card[L]; } } else { cl = dp(L+1, R); cr = dp(L, R-1); // cr = 명우가 L, R-1 카드에서 최선으로 보는 이득 if(cl<cr) { // 오른쪽 고르면 명우가 이득보는게 커짐 // 그럼 근우는 왼쪽을 골라야하고 if(ctable[L+1][R] == LEFT) { // 근우가 왼쪽을 골랐을 때 명우가 고른 카드가 왼쪽이라면 table[L][R] = card[L] + dp(L+2,R); // 왼쪽카드 + 나머지에서 최선 } else { // 근우가 왼쪽을 골랐을 때 명우가 고른 카드가 오른쪽이라면 table[L][R] = card[L] + dp(L+1,R-1); // 왼쪽카드 + 나머지에서 최선 } ctable[L][R] = LEFT; // 근우 왼쪽고름 } else { // 왼쪽을 고르면 명우가 이득보는게 커짐 // 그럼 근우는 오른쪽을 골라야하고 if(ctable[L][R-1] == LEFT) { //근우가 오른쪽을 골랐을 때 명우가 고른 카드가 왼쪽이라면 table[L][R] = card[R] + dp(L+1, R-1); // 오른쪽카드 + 나머지에서 최선 } else { // 근우가 오른쪽을 골랐을 때 명우가 고른 카드가 오른쪽이라면 table[L][R] = card[R] + dp(L, R-2); // 오른쪽카드 + 나머지에서 최선 } ctable[L][R] = RIGHT; // 근우 오른쪽 고름 } } return table[L][R]; } int main() { int t, **gdp, **mdp, gs; cin >> t; while(t--) { cin >> n; card = new int[n]; for(int i=0;i<n;i++) { cin >> card[i]; } memset(table, -1, sizeof(table)); cout << dp(0,n-1) << "\n"; delete [] card; } return 0; }
8fabb92961335044b4c6899be36ecfd7afb1c81a
86dd3706c22680995a92ff92c86ac33d58e55f30
/lib/ADC_Stream_processing/ADC_Stream_proc/ADC_Stream_proc.ino
8f3941ed5edad26898d33a52e0fc01997c04dd65
[]
no_license
davidwkleber/webArduino
eec4f7c6e728ab722a086c317553d059a9368369
7a81968794980f8b09748c27706e4b995e4579a9
refs/heads/master
2020-05-15T21:17:38.163839
2015-04-01T10:36:48
2015-04-01T10:36:48
23,706,715
0
0
null
null
null
null
UTF-8
C++
false
false
885
ino
ADC_Stream_proc.ino
// #define FASTADC 1 // defines for setting and clearing register bits #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif int readA0; int readA1; int readA2; //int readA3; //int readA4; //int readA5; long nowTime=0; long lastTime=0; long deltaTime=0; int readAnalog[3]; //int readPort[] = {0,1,2} int vConv[]={16,3,11}; long buad = 115200; void setup() { #if FASTADC // set prescale to 16 sbi(ADCSRA,ADPS2); cbi(ADCSRA,ADPS1); cbi(ADCSRA,ADPS0); #endif Serial.begin(buad); //Serial.println("Ready"); } void loop() { nowTime = micros(); deltaTime = nowTime - lastTime; if (deltaTime>=1600) { for (int i=0; i<3;i++) { readAnalog[i] = analogRead(i)*vConv[i]; Serial.print(readAnalog[i],DEC); Serial.print(","); } Serial.println(deltaTime); lastTime=nowTime; } }
86a1110c80f725b4ba3ba5fed7027f8189aa6620
9147e7be8697621c2b47c8d1e07d6bfa1b98c38c
/calculator/Calc.h
35d28f8aeeda11728cd19da5444b5066b8ffbf6d
[]
no_license
ljian1992/calculator
e09eebe3d97e5607480d70a106ea1eee2db40d17
abff2de6fa438efb801e9a176dcf2891d236e3b9
refs/heads/master
2021-01-15T23:02:13.255596
2015-02-11T14:35:50
2015-02-11T14:35:50
30,637,279
1
1
null
null
null
null
GB18030
C++
false
false
1,738
h
Calc.h
#ifndef _CALC_H_ #define _CALC_H_ #include <string> #include "SymbolTable.h" #include "FunctionTable.h" #include "Storage.h" #include "Serial.h" class Parser; class Calc : public Serializable { friend class Parser; //使到Parser类方便的访问Calc的私有成员 private: //-->由于定义了SymbolTable类,因此需要把它的头文件包含起来, Calc类负责symTbl_的生命周期,因此是两种之间是组合关系, //由于Storage的构造函数需要用到SymbolTable的引用,故声明顺序SymbolTable在Storage的前面 SymbolTable symTbl_; FunctionTable functionTbl_; //由于函数表中的函数是固定的,因此把函数表的构造放在符号表的前面 Storage storage_; //变量的个数是不固定的 unsigned int FindSymbol(const std::string& str) const; //在符号表中查找str符号 unsigned int AddSymbol(const std::string& str); //往符号表中添加符号 Storage& GetStorage(); //获取stroage_的引用 bool IsFunction(unsigned int id) const; //判断是否是函数 PtrFun GetFunction(unsigned int id) const; //获取函数指针 double GetVariableValue(unsigned int id) const; //获取变量的值 public: Calc() : symTbl_(), functionTbl_(symTbl_), storage_(symTbl_) {} void ListFun() const; //打印函数表 void ListVariable() const; //打印变量表 virtual void Serialize(Serializer& out) const; //将函数表和变量表中的内容存储到文件中 virtual void DeSerialize(DeSerializer& in); //从文件中加载内容到符号表和变量表中 }; #endif //_CALC_H_
2805eea3a2c5a204b773b90ba49c2c427a52f5b3
8bc5715e9fb0a18cb4c70a271b22dc108fdfe4f8
/servotester_final_mit_lcd_4884_shield_011__beta/c_receiver_test.ino
95c07f38275faba58fa5bc4c66b53b81caacad70
[]
no_license
ossilampe/PCB-Projekte
f2c8fd85ee67a5c2eace2e35d7f48481efd394b3
f07ad613103d3a10ed10fa0b44190b0359f76f91
refs/heads/master
2020-05-29T15:11:18.245514
2017-10-30T17:50:03
2017-10-30T17:50:03
60,724,086
0
0
null
null
null
null
UTF-8
C++
false
false
8,591
ino
c_receiver_test.ino
void rxtest() { duration1 = pulseIn(pin1, HIGH, time); //reads rx channel in if (duration1 == 0){pwmin1 = 1500;} // if no input set to 1500us else {pwmin1 = duration1;} duration2 = pulseIn(pin2, HIGH, time); if (duration2 == 0){pwmin2 = 1500;} else {pwmin2 = duration2;} duration3 = pulseIn(pin3, HIGH, time ); if (duration3 == 0){pwmin3 = 1500;} else {pwmin3 = duration3;} duration4 = pulseIn(pin4, HIGH, time); if (duration4 == 0){pwmin4 = 1500;} else {pwmin4 = duration4;} duration5 = pulseIn(pin5, HIGH, time); //reads rx channel in if (duration5 == 0){pwmin5 = 1500;} // if no input set to 1500us else {pwmin5 = duration5;} duration6 = pulseIn(pin6, HIGH, time); if (duration6 == 0){pwmin6 = 1500;} else {pwmin6 = duration6;} duration7 = pulseIn(pin7, HIGH, time ); if (duration7 == 0){pwmin7 = 1500;} else {pwmin7 = duration7;} duration8 = pulseIn(pin8, HIGH, time); if (duration8 == 0){pwmin8 = 1500;} else {pwmin8 = duration8;} //lcd.print("12345678901234"); lcd.LCD_write_string(0, 0, "Receiver Test", MENU_HIGHLIGHT); //stick left lcd.LCD_write_string(0, 2, "1", MENU_NORMAL); itoa(pwmin1, pwm1, 10); lcd.LCD_write_string(12, 2 , pwm1 , MENU_NORMAL); // line = zeile 0-5 int linea = 2; int lineb = 3; int linec = 4; int lined = 5; int x = 1500; //center int y = 25; //step //build this array to show graph float puls[] ={x-20*y,x-19*y,x-18*y,x-17*y,x-16*y,x-15*y,x-14*y,x-13*y, x-12*y,x-11*y,x-10*y,x-9*y,x-8*y,x-7*y,x-6*y,x-5*y,x-4*y,x-3*y,x-2*y, x-y, x, x+y, x+2*y, x+3*y, x+4*y, x+5*y, x+6*y, x+7*y, x+8*y, x+9*y, x+10*y, x+11*y, x+12*y, x+13*y, x+14*y, x+15*y, x+16*y, x+17*y, x+18*y, x+19*y, x+20*y }; // 16 channels every 20 mhz + 4 channels from F band for (int i=0; i <= 40; i++){ // prints 20 bars if (pwmin1 < x) { if (pwmin1 > puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(low, 1); } if (pwmin1 < puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(high, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(center,1);} if (puls[i] > x ) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(low,1);} if (pwmin1 + y/2 >= puls[i] && pwmin1 - y/2 <= puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(pulse,1);} } if (pwmin1 > x) { if (pwmin1 > x && puls[i] < pwmin1) { lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(high, 1); } if (pwmin1 > puls[i] && puls[i] < x) { lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(low, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(center,1);} if (pwmin1 < puls[i] ) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(low,1);} if (pwmin1 + y/2 >= puls[i] && pwmin1 - y/2 <= puls[i]) { lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(pulse,1);} } if (pwmin1 == x) { lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(low, 1); if (x == puls[i]) {lcd.LCD_set_XY(40+i,linea); lcd.LCD_write_byte(center,1);} } } lcd.LCD_write_string(0, 3, "2", MENU_NORMAL); itoa(pwmin2, pwm2, 10); lcd.LCD_write_string(12, 3, pwm2 , MENU_NORMAL); for (int i=0; i <= 40; i++){ // prints 20 bars if (pwmin2 < x) { if (pwmin2 > puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(low, 1); } if (pwmin2 < puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(high, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(center,1);} if (puls[i] > x ) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(low,1);} if (pwmin2 + y/2 >= puls[i] && pwmin2 - y/2 <= puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(pulse,1);} } if (pwmin2 > x) { if (pwmin2 > x && puls[i] < pwmin2) { lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(high, 1); } if (pwmin2 > puls[i] && puls[i] < x) { lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(low, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(center,1);} if (pwmin2 < puls[i] ) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(low,1);} if (pwmin2 + y/2 >= puls[i] && pwmin2 - y/2 <= puls[i]) { lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(pulse,1);} } if (pwmin2 == x) { lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(low, 1); if (x == puls[i]) {lcd.LCD_set_XY(40+i,lineb); lcd.LCD_write_byte(center,1);} } } lcd.LCD_write_string(0, 4, "3", MENU_NORMAL); itoa(pwmin3, pwm3, 10); lcd.LCD_write_string(12, 4 , pwm3 , MENU_NORMAL); for (int i=0; i <= 40; i++){ // prints 20 bars if (pwmin3 < x) { if (pwmin3 > puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(low, 1); } if (pwmin3 < puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(high, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(center,1);} if (puls[i] > x ) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(low,1);} if (pwmin3 + y/2 >= puls[i] && pwmin3 - y/2 <= puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(pulse,1);} } if (pwmin3 > x) { if (pwmin3 > x && puls[i] < pwmin3) { lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(high, 1); } if (pwmin3 > puls[i] && puls[i] < x) { lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(low, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(center,1);} if (pwmin3 < puls[i] ) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(low,1);} if (pwmin3 + y/2 >= puls[i] && pwmin3 - y/2 <= puls[i]) { lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(pulse,1);} } if (pwmin3 == x) { lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(low, 1); if (x == puls[i]) {lcd.LCD_set_XY(40+i,linec); lcd.LCD_write_byte(center,1);} } } lcd.LCD_write_string(0, 5, "4", MENU_NORMAL); itoa(pwmin4, pwm4, 10); lcd.LCD_write_string(12, 5, pwm4 , MENU_NORMAL); for (int i=0; i <= 40; i++){ // prints 20 bars if (pwmin4 < x) { if (pwmin4 > puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(low, 1); } if (pwmin4 < puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(high, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(center,1);} if (puls[i] > x ) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(low,1);} if (pwmin4 + y/2 >= puls[i] && pwmin4 - y/2 <= puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(pulse,1);} } if (pwmin4 > x) { if (pwmin4 > x && puls[i] < pwmin4) { lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(high, 1); } if (pwmin4 > puls[i] && puls[i] < x) { lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(low, 1);} if (x == puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(center,1);} if (pwmin4 < puls[i] ) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(low,1);} if (pwmin4 + y/2 >= puls[i] && pwmin4 - y/2 <= puls[i]) { lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(pulse,1);} } if (pwmin4 == x) { lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(low, 1); if (x == puls[i]) {lcd.LCD_set_XY(40+i,lined); lcd.LCD_write_byte(center,1);} } } // menu leave start ********************************************* z = analogRead(0); if (z > 140 && z <= 145 ) { goto bailout;} {rxtest();} return; bailout: z = 1023; lcd.LCD_init(); // creates instance of LCD lcd.LCD_clear(); // blanks the display delay(150); welcome(); // menu leave end ********************************************* } /* ( THE END ) */
2ac61856a029dae1018b80192a197825d723ba1a
f1fbb63275ff66a97c8e654cabe0301851e9c317
/VS_CPp/Console/MatrixMultiplication/MatrixMultiplication.cpp
c0040809929568b85d7f09ff5b42cdf3088ff856
[]
no_license
AAMORENKO/EXAMPLS_CPP_JAVA
c0eeb489ef1cb10d14cbb8de565e18f6044d0f61
2a732c503be8ac569505f942328524b86d43791e
refs/heads/master
2021-10-28T22:13:44.605096
2021-10-14T09:42:07
2021-10-14T09:42:07
163,251,015
9
9
null
null
null
null
WINDOWS-1251
C++
false
false
1,618
cpp
MatrixMultiplication.cpp
#include <iostream> #include <fstream> using namespace std; int n, m, q, p; int A[20][20], B[20][20],C[20][20]; fstream inf, otf; int main() { setlocale(LC_ALL, "rus"); system("color 1F"); cout << "\n\tПрограма множення матриць AxB=C\n"; cout << "\n\tПочатковi данi з файлу data.txt :\n\n"; inf.open("data.txt", ios::in); if (!inf) return 0; inf >> n; inf >> m; p = n; printf("\n\tЗаповнення матрицi A[%i][%i] цiлими числами. \n\n", n,m); for(int k=0;k<n;k++) { cout << "\n\t"; for (int i = 0; i < m; i++) { inf >> A[k][i]; printf("%4i", A[k][i]); } } inf >> n; inf >> m; q = m; printf("\n\n\tЗаповнення матрицi B[%i][%i] цiлими числами. \n\n", n, m); for (int k = 0; k<n; k++) { cout << "\n\t"; for (int i = 0; i < m; i++) { inf >> B[k][i]; printf("%4i", B[k][i]); } } inf.close(); printf("\n\n\tРезультат множення матриць С[%i][%i]\n\n", p, q); for (int k = 0; k<p; k++) { for (int i = 0; i < q; i++) { C[k][i] = 0; for(int j=0;j<n;j++) C[k][i]+=A[k][j]*B[j][i]; } } for (int k = 0; k<p; k++) { cout << "\n\t"; for (int i = 0; i < q; i++) { inf >> C[k][i]; printf("%5i", C[k][i]); } } otf.open("res.txt", ios::out); if (!otf) return 0; for (int k = 0; k<p; k++) { for (int i = 0; i < q; i++) { otf << C[k][i] << "\t"; } otf << "\n"; } otf.flush(); otf.close(); cout << "\n\n\t"; system("pause"); return 0; }
b78d1473b0e5081420ab79a6025548cb344247f0
485303ba578e154b2c0c110f8e0fec758d921ed0
/week-03/day-02/LookForValue/main.cpp
610e95d89fc0de79322ce3fc41d9f2f2678284df
[]
no_license
green-fox-academy/mazurgab
0b6e3c3a7fe0a4940ff80c4e25f9f386b408ab7b
1eae9aae0338122a3d1536fecd2eb15dc7871a3e
refs/heads/master
2020-04-02T17:22:07.998691
2019-04-28T21:52:14
2019-04-28T21:52:14
154,655,053
0
0
null
null
null
null
UTF-8
C++
false
false
780
cpp
main.cpp
#include <iostream> int main() { // Create a function which takes an array (and it's lenght) and a number as a parameter // the function should return index where it found the given value // if it can't find the number return 0 void returnIndex (int array[], int length, int param); int array[] = {1, 2, 3, 4, 5, 6, 7, 8}; int param; std::cout<<"Give a number please: "<<std::endl; std::cin>>param; returnIndex(array, sizeof(array)/sizeof(array[0]), param); return 0; } int returnIndex (int array[], int length, int param){ for(int i=0; i<length; ++i){ if(param == array[i]){ std::cout<<"The parameter found in the array at index No.: "<< i <<std::endl; return i; } } return 0; }
358718846e352847acdc1d70a84a802a1d0ac74f
78f7c50fe8462758814c5b372b8249a4e2eab700
/src/dwaognie.cpp
57f529f0851d7dabf7204f271d3e7c39dc57df39
[]
no_license
Arquanite/ProjektPO
cc7766eb844ad81813fe89928cc04af05c893488
1810307420e1208a2b94f305e2452cd9cd5c85a4
refs/heads/master
2021-01-17T16:23:41.392695
2016-06-17T06:38:28
2016-06-17T06:38:28
61,349,911
1
0
null
null
null
null
UTF-8
C++
false
false
867
cpp
dwaognie.cpp
#include "dwaognie.h" DwaOgnie::DwaOgnie(){ } DwaOgnie::DwaOgnie(QString Gospodarz, QString Gosc, QString Sedzia, int LiczbaGraczy) : Pilka(Gospodarz, Gosc, Sedzia), m_LiczbaGraczy(LiczbaGraczy){ } QString DwaOgnie::Rozegraj(){ while (m_PunktyGospodarza < m_LiczbaGraczy && m_PunktyGoscia < m_LiczbaGraczy){ qrand()%2 ? m_PunktyGospodarza++ : m_PunktyGoscia++; } if(m_PunktyGospodarza > m_PunktyGoscia){ return m_Gospodarz; } else { return m_Gosc; } } QDataStream &operator<<(QDataStream &out, const DwaOgnie &D){ out<<D.m_Gosc<<D.m_Gospodarz<<D.m_LiczbaGraczy<<D.m_PunktyGoscia<<D.m_PunktyGospodarza<<D.m_Sedzia; return out; } QDataStream &operator>>(QDataStream &in, DwaOgnie &D){ in>>D.m_Gosc>>D.m_Gospodarz>>D.m_LiczbaGraczy>>D.m_PunktyGoscia>>D.m_PunktyGospodarza>>D.m_Sedzia; return in; }
75bd5d3ef578f42594f149c08a0c54ca548ef8e2
61499fa2a25fbc101cb3808148610c3d6490a1cd
/Sorting Algorithms/Bucket Sort.cpp
a113860cd3a09fb5c9d63485bc2c525f5ab7d396
[]
no_license
pz1971/Data-Structures-And-Algorithms-in-C-and-CPP
5c54ba85b1ff97f0c268539448d834f57d9d1321
d00e76d6e7feefd3957e8bfb672966764aeebd73
refs/heads/master
2021-08-08T07:27:15.754558
2020-07-06T15:16:23
2020-07-06T15:16:23
198,986,136
1
0
null
null
null
null
UTF-8
C++
false
false
1,332
cpp
Bucket Sort.cpp
#include <bits/stdc++.h> using namespace std ; class Bucket{ private: class Node{ public: int key ; Node *next ; Node(int key){ this-> key = key ; next = nullptr ; } } *head ; public: Bucket(){ head = nullptr ; } void insert(int key){ if(head == nullptr){ // list was empty head = new Node(key) ; return ; } if(key < head->key){ Node *temp = new Node(key) ; temp-> next = head ; head = temp ; return ; } Node *cur = head ; while(cur -> next && cur -> key < key) cur = cur -> next ; Node *temp = new Node(key) ; temp -> next = cur -> next ; cur -> next = temp ; } bool empty(){ return (head == nullptr) ; } int pop(){ int ret = head -> key ; head = head -> next ; return ret ; } } ; int n, mx ; inline int indx(int key){ return key * n / (mx + 1) ; // value * array_len / (maximum element + 1) } void bucket_sort(int ar[]){ Bucket b[n] ; for(int i = 0 ; i < n; i++){ b[indx(ar[i])].insert(ar[i]) ; } int idx = 0 ; for(int i = 0 ; i < n ; i++){ while(!b[i].empty()){ ar[idx++] = b[i].pop() ; } } } int main(){ cin >> n ; int ar[n] ; mx = 0 ; for(int i = 0 ; i < n ; i++){ cin >> ar[i] ; mx = max(mx, ar[i]) ; } bucket_sort(ar) ; for(int i = 0 ; i < n; i++) cout << ar[i] << " " ; cout << endl ; return 0; }
5f3dd91b913cfb1688d42d5438757890e2e7f51f
8183abbc92d580f400d0a27bba545ac7c70d3c25
/selectionSort.cpp
99e16b4a4756beb63f2c0a196675d94cde5bd32c
[]
no_license
Noymul-Islam/problems
6fce4954377d1d2f1847b3741430820d4dfaa099
dec80211ce6904f81b616e1f16b30cfa80dbbe2a
refs/heads/master
2020-03-29T16:57:46.804665
2018-09-24T17:25:08
2018-09-24T17:25:08
150,136,724
0
0
null
null
null
null
UTF-8
C++
false
false
542
cpp
selectionSort.cpp
#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; void selectionSort(int arr[], int n) { for(int i=0;i<n-1;i++) { int key= i; for(int j=i+1;j<n;j++) { if(arr[key]>arr[j]) { key=j; } } swap(arr[i],arr[key]); } } int main() { int arr[]={1,2,5,6,3,1,4,7,0}; int n = sizeof(arr)/sizeof(arr[0]); selectionSort(arr,n); for(int i=0;i<n;i++) printf("%d ",arr[i]); return 0; }
2983b66c9642a6e9841b0ec6272272e27a92e55f
6bdbbf9ae43daa6d55f5c0491c8f1ab16b52fb16
/src/pack/belov_inc/spprc_dp.h
afb5f7ebcaddb81504560f59639bd3d10ae4b8b4
[]
no_license
ethanschreiber/number_partitioning
cf8f4e3078fb05b2009136e1ff4c564b70e6f357
bfb4b53d711080c125e11ade7b6d52a8387f59ce
refs/heads/master
2022-06-14T09:59:47.507481
2022-06-04T22:11:50
2022-06-04T22:11:50
68,240,729
2
3
null
null
null
null
UTF-8
C++
false
false
1,695
h
spprc_dp.h
#ifndef __SPPRC_DP_H #define __SPPRC_DP_H SS_BEGIN_NAMESPACE__ namespace spprc_dp { /** Dynamic programming for SPPRC, Shortest Path Problem with Resource Constraints with upper bounds on $x_{ii}$ ($x_{ij}$ are binary) and single resource The table filling procedure follows the "Improved DP" from U. Pferschy. Dynamic Programming revisited: improving knapsack algorithms. Computing, 63:419--430, 1999. also discussed in the book H. Kellerer, U. Pferschy, D. Pisinger. Knapsack Problems. Springer-Verlag, 2004. The overall COMPLEXITY results as O(mmL) IMPLEMENTATION No raster points, particularly no reduced RP. Thus, all capacities <L are calculated optimally too. USAGE: For given m & L, call InitBasicData(m,L,&l_first). Before each run, you must set/change the profits d (see below.) Then fill b[1..m] and call Run(). To get the results, use GetObjValue(L) and RestoreSolution(L,x). In the end you may call Clear() (e.g. in your main destructor) */ /// INTERFACE ///////////////////////// /// 1. MANUAL INPUT - THE PROFITS ///// extern Vector< Vector<double> > d; // dimensions m+1,m+1 // i.e. indexing [from 0..m][to 1..m] // e.g. d[0][i] is the profit of arc {0i} // i.e. the products are indexed 1...m // d.empty() => basic data not initialized /// 2. INTERFACE FUNCTIONS //////////// /// l_first points to the length of the first item /// in an array of int's: void InitBasicData(int m_, int L_, int* l_first); void Run(int* b_first); double GetObjValue(const int L0); /// x[1..m] will be calculated: void RestoreSolution(const int L0, Vector<int>& x); void Clear(); } // namespace spprc_dp SS_END_NAMESPACE__ #endif // __SPPRC_DP_H
e89ed76768b6abb110784b94eba1c6501f3b36ab
a411a55762de11dc2c9d913ff33d2f1477ac02cf
/lte/gateway/c/core/oai/tasks/mme_app/mme_app_pdn_context.cpp
4f9d0663d4ba2f0ebf7322e6d34f86ef4ef9026b
[ "BSD-3-Clause" ]
permissive
magma/magma
0dc48c1513d9968bd05fb7589f302c192b7c0f94
0e1d895dfe625681229e181fbc2dbad83e13c5cb
refs/heads/master
2023-09-04T09:31:56.140395
2023-08-29T13:54:49
2023-08-29T13:54:49
170,803,235
1,219
525
NOASSERTION
2023-09-07T17:45:42
2019-02-15T04:46:24
C++
UTF-8
C++
false
false
5,165
cpp
mme_app_pdn_context.cpp
/* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The OpenAirInterface Software Alliance licenses this file to You under * the terms found in the LICENSE file in the root of this source tree. * * 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. *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ /*! \file mme_app_pdn_context.cpp \brief \author Lionel Gauthier \company Eurecom \email: lionel.gauthier@eurecom.fr */ #include "lte/gateway/c/core/oai/tasks/mme_app/mme_app_pdn_context.hpp" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif #include "lte/gateway/c/core/oai/common/common_types.h" #include "lte/gateway/c/core/oai/common/log.h" #include "lte/gateway/c/core/oai/lib/bstr/bstrlib.h" #ifdef __cplusplus } #endif #include "lte/gateway/c/core/common/dynamic_memory_check.h" #include "lte/gateway/c/core/oai/include/mme_app_ue_context.hpp" #include "lte/gateway/c/core/oai/lib/3gpp/3gpp_24.007.h" #include "lte/gateway/c/core/oai/lib/3gpp/3gpp_24.008.h" #include "lte/gateway/c/core/oai/tasks/mme_app/mme_app_apn_selection.hpp" #include "lte/gateway/c/core/oai/tasks/mme_app/mme_app_defs.hpp" static void mme_app_pdn_context_init(ue_mm_context_t* const ue_context, pdn_context_t* const pdn_context); //------------------------------------------------------------------------------ void mme_app_free_pdn_context(pdn_context_t** const pdn_context, imsi64_t imsi64) { bdestroy_wrapper(&(*pdn_context)->apn_in_use); bdestroy_wrapper(&(*pdn_context)->apn_subscribed); bdestroy_wrapper(&(*pdn_context)->apn_oi_replacement); free_protocol_configuration_options(&(*pdn_context)->pco); free_wrapper((void**)pdn_context); } //------------------------------------------------------------------------------ static void mme_app_pdn_context_init(ue_mm_context_t* const ue_context, pdn_context_t* const pdn_context) { if ((pdn_context) && (ue_context)) { memset(pdn_context, 0, sizeof(*pdn_context)); pdn_context->is_active = false; for (int i = 0; i < BEARERS_PER_UE; i++) { // contains bearer indexes in ue_mm_context_t.bearer_contexts[] pdn_context->bearer_contexts[i] = INVALID_BEARER_INDEX; } } } //------------------------------------------------------------------------------ pdn_context_t* mme_app_create_pdn_context( ue_mm_context_t* const ue_mm_context, const pdn_cid_t pdn_cid, const context_identifier_t context_identifier) { OAILOG_FUNC_IN(LOG_MME_APP); if (!ue_mm_context->pdn_contexts[pdn_cid]) { pdn_context_t* pdn_context = reinterpret_cast<pdn_context_t*>(calloc(1, sizeof(*pdn_context))); if (pdn_context) { struct apn_configuration_s* apn_configuration = mme_app_get_apn_config(ue_mm_context, context_identifier); if (apn_configuration) { mme_app_pdn_context_init(ue_mm_context, pdn_context); pdn_context->context_identifier = apn_configuration->context_identifier; pdn_context->pdn_type = apn_configuration->pdn_type; if (apn_configuration->nb_ip_address) { pdn_context->paa.pdn_type = apn_configuration->ip_address[0] .pdn_type; // TODO check this later... pdn_context->paa.ipv4_address = apn_configuration->ip_address[0].address.ipv4_address; if (2 == apn_configuration->nb_ip_address) { pdn_context->paa.ipv6_address = apn_configuration->ip_address[1].address.ipv6_address; pdn_context->paa.ipv6_prefix_length = 64; } } // pdn_context->apn_oi_replacement memcpy(&pdn_context->default_bearer_eps_subscribed_qos_profile, &apn_configuration->subscribed_qos, sizeof(eps_subscribed_qos_profile_t)); memcpy(&pdn_context->subscribed_apn_ambr, &apn_configuration->ambr, sizeof(ambr_t)); // pdn_context->pgw_apn_ambr = ; pdn_context->apn_subscribed = blk2bstr(apn_configuration->service_selection, apn_configuration->service_selection_length); pdn_context->default_ebi = EPS_BEARER_IDENTITY_UNASSIGNED; // TODO pdn_context->apn_in_use = ue_mm_context->pdn_contexts[pdn_cid] = pdn_context; OAILOG_FUNC_RETURN(LOG_MME_APP, pdn_context); } else { free_wrapper((void**)&pdn_context); } } } OAILOG_FUNC_RETURN(LOG_MME_APP, NULL); }
0de897112b017b7f88f28a89d981079a5ddd4efe
ee62e0fffada4dfefc14eda14b6f53826cbeca02
/patch_generator/src/BinaryWriter.cpp
409797c98a882c5c7c3f245b3baddbd7ca65e076
[ "MIT" ]
permissive
beaupreda/cnn-rgbir
cd10471930ee8464807b986433b4de4a10ae87cc
f2011ea72c577953c031164bbf3a866d8a409df6
refs/heads/master
2020-05-31T18:50:04.706566
2019-06-13T00:31:55
2019-06-13T00:31:55
190,444,014
3
0
null
null
null
null
UTF-8
C++
false
false
846
cpp
BinaryWriter.cpp
#include "../include/BinaryWriter.h" BinaryWriter::BinaryWriter(const std::string& name, const std::string& info) { this->filename = name + info; } void BinaryWriter::writePointsToFile(const std::vector<std::vector<float>>& pointsToSave) { std::ofstream file(this->filename, std::ofstream::binary | std::ios::out | std::ios::trunc); if (!file.is_open()) { std::cerr << "Could not open file: " << this->filename << std::endl; return; } for (size_t i = 0; i < pointsToSave.size(); ++i) { for (size_t j = 0; j < pointsToSave[i].size(); ++j) { file.write(reinterpret_cast<const char*>(&pointsToSave[i][j]), sizeof(pointsToSave[i][j])); } } file.close(); } void BinaryWriter::setFilename(const std::string& name, const std::string& info) { this->filename = name + info; }
a0c60b73f77abd471fd880df60338da6b77205c8
6226d6aed3629aa4069c46971ffe764bb6c743f6
/Myway/Math/MWPlane.cpp
cd406c21b27d6b5452cc1327ca80fa27e8331b82
[]
no_license
Myway3D/Myway3D
83c30258f1e3eae90e619269406acd0ddeac7887
39cf569993f62fc648cbba49ebf74b3f8a64e46a
refs/heads/master
2020-04-22T20:24:15.817427
2014-03-09T14:25:23
2014-03-09T14:25:23
170,640,096
2
1
null
null
null
null
UTF-8
C++
false
false
2,375
cpp
MWPlane.cpp
#include "MWPlane.h" #include "MWMath.h" namespace Myway { const Plane Plane::Zero = Plane(0, 0, 0, 0); /* Plane -------------------------------------------------------------------------- @Remark: 3d plane. -------------------------------------------------------------------------- */ inline Plane::Plane() { } inline Plane::~Plane() { } inline Plane::Plane(const Plane & p) : a(p.a), b(p.b), c(p.c), d(p.d) { } inline Plane::Plane(const Vec3 & _n, float _d) : n(_n.x, _n.y, _n.z), d(_d) { } inline Plane::Plane(const Vec3 & _n, const Vec3 & _p) : n(_n) { d = - Math::VecDot(_n, _p); } inline Plane::Plane(float _a, float _b, float _c, float _d) : a(_a), b(_b), c(_c), d(_d) { } inline Plane::Plane(const Vec3 & p1, const Vec3 & p2, const Vec3 & p3) { //d_assert(Math::VecDot((p2 - p1), (p3 - p1)) > Math::EPSILON_E4); Vec3 n; Math::VecCrossN(n, (p2 - p1), (p3 - p1)); a = n.x; b = n.y; c = n.z; d = -Math::VecDot(n, p1); } inline Plane& Plane::operator =(const Plane & p) { a = p.a, b = p.b, c = p.c, d = p.d; return *this; } inline Plane Plane::operator -() const { return Plane(-a, -b, -c, -d); } inline bool Plane::operator ==(const Plane & p) const { return a == p.a && b == p.b && c == p.c && d == p.d; } inline bool Plane::operator !=(const Plane & p) const { return a != p.a || b != p.b || c != p.c || d != p.d; } inline std::ostream & operator << (std::ostream & os, const Plane & p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } Plane Plane::Normalize() const { Plane plane; Math::PlaneNormalize(plane, *this); return plane; } float Plane::Distance(const Vec3 & v) const { return Math::PlaneDistance(*this, v); } Plane::Side Plane::AtSide(const Vec3 & v) const { return Math::PlaneSide(*this, v); } Plane::Side Plane::AtSide(const Aabb & box) const { return Math::PlaneSide(*this, box); } Plane::Side Plane::AtSide(const Vec3 & v, const Vec3 & halfSize) const { return Math::PlaneSide(*this, halfSize); } Plane::Side Plane::AtSide(const Sphere & box) const { return Math::PlaneSide(*this, box); } Plane Plane::Transform(const Mat4 & m) { Plane plane; Math::PlaneTransform(plane, *this, m); return plane; } }
0108a274a44b440f3ca3bafc47255d7dd2f4406d
3dfd8cab46104449ba3aaa80674663bc0ba4b78f
/pku/3435.cc
d2870bbde577a66a645d84b3db3c7109e59bc97d
[]
no_license
chronotable/procon
a449ed506be2d041c26a828e67ce47615c9152f1
8b4c79d91bfb05f6f57114e5e3fe53e2d7394a76
refs/heads/master
2021-01-17T10:05:36.360756
2019-03-17T02:45:55
2019-03-17T02:45:55
21,483,371
0
0
null
null
null
null
UTF-8
C++
false
false
1,412
cc
3435.cc
#include <iostream> #include <stdio.h> using namespace std; int main(){ int m,n; int b[101][101]; cin >> m; n = m*m; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> b[i][j]; //check row for(int i = 0; i < n; i++){ bool u[101]; for(int j = 0; j <= n; j++)u[j] = false; for(int j = 0; j < n; j++){ if(b[i][j] == 0)continue; if(u[b[i][j]]){ cout << "INCORRECT" << endl; return 1; } u[b[i][j]] = true; } } //check column for(int i = 0; i < n; i++){ bool u[101]; for(int j = 0; j <= n; j++)u[j] = false; for(int j = 0; j < n; j++){ if(b[j][i] == 0)continue; if(u[b[j][i]]){ cout << "INCORRECT" << endl; return 1; } u[b[j][i]] = true; } } //check block for(int i = 0; i < m; i++){ for(int j = 0; j < m; j++){ int sy = i * m; int sx = j * m; int ey = (i+1) * m; int ex = (j+1) * m; bool u[101]; for(int j = 0; j <= n; j++)u[j] = false; for(int y = sy; y < ey; y++){ for(int x = sx; x < ex; x++){ if(b[y][x] == 0)continue; if(u[b[y][x]]){ cout << "INCORRECT" << endl; return 1; } u[b[y][x]] = true; } } } } cout << "CORRECT" << endl; return 0; }
c40a9c41de6c2eda179208eab1a70ab30a7bf631
9e76f6c992b80c0fa7b8bf70c6344b83c59ae109
/net-p2p/twister/files/patch-libtorrent_include_libtorrent_pe__crypto.hpp
957e136e07f6db7beef78558f4dcb697848c7769
[]
no_license
O2Graphics/ports
1c54bc1271f46962bd2290cbf2919d4da91e257c
076444f2a71d2f269b0338319520b22e757a1985
refs/heads/master
2021-01-19T20:44:03.866657
2018-01-24T10:28:35
2018-01-24T10:28:35
88,542,367
1
0
null
2017-04-17T19:34:35
2017-04-17T19:21:19
Makefile
UTF-8
C++
false
false
328
hpp
patch-libtorrent_include_libtorrent_pe__crypto.hpp
--- libtorrent/include/libtorrent/pe_crypto.hpp.orig 2014-11-29 15:20:43 UTC +++ libtorrent/include/libtorrent/pe_crypto.hpp @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include <openssl/rc4.h> #include <openssl/evp.h> #include <openssl/aes.h> +#include <openssl/rand.h> #else // RC4 state from libtomcrypt struct rc4 {
6262111e8512e65a4dc483377d221c07bf6ab5c2
1bcb99efd5cc703c8d588e0191da26bea1e8166d
/OOPs Concepts Programs/Pointer to Object for 'N' objects.cpp
bbe6194be0d5bff97214f9c904a4c9b8c91f9968
[]
no_license
leshwar/Object-oriented-programming
e819933157d9e112bb0a7b45c02b90dbdb088778
391b54dc17bbda231bf9f28351d99535e664bf36
refs/heads/master
2021-04-19T07:31:36.102282
2020-03-27T05:15:54
2020-03-27T05:15:54
249,591,380
0
0
null
null
null
null
UTF-8
C++
false
false
690
cpp
Pointer to Object for 'N' objects.cpp
//Implementation of Pointer to Object for a single Object. #include<conio.h> #include<iostream> using namespace std; #define cnst 10 class example { char name[cnst]; public: void getdata(){cout<<"Enter the Name\n";cin>>name;} void display(){cout<<"The Name you Entered is \n"<<name;} }; const int size=4; main() { int i; for(i=0;i<size;i++) { example e[i]; } for(i=0;i<size;i++) { e=new example[i]; } for(i=0;i<size;i++) { e[i]->getdata(); } for(i=0;i<size;i++) { e[i]->display(); } getch(); }
f8e72af152eac36c47e90ac6a9d82b9313d3dc23
a8ec0b280e63eb06c9352402aaa81c4f6b06b47c
/HDU/4111.cpp
354fdfe2afcd62581723e0f10aabdce8647c4f79
[ "Unlicense" ]
permissive
CodingYue/acm-icpc
5eff1b81a50cc9f7cbcd93c38b0232ba085a0b97
667596efae998f5480819870714c37e9af0740eb
refs/heads/master
2020-05-16T21:51:33.553238
2017-02-14T11:52:05
2017-02-14T11:52:05
17,904,772
1
0
null
null
null
null
UTF-8
C++
false
false
1,811
cpp
4111.cpp
// File Name: A.cpp // Author: YangYue // Created Time: Wed Jun 19 14:25:46 2013 //headers #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <cstring> #include <cmath> #include <ctime> #include <string> #include <queue> #include <set> #include <map> #include <iostream> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII; typedef pair<double,double> PDD; typedef pair<LL, LL>PLL; typedef pair<LL,int>PLI; #define lch(n) ((n<<1)) #define rch(n) ((n<<1)+1) #define lowbit(i) (i&-i) #define sqr(x) ((x)*(x)) #define fi first #define se second #define MP make_pair #define PB push_back const int MaxN = 200005; const double eps = 1e-7; const double DINF = 1e100; const int INF = 1000000006; const LL LINF = 1000000000000000005ll; int f[55][55005]; int dp(int i, int j) { int &res = f[i][j]; if (res != -1) return res; res = 0; if (j == 1) return res = dp(i + 1, 0); if (j) res |= !dp(i, j - 1); if (i) res |= !dp(i - 1, j); if (i > 1) { if (j) res |= !dp(i - 2, j + 3); else res |= !dp(i - 2, 2); } if (i && j) res |= !dp(i - 1, j + 1); return res; } int main() { //freopen("in","r",stdin); int cases; cin >> cases; memset(f, -1, sizeof f); for (int cas = 1; cas <= cases; ++cas) { printf("Case #%d: ", cas); int n; cin >> n; int a = 0, b = n - 1; for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); if (x == 1) --b, ++a; else b += x; } if (b < 0) b = 0; if (dp(a, b)) puts("Alice"); else puts("Bob"); } return 0; } // hehe ~
1a95c5ca306a10252858811c7f6f17224b6962b0
5386865e2ea964397b8127aba4b2592d939cd9f2
/grupa C/olimpiada/oblasten/2008/reshenija/Plovdiv/B/NBP/plates.cpp
af961c8533433479987160662cc28be5c2c10a9e
[]
no_license
HekpoMaH/Olimpiads
e380538b3de39ada60b3572451ae53e6edbde1be
d358333e606e60ea83e0f4b47b61f649bd27890b
refs/heads/master
2021-07-07T14:51:03.193642
2017-10-04T16:38:11
2017-10-04T16:38:11
105,790,126
2
0
null
null
null
null
UTF-8
C++
false
false
463
cpp
plates.cpp
#include<iostream> #include<cstring> using namespace std; int main() { char a[50][1000000]; int n, m, br=0; cin>>n>>m; for(int j=0;j<n;j++) for(int i=0;i<m*m;i++) cin>>a[j][i]; int b[50]; for(int i=0;i<n;i++) { for(int j=0;j<m*m;j++) b[i]=b[i]+a[i][j]-'0'; } for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(b[i]==b[j]) br++; cout<<n-br<<"\n"; return 0; }
b2ce67a72fe895d4ba9f53f0437a642d10ee49d4
c9cf0586ace11aa32fa67606d237a130a06364ee
/circular-cylinder-10-20/24.5025/p
0be2a0ad3b30b207c0baae24a1ef678dcf7f7992
[]
no_license
jezvonek/CFD-Final-Project
c74cfa21f22545c27d97d85cf30eb6dc8c824dc1
7c9a7fb032d74f20888effa0a0b75b212bf899f4
refs/heads/master
2022-07-05T14:43:52.967657
2020-05-14T03:40:56
2020-05-14T03:40:56
262,370,756
1
1
null
null
null
null
UTF-8
C++
false
false
24,207
p
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6.0 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "24.5025"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 2400 ( -40.3926 -32.6941 -27.8136 -24.0873 -20.8372 -18.0589 -15.7237 -13.7557 -12.0804 -10.6528 -42.2373 -34.3408 -29.2381 -25.3134 -21.9026 -18.9995 -16.5682 -14.5246 -12.7873 -11.3115 -44.0419 -35.9417 -30.6149 -26.4933 -22.9253 -19.9021 -17.3796 -15.2646 -13.4687 -11.9491 -45.788 -37.4824 -31.9313 -27.615 -23.8941 -20.7555 -18.1463 -15.9642 -14.1151 -12.5595 -47.4584 -38.948 -33.175 -28.6685 -24.8001 -21.5512 -18.8589 -16.6124 -14.7142 -13.1299 -49.0379 -40.3243 -34.3332 -29.643 -25.6355 -22.2844 -19.5153 -17.2075 -15.2606 -13.6456 -50.5163 -41.5991 -35.392 -30.5234 -26.3855 -22.9445 -20.1125 -17.755 -15.765 -14.1175 -51.8907 -42.7656 -36.34 -31.2927 -27.0257 -23.4987 -20.6138 -18.2253 -16.2233 -14.5958 -53.161 -43.8231 -37.1759 -31.9457 -27.5395 -23.908 -20.9453 -18.512 -16.5343 -15.0482 -54.3165 -44.7736 -37.9104 -32.4989 -27.9461 -24.1849 -21.0938 -18.5417 -16.5092 -15.0708 -60.4721 -60.3218 -60.0389 -59.6438 -59.1467 -58.5542 -57.8727 -57.1077 -56.2625 -55.3359 -49.3237 -49.2913 -49.1463 -48.8995 -48.5585 -48.1296 -47.6188 -47.0302 -46.365 -45.6168 -41.1495 -41.1777 -41.1131 -40.9615 -40.7296 -40.4243 -40.0523 -39.6175 -39.1207 -38.5556 -34.9369 -34.9704 -34.9265 -34.8099 -34.6279 -34.3881 -34.0993 -33.7668 -33.3943 -32.9763 -29.9347 -29.9482 -29.8952 -29.7807 -29.613 -29.4 -29.1542 -28.8825 -28.5957 -28.2884 -25.9046 -25.8924 -25.8215 -25.6966 -25.5272 -25.3203 -25.094 -24.8559 -24.6294 -24.4072 -22.6231 -22.588 -22.4996 -22.3618 -22.1845 -21.9726 -21.7514 -21.5281 -21.3487 -21.1925 -19.8956 -19.8434 -19.7419 -19.594 -19.4083 -19.185 -18.9569 -18.7296 -18.5938 -18.4958 -17.5822 -17.5198 -17.4124 -17.2623 -17.0745 -16.8422 -16.5988 -16.3442 -16.2382 -16.2296 -15.6152 -15.5375 -15.4216 -15.2707 -15.0836 -14.8484 -14.5843 -14.2798 -14.1163 -14.2057 -53.6153 -54.9646 -56.1729 -57.2441 -58.1694 -58.9396 -59.5513 -60.0059 -60.3078 -60.4624 -42.4372 -43.6992 -44.848 -45.8753 -46.7724 -47.5342 -48.1595 -48.649 -49.0053 -49.2299 -34.7861 -35.9189 -36.956 -37.8834 -38.6945 -39.3886 -39.9669 -40.4306 -40.781 -41.0199 -29.3833 -30.3843 -31.296 -32.1041 -32.8061 -33.4054 -33.9048 -34.3054 -34.6092 -34.8188 -25.2073 -26.0965 -26.8932 -27.5868 -28.1831 -28.6889 -29.1065 -29.437 -29.6832 -29.8483 -21.8977 -22.7061 -23.4062 -23.9973 -24.5004 -24.9249 -25.27 -25.5372 -25.7301 -25.852 -19.1958 -19.9544 -20.5788 -21.0828 -21.5081 -21.8649 -22.1493 -22.3637 -22.5128 -22.5992 -16.9418 -17.6444 -18.2034 -18.6415 -19.007 -19.3079 -19.5424 -19.716 -19.8326 -19.8929 -15.1689 -15.7187 -16.1664 -16.5583 -16.8808 -17.1286 -17.3167 -17.4576 -17.5511 -17.5937 -14.0808 -14.3757 -14.5459 -14.8784 -15.1651 -15.3439 -15.4673 -15.5641 -15.6276 -15.647 -7.26613 -8.3246 -9.58811 -11.0544 -12.7906 -14.9233 -17.6421 -21.2686 -26.9278 -36.3761 -7.82441 -8.95477 -10.2894 -11.8405 -13.6801 -15.9386 -18.8119 -22.6283 -28.509 -38.164 -8.38974 -9.59263 -10.9993 -12.6372 -14.5827 -16.9695 -19.9998 -24.0079 -30.1082 -39.9606 -8.96472 -10.2391 -11.7168 -13.4423 -15.4948 -18.0111 -21.1997 -25.4005 -31.7195 -41.7656 -9.54552 -10.892 -12.4414 -14.2555 -16.4152 -19.0607 -22.4068 -26.7991 -33.3342 -43.5693 -10.136 -11.5524 -13.1713 -15.0732 -17.3395 -20.1131 -23.6152 -28.1962 -34.9422 -45.3589 -10.7426 -12.2328 -13.9181 -15.9024 -18.2695 -21.1662 -24.8197 -29.5838 -36.5329 -47.1215 -11.3769 -12.9307 -14.6704 -16.7302 -19.1951 -22.2116 -26.0112 -30.9513 -38.0941 -48.8441 -12.1078 -13.7033 -15.4562 -17.5691 -20.1195 -23.2448 -27.1799 -32.2859 -39.6122 -50.513 -12.9571 -14.46 -16.1994 -18.3836 -21.0236 -24.2498 -28.3104 -33.571 -41.068 -52.1119 -2.67429 -3.05674 -3.64718 -4.40565 -5.31905 -6.45183 -7.92411 -9.95749 -13.6121 -20.9947 -3.06384 -3.50956 -4.16986 -4.97445 -5.93106 -7.12176 -8.67525 -10.8222 -14.6328 -22.1915 -3.36863 -3.92201 -4.66639 -5.53845 -6.56318 -7.83332 -9.48552 -11.7614 -15.7403 -23.4796 -3.75038 -4.37364 -5.18213 -6.12153 -7.22317 -8.58413 -10.3475 -12.7659 -16.9278 -24.8605 -4.19352 -4.86863 -5.73487 -6.74104 -7.92202 -9.37868 -11.2606 -13.8314 -18.1882 -26.325 -4.66124 -5.39176 -6.31944 -7.39564 -8.65968 -10.2169 -12.224 -14.9552 -19.5152 -27.8624 -5.14534 -5.9375 -6.93004 -8.0798 -9.43144 -11.095 -13.2339 -16.1328 -20.903 -29.4646 -5.65006 -6.50647 -7.56505 -8.79069 -10.2338 -12.0086 -14.2855 -17.3592 -22.3454 -31.1244 -6.17521 -7.09686 -8.22222 -9.52579 -11.0636 -12.9541 -15.3742 -18.6284 -23.8363 -32.8352 -6.71614 -7.70485 -8.89833 -10.282 -11.9175 -13.9274 -16.495 -19.9341 -25.3673 -34.5898 -1.90796 -1.42387 -1.13282 -0.914087 -0.765271 -0.668958 -0.624371 -0.628362 -0.680479 -0.779992 -2.50611 -2.06098 -1.72897 -1.48105 -1.31107 -1.20163 -1.15055 -1.15365 -1.20977 -1.3176 -3.11676 -2.69398 -2.34858 -2.085 -1.89962 -1.78108 -1.72644 -1.73145 -1.7944 -1.91357 -3.86321 -3.41994 -3.0537 -2.77042 -2.56649 -2.43544 -2.3742 -2.37884 -2.44724 -2.5774 -4.75361 -4.27466 -3.87718 -3.56645 -3.3392 -3.19142 -3.12011 -3.12177 -3.19397 -3.33457 -5.84389 -5.31894 -4.88023 -4.53291 -4.27517 -4.10441 -4.01782 -4.01223 -4.08503 -4.23402 -7.24787 -6.65835 -6.16182 -5.76287 -5.46125 -5.25535 -5.14269 -5.12033 -5.1856 -5.33632 -9.17902 -8.49398 -7.91069 -7.43376 -7.06403 -6.80054 -6.64115 -6.58324 -6.62423 -6.76197 -12.683 -11.8563 -11.1431 -10.5485 -10.0735 -9.71725 -9.47806 -9.35399 -9.34279 -9.44081 -19.8764 -18.8763 -18.0064 -17.2685 -16.6627 -16.1878 -15.8427 -15.6264 -15.537 -15.5659 -0.925942 -1.11688 -1.35124 -1.62637 -1.93791 -2.27767 -2.63027 -2.97673 -3.30814 -3.64873 -1.4759 -1.68289 -1.93656 -2.23378 -2.56988 -2.9387 -3.33099 -3.72752 -4.1075 -4.52892 -2.08747 -2.31404 -2.59109 -2.91541 -3.28264 -3.68759 -4.12319 -4.57633 -5.03861 -5.55048 -2.76755 -3.01537 -3.31857 -3.67409 -4.07809 -4.52601 -5.01162 -5.52692 -6.07294 -6.67459 -3.54157 -3.81239 -4.14482 -4.53602 -4.98274 -5.48103 -6.02574 -6.61225 -7.24428 -7.93615 -4.45707 -4.75137 -5.11491 -5.54512 -6.03924 -6.59402 -7.20566 -7.87173 -8.59537 -9.38412 -5.57033 -5.8844 -6.27681 -6.74528 -7.28751 -7.90095 -8.58305 -9.33266 -10.1518 -11.0443 -6.99387 -7.31587 -7.72695 -8.22524 -8.80885 -9.47579 -10.2245 -11.0548 -11.9682 -12.9664 -9.64246 -9.94582 -10.3513 -10.8574 -11.4625 -12.165 -12.9644 -13.8622 -14.8602 -15.9568 -15.6977 -15.946 -16.3116 -16.7918 -17.3848 -18.0898 -18.9079 -19.8431 -20.8979 -22.0628 -23.3139 -17.145 -14.0479 -12.0098 -10.239 -8.69273 -7.3491 -6.16675 -5.134 -4.27538 -24.6741 -18.4224 -15.2063 -13.0426 -11.1532 -9.5024 -8.07237 -6.82608 -5.75213 -4.84293 -26.1427 -19.7872 -16.4376 -14.1377 -12.1217 -10.3608 -8.84057 -7.5229 -6.3852 -5.40256 -27.7105 -21.2336 -17.7354 -15.288 -13.1368 -11.2596 -9.64364 -8.24824 -7.04398 -6.00266 -29.3669 -22.7525 -19.0912 -16.4854 -14.1913 -12.192 -10.476 -8.9994 -7.72667 -6.62652 -31.1001 -24.3331 -20.4952 -17.7207 -15.2766 -13.1508 -11.3317 -9.77209 -8.43087 -7.27334 -32.8974 -25.9633 -21.9361 -18.9838 -16.3838 -14.1282 -12.2044 -10.561 -9.15048 -7.93479 -34.7458 -27.6306 -23.4018 -20.2636 -17.5036 -15.1164 -13.0877 -11.3608 -9.8817 -8.60927 -36.6294 -29.3204 -24.8792 -21.5486 -18.6258 -16.1069 -13.9741 -12.165 -10.6189 -9.29227 -38.523 -31.0154 -26.355 -22.8274 -19.7407 -17.091 -14.8557 -12.9662 -11.3548 -9.97693 -6.9298 -3.23436 -1.53754 -0.663385 -0.168621 0.0490523 0.126038 0.13184 0.108145 0.0753626 0.0441993 0.0179518 -0.000948025 -0.0142023 -0.0223007 -0.0260332 -0.029266 -0.0266422 -0.0242419 -0.0153397 -7.50843 -3.62107 -1.73586 -0.792565 -0.260097 -0.0118416 0.0836877 0.101997 0.087171 0.0608137 0.0342643 0.0113096 -0.00530161 -0.0169816 -0.0240414 -0.0271382 -0.0299362 -0.0270854 -0.0244976 -0.0153256 -8.08352 -4.03012 -1.95466 -0.927105 -0.352909 -0.0724548 0.042744 0.0736662 0.0674801 0.0472446 0.0250266 0.00513665 -0.00935545 -0.0195764 -0.0256747 -0.0281813 -0.0305701 -0.0275091 -0.0247292 -0.0152904 -8.66067 -4.44906 -2.17842 -1.05849 -0.443489 -0.132032 0.00312939 0.0466773 0.0489275 0.0345529 0.0164195 -0.000609128 -0.013135 -0.022002 -0.0272094 -0.0291674 -0.03117 -0.0279141 -0.0249368 -0.015235 -9.21609 -4.83677 -2.37795 -1.17366 -0.526932 -0.189175 -0.034913 0.0210032 0.0314307 0.0226636 0.00838901 -0.00596303 -0.0166623 -0.0242718 -0.0286527 -0.0301004 -0.0317378 -0.0283005 -0.0251208 -0.0151599 -9.69601 -5.17061 -2.55836 -1.28281 -0.608744 -0.245753 -0.0719363 -0.00354226 0.0148888 0.0115074 0.00088831 -0.0109554 -0.0199562 -0.0263972 -0.0300112 -0.0309837 -0.0322754 -0.0286682 -0.0252819 -0.0150658 -10.143 -5.58124 -2.82852 -1.44838 -0.716329 -0.31176 -0.11141 -0.0282054 -0.00119301 0.000857414 -0.00619875 -0.0156498 -0.0230519 -0.0283978 -0.0312952 -0.0318225 -0.0327859 -0.0290186 -0.0254222 -0.0149542 -10.8601 -6.33461 -3.33418 -1.73685 -0.877103 -0.398897 -0.158555 -0.0552813 -0.0178501 -0.00979252 -0.0131355 -0.0201894 -0.0260278 -0.0303164 -0.0325279 -0.0326291 -0.0332783 -0.0293573 -0.0255472 -0.0148283 -11.9313 -7.29554 -3.94008 -2.05714 -1.04713 -0.492161 -0.209087 -0.0835058 -0.0347143 -0.0203486 -0.0199063 -0.0245773 -0.0288917 -0.0321602 -0.0337151 -0.0334075 -0.033754 -0.0296849 -0.0256582 -0.0146891 -11.9404 -7.41103 -4.03304 -2.0919 -1.08145 -0.529889 -0.236746 -0.10119 -0.0463207 -0.0280619 -0.0250463 -0.0279971 -0.0311897 -0.0336821 -0.0347212 -0.0340876 -0.0341531 -0.0299553 -0.0257144 -0.0145134 -10.146 -6.62593 -3.6132 -1.85167 -0.981945 -0.508248 -0.237884 -0.105761 -0.0510841 -0.032031 -0.0280948 -0.0302479 -0.0329005 -0.0349527 -0.0356417 -0.0347769 -0.0345038 -0.0301773 -0.0256479 -0.0141767 -8.22368 -5.72263 -3.23631 -1.67957 -0.918323 -0.513334 -0.265794 -0.131906 -0.0714451 -0.0469846 -0.0385244 -0.0371986 -0.0374682 -0.0378696 -0.0374704 -0.0359674 -0.0351128 -0.0305131 -0.0255629 -0.0137068 -6.50907 -4.81275 -2.87767 -1.53756 -0.854967 -0.505207 -0.286559 -0.156128 -0.0914678 -0.0624009 -0.0497077 -0.0448101 -0.0425 -0.0410682 -0.0394521 -0.0372309 -0.0357269 -0.0307972 -0.025376 -0.0131163 -4.90698 -3.85931 -2.48323 -1.41349 -0.809091 -0.495943 -0.30287 -0.178684 -0.110436 -0.0769134 -0.0603431 -0.052118 -0.0473637 -0.0441721 -0.0413797 -0.0384495 -0.0362613 -0.0309709 -0.0250405 -0.012383 -3.62714 -3.00454 -2.08477 -1.27367 -0.757012 -0.477992 -0.31016 -0.196814 -0.127597 -0.0903008 -0.0702709 -0.0590219 -0.0519852 -0.0471236 -0.0432084 -0.039577 -0.0366766 -0.0309984 -0.0245363 -0.0115102 -2.6632 -2.27551 -1.68626 -1.12061 -0.714746 -0.468862 -0.315739 -0.210838 -0.142304 -0.102174 -0.0791678 -0.0652958 -0.0562177 -0.0498259 -0.0448692 -0.0405528 -0.0369316 -0.0308505 -0.0238583 -0.0105228 -1.99146 -1.73836 -1.36945 -0.987865 -0.674265 -0.456367 -0.314407 -0.218505 -0.153452 -0.112095 -0.0867155 -0.0706595 -0.059855 -0.0521419 -0.0462668 -0.0413075 -0.0369934 -0.0305204 -0.0230302 -0.00947519 -1.57246 -1.38643 -1.13822 -0.871248 -0.630817 -0.445058 -0.314915 -0.224997 -0.162291 -0.12004 -0.0927013 -0.0748826 -0.0627152 -0.0539504 -0.0473202 -0.0417983 -0.036867 -0.0300497 -0.0221235 -0.00845913 -1.33226 -1.17806 -0.99145 -0.790057 -0.597984 -0.436545 -0.314633 -0.227824 -0.166943 -0.124913 -0.0966667 -0.0777548 -0.0646736 -0.0551798 -0.0479959 -0.0420409 -0.0366205 -0.0295501 -0.0212669 -0.00761286 -1.21859 -1.0784 -0.918926 -0.747371 -0.578863 -0.430862 -0.314285 -0.229401 -0.169542 -0.127713 -0.0989521 -0.0793638 -0.065736 -0.0558306 -0.0483245 -0.0421212 -0.036396 -0.029207 -0.0206599 -0.00711577 -12.9157 -12.7675 -12.5903 -12.3946 -12.1614 -11.8918 -11.5454 -11.1616 -10.7227 -10.659 -9.76887 -9.57572 -9.36262 -9.14385 -8.90366 -8.65868 -8.39233 -8.19902 -8.08313 -8.31202 -7.20413 -7.04764 -6.88898 -6.74382 -6.61352 -6.51731 -6.44917 -6.43478 -6.43017 -6.53922 -5.29088 -5.19973 -5.11618 -5.04667 -4.98905 -4.94163 -4.887 -4.82708 -4.76324 -4.79673 -3.89703 -3.84373 -3.79149 -3.73865 -3.68291 -3.62505 -3.56668 -3.52017 -3.4966 -3.52727 -2.90941 -2.87304 -2.83541 -2.7966 -2.75838 -2.72341 -2.6932 -2.66815 -2.64849 -2.64151 -2.25938 -2.23596 -2.21085 -2.18415 -2.15625 -2.12743 -2.0977 -2.06724 -2.03819 -2.01384 -1.8506 -1.83323 -1.81319 -1.79064 -1.7659 -1.73936 -1.71147 -1.68265 -1.6537 -1.62511 -1.61038 -1.59615 -1.57912 -1.55947 -1.53745 -1.51331 -1.48732 -1.45972 -1.43085 -1.40103 -1.4951 -1.48231 -1.46674 -1.44852 -1.42784 -1.40486 -1.37979 -1.35281 -1.32415 -1.29402 -13.0128 -13.3732 -12.7726 -12.86 -13.0883 -13.1419 -13.1188 -13.0999 -13.0761 -13.0212 -11.3333 -11.4798 -10.445 -10.1366 -10.2924 -10.3493 -10.2584 -10.1443 -10.0425 -9.92659 -9.17234 -9.10129 -8.00129 -7.53519 -7.64071 -7.76668 -7.72308 -7.59821 -7.47081 -7.34572 -6.90398 -6.80043 -5.90325 -5.46141 -5.51936 -5.66859 -5.68618 -5.59863 -5.48747 -5.38587 -4.93323 -4.89233 -4.31841 -3.99105 -3.99845 -4.10614 -4.14371 -4.09895 -4.0246 -3.9556 -3.43762 -3.45378 -3.17532 -2.99045 -2.97278 -3.02216 -3.04716 -3.0287 -2.98861 -2.94708 -2.44325 -2.47988 -2.38578 -2.31353 -2.30119 -2.31742 -2.32762 -2.321 -2.30322 -2.28172 -1.86612 -1.90366 -1.89041 -1.87618 -1.87607 -1.88295 -1.88717 -1.88492 -1.87702 -1.86526 -1.57203 -1.60541 -1.61648 -1.62138 -1.627 -1.63247 -1.63535 -1.63445 -1.62976 -1.62165 -1.44641 -1.47713 -1.49289 -1.5016 -1.50833 -1.51351 -1.51616 -1.51565 -1.51188 -1.50499 0.378416 0.345796 0.27004 0.126795 -0.114265 -0.529668 -1.21579 -2.41423 -4.39345 -8.64272 0.255903 0.220745 0.142731 -0.00456442 -0.248653 -0.670889 -1.34692 -2.56332 -4.40378 -8.05084 0.124612 0.0888457 0.0131121 -0.13022 -0.358252 -0.759027 -1.34952 -2.45266 -3.93364 -6.64839 -0.0130162 -0.0488264 -0.120142 -0.256108 -0.456827 -0.818978 -1.29052 -2.1723 -3.29356 -5.14738 -0.153201 -0.188086 -0.253491 -0.378587 -0.550472 -0.855276 -1.23018 -1.84717 -2.6713 -3.83007 -0.291135 -0.322532 -0.381749 -0.489148 -0.638711 -0.869329 -1.17572 -1.56835 -2.1356 -2.81954 -0.420278 -0.445055 -0.49797 -0.583291 -0.712435 -0.87475 -1.11356 -1.36299 -1.72541 -2.12205 -0.531319 -0.549277 -0.594097 -0.660154 -0.76416 -0.880969 -1.05253 -1.2242 -1.45169 -1.69005 -0.614692 -0.628594 -0.664411 -0.717147 -0.796828 -0.888355 -1.01086 -1.14047 -1.29476 -1.45641 -0.662442 -0.674765 -0.704343 -0.749586 -0.814569 -0.8935 -0.991305 -1.09951 -1.22088 -1.35097 1.17365 1.15673 1.11453 1.02787 0.867241 0.576762 0.0816469 -0.769428 -2.16192 -4.63833 1.08711 1.06853 1.02232 0.929742 0.761735 0.460717 -0.0486384 -0.923022 -2.36555 -4.96166 1.00248 0.982316 0.932299 0.833973 0.658662 0.347158 -0.176958 -1.07496 -2.5661 -5.28015 0.91993 0.898267 0.844673 0.740787 0.558237 0.236277 -0.303067 -1.22551 -2.76689 -5.59945 0.839568 0.816522 0.75961 0.650364 0.460622 0.128141 -0.426955 -1.37459 -2.96761 -5.91052 0.761489 0.737191 0.677239 0.562838 0.365929 0.0227506 -0.548813 -1.52256 -3.17298 -6.2221 0.685767 0.660373 0.597665 0.478307 0.274231 -0.0799394 -0.668753 -1.6687 -3.37717 -6.51397 0.612468 0.586203 0.521036 0.396875 0.18557 -0.180074 -0.787495 -1.81694 -3.5952 -6.84671 0.541587 0.514724 0.447478 0.318702 0.100004 -0.277884 -0.904709 -1.9667 -3.79935 -7.19982 0.472807 0.445065 0.37588 0.242779 0.0166239 -0.375502 -1.02841 -2.14893 -4.07844 -7.86904 2.09679 2.09594 2.09617 2.07358 1.99272 1.7985 1.43338 0.839804 -0.184029 -1.8221 2.00324 1.99962 1.99361 1.95957 1.86104 1.63916 1.22554 0.574008 -0.496206 -2.2269 1.90961 1.90495 1.89522 1.85508 1.75024 1.52624 1.11445 0.474992 -0.531715 -2.23331 1.81577 1.81017 1.79726 1.7527 1.64453 1.42339 1.02119 0.388116 -0.600886 -2.37464 1.72189 1.71501 1.69842 1.64877 1.53524 1.31038 0.903063 0.241781 -0.797314 -2.67028 1.62826 1.61986 1.59915 1.54355 1.42241 1.18756 0.763819 0.0578364 -1.0486 -2.99611 1.5352 1.52515 1.50013 1.43823 1.30869 1.06177 0.620336 -0.125731 -1.29157 -3.31239 1.44295 1.43121 1.40181 1.3336 1.19585 0.937329 0.481242 -0.295697 -1.51748 -3.63297 1.35179 1.33831 1.30457 1.23011 1.08453 0.815169 0.346369 -0.456523 -1.73646 -3.96638 1.26195 1.24674 1.20871 1.12809 0.974922 0.694998 0.213432 -0.613918 -1.95217 -4.30585 4.08925 4.11878 4.1759 4.2547 4.34313 4.42749 4.49713 4.54687 4.57729 4.59295 3.97477 4.00633 4.06785 4.15344 4.25106 4.34683 4.42925 4.49193 4.53461 4.56332 3.78799 3.82153 3.88722 3.97898 4.08444 4.1893 4.28213 4.35558 4.40554 4.44149 3.55897 3.59297 3.65966 3.75286 3.85982 3.96507 4.05343 4.1125 4.14025 4.1627 3.31095 3.34333 3.40667 3.49396 3.59082 3.67964 3.74253 3.76393 3.74223 3.72544 3.06145 3.09033 3.14638 3.22146 3.29952 3.36115 3.38236 3.33297 3.21236 3.12081 2.8227 2.84675 2.89281 2.95073 3.00138 3.02258 2.98601 2.84531 2.59193 2.38838 2.60223 2.62069 2.65534 2.69382 2.71327 2.68761 2.58686 2.34165 1.90084 1.50178 2.40378 2.41653 2.43912 2.45602 2.44047 2.35955 2.18195 1.82797 1.1804 0.504763 2.22772 2.23467 2.24646 2.24304 2.19297 2.05269 1.78257 1.30793 0.440721 -0.712026 4.59676 4.59797 4.59897 4.59966 4.60006 4.60018 4.6 4.59944 4.5984 4.59672 4.58238 4.58763 4.59132 4.59398 4.59574 4.59657 4.59641 4.59517 4.59274 4.58892 4.47908 4.4913 4.50093 4.50801 4.51287 4.51555 4.51596 4.514 4.50952 4.5023 4.21609 4.23916 4.25877 4.27362 4.28428 4.29078 4.29299 4.29079 4.28396 4.27229 3.79301 3.83101 3.86272 3.88692 3.90437 3.91501 3.91871 3.91526 3.90438 3.88576 3.20642 3.26737 3.31604 3.35398 3.38158 3.3987 3.4051 3.40043 3.38426 3.35625 2.49177 2.57898 2.64482 2.69758 2.736 2.7597 2.76822 2.76114 2.73798 2.69841 1.61496 1.74639 1.83811 1.91121 1.96325 1.99553 2.00789 1.99986 1.97038 1.9184 0.610177 0.785189 0.904064 1.00558 1.07934 1.12656 1.14558 1.13542 1.09436 1.021 -0.593531 -0.297124 -0.121599 0.023323 0.121137 0.180028 0.198947 0.178271 0.116962 0.0144475 4.59422 4.59067 4.58582 4.5794 4.57114 4.56075 4.54799 4.53261 4.51447 4.49344 4.58351 4.57625 4.56685 4.55502 4.54047 4.52297 4.50222 4.47777 4.44916 4.41767 4.4921 4.4786 4.46144 4.44029 4.41498 4.38546 4.35087 4.30864 4.25773 4.21023 4.25547 4.23307 4.20458 4.16976 4.12921 4.08351 4.02919 3.95657 3.86552 3.80234 3.85902 3.82355 3.77843 3.72372 3.66195 3.5955 3.5152 3.39541 3.23727 3.15504 3.31619 3.26335 3.19628 3.11499 3.02456 2.93113 2.81899 2.63651 2.37815 2.25637 2.64235 2.56895 2.47571 2.36117 2.23128 2.0971 1.94084 1.68283 1.29801 1.10704 1.84347 1.74441 1.61777 1.45993 1.27496 1.07819 0.859448 0.525526 0.0288713 -0.224175 0.91518 0.776459 0.602364 0.389596 0.140027 -0.129508 -0.410907 -0.781501 -1.30799 -1.55057 -0.128682 -0.311841 -0.535109 -0.79808 -1.09819 -1.42217 -1.74523 -2.08935 -2.53137 -2.71452 4.43257 4.26421 4.06326 3.80561 3.46981 3.05988 2.60015 2.12297 1.66178 1.24502 0.89221 0.611468 0.40062 0.249784 0.146946 0.079125 0.0374042 0.0125955 0.00131705 -0.00170203 4.33437 4.14317 3.94997 3.68177 3.3282 2.90854 2.45027 1.98357 1.5396 1.14391 0.81303 0.552475 0.358274 0.220516 0.127049 0.0661274 0.0289209 0.00715832 -0.00196244 -0.00382773 4.11795 3.91697 3.72591 3.44387 3.08067 2.66272 2.21776 1.77454 1.36164 1.00031 0.703133 0.47219 0.301836 0.182307 0.10165 0.0500378 0.0185824 0.00081674 -0.00562694 -0.00585236 3.75032 3.57923 3.38673 3.1116 2.76503 2.37025 1.95479 1.54753 1.17471 0.853693 0.593629 0.393792 0.247886 0.14643 0.078315 0.0356078 0.00935992 -0.00457994 -0.00878925 -0.00765418 3.19565 3.11894 2.95058 2.71648 2.41599 2.0663 1.69468 1.33145 1.00206 0.721571 0.49687 0.325604 0.201674 0.116015 0.0588323 0.0236659 0.00171885 -0.00890279 -0.0115176 -0.00929874 2.40522 2.50139 2.42246 2.27364 2.05181 1.76868 1.4525 1.13773 0.851584 0.608858 0.415625 0.269059 0.163744 0.0912157 0.0431082 0.0140389 -0.00442933 -0.0123276 -0.0138508 -0.0107062 1.33912 1.68307 1.79739 1.79424 1.68539 1.48707 1.23434 0.969549 0.724435 0.515467 0.349239 0.223327 0.133292 0.0714099 0.0306342 0.00639958 -0.00928747 -0.0150296 -0.0157939 -0.0118447 0.0664992 0.7049 1.11454 1.31036 1.33497 1.22874 1.04123 0.825052 0.617762 0.438531 0.29528 0.186523 0.108953 0.0556655 0.0207701 0.000359818 -0.0131104 -0.0171707 -0.0173878 -0.0127393 -1.1595 -0.242795 0.497454 0.891415 1.03375 1.00708 0.876178 0.702599 0.528357 0.374759 0.251 0.156575 0.0892825 0.0430177 0.0128891 -0.00445788 -0.0161416 -0.0188859 -0.0186888 -0.0134309 -1.94087 -0.87745 0.109888 0.622566 0.823253 0.843429 0.748959 0.605905 0.457005 0.323648 0.215492 0.132584 0.0735581 0.0329359 0.00662807 -0.00828285 -0.0185342 -0.0202489 -0.0197299 -0.0139505 -2.06314 -1.03492 -0.000213625 0.54351 0.737872 0.769081 0.686761 0.556686 0.419962 0.296723 0.196523 0.11957 0.0648789 0.0272656 0.00303662 -0.0105399 -0.019966 -0.0210883 -0.0203854 -0.0142537 -2.19965 -1.09571 -0.125453 0.456027 0.645722 0.686142 0.617671 0.502176 0.37942 0.267898 0.176804 0.106526 0.0565209 0.0220479 -0.000114827 -0.0124288 -0.0211012 -0.0217256 -0.0208595 -0.0144633 -2.57342 -1.20538 -0.291451 0.349669 0.554447 0.60566 0.551808 0.449796 0.339759 0.239173 0.15684 0.0931727 0.0479082 0.0166621 -0.00335915 -0.0143674 -0.0222497 -0.0223678 -0.0213257 -0.014653 -3.03134 -1.33696 -0.457067 0.229185 0.462654 0.526145 0.488675 0.400947 0.30343 0.213146 0.13883 0.0811242 0.0401077 0.0117573 -0.00633602 -0.0161653 -0.0233223 -0.0229818 -0.0217707 -0.014819 -3.53699 -1.50697 -0.614091 0.10099 0.372299 0.449694 0.428458 0.354929 0.269498 0.189018 0.122223 0.0700477 0.0329391 0.00724432 -0.00908582 -0.0178382 -0.0243251 -0.0235686 -0.0221933 -0.0149616 -4.06059 -1.70956 -0.760958 -0.0303362 0.282139 0.376351 0.371166 0.311622 0.237717 0.166474 0.10672 0.0597109 0.0262444 0.00302619 -0.0116625 -0.019414 -0.0252714 -0.0241325 -0.0225936 -0.0150812 -4.60224 -1.9478 -0.903702 -0.16142 0.191848 0.306092 0.316803 0.270957 0.20804 0.145474 0.0922837 0.0500775 0.0199943 -0.000918088 -0.0140796 -0.0209005 -0.0261653 -0.0246752 -0.0229713 -0.0151779 -5.1623 -2.22 -1.04722 -0.289965 0.101475 0.238636 0.265295 0.232811 0.180374 0.125956 0.0788766 0.041126 0.0141756 -0.00459734 -0.0163428 -0.0223008 -0.0270091 -0.025197 -0.0233256 -0.0152519 -5.74383 -2.52814 -1.1976 -0.415466 0.0113169 0.173627 0.216493 0.197033 0.154597 0.107832 0.0664383 0.0328171 0.00876407 -0.00802642 -0.0184608 -0.0236195 -0.0278052 -0.0256984 -0.0236557 -0.0153033 -6.33883 -2.8687 -1.35955 -0.538951 -0.0785177 0.110632 0.170177 0.163443 0.13057 0.0910012 0.0549019 0.025107 0.00373194 -0.0112224 -0.0204435 -0.0248619 -0.0285567 -0.0261798 -0.0239614 -0.0153324 ) ; boundaryField { inlet { type freestreamPressure; freestreamValue uniform 0; supersonic false; value nonuniform List<scalar> 40 ( 0.378416 0.255903 0.124612 -0.0130162 -0.153201 -0.291135 -0.420278 -0.531319 -0.614692 -0.662442 1.17365 1.08711 1.00248 0.91993 0.839568 0.761489 0.685767 0.612468 0.541587 0.472807 2.09679 2.00324 1.90961 1.81577 1.72189 1.62826 1.5352 1.44295 1.35179 1.26195 4.08925 3.97477 3.78799 3.55897 3.31095 3.06145 2.8227 2.60223 2.40378 2.22772 ) ; } outlet { type freestreamPressure; freestreamValue uniform 0; supersonic false; value nonuniform List<scalar> 40 ( -1.09602e-05 -1.37933e-05 -1.75724e-05 -2.23325e-05 -2.77012e-05 -3.23455e-05 -3.3555e-05 -2.80652e-05 -1.53711e-05 -2.25169e-06 -2.69359e-06 -3.08923e-06 -3.5538e-06 -4.09534e-06 -4.72131e-06 -5.43799e-06 -6.24998e-06 -7.15889e-06 -8.16037e-06 -9.24461e-06 -9.38711e-07 -1.01819e-06 -1.10817e-06 -1.2113e-06 -1.33132e-06 -1.47258e-06 -1.63999e-06 -1.83915e-06 -2.07636e-06 -2.35862e-06 -1.39992e-09 -3.13893e-08 -1.05215e-07 -2.03907e-07 -3.16417e-07 -4.29381e-07 -5.35505e-07 -6.36553e-07 -7.37484e-07 -8.43187e-07 ) ; } top { type symmetryPlane; } bottom { type symmetryPlane; } cylinder { type zeroGradient; } frontandback { type empty; } } // ************************************************************************* //
b4a954762864b38aebcb8691b74976f9872a4f13
aed0e5a7cbb1fc035a525f6d7458a494f05d7679
/src/engine/core/Entities.cpp
6ae61a2d0e8a4eac87fe3bcaeeba1b7dcd05fd18
[ "MIT" ]
permissive
arcln/indie
829ea8d000e0541f5fb63ed6a7c3b947d65de48e
984450211c8b1b5405da2431eeb858d0d5fec5e5
refs/heads/master
2021-09-16T07:21:01.231131
2018-06-06T15:10:31
2018-06-06T15:10:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,404
cpp
Entities.cpp
/* ** EPITECH PROJECT, 2017 ** worms ** File description: ** A file for worms - Paul Laffitte */ #include <algorithm> #include <engine/components/TransformComponent.hpp> #include <engine/utils/TagComparator.hpp> #include "engine/utils/EntityComparator.hpp" #include "engine/components/TagComponent.hpp" #include "engine/components/IrrlichtComponent.hpp" #include "engine/core/Entity.hpp" #include "engine/core/Entities.hpp" engine::Entity const& engine::Entities::add(engine::Entity&& entity, engine::EntityModel const& model) { EntityId parentId = entity.getParentId(); model(entity); if (entity.has<IrrlichtComponent>()) entity.get<TransformComponent>([](auto& t) {}); if (parentId == engine::Entity::nullId) _roots.emplace(entity.getId(), entity); _childs[parentId].emplace_back(entity); return _childs[parentId].back(); } void engine::Entities::remove(engine::EntityId id) { Entity& entity = _roots[id]; auto entityIt = _childs.find(entity.getParentId()); for (; entityIt->first == entity.getParentId(); entityIt++); if (entity.getParentId() != entityIt->first) throw std::runtime_error("unable to kill entity " + std::to_string(entity.getId())); _roots.erase(id); _childs.erase(entityIt); } void engine::Entities::attach(engine::EntityId parentId, engine::Entity const& child) { auto const& childIt = _roots.find(child.getId()); if (childIt != std::end(_roots)) this->detach(child); _childs[parentId].emplace_back(childIt->second); _roots.erase(childIt); } void engine::Entities::detach(engine::Entity const& entity) { engine::EntityId parentId = entity.getParentId(); engine::Entities::Siblings& siblings = _childs[parentId]; if (parentId == engine::Entity::nullId) throw std::runtime_error("unable to detach an entity without parent"); auto const& entityIt = std::find_if(std::begin(siblings), std::end(siblings), engine::EntityComparator(entity)); if (entityIt != std::end(siblings)) { _roots[entity.getId()] = *entityIt; siblings.erase(entityIt); } } void engine::Entities::withTag(std::string tag, std::function<void (engine::Entity const&)> callback) const { this->each<engine::TagComponent>([&tag, &callback](engine::Entity const& entity, auto const& tagComponents) { if (std::find_if(std::begin(tagComponents), std::end(tagComponents), engine::TagComparator(tag)) != std::end(tagComponents)) { callback(entity); } }); }
e105d4a77d243c01c691280161146616f227f6d3
ba24c7e8496dab2498f3e8fdcaad3347842d017c
/General/TernaryExample.cpp
6a8acaf8ddacb6ee5fdd529710b47fa8d1b5b84b
[]
no_license
codejith/TestPrograms
7c4eb31b505349df2dbdc6b80bb3aa075a50b410
56e53fc76af0262a75a96d77e3e6eb44ae382656
refs/heads/master
2021-01-12T05:17:42.195835
2017-03-31T09:44:39
2017-03-31T09:44:39
77,902,957
0
0
null
null
null
null
UTF-8
C++
false
false
122
cpp
TernaryExample.cpp
#include <iostream> int main() { int test = 0; std::cout << (test? 'S' : 1) << std::endl; return 0; }
4e4be54fd517c7b38d1590300ca0536c8d83aa31
7949db20aad375304227ee7af25aed92e00cb7d7
/resultado final/Trabajo Final/Jump Mario 3.0/src/Personaje.cpp
3ee458f9a22fa646fa71d2cc08238c1dfbd65f45
[]
no_license
jorgealfaro1345/Trabajo-final
a598f7ca8cf13a7fe9fe20c1e8f13e5faf52d9cb
befcadf3f88cf0929099458573992f584d310952
refs/heads/master
2021-08-22T07:25:29.602725
2017-11-29T16:10:06
2017-11-29T16:10:06
108,771,149
0
0
null
null
null
null
MacCentralEurope
C++
false
false
3,443
cpp
Personaje.cpp
#include "Personaje.h" #include "sstream" #include "iostream" //CLASE CREADA #include "Texto.h" //LIBRERIAS DE SFML #include <SFML/Graphics.hpp> #include<SFML/Audio.hpp> using namespace sf; Personaje::Personaje() { txt_jugador = new Texture; spr_jugador = new Sprite; vidas=new int; *vidas= 3; vidast=new Texto; } void Personaje::pers_imagen() { carpeta="Mario"; imagen="marioderecha"; imagen2="marioizquierda"; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen+".png"); spr_jugador->setTexture(*txt_jugador); } void Personaje::pers_imagen(int x) { carpeta="Luigi"; imagen="luigiderecha"; imagen2="luigiizquierda"; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen+".png"); spr_jugador->setTexture(*txt_jugador); } void Personaje::pers_imagen(double x) { carpeta="Conyoshi"; imagen="conyoshiderecha"; imagen2="conyoshiizquierda"; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen+".png"); spr_jugador->setTexture(*txt_jugador); } void Personaje::pers_imagen(std:: string x) { carpeta="Toad"; imagen="toadderecha"; imagen2="toadizquierda"; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen+".png"); spr_jugador->setTexture(*txt_jugador); } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// void Personaje::agregar_movimiento() { if (Keyboard::isKeyPressed(Keyboard::Right)) { x+=3; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen+".png"); } if (Keyboard::isKeyPressed(Keyboard::Left)) { x-=3; txt_jugador->loadFromFile("Imagenes/Personaje/"+carpeta+"/"+imagen2+".png"); } if (Keyboard::isKeyPressed(Keyboard::Up)) { y-=50; } if(x>600) { x=1; } if(x<0) { x=600; } dy+=0.2;//la velocidad en q baja y+=dy;// hace q baje el personajeÁ std::stringstream ss; ss<<*vidas; std::string vidasstr=ss.str(); vidast->mens_tam_pos("Lifes: "+vidasstr,34,10,653); } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// Sprite Personaje::devol_spr() { return *spr_jugador; } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// void Personaje::posyvidas_iniciales() { x=100,y=100,h=200; *vidas= 20; } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// int Personaje::return_vidas() { return *vidas; } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// Text Personaje::devo_vidas() { return vidast->dev_text(); } /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// Personaje::~Personaje() { delete txt_jugador; delete spr_jugador; }
ce902300fbffd89824dc364deed366e7d810aeb7
88c0e520e2389e676fea559f944109e1ee7e157b
/include/Windows.UI.Xaml.Core.Direct.2_4bc8ceb3.h
15ecadb4848ba377fcc62769547bd04814b15a29
[]
no_license
jchoi2022/NtFuzz-HeaderData
fb4ecbd5399f4fac6a4982a0fb516dd7f9368118
6adc3d339e6cac072cde6cfef07eccafbc6b204c
refs/heads/main
2023-08-03T02:26:10.666986
2021-09-17T13:35:26
2021-09-17T13:35:26
407,547,359
4
0
null
null
null
null
UTF-8
C++
false
false
599
h
Windows.UI.Xaml.Core.Direct.2_4bc8ceb3.h
#include "winrt/impl/Windows.UI.1.h" #include "winrt/impl/Windows.UI.Xaml.1.h" #include "winrt/impl/Windows.UI.Xaml.Media.1.h" #include "winrt/impl/Windows.UI.Xaml.Media.Media3D.1.h" #include "winrt/impl/Windows.UI.Xaml.Core.Direct.1.h" WINRT_EXPORT namespace winrt::Windows::UI::Xaml::Core::Direct { } namespace winrt::impl { } WINRT_EXPORT namespace winrt::Windows::UI::Xaml::Core::Direct { struct WINRT_EBO XamlDirect : Windows::UI::Xaml::Core::Direct::IXamlDirect { XamlDirect(std::nullptr_t) noexcept {} static Windows::UI::Xaml::Core::Direct::XamlDirect GetDefault(); }; }
056bc64cc2d28766a93a6f1298154c12fbc1c38b
f58365bcef42779533bcc3b93d7449b26139dfba
/kernel/objects/flock_child/flock_child_view.cpp
a45a0a6d0d184119c0ff90795b4f4a5aec5f8c00
[]
no_license
hl0071/test_osg
763b83895f30e1761b6b3e86171fca5c0508a08e
2ea41efe216e15f7a4452c6b105397a923f3b04f
refs/heads/master
2023-03-19T09:02:48.435332
2017-03-16T18:32:40
2017-03-16T18:32:40
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,211
cpp
flock_child_view.cpp
#include "flock_child_view.h" namespace flock { namespace child { object_info_ptr view::create(kernel::object_create_t const& oc, dict_copt dict) { return object_info_ptr(new view(oc, dict)); } AUTO_REG_NAME(flock_child_view, view::create); view::view(kernel::object_create_t const& oc, dict_copt dict) : base_view_presentation(oc) , obj_data_base (dict) , _spawner (find_object<manager::info_ptr>(collection_, manager_id())) , _init (false) { if (nodes_manager_ = find_first_child<nodes_management::manager_ptr>(this)) { root_ = nodes_manager_->get_node(0); // conn_holder() << nodes_manager_->subscribe_model_changed(boost::bind(&view::on_model_changed_internal, this)); } msg_disp() .add<msg::settings_msg>(boost::bind(&view::on_settings, this, _1)); } geo_point_3 const& view::pos() const { return state_.pos; } std::string const& view::name() const { return settings_.model; } uint32_t view::manager_id() const { return parent_id; } settings_t const& view::settings() const { return settings_; } void view::on_settings(msg::settings_msg const& msg) { #if 0 // Нужно или нет пока не понятно if (nodes_manager_ && nodes_manager_->get_model() != settings.model) nodes_manager_->set_model(settings.model); #endif settings_ = msg.settings; on_new_settings(); } void view::on_model_changed_internal() { #if 0 if (nodes_manager_) { if (nodes_manager_->get_model() != get_model(name())) on_model_changed(); } #endif } void view::update(double time) { if (!_init) { _spawner = find_object<manager::info_ptr>(collection_, parent_id); _init = _spawner.expired(); } } void view::on_child_removing(object_info_ptr child) { base_view_presentation::on_child_removing(child) ; if (nodes_manager_ == child) nodes_manager_.reset() ; } void view::on_object_destroying(object_info_ptr object) { base_view_presentation::on_object_destroying(object) ; if (object->object_id() == this->object_id()) { remove_child(nodes_manager_); } } } } // flock
89445e121602b7d87cede0e77de7bfad8077dcb4
944d1030c23ae7f231647d7d1ca57ed2e8b7701b
/Chapter2-Lighting/02-BasicLighting/src/Exercise2.cpp
e750487dca5c920f21548229eb80e34630b93230
[]
no_license
inlet511/LearnOpenGL_execise
510cc55711a95dc9f43a2f0843b958246630a9e9
caaeb29b1b51ff89ab70724abee0bf05fe139a7b
refs/heads/master
2023-07-17T15:20:29.946804
2021-09-03T09:39:23
2021-09-03T09:39:23
389,158,011
0
0
null
null
null
null
UTF-8
C++
false
false
10,058
cpp
Exercise2.cpp
 #define STB_IMAGE_IMPLEMENTATION #include <glad/glad.h> #include <GLFW/glfw3.h> #include "Shader.h" #include "stb_image.h" #include <iostream> #include <glm.hpp> #include <gtc/matrix_transform.hpp> #include <gtc/type_ptr.hpp> #include <Camera.h> #include "imgui.h" #include "backends/imgui_impl_glfw.h" #include "backends/imgui_impl_opengl3.h" void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow* window, float deltaTime); void mouse_callback(GLFWwindow* window, double xpos, double ypos); void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); unsigned int SCR_WIDTH = 800; unsigned int SCR_HEIGHT = 600; Camera camera(glm::vec3(1.0f,1.0f,3.0f),glm::vec3(0.0f,1.0f,0.0f),-75.0f,45.0f); float deltaTime = 0.0f; // 当前帧与上一帧的时间差 float lastFrame = 0.0f; // 上一帧的时间 glm::vec3 lightPos(2.2f, 2.0f, 2.0f); glm::vec3 objectPos(0.0f, 0.0f, 0.0f); ImVec4 ambient_lightColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); ImVec4 diffuse_lightColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); ImVec4 specular_lightColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); float shininess = 32.0f; float specular_multiplier = 0.5f; int main() { glfwInit(); const char* glsl_version = "#version 130"; glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetCursorPosCallback(window, mouse_callback); glfwSetScrollCallback(window, scroll_callback); //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; } // Setup Imgui // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init(glsl_version); Shader cubeShader("shaders/vertex.vert", "shaders/fragment.frag"); Shader lightShader("shaders/vertex.vert", "shaders/fragment_light.frag"); // set up vertex data and buffers // ----------------------- float vertices[] = { -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f }; unsigned int VBO; unsigned int VAO; unsigned int lightVAO; glGenVertexArrays(1, &VAO); glGenVertexArrays(1, &lightVAO); glGenBuffers(1, &VBO); // Bind Vertex Array Object glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3*sizeof(float))); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); // Bind Light Object Vertex Array glBindVertexArray(lightVAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float))); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glEnable(GL_DEPTH_TEST); while (!glfwWindowShouldClose(window)) { float current_time = (float)glfwGetTime(); deltaTime = current_time - lastFrame; lastFrame = current_time; // Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); { ImGui::Begin("Control Panel!"); ImGui::SliderFloat("Shininess", &shininess, 1.0f, 128.0f); ImGui::SliderFloat("Specular Multiplier", &specular_multiplier, 0.0f, 1.0f); ImGui::ColorEdit3("Ambient Light Color", (float*)&ambient_lightColor); ImGui::ColorEdit3("Diffuse Light Color", (float*)&diffuse_lightColor); ImGui::ColorEdit3("Specular Light Color", (float*)&specular_lightColor); ImGui::End(); } processInput(window, deltaTime); glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //lightPos = glm::vec3( // glm::cos(glm::radians(100.0f * glfwGetTime())) * 2.0f, // 2.0f, // glm::sin(glm::radians(100.0f * glfwGetTime())) * 2.0f //); // 绘制第一个立方体 glBindVertexArray(VAO); cubeShader.use(); cubeShader.setMatrix4("view", camera.GetViewMatrix()); glm::mat4 projection = glm::mat4(1.0f); projection = glm::perspective<float>(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f); cubeShader.setMatrix4("projection", projection); glm::mat4 model = glm::mat4(1.0f); glm::translate(model, objectPos); cubeShader.setMatrix4("model", model); glm::mat3 normalMatrix = glm::transpose(glm::inverse(model)); cubeShader.setMatrix3("normalMatrix", normalMatrix); cubeShader.setVec3("objectColor", glm::vec3(1.0f, 0.5f, 0.31f)); cubeShader.setVec3("ambient_lightColor", glm::vec3(ambient_lightColor.x,ambient_lightColor.y,ambient_lightColor.z)); cubeShader.setVec3("diffuse_lightColor", glm::vec3(diffuse_lightColor.x, diffuse_lightColor.y, diffuse_lightColor.z)); cubeShader.setVec3("specular_lightColor", glm::vec3(specular_lightColor.x, specular_lightColor.y, specular_lightColor.z)); cubeShader.setVec3("lightPos", lightPos); cubeShader.setVec3("eyePos", camera.Position); cubeShader.setFloat("Shininess", shininess); cubeShader.setFloat("specularMultiplier", specular_multiplier); glDrawArrays(GL_TRIANGLES, 0, 36); // 绘制第二个立方体(表示光源) glBindVertexArray(lightVAO); lightShader.use(); lightShader.setMatrix4("view", camera.GetViewMatrix()); lightShader.setMatrix4("projection", projection); lightShader.setVec3("objectColor", glm::vec3(1.0f)); lightShader.setVec3("ambient_lightColor", glm::vec3(1.0f)); lightShader.setVec3("diffuse_lightColor", glm::vec3(1.0f)); lightShader.setVec3("specular_lightColor", glm::vec3(1.0f)); lightShader.setFloat("Shininess", 1.0f); lightShader.setFloat("specularMultiplier", 1.0f); model = glm::mat4(1.0f); model = glm::translate(model, lightPos); model = glm::scale(model, glm::vec3(0.2f)); lightShader.setMatrix4("model", model); normalMatrix = glm::transpose(glm::inverse(model)); lightShader.setMatrix3("normalMatrix", normalMatrix); glDrawArrays(GL_TRIANGLES, 0, 36); // Rendering ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); glfwPollEvents(); } glDeleteVertexArrays(1, &VAO); glDeleteVertexArrays(1, &lightVAO); glDeleteBuffers(1, &VBO); // Cleanup ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); glfwTerminate(); return 0; } void processInput(GLFWwindow* window, float deltaTime) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL)==GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) camera.OnKeyboard(deltaTime, FORWARD); if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) camera.OnKeyboard(deltaTime, BACKWARD); if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) camera.OnKeyboard(deltaTime, LEFT); if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) camera.OnKeyboard(deltaTime, RIGHT); } } void framebuffer_size_callback(GLFWwindow* window, int width, int height) { SCR_WIDTH = width; SCR_HEIGHT = height; glViewport(0, 0, width, height); } void mouse_callback(GLFWwindow* window, double xpos, double ypos) { if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) camera.OnMouseMove(xpos, ypos); } void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) camera.OnScroll(yoffset); }
e723014946c7f4bb8587fcb8727a22c54d25494f
2a594aeb45cf16333d83421ae3c11f9ef39dc8bc
/leecode-II/RemoveElement/源.cpp
4ceb3bee3d001a087431e9ddd8bb943bacfc001e
[ "MIT" ]
permissive
lisnb/leetcode
9bcd40c9fd8a84ed30e4a91edc7451220ffef676
7875e4ff20412b663c59e57f76d08cd62b91481c
refs/heads/master
2020-06-04T05:32:52.595221
2015-08-20T14:39:46
2015-08-20T14:39:46
22,034,965
2
0
null
null
null
null
UTF-8
C++
false
false
590
cpp
源.cpp
#include <algorithm> #include <iostream> #include <vector> using namespace std; class Solution { public: int removeElement(vector<int>& nums, int val) { if (nums.empty()) return 0; int p1(-1), p2(0); while (p2 < nums.size()) { if (nums.at(p2) != val) swap(nums.at(++p1), nums.at(p2)); ++p2; } return p1 + 1; } }; int main() { Solution s; vector<int> test = { 1, 1, 1, 1, 2, 2, 2, 2, 3 }; cout << s.removeElement(test, 3) << endl; system("pause"); return 0; }
2cc1baa228e562ede3ec87e4c7de2e0f5815bf44
44fd7e3915a6d00b5c668f4c404467e15dfb1eb6
/src/Triangle.h
ad2f559c6ebbb4d8e38edb41f9808c201c44b484
[]
no_license
davidnov12/Path-Tracer
e47278c4ae76f9c94c3462446fa503e3ae65d881
6b4ddf34017ba394b3e8b637995c8890937bb12a
refs/heads/master
2021-01-13T08:09:22.128920
2017-05-01T11:03:46
2017-05-01T11:03:46
69,872,341
4
1
null
null
null
null
UTF-8
C++
false
false
773
h
Triangle.h
/* * Path tracing na GPU * Bakalarska prace * David Novak, xnovak1l * FIT VUT Brno, 2016 * * Triangle.h - trida pro reprezentaci trojuhelniku */ #pragma once #include <vector> #include <glm/glm.hpp> using namespace std; using namespace glm; class Triangle { public: // Konstruktor Triangle(vector<vec3> verts, vector<vec3> norm); Triangle(vector<vec3> verts, vector<vec2> uvs, vector<vec3> norm); void append(vector<vec3> verts, vector<vec2> uvs, vector<vec3> normal); // Ziskani vrcholu a normaly trojuhelniku vector<vec3> getVertices(); vector<vec2> getUVs(); vector<vec3> getNormals(); private: // Vrcholy a normala trojuhelniku vector<vec3> vertices; vector<vec2> tex_coords; vector<vec3> normal; };
ecf8f829ebd01e15602d591860d95df533d9f356
ed0124801e8cea3c955cd35de1e4b7de0c4cc7de
/select/buffer.h
5844a094ab95cc36982e74453950eff68d76260a
[]
no_license
Pramy/agent
47287b22d75bb74041f68e28d70fc0153957f19c
e8a32ec4af093fc5116fb9331e4497037a06dd1b
refs/heads/master
2022-06-28T17:21:58.279131
2020-05-11T11:12:04
2020-05-11T11:13:36
257,616,156
1
0
null
null
null
null
UTF-8
C++
false
false
682
h
buffer.h
// // Created by tuffy on 2020/4/24. // #ifndef AGENT_BUFFER_H #define AGENT_BUFFER_H #include <unistd.h> #include <cstring> class Buffer { public: explicit Buffer(int maxLen); virtual ~Buffer(); bool IsReadable(); bool IsWriteable(); bool IsEmpty(); bool IsFull(); void Reset(); int Read(int socket_fd); int Read(const char *src, int len); int Write(int socket_fd); int Write(char *des, int len); char *GetReadIndex() const; bool SetReadIndex(char *index); char *GetWriteIndex() const; bool SetWriteIndex(char *index); int GetSize(); private: char *data; int max_len; char *read_index; char *write_index; }; #endif // AGENT_BUFFER_H
0dd8e85bc9ea4255dfbb975f40e890e9a6ccfc43
def6c8adbd89e27fb1b63602b76e38bbaf995974
/cordic_posit.cpp
c2f0bccc7bac13eb32e2e826fc57709c32ca29ce
[]
no_license
mshachnai/Posit-mathlib
61e6a30410a91261a9204abec42ecad86369594f
f498b35c2ec8870a3524eef7d0fc16c8d2fc3f0b
refs/heads/master
2022-03-27T07:09:53.879495
2020-01-22T16:11:10
2020-01-22T16:11:10
192,587,680
1
0
null
null
null
null
UTF-8
C++
false
false
3,369
cpp
cordic_posit.cpp
//CORDIC algo to compute sine/cos/tan using Posit #include <math.h> #include "../SoftPosit/source/include/softposit_cpp.h" #include "mpreal.h" #include "mpfr.h" #include "gmp.h" #include <iostream> #include <iomanip> #include <vector> //#define M_PI const float R_to_D = 180 / M_PI; //radians to degrees const float D_to_R = M_PI / 180; //degrees to radians const int deci = 50; using namespace std; //function to return value of Ki posit32 val_Ki(int n){ posit32 Ki = 1 / sqrt(1 + pow(2,-2*n)); return Ki; } //function to return value of An (cordic gain) posit32 val_An(int n){ posit32 An = sqrt(2); for(int i = 1; i < n; i++){ An = An * sqrt(1 + pow(2,-2*i)); } return An; } //function to create table of arctan values (tan:arctan) void atan_table(posit32 table[][2], int n){ for(int i = 0; i < n+1; i++){ table[i][0] = pow(2, -i); table[i][1] = atan(pow(2, -i)) * R_to_D; } return; } //function for computing the cordic iteration void cordic_itr(posit32 ang, int n){ posit32 z = ang; posit32 x = 1 / val_An(n); posit32 y = 0; int di = 0; posit32 arctan_table [50][2] = {}; atan_table(arctan_table, n); //iterate cordic algorithm for(int i = 0; i < n+1; i++){ posit32 rot_ang = arctan_table[i][1]; if(z >= 0){ di = 1; } else{ di = -1; } posit32 x_prime = x - y * di * pow(2, -i); posit32 y_prime = y + x * di * pow(2, -i); posit32 z_prime = z - di * rot_ang; //verification table - to check if iteration is correct //printf("%d -- %f -- %f -- %f -- %f -- %f\n", i, pow(2, -i), rot_ang, z, rot_ang, z_prime); x = x_prime; y = y_prime; z = z_prime; } printf("\nPosit representation:\n"); //printf("cos of %f (in degrees) = %f\n", ang, x); cout << "cos of " << ang << " (in degrees) = " << setprecision(200) << x << endl; cout << "sin of " << ang << " (in degrees) = " << y << endl; cout << "tan of " << ang << " (in degrees) = " << y/x << endl; //printf("sin of %f (in degrees) = %f\n", ang, y); //printf("tan of %f (in degrees) = %f\n", ang, y/x); //verify angle is correct //printf("angle = %f \n", atan(y/x) * R_to_D); printf("\nMathlib representation:\n"); cout << "cos of " << ang << " (in degrees) = " << cos(M_PI/9) << endl; cout << "sin of " << ang << " (in degrees) = " << sin(M_PI/9) << endl; cout << "tan of " << ang << " (in degrees) = " << tan(M_PI/9) << endl; //printf("cos of %f (in degrees) = %f\n", ang.toDouble(), cos(M_PI/9)); //printf("sin of %f (in degrees) = %f\n", ang, sin(M_PI/9)); //printf("tan of %f (in degrees) = %f\n", ang, tan(M_PI/9)); } //utility function to print 2d array void print_2d(float table[][2], int n){ for(int i = 0; i < n+1; i++){ cout << table[i][0] << " " << table[i][1] << endl; } return; } int main(){ //default precision for all subsequent calculations //mpfr::mpreal::set_precision(2); //mpreal pi = 2.32; //cout << val_An(2) << endl; //mpfr_t s; //mpfr::mpreal::mpfr_init(s); posit32 table[50][2] = {}; atan_table(table, 10); //print_2d(table, 10); //cout << M_PI; cordic_itr(20, 40); return 0; }
f06d027b99ae06ab37b69351966a6faf200fb5ce
5a7e9f03e0adcff08aa3cb0302601d8f7df2ff5f
/src/Entity.cpp
f7d6032071763fb80f0cf93272ce053de0533fb2
[]
no_license
jaccen/entity-framework
3fccdfcd2773a47131e64477b632435d66b762ee
5fbc9db334abd8d8ecc7f2069fe971ab5a1646a9
refs/heads/master
2021-01-25T06:56:25.211222
2016-12-30T18:16:08
2016-12-30T18:16:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
825
cpp
Entity.cpp
#include "Entity.h" Entity::Entity() { resetUUID(); } Entity::Entity(int32_t uuid, shared_ptr<ComponentOperationHandler> componentOperationHandler) : uuid(uuid), componentOperationHandler(componentOperationHandler) { } int32_t Entity::getUUID() { return uuid; } ComponentBitSet& Entity::getComponentBits() { return componentBits; } ComponentBitSet& Entity::getFamilyBits() { return familyBits; } void Entity::setUUID(int32_t uuid) { this->uuid = uuid; } void Entity::resetUUID() { this->uuid = -1; } void Entity::addInternal(shared_ptr<Component> component, TypeId componentId) { components[componentId] = component; componentBits.set(componentId); } void Entity::removeInternal(TypeId componentId) { components[componentId] = nullptr; componentBits.reset(componentId); }
14ec2a17a70429357ca0d39f0ee55c96f86c4e81
426e6d4c9147d105087f0d5c13fbb58d57758e39
/trunk/pacman/jni/input_manager.h
f0e043bd13cd64ea7ca5a863a19ad9591fe20252
[]
no_license
Im-dex/pacman
52e08d183cd4785472f9d7de4a84863a3479e764
26c545aa21adba35ec00e8fc8c515e6a54a76bb4
refs/heads/master
2021-05-04T06:42:01.518772
2012-10-15T00:59:21
2012-10-15T00:59:21
70,499,036
1
0
null
null
null
null
UTF-8
C++
false
false
969
h
input_manager.h
#pragma once #include <memory> #include <atomic> #include "base.h" #include "utils.h" #include "engine_listeners.h" namespace Pacman { enum class TouchEvent { Up = 0, Down = 1, Move = 2 }; struct TouchInfo { TouchEvent event; float x; float y; }; class InputManager { public: InputManager(); InputManager(const InputManager&) = delete; ~InputManager() = default; InputManager& operator= (const InputManager&) = delete; void PushInfo(const TouchInfo& touchInfo); void Update(); void SetListener(const std::weak_ptr<IGestureListener>& listenerPtr) { mListenerPtr = listenerPtr; } private: typedef EnumType<GestureType>::value GestureEnumType; TouchInfo mBeginGestureTouch; std::atomic<GestureEnumType> mLastGesture; std::weak_ptr<IGestureListener> mListenerPtr; }; } // Pacman namespace
12e5bd3e66ae9f405b20aa54e7d46dd5fb6281b1
483255eebf46a12460a9349fdfb78a5e7d1c1048
/homeworks/LaxWendroffScheme/mastersolution/laxwendroffscheme.h
21de0b19ca04bb5b199f6a01faf777afa4102b26
[ "MIT" ]
permissive
erickschulz/NPDECODES
5460331cb4c608ff922658c9beb1e31b4b6c9b2e
47b4fe6d60640a10bfe0ed085d67a3ccdadac831
refs/heads/master
2023-05-03T09:46:22.047387
2023-05-01T07:27:10
2023-05-01T07:27:10
184,058,364
32
64
MIT
2023-04-28T14:58:23
2019-04-29T11:28:34
C++
UTF-8
C++
false
false
2,917
h
laxwendroffscheme.h
/** * @file laxwendroffscheme.h * @brief NPDE homework "LaxWendroffScheme" code * @author Oliver Rietmann * @date 29.04.2019 * @copyright Developed at ETH Zurich */ #include <Eigen/Core> namespace LaxWendroffScheme { /** * @brief Returns the x-values as needed in the exercise. * @param c speed of propagation * @param T endtime, T > 0 * @param M number of time steps, M > 0 * @return [floor(-3T/h), ..., ceil((3T+1)/h)], where h = tau / e, tau = T / M, * e = 2.7182... */ Eigen::VectorXd getXValues(double T, unsigned int M); /** * @brief Computes the solution u(x, T) the scalar conservation law with f() = * exp() on the nodes x in getXValues(T, M), using the Lax-Wendroff scheme. * @param u0 initial data u(x, 0), with x = getXValues(T, M). * @param T endtime, T > 0 * @param M number of time steps, M > 0 * @return approximation of u(x, T) */ Eigen::VectorXd solveLaxWendroff(const Eigen::VectorXd &u0, double T, unsigned int M); /** * @brief Computes the L1-error of solveLaxWendroff(u0, T, M(i)) against the * analytical solution for different values M(i), u0 being the characteristic * function of [0, infty) and T = 1.0. * @param M vector of numbers of timesteps, M(i) > 0. * @return vector of same size as M containing the L1-error for each M(i) */ Eigen::VectorXd numexpLaxWendroffRP(const Eigen::VectorXi &M); /** * @brief Provides a reference solution evaluated at the nodes x, obtained by * solveLaxWendroff(u0, T, M), where u0 is the smooth inital data from the * exercise, T = 1.0 and M = 3200. * @param equidistant x-values * @return vector of same size as x containing the solution evaluated at x. */ Eigen::VectorXd referenceSolution(const Eigen::VectorXd &x); /** * @brief Same as numexpLaxWendroffRP(...), but with the smooth initial data u0 * from the exercise. * @param M vector of numbers of timesteps, M(i) > 0. * @return vector of same size as M containing the L1-error for each M(i) */ Eigen::VectorXd numexpLaxWendroffSmoothU0(const Eigen::VectorXi &M); /** * @brief Computes the solution u(x, T) the scalar conservation law with f() = * exp() on the nodes x in getXValues(T, M), using the Godunov numerical flux * (semi-discretization) and explicit euler (full discretization). * @param initial data u(x, 0), with x = getXValues(T, M). * @param T endtime, T > 0 * @param M number of time steps, M > 0 * @return approximation of u(x, T) */ Eigen::VectorXd solveGodunov(const Eigen::VectorXd &u0, double T, unsigned int M); /** * @brief Same as numexpLaxWendroffSmoothU0(...), but with solveGodunov(...) * instead of solveLaxWendroff(...). * @param M vector of numbers of timesteps, M(i) > 0. * @return vector of same size as M containing the L1-error for each M(i) */ Eigen::VectorXd numexpGodunovSmoothU0(const Eigen::VectorXi &M); } // namespace LaxWendroffScheme
89a50697aa1b789a2b6aef3ed74d3f3677a05861
e386871963ddd0e2d526f7817c52add4a59629ce
/Source/Tonks/Pawns/BasePawn.cpp
97145dbd19474966db4e04021bf427be39207ef3
[]
no_license
FAnargyrou/Tonks
f8821e909c68e9ade33b8f30ab1cadc1e446ca82
2754fb1917f90fcb2e9ba9d5cc9dc56a186d0842
refs/heads/master
2023-02-13T18:02:42.876090
2021-01-08T17:13:39
2021-01-08T17:13:39
314,864,753
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
7,421
cpp
BasePawn.cpp
// Tonks © 2020 Felipe Anargyrou. All Rights Reserved #include "BasePawn.h" #include "Components/BoxComponent.h" #include "Camera/CameraComponent.h" #include "Engine/World.h" #include "GameFramework/SpringArmComponent.h" #include "Kismet/GameplayStatics.h" #include "Tonks/Actors/ProjectileBase.h" #include "Tonks/GameModes/TonksGameModeBase.h" // Sets default values ABasePawn::ABasePawn() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box Collider")); RootComponent = BoxComponent; BodyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Body Mesh")); BodyMesh->SetupAttachment(RootComponent); TurretMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Turret Mesh")); TurretMesh->SetupAttachment(BodyMesh); GunMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Gun Mesh")); GunMesh->SetupAttachment(TurretMesh); ProjectileSpawnPoint = CreateDefaultSubobject<USceneComponent>(TEXT("Projectile Spawn Point")); ProjectileSpawnPoint->SetupAttachment(GunMesh); AimModePoint = CreateDefaultSubobject<USceneComponent>(TEXT("Aim Mode Point")); AimModePoint->SetupAttachment(GunMesh); SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm")); SpringArm->SetupAttachment(RootComponent); SpringArm->bUsePawnControlRotation = true; Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera")); Camera->SetupAttachment(SpringArm); } // Called when the game starts or when spawned void ABasePawn::BeginPlay() { Super::BeginPlay(); OriginalSpringArmLength = SpringArm->TargetArmLength; GameModeRef = Cast<ATonksGameModeBase>(UGameplayStatics::GetGameMode(GetWorld())); if (!GameModeRef) { UE_LOG(LogTemp, Error, TEXT("Game Mode is not set to TonksGameModeBase. Game loop will not work as intended!")); } } // Called every frame void ABasePawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); FVector ActorUpVector = GetActorUpVector(); float DotProduct = FVector::DotProduct(ActorUpVector, FVector::UpVector); if (DotProduct <= 0.f || FMath::IsNearlyZero(DotProduct, FLOAT_NORMAL_THRESH)) { FVector Velocity = BoxComponent->GetComponentVelocity(); Velocity.Normalize(); if (Velocity.IsNearlyZero()) { FRotator Rot = GetActorRotation(); Rot.Normalize(); SetActorRotation(FRotator(0.f, Rot.Yaw, 0.f)); } } if (bIsPreparingFire) { CurrentProjectileSpeed = FMath::Clamp(CurrentProjectileSpeed + (ProjectileSpeedIncrement * DeltaTime), 0.f, MaxProjectileSpeed); if (CurrentProjectileSpeed >= MaxProjectileSpeed) ProjectileSpeedIncrement *= -1.f; else if (FMath::IsNearlyZero(CurrentProjectileSpeed, FLOAT_NORMAL_THRESH) || CurrentProjectileSpeed < 0.f) ProjectileSpeedIncrement *= -1.f; UE_LOG(LogTemp, Warning, TEXT("Current Speed = %f"), CurrentProjectileSpeed); } } // Called to bind functionality to input void ABasePawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); } void ABasePawn::InitiateTurn() { // Sets Controller Rotation's intial Pitch to SpringArm's Relative Pitch // (To ensure a smooth Start in the game, instead of spawning the camera straight at the back of the tank) FRotator Rotator = GetControlRotation(); Rotator.Pitch = SpringArm->GetRelativeRotation().Pitch; Controller->SetControlRotation(Rotator); // Reset CurrentProjectile to a nullptr as this shouldn't be referenced anymore if (CurrentProjectile) { CurrentProjectile = nullptr; } bIsOnTurn = true; } void ABasePawn::Move(FVector MoveDirection) { if (!bIsInAimMode && bIsOnTurn && MoveDistance > 0.f) { AddActorLocalOffset(MoveDirection, false); MoveDistance = FMath::Clamp(MoveDistance - MoveDirection.Size(), 0.f, MaxDistance); } } void ABasePawn::Turn(FQuat TurnDirection) { if (!bIsInAimMode && bIsOnTurn) AddActorLocalRotation(TurnDirection, true); } void ABasePawn::Rotate(FQuat RotationDirection) { AddControllerYawInput(RotationDirection.Rotator().Yaw); if (bIsInAimMode && bIsOnTurn) { // Rotates the TurretMesh's Yaw value; We want the Turret to be attached to the base so only Yaw rotation should be valid here FRotator ActorRotation = BodyMesh->GetComponentRotation(); FRotator Rotation(ActorRotation.Pitch, GetControlRotation().Yaw, ActorRotation.Roll); TurretMesh->AddLocalRotation(RotationDirection); } } void ABasePawn::LookUp(FQuat LookUpDirection) { AddControllerPitchInput(LookUpDirection.Rotator().Pitch * -1.f); if (bIsInAimMode && bIsOnTurn) { // Clamps Gun's rotation to prevent it from rotating 360 degrees FRotator NewRotation = GunMesh->GetRelativeRotation(); NewRotation.Pitch += LookUpDirection.Rotator().Pitch; NewRotation.Pitch = FMath::Clamp(NewRotation.Pitch, GunMinPitch, GunMaxPitch); GunMesh->SetRelativeRotation(NewRotation); } } void ABasePawn::PrepareFire() { if (bIsInAimMode && bIsOnTurn) bIsPreparingFire = true; } void ABasePawn::ReleaseFire() { if (bIsInAimMode && bIsOnTurn) { bIsPreparingFire = false; Fire(); } } void ABasePawn::Fire() { if (ProjectileClass && bIsInAimMode) { FVector Position = ProjectileSpawnPoint->GetComponentLocation(); FRotator Rotation = ProjectileSpawnPoint->GetComponentRotation(); AProjectileBase* Projectile = GetWorld()->SpawnActor<AProjectileBase>(ProjectileClass, Position, Rotation); Projectile->AddVelocity(CurrentProjectileSpeed); // Reset modifier back to 0.f ready for this Pawn's next turn CurrentProjectileSpeed = 0.f; Projectile->SetOwner(this); APlayerController* Player = Cast<APlayerController>(Controller); if (Player) Player->SetViewTarget(Projectile); MoveMode(); CurrentProjectile = Projectile; bIsOnTurn = false; } } void ABasePawn::ResetMovement() { MoveDistance = MaxDistance; } AActor* ABasePawn::GetCurrentProjectile() { return CurrentProjectile; } FString ABasePawn::GetPlayerName() { return PlayerName; } // TODO - Implement FMath::FInterpConstantTo to reproduce a smooth transition between Aim and Move Modes // Attaches the SpringArm/Player Camera to the AimModePoint Component, which should be set to somewhere around the GunMesh void ABasePawn::AimMode() { if (SpringArm && !bIsInAimMode && bIsOnTurn) { SpringArm->TargetArmLength = 0.f; MoveModeRotation = GetControlRotation(); Controller->SetControlRotation(GunMesh->GetComponentRotation()); FAttachmentTransformRules Rules(EAttachmentRule::SnapToTarget , false); SpringArm->AttachToComponent(AimModePoint, Rules); SpringArm->bUsePawnControlRotation = false; bIsInAimMode = true; } } // Attaches the SpringArm/Player Camera back to it's original Position and allows player to move around again void ABasePawn::MoveMode() { if (SpringArm && bIsInAimMode && bIsOnTurn && !bIsPreparingFire) { SpringArm->TargetArmLength = OriginalSpringArmLength; Controller->SetControlRotation(MoveModeRotation); FAttachmentTransformRules Rules(EAttachmentRule::KeepRelative, false); SpringArm->AttachToComponent(RootComponent, Rules); SpringArm->bUsePawnControlRotation = true; bIsInAimMode = false; } } // Called if Controller decides to end turn without firing. void ABasePawn::EndTurn() { if (GameModeRef && !bIsInAimMode && bIsOnTurn) { bIsOnTurn = false; GameModeRef->EndTurn(); } }
0ae7f3c58d095a460e14997b404621b2723528ef
b1d49de22c9cee06e934fac53adebae84773fe80
/Player.h
47130a9f6de9731cd56baefb2ba91ef2f8a766f0
[]
no_license
play3577/GoSample2
ccc370f2169e8968c13b2c41112c71aea1e5b5a0
37d9231566dc04167e39d2418197f3ab035f3ddd
refs/heads/master
2021-04-12T08:35:55.435271
2016-08-21T02:26:12
2016-08-21T02:26:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
117
h
Player.h
#pragma once #include "Board.h" class Player { public: virtual XY select_move(Board& board, Color color) = 0; };
91255d2edd9e837d1a8402909201b2ed4d712266
d932e10fc9a2930d3e7e75d6ff332265d2f2cda2
/target_com/power_crc.cpp
723dbf591c32402c8e193657acbf3caf3ff7a4db
[]
no_license
bding2018/targetman
aa70f55ca4c453101c1a71ff5eef329a43f51985
0169e8f90f0eeade2bbb25d61f449730f675986b
refs/heads/master
2020-05-04T07:28:49.155222
2019-04-08T07:52:24
2019-04-08T07:52:24
179,028,873
7
1
null
null
null
null
GB18030
C++
false
false
6,691
cpp
power_crc.cpp
/*--------------------------------------------------------------------------- CRC 校验计算类 该类可用于计算8位、16位和32位 CRC 校验。在类的初始化函数中指明要计算 的CRC的位长、多项式、运算顺序、初始值和屏蔽值。 Reverse为真时表示是右移 ---------------------------------------------------------------------------*/ #include "power_crc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------------- UBYTE4 Crc::bits [BITSPERBYTE * 4] = { 0x00000001UL, 0x00000002UL, 0x00000004UL, 0x00000008UL, 0x00000010UL, 0x00000020UL, 0x00000040UL, 0x00000080UL, 0x00000100UL, 0x00000200UL, 0x00000400UL, 0x00000800UL, 0x00001000UL, 0x00002000UL, 0x00004000UL, 0x00008000UL, 0x00010000UL, 0x00020000UL, 0x00040000UL, 0x00080000UL, 0x00100000UL, 0x00200000UL, 0x00400000UL, 0x00800000UL, 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL, 0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL, } ; //--------------------------------------------------------------------------- Crc::Crc (unsigned int BitCount, unsigned long Polynominal, bool Reverse, unsigned long Initial, unsigned long FinalMask) // BitCount : CRC Size // Polynominal : CRC Polynomial // Reverse : Reversed (means shift right) // Initial : Initial CRC Register Value // FinalMask : Final CRC XOR Value { BITCOUNT = BitCount; //校验码的位数 POLYNOMINAL = Polynominal;//生成多项式 INITIAL = Initial; //注册码 FINALMASK = FinalMask; //掩码 // Mask needed to mask off redundent bits mask = ((1UL << (BITCOUNT - 1)) - 1UL) | (1UL << (BITCOUNT - 1)) ; REVERSE = Reverse; // Before set this property // mask must be calculated } //--------------------------------------------------------------------------- void Crc::SetReverse(bool reverse) { FREVERSE = reverse; if (reverse) { for (unsigned int ii = 0 ; ii < MAXBYTEVALUES ; ++ ii) values [ii] = ReverseTableEntry (ii) ; } else { for (unsigned int ii = 0 ; ii < MAXBYTEVALUES ; ++ ii) values [ii] = ForwardTableEntry (ii) ; } } //--------------------------------------------------------------------------- /************************************************************************/ /* 函数名称: Reverse (UBYTE4 value) /* 参 数: 1.UBYTE4 value - 需要首尾互调的数 /* 返 回 值: 返回首尾互调后的数值 /* 功 能: 将一个数值首尾互调,如 1010 -> 0101 /* 作 者:ebaoqigai@sina.com /* 修 改: version purpose date 1.0 create 2014.09.12 /************************************************************************/ BYTE4 Crc::Reverse (UBYTE4 value) { unsigned long result = 0 ; for (unsigned int jj = 0 ; jj < BITCOUNT ; ++ jj) { if ((value & bits [jj]) != 0) result |= bits [BITCOUNT - jj - 1] ; } return result ; } //--------------------------------------------------------------------------- /************************************************************************/ /* 函数名称: ForwardTableEntry (unsigned int entryindex) /* 参 数: 1.unsigned int entryindex - 需要首尾互调的数 /* 返 回 值: 返回首尾互调后的数值 /* 功 能: 将一个数值首尾互调,如 1010 -> 0101 /* 作 者:ebaoqigai@sina.com /* 修 改: version purpose date 1.0 create 2014.09.12 /************************************************************************/ UBYTE4 Crc::ForwardTableEntry (unsigned int entryindex) // This function creates a CRC table entry for a non-reversed // CRC function. // // Parameters: // // entryindex: The index of the CRC table entry. // // Return Value: // // The value for the specified CRC table entry. // { UBYTE4 result = entryindex << (BITCOUNT - BITSPERBYTE) ; for (unsigned int ii = 0 ; ii < BITSPERBYTE ; ++ ii) { if ((result & bits [BITCOUNT - 1]) == 0) result <<= 1 ; else result = (result << 1) ^ POLYNOMINAL ; } result &= mask ; return result ; } //--------------------------------------------------------------------------- UBYTE4 Crc::ReverseTableEntry (unsigned int entryindex) // This function creates a CRC table entry for a reversed // // CRC function. // // Parameters: // // entryindex: The index of the CRC table entry. // // Return Value: // // The value for the specified CRC table entry. // { UBYTE4 result = entryindex ; for (unsigned int ii = 0 ; ii < BITSPERBYTE ; ++ ii) { if ((result & 1) == 0) result >>= 1 ; else result = (result >> 1) ^ Reverse (POLYNOMINAL) ; } result &= mask ; return result ; } //--------------------------------------------------------------------------- void Crc::reset (void) { crc_register = INITIAL ; } //--------------------------------------------------------------------------- UBYTE4 Crc::value (void) const { UBYTE4 result = crc_register ^ FINALMASK ; result &= mask ; return result ; } //--------------------------------------------------------------------------- void Crc::update (const char *buffer, unsigned int length) // This function updates the value of the CRC register based upon // the contents of a buffer. // // Parameters: // // buffer: The input buffer // length: The length of the input buffer. // { // The process for updating depends upon whether or not we are using // the reversed CRC form. if (REVERSE) { for (unsigned int ii = 0 ; ii < length ; ++ ii) { crc_register = values [(crc_register ^ buffer [ii]) & 0xFF] ^ (crc_register >> 8) ; } } else { for (unsigned int ii = 0 ; ii < length ; ++ ii) { UBYTE4 index = ((crc_register >> (BITCOUNT - BITSPERBYTE)) ^ buffer [ii]) ; crc_register = values [index & 0xFF] ^ (crc_register << BITSPERBYTE) ; } } return ; } //--------------------------------------------------------------------------- UBYTE4 Crc::getcrc(const char *buffer, unsigned int length) { reset(); update(buffer,length); return value(); }
8ac072a90a0b3366d90affa6ceb9a3afcb4f4c48
645c6766afe021387b0d391e20e77514e4222b13
/1208.cpp
f3a35fcc20700b7624476f317fea42215fea1b4e
[]
no_license
krofna/uva
2d48218c26e59ccf56dabc1ec75fa1acb2ac75ea
fbc956d98c14b55a62b606747acdf467d304b142
refs/heads/master
2020-06-22T09:31:03.786648
2019-03-11T22:10:22
2019-03-11T22:10:22
74,597,336
0
0
null
null
null
null
UTF-8
C++
false
false
1,590
cpp
1208.cpp
#include <iostream> #include <vector> #include <tuple> #include <queue> #include <sstream> using namespace std; typedef tuple<int, int, int> iii; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; typedef vector<iii> viii; typedef greater<iii> giii; typedef priority_queue<iii, viii, giii> pqiii; typedef vector<bool> vb; void p(pqiii& Q, vvii& G, vb& T, int x) { T[x] = true; for (int i = 0; i < G[x].size(); ++i) if (!T[G[x][i].second]) Q.emplace(G[x][i].first, G[x][i].second, x); } int main() { int t, n, x, y, w; cin >> t; for (int z = 1; z <= t; ++z) { cout << "Case " << z << ":\n"; cin >> n; cin.ignore(); vvii G(n, vii()); for (int i = 0; i < n; ++i) { string s; getline(cin, s); istringstream iss(s); for (int j = 0; j < n; ++j) { getline(iss, s, ','); if (w = stoi(s)) G[i].emplace_back(w, j); } } pqiii Q, R; vb T(n, false); p(Q, G, T, 0); while (!Q.empty()) { tie(w, x, y) = Q.top(); Q.pop(); if (!T[x]) { R.emplace(w, x, y); p(Q, G, T, x); } } // TODO: Trebo sam kruskal... while (!R.empty()) { tie(w, x, y) = R.top(); R.pop(); cout << char('A' + min(x, y)) << '-'; cout << char('A' + max(x, y)) << ' ' << w << '\n'; } } }
e14b723acceaa14050337a5b765ed35615551e8c
05f76534047232e08b32dfa59e0703859c206c74
/Campfire keeper xxx engine version=1.0/code/Game/game_utils.cpp
bfb9e857a8fecbfe75ecb57a81c09c215491243b
[]
no_license
Straple/Lunar-Oblivion-CPP-2d-Game-Engine
1f50eb864ac8569ab7acf18a72d438f2d5994b59
02c5669cee5ddaecd3a2befec9e043981a0e2123
refs/heads/main
2023-04-24T18:08:42.570009
2021-05-12T14:55:27
2021-05-12T14:55:27
348,034,204
0
0
null
null
null
null
UTF-8
C++
false
false
855
cpp
game_utils.cpp
 void draw_collision(const collision_circle& coll) { if (eng_state.debug_mode()) { Circle circle = coll.circle; static_pos_update(circle.pos, !eng_state.camera_mode()); draw_circle(circle, Color(0xffffff, 128)); } } void draw_collision(const collision_box& coll) { if (eng_state.debug_mode()) { dot p0 = coll.p0; dot p1 = coll.p1; std::swap(p0.y, p1.y); static_pos_update(p0, !eng_state.camera_mode()); static_pos_update(p1, !eng_state.camera_mode()); draw_rect2(p0, p1, Color(0xffffff, 128)); } } template<typename T> void draw_collision_obj(const T& object) { draw_collision(object.get_collision()); } template<typename T> void draw_hp(const T& object) { if (eng_state.debug_mode()) { dot p = object.pos; static_pos_update(p, !eng_state.camera_mode()); draw_object(object.hp, p, 0.3, Color(0x0000ff, 0xff)); } }
582b81ca9274eead19d92f6fddf09708725bbb0b
5c68ef82ad13b694bb92763f36f939526305509d
/Config/Cpp/Templet/ConfigStruct.h
ba75c196327128ef06230456ab8deb306a821423
[ "MIT" ]
permissive
catdoc/CSVGenCode
c33ac4ef0e4357c4713d42ccb140ed8d054cc2ce
c4f1977419ed8d700fa6a59c7de3f2acd3587f78
refs/heads/master
2020-06-21T03:25:10.539150
2018-04-20T06:13:12
2018-04-20T06:13:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,999
h
ConfigStruct.h
/******************************************************************** ** This head file is generated by program, ** ** Please do not change it directly. ** ********************************************************************/ #ifndef CODE_GEN_BY_CSV_CONFIG_STRUCT_H_H_HHHH #define CODE_GEN_BY_CSV_CONFIG_STRUCT_H_H_HHHH /* Define c types. */ #ifndef TDR_CUSTOM_C_TYPES #define TDR_CUSTOM_C_TYPES #include <stddef.h> #include <time.h> #include <sys/types.h> #if !defined(_WIN32) && !defined(_WIN64) #include <stdint.h> #include <inttypes.h> #else /*if !defined(_WIN32) && !defined(_WIN64)*/ //The stdint declaras typedef signed char int8_t; typedef short int16_t; typedef int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #if _MSC_VER >= 1300 typedef unsigned long long uint64_t; typedef long long int64_t; #else /* _MSC_VER */ typedef unsigned __int64 uint64_t; typedef __int64 int64_t; #endif /* _MSC_VER */ #endif /*if !defined(_WIN32) && !defined(_WIN64)*/ typedef int64_t tdr_longlong; typedef uint64_t tdr_ulonglong; typedef uint16_t tdr_wchar_t; /**<Wchar基本数据类型*/ typedef uint32_t tdr_date_t; /**<data基本数据类型*/ typedef uint32_t tdr_time_t; /**<time基本数据类型*/ typedef uint64_t tdr_datetime_t; /**<datetime基本数据类型*/ typedef uint32_t tdr_ip_t; /**<IPv4数据类型*/ #endif /*TDR_CUSTOM_C_TYPES*/ /* Define structs/unions. */ #pragma pack(1) #include<string> using std::string; #Begin_Replace_Tag_Class struct #StructName { #Begin_Replace_Tag_Attri #AttriTypeName #AttriName;//#AttriCommment #End_Replace_Tag_Attri }; #End_Replace_Tag_Class #pragma pack() #endif /* CODE_GEN_BY_CSV_CONFIG_STRUCT_H_H_HHHH */
64a0f9c3965888eea47095ca74f8175a406c3470
0ef6f523f64dd2461893bfa510eae3ac2da47dc1
/Classes/CannonTypeMagicSlowLine.cpp
5f6fe0c3a7673be2c0a725d154a0ec0e07fbe993
[]
no_license
Crasader/ColorDefence
2654fcd368f9a3f20056dbb8733f3f9c99264770
e0f940c26bbf3803ff64b7a4e4d2e248967db2ab
refs/heads/master
2020-12-07T08:41:53.498516
2016-05-21T06:17:23
2016-05-21T06:17:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,731
cpp
CannonTypeMagicSlowLine.cpp
#include "CannonTypeMagicSlowLine.h" #include "BulletTypeMagicSlowLine.h" #include "NumericalManager.h" USING_NS_CC; bool CannonTypeMagicSlowLine::init() { if ( !Cannon::init() ) { return false; } _cannonType = 0; setTexture("cannons/CannonCover_MagicSlowLine.png"); return true; } void CannonTypeMagicSlowLine::attackOnce() { stopAllActions(); ScaleTo* st = ScaleTo::create(0.05,1,0.5); //MoveBy* mb = MoveBy::create(0.05,Vect(0,getContentSize().height*0.25)); ScaleTo* st2 = ScaleTo::create(0.05,1); //MoveBy* mb2 = mb->reverse(); //Spawn* sp = Spawn::create(st,mb,nullptr); //Spawn* sp2 = Spawn::create(st2,mb2,nullptr); Sequence* seq = Sequence::create(st,st2,nullptr); runAction(seq); BulletTypeMagicSlowLine* bullet = BulletTypeMagicSlowLine::create(); bullet->setPosition(getPosition()); bullet->setRotation(getRotation()); bullet->setDamage(_damage, 45, 0.6, 0.4); bullet->setDamageContributerID(_damageContributerID); bullet->setTarget(_target); getParent()->addChild(bullet); // //bullet->setColor(NumericalManager::getInstance()->getBulletColor(getColorInfo())); // SoundManager::getInstance()->playSoundEffect("sound/cannon_shot_magicSlowLine.wav"); } void CannonTypeMagicSlowLine::tryGetTarget() { Vector<Enemy*> v_target = Vector<Enemy*>(); for (Enemy* e: em->enemiesInSequence) { if ((!e->isAntiMagic())&&(getPosition().getDistance(e->getPosition())<=attackRange)) { v_target.pushBack(e); } } if (v_target.empty()) { return; } _target = v_target.front(); for (Enemy*e : v_target) { if (getPosition().getDistance(e->getPosition())<=getPosition().getDistance(_target->getPosition())) { _target = e; isAttacking = true; } } }
908bbd81b9ba9ee3d8129de9025e1919678736cd
8483830175b98ba2915d7bf90bed728bb6a4ed75
/Examples/include/asposecpplib/system/io/string_writer.h
56070f466e92d5df3e477a06e6c5f9c66b7a895f
[ "MIT" ]
permissive
kashifiqb/Aspose.PDF-for-C
83393e3173e2d74540f7ec7904eb91fb23b13550
13d49bba591c5704685820185741e64a462a5bdc
refs/heads/master
2020-08-08T11:15:23.173738
2019-10-09T04:41:03
2019-10-09T04:41:03
213,819,800
0
0
MIT
2019-10-09T04:20:06
2019-10-09T04:20:06
null
UTF-8
C++
false
false
4,762
h
string_writer.h
/// @file system/io/string_writer.h #ifndef string_writer_h #define string_writer_h #include "fwd.h" #include "system/iformatprovider.h" #include "system/exceptions.h" #include "system/reflection.h" #include "system/globalization/culture_info.h" #include "system/io/text_writer.h" #include "system/text/string_builder.h" #include "system/text/unicode_encoding.h" namespace System { namespace IO { /// Implements a TextWriter that writes information to a string. /// Objects of this class should only be allocated using System::MakeObject() function. /// Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. /// Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument. class ASPOSECPP_SHARED_CLASS StringWriter : public TextWriter { RTTI_INFO(System::IO::StringWriter, ::System::BaseTypesInfo<System::IO::TextWriter>) public: /// Constructs a new instance of StringWriter using the specified StringBuilder and IFormatProvider. /// @param sb The StringBuilder object to be used by the StringWriter being constructed /// @param formatProvider An IFormatProvider object to be used by the object being constructed StringWriter(System::SharedPtr<Text::StringBuilder> sb, IFormatProviderPtr formatProvider) : TextWriter(formatProvider) { if (sb == nullptr) throw ArgumentNullException(u"StringBuilder"); _sb = sb; } /// Constructs a new instance of StringWriter using the specified StringBuilder and IFormatProvider from the current culture. /// @param sb The StringBuilder object to be used by the StringWriter being constructed StringWriter(System::SharedPtr<Text::StringBuilder> sb) : StringWriter(sb, Globalization::CultureInfo::get_CurrentCulture()) {} /// Constructs a new instance of StringWriter using the specified IFormatProvider. /// @param formatProvider An IFormatProvider object to be used by the object being constructed StringWriter(IFormatProviderPtr formatProvider) : StringWriter(MakeObject<Text::StringBuilder>(), formatProvider) {} /// Constructs a new instance of StringWriter using IFormatProvider from the current culture. StringWriter() : StringWriter(MakeObject<Text::StringBuilder>(), Globalization::CultureInfo::get_CurrentCulture()) {} /// Returns the currently used encoding. virtual SharedPtr<Text::Encoding> get_Encoding() override { if (m_Encoding == nullptr) m_Encoding = MakeObject<Text::UnicodeEncoding>(false, false); return m_Encoding; }; /// Returns the currently used StringBuilder. virtual SharedPtr<Text::StringBuilder> GetStringBuilder() { return _sb; } /// Writes the specified character to the stream. /// @param value The value to write virtual void Write(char_t value) override { _sb->Append(value); } /// Writes the specified subrange of characters from the specified character array to the stream. /// @param buffer The array containing the characters to write /// @param index A 0-based index of the elemnet in @p buffer at which the subrange to write begins /// @param count The number of characters in the subrange to write virtual void Write(ArrayPtr<char_t> buffer, int index, int count) override { if (buffer == nullptr) throw ArgumentNullException(u"buffer"); if (index < 0) throw ArgumentOutOfRangeException(u"index"); if (count < 0) throw ArgumentOutOfRangeException(u"count"); if (buffer->get_Length() - index < count) throw ArgumentException(u"insufficient buffer length"); _sb->Append(buffer, index, count); } /// Writes the specified string to the stream. /// @param value The string to write virtual void Write(const String& value) override { if (!value.IsNull()) _sb->Append(value); } /// Returns the underlying string. virtual String ToString() ASPOSE_CONST override { return _sb->ToString(); } private: /// The StringBuilder used by the current object. SharedPtr<Text::StringBuilder> _sb = nullptr; /// The encoding currently used. static SharedPtr<Text::UnicodeEncoding> ASPOSECPP_SHARED_API m_Encoding; }; }} // namespace System{ namespace IO{ #endif //string_writer_h
948925f4a6f2a82ca52f86edd9b31038362875dd
e70d0bcc547d63b338ff51c253aa95d78ea99992
/xdl/ps-plus/ps-plus/common/initializer/random/philox_random.h
09fb8178473a8ad555a59bb1a361b58821f0395f
[ "Apache-2.0" ]
permissive
niumeng07/x-deeplearning
2513f7ba823521c40e0346284f5dd0aca5562e40
6d3bc3ad4996ab8938c56d8a834af07a04dc2f67
refs/heads/master
2020-04-12T23:06:24.447833
2019-07-06T16:06:16
2019-07-06T16:06:16
162,808,758
2
0
Apache-2.0
2018-12-22T12:18:01
2018-12-22T12:17:59
null
UTF-8
C++
false
false
7,220
h
philox_random.h
/* Copyright (C) 2016-2018 Alibaba Group Holding Limited 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 PS_COMMON_INITIALIZER_RANDOM_PHILOX_RANDOM_H #define PS_COMMON_INITIALIZER_RANDOM_PHILOX_RANDOM_H #include <stdlib.h> #include <math.h> #include <cstdint> namespace ps { typedef int8_t int8; typedef int16_t int16; typedef int32_t int32; typedef int64_t int64; typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; static const uint8_t kuint8max = ((uint8_t)0xFF); static const uint16_t kuint16max = ((uint16_t)0xFFFF); static const uint32_t kuint32max = ((uint32_t)0xFFFFFFFF); static const uint64_t kuint64max = ((uint64_t)0xFFFFFFFFFFFFFFFFull); static const int8_t kint8min = ((int8_t)~0x7F); static const int8_t kint8max = ((int8_t)0x7F); static const int16_t kint16min = ((int16_t)~0x7FFF); static const int16_t kint16max = ((int16_t)0x7FFF); static const int32_t kint32min = ((int32_t)~0x7FFFFFFF); static const int32_t kint32max = ((int32_t)0x7FFFFFFF); static const int64_t kint64min = ((int64_t)~0x7FFFFFFFFFFFFFFFll); static const int64_t kint64max = ((int64_t)0x7FFFFFFFFFFFFFFFll); template <typename T, int ElementCount> class Array { public: Array() { for (int i = 0; i < ElementCount; ++i) { data_[i] = T(0); } } const T& operator[](int index) const { return data_[index]; } T& operator[](int index) { return data_[index]; } size_t size() const { return ElementCount; } private: T data_[ElementCount]; }; // A class that encapsulates all the states for a random number generator using // the philox_4x32_10 algorithm. Each invocation returns a 128-bit random bits // in the form of four uint32_t. // There are multiple variants of this algorithm, we picked the 4x32_10 version // that is most suited for our applications. // Since this class is meant to be copied between CPU to GPU, it maintains a // value semantics. // // For example: To use this class and populate an array of 1024 randoms on CPU // with two threads, // // void Fill(PhiloxRandom rnd, uint32_t* output, int start, int limit) { // assert(start % 4 == 0); // assert(limit % 4 == 0); // rnd.Skip(start / 4); // for (int i = start; i < limit; i += 4) { // auto sample = rnd(); // ... copy sample[0..3] to output[i..i+3] // } // } // // PhiloxRandom rng(seed); // PhiloxRandom rng_copy = rng; // rng.Skip(1000/4); // // ... schedule Fill(rng_copy, output, 0, 512) in thread 1; // ... schedule Fill(rng_copy, output, 512, 1024) in thread 2; // ... wait for thread 1 & 2 to finish executing Fill(). // class PhiloxRandom { public: typedef Array<uint32_t, 4> ResultType; typedef uint32_t ResultElementType; // The number of elements that will be returned. static const int kResultElementCount = 4; // Cost of generation of a single element (in cycles). static const int kElementCost = 10; PhiloxRandom() {} explicit PhiloxRandom(uint64 seed) { key_[0] = static_cast<uint32_t>(seed); key_[1] = static_cast<uint32_t>(seed >> 32); } explicit PhiloxRandom(uint64 seed_lo, uint64 seed_hi) { key_[0] = static_cast<uint32_t>(seed_lo); key_[1] = static_cast<uint32_t>(seed_lo >> 32); counter_[2] = static_cast<uint32_t>(seed_hi); counter_[3] = static_cast<uint32_t>(seed_hi >> 32); } // Skip the specified number of samples of 128-bits in the current stream. inline void Skip(uint64 count) { const uint32_t count_lo = static_cast<uint32_t>(count); uint32_t count_hi = static_cast<uint32_t>(count >> 32); counter_[0] += count_lo; if (counter_[0] < count_lo) { ++count_hi; } counter_[1] += count_hi; if (counter_[1] < count_hi) { if (++counter_[2] == 0) { ++counter_[3]; } } } // Returns a group of four random numbers using the underlying Philox // algorithm. inline ResultType operator()() { ResultType counter = counter_; Key key = key_; // Run the single rounds for ten times. Manually unrolling the loop // for better performance. counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); RaiseKey(&key); counter = ComputeSingleRound(counter, key); SkipOne(); return counter; } private: // The type for the 64-bit key stored in the form of two 32-bit uint // that are used in the diffusion process. typedef Array<uint32_t, 2> Key; // We use the same constants as recommended by the original paper. static const uint32_t kPhiloxW32A = 0x9E3779B9; static const uint32_t kPhiloxW32B = 0xBB67AE85; static const uint32_t kPhiloxM4x32A = 0xD2511F53; static const uint32_t kPhiloxM4x32B = 0xCD9E8D57; // Helper function to skip the next sample of 128-bits in the current stream. inline void SkipOne() { if (++counter_[0] == 0) { if (++counter_[1] == 0) { if (++counter_[2] == 0) { ++counter_[3]; } } } } // Helper function to return the lower and higher 32-bits from two 32-bit // integer multiplications. inline static void MultiplyHighLow(uint32_t a, uint32_t b, uint32_t* result_low, uint32_t* result_high) { const uint64 product = static_cast<uint64>(a) * b; *result_low = static_cast<uint32>(product); *result_high = static_cast<uint32>(product >> 32); } // Helper function for a single round of the underlying Philox algorithm. inline static ResultType ComputeSingleRound( const ResultType& counter, const Key& key) { uint32_t lo0; uint32_t hi0; MultiplyHighLow(kPhiloxM4x32A, counter[0], &lo0, &hi0); uint32_t lo1; uint32_t hi1; MultiplyHighLow(kPhiloxM4x32B, counter[2], &lo1, &hi1); ResultType result; result[0] = hi1 ^ counter[1] ^ key[0]; result[1] = lo1; result[2] = hi0 ^ counter[3] ^ key[1]; result[3] = lo0; return result; } inline void RaiseKey(Key* key) { (*key)[0] += kPhiloxW32A; (*key)[1] += kPhiloxW32B; } private: ResultType counter_; Key key_; }; } // namespace ps #endif // PS_COMMON_INITIALIZER_RANDOM_PHILOX_RANDOM_H
d7b116ecb1a96aec5bedd35d282922286bf2266e
1cf71a114fc68752034582a5d4ea9330cd9b7ace
/SP4 GDT Team 10/AI/Source/EffectReticle.h
7cbdab87a9a4400bfb0341f51d8086fefc1b8f26
[]
no_license
Tynk3r/2019sp4gdt
19af09673f1ab468331d1ebd93061b13cc1caeec
8889a96d66a8cd4bfd7f3b34b0976bdb61d34830
refs/heads/master
2020-04-22T02:51:27.359357
2019-02-28T13:03:25
2019-02-28T13:03:25
170,065,462
0
0
null
null
null
null
UTF-8
C++
false
false
419
h
EffectReticle.h
#pragma once #include "EffectBase.h" struct GameObject; class EffectReticle : public EffectBase { public: enum RETICLE_TYPE { RETICLE_OUTER, RETICLE_INNER }; EffectReticle(RETICLE_TYPE type = RETICLE_OUTER); virtual ~EffectReticle(); GameObject* selected; float reticleThickness; float fElapsedTime; virtual void Update(float dt); protected: RETICLE_TYPE type; private: //virtual void Render() = 0; };
d4f4957e473c19b3e59ba1c523aba00b621cb89c
ed42076d431ed30b3085e378075ee3368ec8631c
/RegularRock.cpp
9d73b420e5d90dc459ee4805da5cea3ddcf68888
[]
no_license
yanivys4/Gold-Miner
fdebc1047a6abe2f6a4c45dd9c8e614ae46fa9d7
d40d11c6476e4d57b01ef35594b48fed023ba068
refs/heads/master
2020-07-01T03:13:27.241689
2019-08-07T11:27:58
2019-08-07T11:27:58
201,028,797
2
2
null
2019-08-07T11:26:59
2019-08-07T10:34:24
C++
UTF-8
C++
false
false
1,084
cpp
RegularRock.cpp
#include "RegularRock.h" bool RegularRock::m_registeritSmall = Factory::registerit('1', [](const sf::Vector2f & pos) -> std::unique_ptr<BoardObject> { return std::make_unique<RegularRock>(pos); }); bool RegularRock::m_registeritRegular = Factory::registerit('2', [](const sf::Vector2f & pos) -> std::unique_ptr<BoardObject> { return std::make_unique<RegularRock>(pos); }); bool RegularRock::m_registeritBig = Factory::registerit('3', [](const sf::Vector2f & pos) -> std::unique_ptr<BoardObject> { return std::make_unique<RegularRock>(pos); }); //============================================================================= RegularRock::RegularRock(const sf::Vector2f &position) :Rock(position) { m_shape.setTexture(&Textures::instance()[REGULAR_ROCK_TN]); // during init of rocks it is needed to set size outside the c-tor } //============================================================================= int RegularRock::getScore() const { return int(m_shape.getSize().x); } //=============================================================================
f46bf62780cbd8d418f7d51b3902990894c5fbab
58e631e84062a18a8202fb68f5cce2c754c0fe49
/Tools/PreZ/utils.cpp
c0f27cc1e6750aa4245c32cc2ddbc541b8677d26
[]
no_license
zhaosiwen1949/Fire_Game_Engine
e816215833cc5a3a006da0c257f0f447c2a7cbbc
f2c13c3f32765fd6df368649fccd1b67564cb3ec
refs/heads/main
2023-07-06T18:55:12.437310
2021-08-06T01:38:12
2021-08-06T01:38:12
393,214,296
0
0
null
null
null
null
UTF-8
C++
false
false
488
cpp
utils.cpp
#include "utils.h" #include "soil.h" GLuint CreateTexture2DFromPNG(const char *imgFilePath, bool invertY) { int nFileSize = 0; unsigned char *filecontent = LoadFileContent(imgFilePath, nFileSize); if (filecontent == nullptr) { return 0; } unsigned int flags = SOIL_FLAG_POWER_OF_TWO; if (invertY) { flags |= SOIL_FLAG_INVERT_Y; } GLuint texture = SOIL_load_OGL_texture_from_memory(filecontent, nFileSize, 0, 0, flags); delete [] filecontent; return texture; }
e7d0d2442bf2baadb8f327803ff76050dc12e7f1
f828f4a295574acfd2846d151dc7d705831e7387
/src/internet/ipnetwork.cpp
16edc2f46e95712fb49ae3b7eda302196f7b71e4
[ "BSD-2-Clause" ]
permissive
pfedick/pplib
7f45ae312d7881bc7f774e77839082a7f692983f
39296a209630b16a788a609611aaf85651b822f5
refs/heads/master
2023-08-22T05:24:24.242007
2023-08-18T19:29:13
2023-08-18T19:29:13
46,127,089
1
1
BSD-2-Clause
2019-10-27T15:40:00
2015-11-13T14:38:47
C++
UTF-8
C++
false
false
7,933
cpp
ipnetwork.cpp
/******************************************************************************* * This file is part of "Patrick's Programming Library", Version 7 (PPL7). * Web: http://www.pfp.de/ppl/ * * $Author$ * $Revision$ * $Date$ * $Id$ * ******************************************************************************* * Copyright (c) 2017, Patrick Fedick <patrick@pfp.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER AND CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include "prolog_ppl7.h" #ifdef HAVE_STDIO_H #include <stdio.h> #endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #ifdef HAVE_STRING_H #include <string.h> #endif #ifdef HAVE_STDARG_H #include <stdarg.h> #endif #include <time.h> #ifdef _WIN32 #include <winsock2.h> #include <Ws2tcpip.h> #include <windows.h> #else #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif #ifdef HAVE_NETDB_H #include <netdb.h> #endif #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif #include <netdb.h> #endif #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif #ifdef HAVE_ERRNO_H #include <errno.h> #endif #include "ppl7.h" #include "ppl7-inet.h" //#include "socket.h" namespace ppl7 { static unsigned int bytemask[]={ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; /*!\class IPNetwork * \ingroup PPLGroupInternet * * */ IPNetwork::IPNetwork() { _prefixlen=-1; } IPNetwork::IPNetwork(const IPNetwork &other) { _prefixlen=-1; set(other); } IPNetwork::IPNetwork(const String &other) { _prefixlen=-1; set(other); } IPNetwork &IPNetwork::operator=(const IPNetwork &other) { set(other); return *this; } IPNetwork &IPNetwork::operator=(const String &other) { set(other); return *this; } void IPNetwork::set(const IPAddress &other, int prefixlen) { _addr=other.mask(prefixlen); _prefixlen=prefixlen; } void IPNetwork::set(const IPNetwork &other) { _prefixlen=other._prefixlen; _addr=other._addr; } static int validateNetmaskByte(unsigned char byte) { switch(byte) { case 0xfe: return 7; case 0xfc: return 6; case 0xf8: return 5; case 0xf0: return 4; case 0xe0: return 3; case 0xc0: return 2; case 0x80: return 1; case 0x00: return 0; default: return -1; } return -1; } int IPNetwork::getPrefixlenFromNetmask(const String &netmask) { unsigned char _addr[16]; int len; int res=0; if (netmask.has(":")) { res=inet_pton(AF_INET6, netmask.getPtr(), &_addr); len=16; } else { res=inet_pton(AF_INET, netmask.getPtr(), &_addr); len=4; } if (res!=1) throw InvalidNetmaskOrPrefixlenException("%s",(const char*)netmask); int stage=0; int prefixlen=0; for (int i=0;i<len;i++) { unsigned char byte=_addr[i]; if (stage==0 && byte==0xff) { prefixlen+=8; } else if (stage==1 && byte!=0) { throw InvalidNetmaskOrPrefixlenException("%s",(const char*)netmask); } else if (stage==0 && byte!=0xff) { stage=1; int bits=validateNetmaskByte(byte); if (bits<0) throw InvalidNetmaskOrPrefixlenException("%s",(const char*)netmask); prefixlen+=bits; } } return prefixlen; } void IPNetwork::set(const String &network) { int t=network.instr("/"); if (t<0) throw InvalidNetworkAddressException(network); IPAddress addr=network.left(t); String mask=network.mid(t+1); int prefixlen=0; if (mask.instr(".")>=0 || mask.instr(":")>=0) { prefixlen=getPrefixlenFromNetmask(mask); if (prefixlen<0) throw InvalidNetmaskOrPrefixlenException("%s",(const char*)mask); } else { prefixlen=mask.toInt(); } _addr=addr.mask(prefixlen); _prefixlen=prefixlen; } IPAddress::IP_FAMILY IPNetwork::family() const { return _addr.family(); } IPAddress IPNetwork::addr() const { if (_prefixlen<0) throw InvalidNetworkAddressException(); return _addr; } IPAddress IPNetwork::first() const { if (_prefixlen<0) throw InvalidNetworkAddressException(); return _addr; } IPAddress IPNetwork::last() const { if (_prefixlen<0) throw InvalidNetworkAddressException(); IPAddress mask=netmask(); IPAddress ret(_addr); unsigned char *adr=(unsigned char*)mask.addr(); unsigned char *r=(unsigned char*)ret.addr(); for (size_t i=0;i<mask.addr_len();i++) r[i]+=255-adr[i]; return ret; } int IPNetwork::prefixlen() const { if (_prefixlen<0) throw InvalidNetworkAddressException(); return _prefixlen; } String IPNetwork::toString() const { if (_prefixlen<0) throw InvalidNetworkAddressException(); return ppl7::ToString("%s/%d",(const char*)_addr.toString(),_prefixlen); } IPNetwork::operator String() const { return toString(); } IPAddress IPNetwork::netmask() const { int hbyte=0; if (_addr.family()==IPAddress::IPv4) { hbyte=3; } else if (_addr.family()==IPAddress::IPv6) { hbyte=15; } else { throw InvalidNetworkAddressException(); } unsigned char tmp[16]; memset(tmp,255,16); int prange=hbyte*8; for (int byte=hbyte;byte>=0;byte--) { if (_prefixlen>prange) { tmp[byte]=(unsigned char)bytemask[_prefixlen-prange]; byte=0; } else { tmp[byte]=(unsigned char)0; } prange-=8; } return IPAddress(_addr.family(),&tmp,_addr.addr_len()); } bool IPNetwork::contains(const IPAddress &addr) const { IPAddress start=first(); IPAddress end=last(); if (addr>=start && addr<=end) return true; return false; } static int cmp_net(const IPNetwork &net1, const IPNetwork &net2) { int ret=net1.addr().compare(net2.addr()); if (ret==0) { if (net1.prefixlen()<net2.prefixlen()) ret=1; else if (net1.prefixlen()>net2.prefixlen()) ret=-1; } return ret; } int IPNetwork::compare(const IPNetwork &other) const { return cmp_net(*this, other); } bool IPNetwork::operator<(const IPNetwork &other) const { if (cmp_net(*this, other)<0) return true; return false; } bool IPNetwork::operator<=(const IPNetwork &other) const { if (cmp_net(*this, other)<=0) return true; return false; } bool IPNetwork::operator==(const IPNetwork &other) const { if (cmp_net(*this, other)==0) return true; return false; } bool IPNetwork::operator!=(const IPNetwork &other) const { if (cmp_net(*this, other)!=0) return true; return false; } bool IPNetwork::operator>=(const IPNetwork &other) const { if (cmp_net(*this, other)>=0) return true; return false; } bool IPNetwork::operator>(const IPNetwork &other) const { if (cmp_net(*this, other)>0) return true; return false; } std::ostream& operator<<(std::ostream& s, const IPNetwork &net) { String str=net.toString(); return s.write((const char*)str,str.size()); } } // namespace ppl7
7dd3e01861a47184c07703b726564bcadb2695f6
0bcd128368e2de959ca648960ffd7944067fcf27
/gm/crbug_1156804.cpp
d4bec89a4911e49d9c2d9be63aec09c920351885
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
google/skia
ac6e39179cd33cf0c8a46d29c1a70bf78b4d74ee
bf6b239838d3eb56562fffd0856f4047867ae771
refs/heads/main
2023-08-31T21:03:04.620734
2023-08-31T18:24:15
2023-08-31T20:20:26
15,773,229
8,064
1,487
BSD-3-Clause
2023-09-11T13:42:07
2014-01-09T17:09:57
C++
UTF-8
C++
false
false
1,816
cpp
crbug_1156804.cpp
/* * Copyright 2020 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "gm/gm.h" #include "include/core/SkCanvas.h" #include "include/core/SkPaint.h" #include "include/core/SkRect.h" #include "include/effects/SkImageFilters.h" #include "src/effects/imagefilters/SkCropImageFilter.h" static void drawOne(SkCanvas* canvas, SkRect rect, float saveBorder, float sigma, SkColor c) { SkRect borderRect = rect.makeOutset(saveBorder, saveBorder); SkPaint p; p.setColor(c); p.setImageFilter( SkImageFilters::Blur(sigma, sigma, // The blur's input is forced to have transparent padding because 'borderRect' is outset // from the non-transparent content ('rect') that's drawn into the layer. SkMakeCropImageFilter(borderRect, SkTileMode::kClamp, nullptr), // The blur's output crop visually won't affect the output because the transparent // padding is blurred out by the edge of 3*sigma. borderRect.makeOutset(3 * sigma, 3 * sigma))); p.setAntiAlias(true); canvas->drawRect(rect, p); } DEF_SIMPLE_GM(crbug_1156804, canvas, 250, 250) { drawOne(canvas, SkRect::MakeXYWH( 64, 64, 25, 25), 1, 3, SK_ColorGREEN); drawOne(canvas, SkRect::MakeXYWH(164, 64, 25, 25), 30, 3, SK_ColorGREEN); // This one would draw incorrectly because the large sigma causes downscaling of the source // and the one-pixel border would make the downscaled image not contain trans-black at the // edges. Combined with the clamp mode on the blur filter it would "harden" the edge. drawOne(canvas, SkRect::MakeXYWH( 64, 164, 25, 25), 1, 20, SK_ColorRED); drawOne(canvas, SkRect::MakeXYWH(164, 164, 25, 25), 30, 20, SK_ColorGREEN); }