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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
391e3080b92771ab03eccfdb4a2971de076d57f3 | 8227f8a003973a4c579c257d3763d0e7295e52d1 | /EnemyShips.h | e2d144d19f7c1f8528523f06d979388d485f6142 | [] | no_license | GDC-CEG/Galaxy-Shooter-2 | 3990633755f5d4a3542e97930783f8bc600b4284 | d06c70ae3177863ed3c76c30f7e50752ced26151 | refs/heads/master | 2016-08-07T20:09:25.110402 | 2014-04-01T15:03:16 | 2014-04-01T15:03:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,086 | h | EnemyShips.h | #pragma once
#ifndef ENEMYSHIPS_H
#define ENEMYSHIPS_H
#include"SFML\Graphics.hpp"
class EnemyShip
{
public:
sf::IntRect box;
sf::RectangleShape rect;
int xVel,yVel;
EnemyShip();
void update();
void display(sf::RenderWindow *window);
void changeColor();
};
EnemyShip::EnemyShip()
{
//position of enemy ship on screen
box.left=300;
box.top=200;
box.height=20;
box.width=20;
rect.setSize(sf::Vector2f(box.width,box.height));
rect.setFillColor(sf::Color::Yellow); // enemy ship is colored yellow
xVel=0;
yVel=0;
}
void EnemyShip::update()
{
// since enemy ship doesnt move , we do nothing here in update
}
void EnemyShip::changeColor()
{
rect.setFillColor(sf::Color::Black); // when enemy ship is hit by a bullet we change its color
}
void EnemyShip::display(sf::RenderWindow *window)
{
//enemy ship is drawn here
rect.setPosition(box.left,box.top);
window->draw(rect);
}
#endif
|
ef97fd2e7193ba981cd80d4074342cdeb5949465 | ffc8a74313436a7982ddefdd50a9308219cedee3 | /DevC++/OOP/vd lop co so truu tuong.cpp | 822d21ec03b6aca49086596b0fac879e40e8db5f | [] | no_license | hieubui97/DevC | 659dff5428cb52d5740948e44cfdde0dcb37ed42 | cf058e0473bc5d752c853334a84c3738bef65bea | refs/heads/master | 2023-02-08T13:18:01.193367 | 2020-10-05T04:27:52 | 2020-10-05T04:27:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 451 | cpp | vd lop co so truu tuong.cpp | #include <iostream>
#include <conio.h>
using namespace std;
class A
{
public:
virtual void Chao() =0;
};
// class B
class B:public A
{
public:
void Chao()
{
cout<<"\nB chao cac ban";
}
};
// class C
class C:public A
{
public:
void Chao()
{
cout<<"\nC chao cac ban";
}
};
// ham main
int main()
{
// A a; khong the khai bao doi tuong thuoc lop co so truu tuong
B b;
b.Chao();
C c;
c.Chao();
}
|
bb44de799e18e78774e3370f231cfe65b7cf98a3 | 00638a5bb7048fe61ddaacad4125a2133bf67f80 | /cpp_05 exceptions and nested classes/fabric/ShrubberyCreationForm.cpp | 996dd3a7a3c8979b426811a03da3cb33433cbb4d | [] | no_license | hheimerd/cpp_mini_projects | 11ae23a1533b03a19cf39f920f69d5acf3a33865 | 0295b26c7578df546e05d41ee70019531b639789 | refs/heads/master | 2023-01-18T16:42:00.818964 | 2020-11-26T10:01:26 | 2020-11-26T10:01:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,026 | cpp | ShrubberyCreationForm.cpp | //
// Created by Holli Heimerdinger on 11/19/20.
//
#include "ShrubberyCreationForm.hpp"
ShrubberyCreationForm::ShrubberyCreationForm()
:Form("ShrubberyCreationForm", 25, 5)
{
}
ShrubberyCreationForm::ShrubberyCreationForm(ShrubberyCreationForm &src)
:Form("ShrubberyCreationForm", 25, 5)
{
*this = src;
}
ShrubberyCreationForm::~ShrubberyCreationForm()
{
}
ShrubberyCreationForm &ShrubberyCreationForm::operator=(ShrubberyCreationForm const &src)
{
if (this != &src) {
this->_target = src._target;
}
return *this;
}
ShrubberyCreationForm::ShrubberyCreationForm(std::string target)
:Form("shrubbery creation", 25, 5),
_target(target)
{
}
void ShrubberyCreationForm::execute(const Bureaucrat &executor) const
{
Form::execute(executor);
std::cout << "file called " << this->_target << "_shrubbery, and ASCII trees are written "\
"inside it, in the current directory" << std::endl;
}
Form *ShrubberyCreationForm::create(std::string target)
{
return new ShrubberyCreationForm(target);
}
|
cb9091d55486b261ebd08e573a74fe1529066412 | fdf873f74d8576de68df637e96c5aff424e7cea7 | /src/chebuilderregulargrid.cpp | eef5ea92b3c906eba163e183d4aa9134162b8242 | [] | no_license | ethiago/triquadgl | bba50ded1dafc03ad301125fe5b2c9b68f18349f | ee36ecf6b4d7412c6127edaa9f6d3c0f52fcd65d | refs/heads/master | 2021-01-10T12:08:39.889628 | 2018-10-02T17:28:10 | 2018-10-02T17:28:42 | 55,521,045 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | chebuilderregulargrid.cpp | #include "chebuilderregulargrid.h"
CHEBuilderRegularGrid::CHEBuilderRegularGrid(float _xMin, float _xMax, float _yMin, float _yMax, int _nSubX, int _nSubY) : CHEBuilder()
{
xMin = _xMin ;
xMax = _xMax ;
yMin = _yMin ;
yMax = _yMax ;
nSubX = _nSubX;
nSubY = _nSubY;
}
void CHEBuilderRegularGrid::build()
{
m_che.clear();
float dx = (xMax-xMin)/nSubX;
float dy = (yMax-yMin)/nSubY;
QVector<Vertex> list;
for(int i = 0; i <= nSubX; ++i)
{
for(int j = 0; j <= nSubY; ++j)
{
list.append(Vertex(xMin + i*dx, yMin + j*dy));
}
}
m_che.addVertices(list);
for(int i = 0; i < nSubX; ++i)
{
for(int j = 0; j < nSubY; ++j)
{
int vIdx00 = (i+0)*(nSubY+1) + (j+0);
int vIdx01 = (i+1)*(nSubY+1) + (j+0);
int vIdx10 = (i+0)*(nSubY+1) + (j+1);
int vIdx11 = (i+1)*(nSubY+1) + (j+1);
m_che.addTriangle(vIdx00,vIdx01, vIdx11);
m_che.addTriangle(vIdx00,vIdx11, vIdx10);
}
}
}
|
a9a377ec200d6c06f5c8cb286253fc1b4c3fdc94 | 46f2e7a10fca9f7e7b80b342240302c311c31914 | /lid_driven_flow/cavity/0.0644/U | 9c097138902eb252125fd3c13b5c110a76973108 | [] | no_license | patricksinclair/openfoam_warmups | 696cb1950d40b967b8b455164134bde03e9179a1 | 03c982f7d46b4858e3b6bfdde7b8e8c3c4275df9 | refs/heads/master | 2020-12-26T12:50:00.615357 | 2020-02-04T20:22:35 | 2020-02-04T20:22:35 | 237,510,814 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 62,995 | U | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0.0644";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
2500
(
(3.02796e-05 -3.03825e-05 0)
(9.21876e-05 -3.72986e-05 0)
(0.000127646 -1.91966e-05 0)
(9.6379e-05 7.34891e-06 0)
(-1.39714e-05 3.46062e-05 0)
(-0.000201805 5.97093e-05 0)
(-0.000460044 8.14823e-05 0)
(-0.000779416 9.95746e-05 0)
(-0.00114959 0.000113999 0)
(-0.00155993 0.000124903 0)
(-0.00199993 0.000132488 0)
(-0.00245944 0.000136971 0)
(-0.00292879 0.000138577 0)
(-0.00339889 0.000137528 0)
(-0.00386124 0.000134041 0)
(-0.00430799 0.000128331 0)
(-0.00473193 0.000120606 0)
(-0.00512653 0.000111068 0)
(-0.0054859 9.99155e-05 0)
(-0.00580482 8.73441e-05 0)
(-0.00607873 7.35474e-05 0)
(-0.00630375 5.87188e-05 0)
(-0.00647668 4.30531e-05 0)
(-0.00659499 2.67486e-05 0)
(-0.00665687 1.0009e-05 0)
(-0.00666123 -6.95621e-06 0)
(-0.00660773 -2.39299e-05 0)
(-0.00649679 -4.0687e-05 0)
(-0.00632963 -5.69941e-05 0)
(-0.00610827 -7.26092e-05 0)
(-0.00583559 -8.72829e-05 0)
(-0.00551529 -0.00010076 0)
(-0.00515195 -0.00011278 0)
(-0.004751 -0.000123083 0)
(-0.00431873 -0.000131408 0)
(-0.00386224 -0.0001375 0)
(-0.00338944 -0.00014111 0)
(-0.00290897 -0.000142004 0)
(-0.00243014 -0.000139959 0)
(-0.00196285 -0.000134774 0)
(-0.00151744 -0.00012627 0)
(-0.00110458 -0.000114298 0)
(-0.000735067 -9.87525e-05 0)
(-0.000419493 -7.96047e-05 0)
(-0.000167799 -5.69879e-05 0)
(1.14879e-05 -3.14333e-05 0)
(0.000112566 -4.27321e-06 0)
(0.000135098 2.14249e-05 0)
(9.34354e-05 3.82797e-05 0)
(2.98642e-05 2.98026e-05 0)
(3.75877e-05 -9.25232e-05 0)
(8.52739e-05 -8.44573e-05 0)
(3.6836e-05 1.69674e-05 0)
(-0.00016902 0.000155292 0)
(-0.000556652 0.000301739 0)
(-0.00112667 0.000441518 0)
(-0.00186725 0.000566889 0)
(-0.00275924 0.000674115 0)
(-0.0037793 0.000761634 0)
(-0.0049021 0.000829065 0)
(-0.00610158 0.000876697 0)
(-0.00735187 0.000905223 0)
(-0.00862782 0.000915576 0)
(-0.0099054 0.000908842 0)
(-0.0111619 0.000886193 0)
(-0.0123762 0.00084886 0)
(-0.0135287 0.000798102 0)
(-0.0146015 0.000735195 0)
(-0.0155786 0.000661427 0)
(-0.0164456 0.000578097 0)
(-0.0171901 0.000486509 0)
(-0.0178013 0.000387986 0)
(-0.0182705 0.00028387 0)
(-0.0185909 0.000175529 0)
(-0.0187576 6.43652e-05 0)
(-0.0187676 -4.81801e-05 0)
(-0.0186202 -0.000160625 0)
(-0.0183166 -0.000271442 0)
(-0.0178605 -0.000379061 0)
(-0.0172574 -0.000481871 0)
(-0.0165154 -0.000578229 0)
(-0.0156447 -0.000666472 0)
(-0.0146579 -0.00074493 0)
(-0.0135698 -0.000811946 0)
(-0.0123975 -0.000865898 0)
(-0.0111602 -0.000905227 0)
(-0.00987898 -0.000928465 0)
(-0.00857699 -0.00093427 0)
(-0.00727879 -0.00092147 0)
(-0.00601023 -0.000889108 0)
(-0.00479804 -0.00083651 0)
(-0.00366924 -0.000763374 0)
(-0.00265047 -0.000669923 0)
(-0.00176699 -0.000557158 0)
(-0.00104122 -0.000427341 0)
(-0.000490614 -0.000284958 0)
(-0.000124402 -0.000138398 0)
(6.11204e-05 -3.06312e-06 0)
(9.37047e-05 9.26528e-05 0)
(3.86294e-05 9.34357e-05 0)
(2.05e-05 -0.000129557 0)
(-1.27273e-05 -3.70754e-05 0)
(-0.000228012 0.000233594 0)
(-0.000677383 0.000582308 0)
(-0.00138457 0.000952793 0)
(-0.00235049 0.00131096 0)
(-0.00355994 0.00163669 0)
(-0.00498721 0.00191872 0)
(-0.00660007 0.00215121 0)
(-0.00836258 0.00233169 0)
(-0.0102371 0.00245978 0)
(-0.0121855 0.00253651 0)
(-0.0141703 0.00256378 0)
(-0.0161554 0.00254411 0)
(-0.0181063 0.00248041 0)
(-0.0199908 0.00237586 0)
(-0.0217787 0.00223379 0)
(-0.0234426 0.00205767 0)
(-0.0249576 0.00185106 0)
(-0.0263016 0.00161756 0)
(-0.0274552 0.00136085 0)
(-0.028402 0.00108465 0)
(-0.0291283 0.000792791 0)
(-0.0296235 0.000489144 0)
(-0.0298803 0.000177693 0)
(-0.0298942 -0.000137477 0)
(-0.0296641 -0.00045217 0)
(-0.0291921 -0.000762081 0)
(-0.0284839 -0.0010628 0)
(-0.0275483 -0.00134982 0)
(-0.0263978 -0.00161857 0)
(-0.0250484 -0.00186445 0)
(-0.0235195 -0.00208287 0)
(-0.0218339 -0.0022693 0)
(-0.020018 -0.00241935 0)
(-0.018101 -0.00252885 0)
(-0.0161153 -0.00259395 0)
(-0.0140958 -0.00261119 0)
(-0.0120795 -0.00257769 0)
(-0.0101052 -0.00249127 0)
(-0.00821253 -0.00235069 0)
(-0.00644117 -0.00215593 0)
(-0.00482964 -0.00190862 0)
(-0.00341376 -0.00161277 0)
(-0.00222458 -0.00127589 0)
(-0.00128555 -0.000910893 0)
(-0.000608576 -0.000539375 0)
(-0.000188763 -0.000196508 0)
(2.26264e-06 6.14283e-05 0)
(2.29151e-05 0.000136665 0)
(-4.51202e-06 -0.000102396 0)
(-0.00014738 0.000164844 0)
(-0.000572879 0.000681758 0)
(-0.0013063 0.00131344 0)
(-0.00236154 0.00197758 0)
(-0.00373576 0.00262041 0)
(-0.0054091 0.00320774 0)
(-0.00734986 0.00371885 0)
(-0.00951868 0.00414198 0)
(-0.0118714 0.00447129 0)
(-0.0143612 0.00470495 0)
(-0.0169403 0.0048439 0)
(-0.0195615 0.00489094 0)
(-0.0221787 0.00485019 0)
(-0.0247477 0.00472669 0)
(-0.0272269 0.00452609 0)
(-0.0295776 0.00425451 0)
(-0.0317641 0.00391834 0)
(-0.0337541 0.00352424 0)
(-0.0355187 0.00307901 0)
(-0.0370328 0.00258964 0)
(-0.0382748 0.00206323 0)
(-0.0392272 0.00150708 0)
(-0.0398761 0.000928612 0)
(-0.0402118 0.00033545 0)
(-0.0402288 -0.000264596 0)
(-0.0399257 -0.000863516 0)
(-0.0393054 -0.0014531 0)
(-0.0383753 -0.00202498 0)
(-0.037147 -0.0025706 0)
(-0.035637 -0.00308134 0)
(-0.0338659 -0.00354853 0)
(-0.0318592 -0.00396357 0)
(-0.0296465 -0.00431803 0)
(-0.0272618 -0.00460378 0)
(-0.0247429 -0.00481315 0)
(-0.0221313 -0.00493914 0)
(-0.0194718 -0.00497561 0)
(-0.0168118 -0.00491757 0)
(-0.0142004 -0.00476151 0)
(-0.0116876 -0.00450579 0)
(-0.00932307 -0.00415122 0)
(-0.00715477 -0.00370187 0)
(-0.00522684 -0.00316621 0)
(-0.00357738 -0.00255888 0)
(-0.00223551 -0.00190341 0)
(-0.00121733 -0.00123652 0)
(-0.00052104 -0.000613743 0)
(-0.000126837 -0.000117751 0)
(-9.07639e-07 0.000119024 0)
(-3.06186e-05 1.93542e-06 0)
(-0.000293253 0.000548498 0)
(-0.000949372 0.00139101 0)
(-0.00198831 0.00237112 0)
(-0.00340821 0.00338571 0)
(-0.0051988 0.00436363 0)
(-0.00733351 0.00525718 0)
(-0.00977406 0.00603582 0)
(-0.0124744 0.00668115 0)
(-0.0153831 0.00718324 0)
(-0.0184458 0.00753823 0)
(-0.0216069 0.00774661 0)
(-0.0248108 0.00781192 0)
(-0.0280034 0.00773994 0)
(-0.0311324 0.00753805 0)
(-0.0341486 0.00721475 0)
(-0.0370058 0.00677938 0)
(-0.0396615 0.00624187 0)
(-0.0420771 0.00561262 0)
(-0.0442181 0.00490234 0)
(-0.0460544 0.00412207 0)
(-0.0475602 0.00328311 0)
(-0.0487144 0.00239704 0)
(-0.0495006 0.00147568 0)
(-0.0499071 0.000531184 0)
(-0.0499274 -0.000424024 0)
(-0.0495598 -0.00137721 0)
(-0.0488078 -0.00231534 0)
(-0.0476804 -0.00322514 0)
(-0.0461918 -0.00409311 0)
(-0.0443614 -0.00490565 0)
(-0.0422141 -0.00564913 0)
(-0.0397802 -0.00631006 0)
(-0.0370952 -0.00687529 0)
(-0.0341993 -0.00733219 0)
(-0.0311376 -0.00766894 0)
(-0.0279595 -0.00787485 0)
(-0.0247177 -0.00794066 0)
(-0.021468 -0.00785908 0)
(-0.0182684 -0.00762519 0)
(-0.0151774 -0.00723718 0)
(-0.012253 -0.00669715 0)
(-0.00955116 -0.00601229 0)
(-0.00712334 -0.00519639 0)
(-0.00501443 -0.00427208 0)
(-0.00325999 -0.00327411 0)
(-0.0018825 -0.00225394 0)
(-0.000886975 -0.00128552 0)
(-0.000268125 -0.000473113 0)
(-2.60696e-05 2.67696e-05 0)
(-5.54432e-05 0.00018403 0)
(-0.000438631 0.0011217 0)
(-0.00133155 0.00237418 0)
(-0.00268451 0.00376915 0)
(-0.00447653 0.00518823 0)
(-0.00668713 0.00654614 0)
(-0.00928103 0.00778332 0)
(-0.0122123 0.00886007 0)
(-0.0154277 0.00975136 0)
(-0.0188691 0.0104431 0)
(-0.0224752 0.010929 0)
(-0.0261834 0.0112091 0)
(-0.0299312 0.0112876 0)
(-0.0336575 0.0111719 0)
(-0.0373034 0.010872 0)
(-0.040813 0.0103996 0)
(-0.0441341 0.00976747 0)
(-0.0472183 0.0089897 0)
(-0.0500217 0.00808092 0)
(-0.0525052 0.00705636 0)
(-0.0546343 0.00593177 0)
(-0.0563798 0.00472329 0)
(-0.0577175 0.00344749 0)
(-0.0586288 0.00212135 0)
(-0.0591004 0.000762275 0)
(-0.0591248 -0.000611927 0)
(-0.0587002 -0.00198302 0)
(-0.0578306 -0.00333236 0)
(-0.0565262 -0.00464098 0)
(-0.054803 -0.00588965 0)
(-0.0526833 -0.00705898 0)
(-0.0501954 -0.00812964 0)
(-0.0473736 -0.00908252 0)
(-0.0442582 -0.00989903 0)
(-0.0408949 -0.0105614 0)
(-0.0373347 -0.0110531 0)
(-0.0336334 -0.0113593 0)
(-0.0298508 -0.0114673 0)
(-0.0260499 -0.0113671 0)
(-0.0222959 -0.0110525 0)
(-0.0186549 -0.0105215 0)
(-0.0151924 -0.00977778 0)
(-0.0119715 -0.00883187 0)
(-0.00905094 -0.00770322 0)
(-0.00648286 -0.00642257 0)
(-0.00431048 -0.00503541 0)
(-0.00256468 -0.0036066 0)
(-0.00126015 -0.00222562 0)
(-0.000409535 -0.00101317 0)
(-5.00741e-05 -0.000140944 0)
(-7.83154e-05 0.000440813 0)
(-0.000578664 0.00188358 0)
(-0.0017068 0.00363355 0)
(-0.00337432 0.00551135 0)
(-0.00553976 0.00738829 0)
(-0.00817055 0.00916834 0)
(-0.0112211 0.0107823 0)
(-0.0146366 0.0121825 0)
(-0.0183562 0.013338 0)
(-0.0223147 0.0142307 0)
(-0.026444 0.0148524 0)
(-0.0306751 0.0152025 0)
(-0.0349393 0.0152858 0)
(-0.0391694 0.0151119 0)
(-0.0433007 0.0146933 0)
(-0.0472718 0.0140451 0)
(-0.051025 0.0131844 0)
(-0.0545073 0.0121293 0)
(-0.0576703 0.0108993 0)
(-0.0604707 0.00951476 0)
(-0.0628707 0.00799654 0)
(-0.0648379 0.00636623 0)
(-0.0663458 0.004646 0)
(-0.0673737 0.00285858 0)
(-0.0679069 0.00102723 0)
(-0.0679371 -0.000824197 0)
(-0.0674622 -0.00267131 0)
(-0.0664867 -0.00448922 0)
(-0.0650216 -0.0062526 0)
(-0.0630847 -0.00793579 0)
(-0.0607002 -0.00951301 0)
(-0.0578993 -0.0109585 0)
(-0.0547197 -0.012247 0)
(-0.0512056 -0.0133538 0)
(-0.0474073 -0.0142554 0)
(-0.0433809 -0.0149302 0)
(-0.0391876 -0.0153586 0)
(-0.0348933 -0.015524 0)
(-0.0305672 -0.0154139 0)
(-0.0262812 -0.0150201 0)
(-0.0221083 -0.0143406 0)
(-0.0181209 -0.0133805 0)
(-0.0143895 -0.0121536 0)
(-0.0109801 -0.0106849 0)
(-0.00795305 -0.00901269 0)
(-0.00536043 -0.00719217 0)
(-0.00324328 -0.00529975 0)
(-0.00162782 -0.00343741 0)
(-0.000546102 -0.00173786 0)
(-7.22096e-05 -0.000381378 0)
(-9.92951e-05 0.000768337 0)
(-0.000712059 0.00282936 0)
(-0.00207031 0.00516589 0)
(-0.00404877 0.00759601 0)
(-0.00658537 0.0099846 0)
(-0.00963439 0.012228 0)
(-0.0131388 0.0142496 0)
(-0.0170339 0.0159955 0)
(-0.0212503 0.0174298 0)
(-0.0257155 0.0185312 0)
(-0.0303545 0.0192899 0)
(-0.0350922 0.0197049 0)
(-0.0398539 0.0197824 0)
(-0.044567 0.0195338 0)
(-0.0491614 0.0189747 0)
(-0.0535709 0.0181242 0)
(-0.0577334 0.0170033 0)
(-0.0615917 0.0156353 0)
(-0.0650935 0.0140446 0)
(-0.0681923 0.012257 0)
(-0.0708472 0.0102992 0)
(-0.0730234 0.00819856 0)
(-0.074692 0.00598335 0)
(-0.0758308 0.00368253 0)
(-0.076424 0.00132576 0)
(-0.0764623 -0.00105656 0)
(-0.0759435 -0.00343337 0)
(-0.0748722 -0.00577297 0)
(-0.0732601 -0.00804314 0)
(-0.071126 -0.0102113 0)
(-0.068496 -0.0122445 0)
(-0.0654036 -0.0141103 0)
(-0.0618891 -0.0157765 0)
(-0.0579999 -0.0172118 0)
(-0.0537903 -0.0183865 0)
(-0.0493206 -0.0192732 0)
(-0.044657 -0.0198474 0)
(-0.0398705 -0.0200881 0)
(-0.0350362 -0.0199796 0)
(-0.0302321 -0.0195119 0)
(-0.0255377 -0.0186823 0)
(-0.0210326 -0.017497 0)
(-0.0167946 -0.015973 0)
(-0.012898 -0.0141398 0)
(-0.00941175 -0.0120427 0)
(-0.00639822 -0.00974525 0)
(-0.00390978 -0.00733339 0)
(-0.00198532 -0.00491893 0)
(-0.000676509 -0.00264312 0)
(-9.24961e-05 -0.000690768 0)
(-0.00011871 0.00116276 0)
(-0.000839212 0.00395305 0)
(-0.00242149 0.00696574 0)
(-0.00470573 0.010019 0)
(-0.00760967 0.0129741 0)
(-0.011074 0.0157223 0)
(-0.0150296 0.0181819 0)
(-0.0194009 0.0202942 0)
(-0.0241095 0.0220199 0)
(-0.0290748 0.0233353 0)
(-0.0342152 0.0242296 0)
(-0.0394488 0.0247023 0)
(-0.0446955 0.024761 0)
(-0.0498772 0.0244197 0)
(-0.0549194 0.0236976 0)
(-0.0597513 0.0226175 0)
(-0.064307 0.0212054 0)
(-0.0685255 0.0194897 0)
(-0.0723515 0.0175002 0)
(-0.0757355 0.0152687 0)
(-0.0786341 0.0128278 0)
(-0.0810104 0.0102112 0)
(-0.0828337 0.00745362 0)
(-0.0840803 0.00459067 0)
(-0.0847333 0.00165882 0)
(-0.0847828 -0.00130461 0)
(-0.0842261 -0.00426143 0)
(-0.0830678 -0.00717273 0)
(-0.0813201 -0.00999891 0)
(-0.0790026 -0.0126999 0)
(-0.0761426 -0.0152356 0)
(-0.0727753 -0.0175657 0)
(-0.0689433 -0.0196509 0)
(-0.0646966 -0.0214528 0)
(-0.0600928 -0.0229351 0)
(-0.0551959 -0.0240639 0)
(-0.0500763 -0.0248091 0)
(-0.04481 -0.0251453 0)
(-0.0394775 -0.0250527 0)
(-0.0341627 -0.024519 0)
(-0.0289518 -0.0235405 0)
(-0.0239315 -0.022124 0)
(-0.0191875 -0.0202885 0)
(-0.0148029 -0.018068 0)
(-0.0108565 -0.015513 0)
(-0.0074216 -0.0126942 0)
(-0.0045629 -0.00970553 0)
(-0.0023325 -0.00666626 0)
(-0.000801274 -0.00372384 0)
(-0.000111268 -0.00106553 0)
(-0.00013694 0.00162083 0)
(-0.000961238 0.00524894 0)
(-0.00276195 0.00902735 0)
(-0.00534686 0.0127755 0)
(-0.00861425 0.0163531 0)
(-0.0124912 0.0196485 0)
(-0.0168957 0.0225765 0)
(-0.0217411 0.0250756 0)
(-0.0269393 0.027104 0)
(-0.0324012 0.0286371 0)
(-0.0380377 0.0296641 0)
(-0.0437608 0.0301855 0)
(-0.0494845 0.0302111 0)
(-0.0551258 0.029758 0)
(-0.0606055 0.0288491 0)
(-0.0658489 0.027512 0)
(-0.0707866 0.0257777 0)
(-0.0753545 0.02368 0)
(-0.0794944 0.0212548 0)
(-0.0831546 0.0185399 0)
(-0.0862894 0.0155742 0)
(-0.08886 0.0123983 0)
(-0.0908345 0.00905345 0)
(-0.0921878 0.00558229 0)
(-0.0929018 0.00202837 0)
(-0.0929661 -0.00156371 0)
(-0.0923775 -0.00514834 0)
(-0.0911404 -0.00867902 0)
(-0.089267 -0.0121085 0)
(-0.0867776 -0.0153888 0)
(-0.0837004 -0.0184719 0)
(-0.0800716 -0.0213098 0)
(-0.0759355 -0.0238553 0)
(-0.0713445 -0.0260625 0)
(-0.0663587 -0.0278875 0)
(-0.0610455 -0.02929 0)
(-0.0554792 -0.0302336 0)
(-0.0497403 -0.0306873 0)
(-0.0439145 -0.0306273 0)
(-0.0380918 -0.0300379 0)
(-0.0323649 -0.0289138 0)
(-0.0268283 -0.0272616 0)
(-0.0215761 -0.0251017 0)
(-0.0167008 -0.022471 0)
(-0.0122917 -0.0194246 0)
(-0.00843409 -0.016039 0)
(-0.00520552 -0.0124142 0)
(-0.00267157 -0.0086756 0)
(-0.000921737 -0.00497547 0)
(-0.00012894 -0.00150274 0)
(-0.000154346 0.00214009 0)
(-0.00107951 0.0067124 0)
(-0.0030943 0.0113458 0)
(-0.00597581 0.0158614 0)
(-0.00960363 0.0201187 0)
(-0.0138911 0.0240044 0)
(-0.0187434 0.0274319 0)
(-0.0240621 0.0303379 0)
(-0.0297488 0.0326802 0)
(-0.0357057 0.0344339 0)
(-0.0418361 0.0355895 0)
(-0.0480451 0.0361493 0)
(-0.0542411 0.0361261 0)
(-0.060336 0.0355409 0)
(-0.0662465 0.034421 0)
(-0.0718942 0.0327989 0)
(-0.0772063 0.0307112 0)
(-0.0821161 0.0281977 0)
(-0.086563 0.0253005 0)
(-0.0904932 0.0220638 0)
(-0.0938593 0.0185334 0)
(-0.096621 0.0147565 0)
(-0.098745 0.0107815 0)
(-0.100205 0.0066581 0)
(-0.100983 0.00243729 0)
(-0.101066 -0.00182888 0)
(-0.100451 -0.00608715 0)
(-0.0991433 -0.0102832 0)
(-0.0971536 -0.0143617 0)
(-0.0945026 -0.0182667 0)
(-0.091219 -0.0219418 0)
(-0.0873398 -0.0253307 0)
(-0.0829107 -0.0283781 0)
(-0.0779857 -0.0310298 0)
(-0.072627 -0.0332343 0)
(-0.066905 -0.0349437 0)
(-0.0608976 -0.0361146 0)
(-0.0546896 -0.0367103 0)
(-0.0483719 -0.0367015 0)
(-0.0420405 -0.0360689 0)
(-0.0357953 -0.0348042 0)
(-0.0297384 -0.032913 0)
(-0.0239731 -0.0304162 0)
(-0.0186021 -0.0273524 0)
(-0.013726 -0.0237804 0)
(-0.00944255 -0.0197807 0)
(-0.00584282 -0.0154586 0)
(-0.00300596 -0.0109446 0)
(-0.00103957 -0.00639486 0)
(-0.00014592 -0.0020004 0)
(-0.000171247 0.00271885 0)
(-0.00119541 0.00834017 0)
(-0.00342152 0.0139176 0)
(-0.00659718 0.0192739 0)
(-0.0105838 0.0242688 0)
(-0.0152812 0.0287891 0)
(-0.0205812 0.0327475 0)
(-0.0263736 0.036081 0)
(-0.0325493 0.0387478 0)
(-0.0390012 0.0407246 0)
(-0.0456245 0.0420037 0)
(-0.0523178 0.0425907 0)
(-0.0589834 0.0425022 0)
(-0.0655284 0.0417637 0)
(-0.0718653 0.0404075 0)
(-0.0779122 0.038472 0)
(-0.0835934 0.0359998 0)
(-0.0888398 0.0330369 0)
(-0.0935887 0.0296321 0)
(-0.0977847 0.0258363 0)
(-0.101379 0.0217022 0)
(-0.10433 0.0172841 0)
(-0.106603 0.0126377 0)
(-0.108171 0.00781994 0)
(-0.109015 0.00288921 0)
(-0.109122 -0.00209476 0)
(-0.108488 -0.0070709 0)
(-0.107117 -0.0119769 0)
(-0.10502 -0.0167492 0)
(-0.102217 -0.0213234 0)
(-0.0987375 -0.0256347 0)
(-0.0946182 -0.0296182 0)
(-0.0899057 -0.0332096 0)
(-0.0846552 -0.0363464 0)
(-0.0789309 -0.0389684 0)
(-0.0728057 -0.0410196 0)
(-0.0663607 -0.0424492 0)
(-0.0596849 -0.0432132 0)
(-0.0528744 -0.0432766 0)
(-0.0460313 -0.0426149 0)
(-0.0392627 -0.0412163 0)
(-0.0326792 -0.039084 0)
(-0.0263939 -0.0362381 0)
(-0.02052 -0.0327182 0)
(-0.0151702 -0.028585 0)
(-0.0104557 -0.0239226 0)
(-0.00648114 -0.0188402 0)
(-0.00333963 -0.0134729 0)
(-0.00115652 -0.00798073 0)
(-0.000162588 -0.0025575 0)
(-0.000187919 0.00335622 0)
(-0.00131029 0.0101305 0)
(-0.00374665 0.0167409 0)
(-0.0072158 0.0230117 0)
(-0.0115613 0.0288031 0)
(-0.0166693 0.0340028 0)
(-0.0224185 0.0385243 0)
(-0.0286861 0.042306 0)
(-0.0353522 0.0453079 0)
(-0.0423001 0.0475094 0)
(-0.0494169 0.0489063 0)
(-0.0565938 0.0495083 0)
(-0.0637274 0.049337 0)
(-0.07072 0.048423 0)
(-0.0774799 0.0468049 0)
(-0.0839219 0.0445271 0)
(-0.0899679 0.041639 0)
(-0.0955465 0.0381932 0)
(-0.100594 0.0342456 0)
(-0.105052 0.0298541 0)
(-0.108872 0.0250787 0)
(-0.112011 0.0199807 0)
(-0.114434 0.0146231 0)
(-0.116112 0.0090704 0)
(-0.117026 0.00338839 0)
(-0.117163 -0.00235549 0)
(-0.116516 -0.00809229 0)
(-0.11509 -0.0137516 0)
(-0.112895 -0.0192615 0)
(-0.10995 -0.0245492 0)
(-0.106284 -0.0295409 0)
(-0.101935 -0.0341627 0)
(-0.0969485 -0.0383412 0)
(-0.0913809 -0.0420047 0)
(-0.0852978 -0.045084 0)
(-0.0787742 -0.0475141 0)
(-0.0718942 -0.0492356 0)
(-0.0647509 -0.0501968 0)
(-0.0574454 -0.0503554 0)
(-0.0500861 -0.0496809 0)
(-0.0427876 -0.0481566 0)
(-0.0356695 -0.0457821 0)
(-0.0288549 -0.0425757 0)
(-0.0224688 -0.0385762 0)
(-0.0166365 -0.0338456 0)
(-0.0114828 -0.0284703 0)
(-0.00712724 -0.022563 0)
(-0.00367666 -0.0162627 0)
(-0.00127432 -0.00973377 0)
(-0.000179283 -0.00317395 0)
(-0.000204598 0.00405198 0)
(-0.00142535 0.0120831 0)
(-0.00407256 0.0198159 0)
(-0.0078364 0.0270754 0)
(-0.0125426 0.0337229 0)
(-0.0180636 0.0396474 0)
(-0.0242646 0.0447644 0)
(-0.0310101 0.0490148 0)
(-0.0381689 0.052362 0)
(-0.0456145 0.0547894 0)
(-0.0532253 0.0562975 0)
(-0.0608855 0.0569014 0)
(-0.0684858 0.0566286 0)
(-0.0759234 0.0555163 0)
(-0.0831029 0.0536096 0)
(-0.0899362 0.0509603 0)
(-0.0963426 0.0476246 0)
(-0.102249 0.0436627 0)
(-0.10759 0.0391377 0)
(-0.112308 0.0341148 0)
(-0.116351 0.0286614 0)
(-0.119677 0.0228461 0)
(-0.12225 0.0167392 0)
(-0.124041 0.0104126 0)
(-0.125029 0.00393959 0)
(-0.125201 -0.00260472 0)
(-0.124549 -0.00914355 0)
(-0.123077 -0.0155984 0)
(-0.120793 -0.021889 0)
(-0.117718 -0.0279337 0)
(-0.113877 -0.0336499 0)
(-0.109309 -0.0389542 0)
(-0.104058 -0.0437639 0)
(-0.0981827 -0.0479972 0)
(-0.0917482 -0.0515753 0)
(-0.0848315 -0.0544234 0)
(-0.0775195 -0.0564727 0)
(-0.069909 -0.0576623 0)
(-0.062106 -0.0579418 0)
(-0.0542254 -0.057273 0)
(-0.0463896 -0.0556331 0)
(-0.0387276 -0.0530169 0)
(-0.0313731 -0.049439 0)
(-0.0244633 -0.0449368 0)
(-0.018137 -0.039572 0)
(-0.0125338 -0.0334324 0)
(-0.00778795 -0.0266337 0)
(-0.00402109 -0.0193187 0)
(-0.00139463 -0.0116567 0)
(-0.000196315 -0.0038506 0)
(-0.000221487 0.0048065 0)
(-0.00154168 0.014199 0)
(-0.00440191 0.0231443 0)
(-0.00846341 0.0314675 0)
(-0.0135338 0.039031 0)
(-0.0194717 0.045726 0)
(-0.0261284 0.0514709 0)
(-0.0333552 0.0562103 0)
(-0.0410095 0.0599124 0)
(-0.0489544 0.0625659 0)
(-0.0570598 0.0641774 0)
(-0.0652026 0.064769 0)
(-0.0732673 0.064375 0)
(-0.0811467 0.0630403 0)
(-0.0887415 0.0608178 0)
(-0.0959608 0.057767 0)
(-0.102722 0.053952 0)
(-0.108951 0.0494409 0)
(-0.114581 0.0443044 0)
(-0.119554 0.0386153 0)
(-0.123817 0.0324485 0)
(-0.127329 0.0258799 0)
(-0.130053 0.0189873 0)
(-0.131958 0.0118497 0)
(-0.133025 0.00454787 0)
(-0.133237 -0.00283559 0)
(-0.132588 -0.0102162 0)
(-0.13108 -0.0175074 0)
(-0.128719 -0.0246206 0)
(-0.125525 -0.0314654 0)
(-0.121522 -0.03795 0)
(-0.116747 -0.0439816 0)
(-0.111245 -0.0494672 0)
(-0.105072 -0.0543149 0)
(-0.0982954 -0.0584353 0)
(-0.0909926 -0.0617429 0)
(-0.0832528 -0.0641584 0)
(-0.0751764 -0.0656106 0)
(-0.0668743 -0.0660393 0)
(-0.0584676 -0.0653975 0)
(-0.050087 -0.0636547 0)
(-0.0418709 -0.0607989 0)
(-0.0339645 -0.0568402 0)
(-0.0265178 -0.0518125 0)
(-0.019684 -0.0457763 0)
(-0.0136179 -0.0388201 0)
(-0.00846991 -0.0310618 0)
(-0.00437681 -0.0226483 0)
(-0.00151898 -0.0137542 0)
(-0.000213963 -0.00458912 0)
(-0.000238758 0.00562073 0)
(-0.00166026 0.0164805 0)
(-0.00473711 0.0267294 0)
(-0.00910089 0.0361919 0)
(-0.0145406 0.044732 0)
(-0.0209006 0.0522432 0)
(-0.0280177 0.0586479 0)
(-0.0357299 0.063896 0)
(-0.0438824 0.0679614 0)
(-0.0523281 0.0708399 0)
(-0.0609278 0.0725457 0)
(-0.069551 0.0731091 0)
(-0.0780766 0.0725728 0)
(-0.0863925 0.0709905 0)
(-0.0943963 0.0684239 0)
(-0.101995 0.0649411 0)
(-0.109103 0.060615 0)
(-0.115647 0.0555217 0)
(-0.121559 0.0497403 0)
(-0.12678 0.0433514 0)
(-0.13126 0.0364372 0)
(-0.134954 0.0290812 0)
(-0.137827 0.0213683 0)
(-0.139849 0.0133848 0)
(-0.140998 0.00521847 0)
(-0.141258 -0.00304073 0)
(-0.140621 -0.0113008 0)
(-0.139087 -0.0194675 0)
(-0.136662 -0.0274439 0)
(-0.133362 -0.035131 0)
(-0.129213 -0.0424277 0)
(-0.124246 -0.0492313 0)
(-0.118507 -0.0554386 0)
(-0.112051 -0.0609468 0)
(-0.104944 -0.0656549 0)
(-0.097265 -0.0694661 0)
(-0.0891044 -0.072289 0)
(-0.0805656 -0.0740411 0)
(-0.0717644 -0.0746508 0)
(-0.0628282 -0.0740606 0)
(-0.0538956 -0.0722302 0)
(-0.0451153 -0.0691397 0)
(-0.0366442 -0.0647924 0)
(-0.0286459 -0.0592176 0)
(-0.0212889 -0.0524732 0)
(-0.0147443 -0.0446474 0)
(-0.00917948 -0.0358598 0)
(-0.0047475 -0.0262614 0)
(-0.00164885 -0.0160327 0)
(-0.000232481 -0.00539199 0)
(-0.000256565 0.00649606 0)
(-0.00178193 0.0189312 0)
(-0.00508031 0.0305761 0)
(-0.00975248 0.0412545 0)
(-0.0155681 0.0508317 0)
(-0.0223565 0.0592044 0)
(-0.0299395 0.0663003 0)
(-0.0381413 0.0720751 0)
(-0.0467945 0.0765108 0)
(-0.0557413 0.0796114 0)
(-0.0648334 0.0814005 0)
(-0.0739332 0.0819179 0)
(-0.0829135 0.0812166 0)
(-0.091658 0.07936 0)
(-0.100061 0.0764199 0)
(-0.108028 0.0724741 0)
(-0.115473 0.0676046 0)
(-0.122321 0.0618967 0)
(-0.128505 0.0554377 0)
(-0.133967 0.0483164 0)
(-0.138655 0.0406227 0)
(-0.142527 0.0324473 0)
(-0.145547 0.0238822 0)
(-0.147686 0.0150203 0)
(-0.14892 0.00595656 0)
(-0.149234 -0.00321232 0)
(-0.148619 -0.0123872 0)
(-0.147071 -0.0214662 0)
(-0.144597 -0.0303447 0)
(-0.141209 -0.0389149 0)
(-0.13693 -0.0470665 0)
(-0.13179 -0.0546869 0)
(-0.125833 -0.0616622 0)
(-0.119111 -0.0678781 0)
(-0.11169 -0.0732215 0)
(-0.103648 -0.0775829 0)
(-0.0950774 -0.0808579 0)
(-0.0860833 -0.0829508 0)
(-0.0767858 -0.083777 0)
(-0.0673187 -0.0832666 0)
(-0.0578286 -0.0813679 0)
(-0.0484744 -0.0780507 0)
(-0.0394256 -0.0733098 0)
(-0.0308601 -0.0671681 0)
(-0.0229625 -0.0596795 0)
(-0.0159216 -0.0509306 0)
(-0.00992268 -0.0410424 0)
(-0.00513666 -0.0301701 0)
(-0.00178561 -0.0185007 0)
(-0.000252109 -0.00626242 0)
(-0.00027504 0.00743433 0)
(-0.00190749 0.0215554 0)
(-0.00543347 0.0346906 0)
(-0.0104215 0.0466621 0)
(-0.0166208 0.057337 0)
(-0.0238449 0.0666161 0)
(-0.0318997 0.0744328 0)
(-0.040595 0.080751 0)
(-0.0497504 0.0855615 0)
(-0.0591971 0.0888789 0)
(-0.0687777 0.0907378 0)
(-0.078347 0.0911892 0)
(-0.0877725 0.0902977 0)
(-0.0969341 0.0881385 0)
(-0.105724 0.0847942 0)
(-0.114044 0.0803533 0)
(-0.121811 0.0749082 0)
(-0.128948 0.0685536 0)
(-0.13539 0.0613856 0)
(-0.141079 0.0535012 0)
(-0.145966 0.0449979 0)
(-0.150008 0.0359737 0)
(-0.153171 0.0265271 0)
(-0.155426 0.0167578 0)
(-0.156748 0.00676701 0)
(-0.157123 -0.00334218 0)
(-0.156539 -0.0134639 0)
(-0.154992 -0.0234893 0)
(-0.152484 -0.033306 0)
(-0.149028 -0.0427982 0)
(-0.14464 -0.0518463 0)
(-0.139351 -0.0603278 0)
(-0.133198 -0.0681177 0)
(-0.126233 -0.0750898 0)
(-0.118519 -0.081118 0)
(-0.110133 -0.0860791 0)
(-0.101167 -0.0898542 0)
(-0.0917295 -0.0923329 0)
(-0.0819426 -0.0934157 0)
(-0.0719464 -0.0930182 0)
(-0.0618955 -0.0910748 0)
(-0.0519594 -0.087543 0)
(-0.0423204 -0.0824069 0)
(-0.0331717 -0.0756811 0)
(-0.0247148 -0.0674136 0)
(-0.0171576 -0.0576883 0)
(-0.0107052 -0.0466271 0)
(-0.00554763 -0.0343889 0)
(-0.00193058 -0.0211682 0)
(-0.000273071 -0.00720431 0)
(-0.00029431 0.00843776 0)
(-0.00203765 0.0243586 0)
(-0.00579844 0.0390801 0)
(-0.011111 0.052423 0)
(-0.0177028 0.0642561 0)
(-0.0253704 0.074485 0)
(-0.0339031 0.0830505 0)
(-0.0430951 0.0899259 0)
(-0.0527529 0.095113 0)
(-0.0626959 0.0986387 0)
(-0.0727578 0.100551 0)
(-0.082786 0.100913 0)
(-0.0926429 0.0998037 0)
(-0.102205 0.0973111 0)
(-0.111362 0.0935303 0)
(-0.120017 0.0885617 0)
(-0.128085 0.0825086 0)
(-0.135491 0.0754757 0)
(-0.142171 0.0675685 0)
(-0.148071 0.0588922 0)
(-0.153142 0.0495521 0)
(-0.157343 0.0396528 0)
(-0.160641 0.0292994 0)
(-0.163008 0.0185975 0)
(-0.164421 0.00765406 0)
(-0.164862 -0.00342188 0)
(-0.16432 -0.0145185 0)
(-0.162789 -0.0255205 0)
(-0.160268 -0.0363086 0)
(-0.156765 -0.0467588 0)
(-0.152295 -0.0567431 0)
(-0.146883 -0.0661288 0)
(-0.140564 -0.0747797 0)
(-0.133385 -0.0825572 0)
(-0.125405 -0.0893217 0)
(-0.1167 -0.0949347 0)
(-0.107361 -0.0992619 0)
(-0.0974966 -0.102176 0)
(-0.0872326 -0.10356 0)
(-0.0767136 -0.103314 0)
(-0.0661024 -0.101355 0)
(-0.0555787 -0.0976262 0)
(-0.0453383 -0.092098 0)
(-0.0355903 -0.0847743 0)
(-0.0265547 -0.0756955 0)
(-0.0184599 -0.0649414 0)
(-0.0115325 -0.0526334 0)
(-0.0059836 -0.0389344 0)
(-0.002085 -0.0240467 0)
(-0.000295589 -0.00822223 0)
(-0.000314496 0.00950893 0)
(-0.00217314 0.027347 0)
(-0.00617696 0.0437533 0)
(-0.0118239 0.0585464 0)
(-0.0188179 0.0715976 0)
(-0.0269373 0.0828182 0)
(-0.0359535 0.0921578 0)
(-0.0456445 0.0996008 0)
(-0.0558025 0.105163 0)
(-0.0662354 0.108884 0)
(-0.0767673 0.110828 0)
(-0.087239 0.111074 0)
(-0.0975079 0.109717 0)
(-0.107448 0.106857 0)
(-0.116947 0.102606 0)
(-0.125909 0.097076 0)
(-0.134251 0.0903823 0)
(-0.1419 0.0826405 0)
(-0.148794 0.0739656 0)
(-0.154881 0.0644713 0)
(-0.160116 0.0542702 0)
(-0.164461 0.0434736 0)
(-0.167884 0.0321923 0)
(-0.170357 0.0205375 0)
(-0.17186 0.00862103 0)
(-0.172373 -0.00344297 0)
(-0.171884 -0.0155375 0)
(-0.170385 -0.0275416 0)
(-0.167873 -0.0393296 0)
(-0.16435 -0.0507706 0)
(-0.159829 -0.0617277 0)
(-0.154328 -0.0720587 0)
(-0.147877 -0.0816164 0)
(-0.140519 -0.090249 0)
(-0.132309 -0.0978027 0)
(-0.123318 -0.104123 0)
(-0.113635 -0.109058 0)
(-0.103369 -0.112462 0)
(-0.0926465 -0.114199 0)
(-0.0816171 -0.114149 0)
(-0.0704506 -0.11221 0)
(-0.0593373 -0.108308 0)
(-0.0484866 -0.102396 0)
(-0.0381244 -0.0944652 0)
(-0.0284905 -0.084546 0)
(-0.0198356 -0.072712 0)
(-0.0124097 -0.059083 0)
(-0.00644767 -0.0438253 0)
(-0.00225015 -0.0271495 0)
(-0.000319882 -0.00932142 0)
(-0.000335724 0.0106508 0)
(-0.00231467 0.0305277 0)
(-0.00657084 0.0487196 0)
(-0.012563 0.0650426 0)
(-0.0199698 0.0793708 0)
(-0.0285494 0.0916225 0)
(-0.0380542 0.101758 0)
(-0.0482445 0.109775 0)
(-0.0588979 0.115704 0)
(-0.0698101 0.119604 0)
(-0.080796 0.121554 0)
(-0.0916897 0.121653 0)
(-0.102344 0.120012 0)
(-0.112632 0.11675 0)
(-0.122441 0.111992 0)
(-0.131676 0.105866 0)
(-0.140257 0.0984989 0)
(-0.148113 0.0900186 0)
(-0.155188 0.0805496 0)
(-0.161433 0.0702142 0)
(-0.166807 0.059132 0)
(-0.171274 0.0474205 0)
(-0.174806 0.0351959 0)
(-0.177378 0.0225736 0)
(-0.178967 0.00966988 0)
(-0.179557 -0.00339719 0)
(-0.179134 -0.0165064 0)
(-0.177685 -0.0295322 0)
(-0.175206 -0.0423434 0)
(-0.171694 -0.0548026 0)
(-0.167157 -0.0667654 0)
(-0.161607 -0.0780802 0)
(-0.155067 -0.0885885 0)
(-0.147574 -0.0981258 0)
(-0.139177 -0.106523 0)
(-0.129943 -0.113608 0)
(-0.119955 -0.119211 0)
(-0.10932 -0.123165 0)
(-0.0981671 -0.125312 0)
(-0.086647 -0.12551 0)
(-0.0749368 -0.123636 0)
(-0.0632367 -0.119591 0)
(-0.0517702 -0.113311 0)
(-0.0407807 -0.104771 0)
(-0.0305294 -0.0939866 0)
(-0.021291 -0.0810238 0)
(-0.0133419 -0.0659994 0)
(-0.00694294 -0.0490821 0)
(-0.00242727 -0.0304912 0)
(-0.000346177 -0.0105078 0)
(-0.000358135 0.0118667 0)
(-0.00246304 0.0339089 0)
(-0.00698203 0.0539897 0)
(-0.0133316 0.0719226 0)
(-0.0211624 0.0875854 0)
(-0.0302107 0.100905 0)
(-0.0402079 0.111853 0)
(-0.0508957 0.120445 0)
(-0.062036 0.126728 0)
(-0.0734121 0.130782 0)
(-0.0848296 0.132707 0)
(-0.0961165 0.132623 0)
(-0.107123 0.130659 0)
(-0.117719 0.126954 0)
(-0.127796 0.12165 0)
(-0.13726 0.114892 0)
(-0.146034 0.106819 0)
(-0.154056 0.0975723 0)
(-0.16127 0.0872856 0)
(-0.167635 0.0760897 0)
(-0.173115 0.0641111 0)
(-0.177677 0.051473 0)
(-0.181298 0.0382958 0)
(-0.183954 0.0246986 0)
(-0.185626 0.0108008 0)
(-0.186296 -0.00327679 0)
(-0.185948 -0.0174098 0)
(-0.18457 -0.0314694 0)
(-0.182152 -0.0453201 0)
(-0.178687 -0.0588192 0)
(-0.174175 -0.0718153 0)
(-0.168622 -0.0841483 0)
(-0.162045 -0.0956487 0)
(-0.154471 -0.106139 0)
(-0.145942 -0.115434 0)
(-0.136516 -0.123345 0)
(-0.126273 -0.12968 0)
(-0.115315 -0.13425 0)
(-0.103768 -0.136873 0)
(-0.0917865 -0.137379 0)
(-0.0795519 -0.135621 0)
(-0.0672744 -0.131475 0)
(-0.0551913 -0.124852 0)
(-0.0435645 -0.115707 0)
(-0.0326779 -0.104038 0)
(-0.0228326 -0.0899014 0)
(-0.014334 -0.0734075 0)
(-0.00747254 -0.0547272 0)
(-0.00261768 -0.0340882 0)
(-0.000374714 -0.0117878 0)
(-0.000381891 0.0131605 0)
(-0.00261919 0.0374996 0)
(-0.00741276 0.0595754 0)
(-0.014133 0.0791987 0)
(-0.0223998 0.0962514 0)
(-0.031925 0.11067 0)
(-0.0424171 0.122443 0)
(-0.0535976 0.131603 0)
(-0.0652117 0.138221 0)
(-0.0770302 0.142397 0)
(-0.0888495 0.144259 0)
(-0.100492 0.143947 0)
(-0.111806 0.141615 0)
(-0.122662 0.137423 0)
(-0.132953 0.131533 0)
(-0.142591 0.124104 0)
(-0.151505 0.115294 0)
(-0.159636 0.105254 0)
(-0.166939 0.0941294 0)
(-0.173377 0.0820582 0)
(-0.178921 0.0691738 0)
(-0.183545 0.055604 0)
(-0.187228 0.0414727 0)
(-0.189951 0.0269015 0)
(-0.191696 0.0120115 0)
(-0.192447 -0.00307486 0)
(-0.192187 -0.0182318 0)
(-0.190901 -0.0333285 0)
(-0.188574 -0.0482266 0)
(-0.185195 -0.0627794 0)
(-0.180756 -0.0768298 0)
(-0.175257 -0.0902097 0)
(-0.168702 -0.10274 0)
(-0.161111 -0.114229 0)
(-0.152515 -0.124478 0)
(-0.142963 -0.133277 0)
(-0.132528 -0.140412 0)
(-0.121303 -0.14567 0)
(-0.109413 -0.148841 0)
(-0.09701 -0.149727 0)
(-0.0842807 -0.148148 0)
(-0.0714433 -0.143952 0)
(-0.0587491 -0.137022 0)
(-0.0464792 -0.127285 0)
(-0.0349415 -0.114721 0)
(-0.0244664 -0.0993697 0)
(-0.0153912 -0.081334 0)
(-0.00803977 -0.0607848 0)
(-0.00282278 -0.0379581 0)
(-0.000405757 -0.0131688 0)
(-0.000407193 0.0145363 0)
(-0.00278423 0.0413101 0)
(-0.00786574 0.0654901 0)
(-0.0149716 0.086884 0)
(-0.0236871 0.105379 0)
(-0.033697 0.120924 0)
(-0.0446846 0.133526 0)
(-0.0563491 0.143239 0)
(-0.0684186 0.150161 0)
(-0.0806505 0.15442 0)
(-0.0928327 0.156169 0)
(-0.104783 0.155579 0)
(-0.116349 0.152828 0)
(-0.127403 0.148101 0)
(-0.137843 0.141579 0)
(-0.147587 0.133443 0)
(-0.156572 0.123864 0)
(-0.164747 0.113007 0)
(-0.172076 0.101027 0)
(-0.17853 0.0880712 0)
(-0.184088 0.0742782 0)
(-0.18873 0.0597795 0)
(-0.192441 0.0447015 0)
(-0.195208 0.0291669 0)
(-0.197014 0.013297 0)
(-0.197845 -0.00278582 0)
(-0.197683 -0.018956 0)
(-0.196511 -0.0350824 0)
(-0.19431 -0.0510256 0)
(-0.191061 -0.0666364 0)
(-0.186751 -0.0817536 0)
(-0.181367 -0.0962025 0)
(-0.174905 -0.109794 0)
(-0.167373 -0.122326 0)
(-0.158789 -0.133582 0)
(-0.149192 -0.143332 0)
(-0.138641 -0.15134 0)
(-0.127222 -0.157365 0)
(-0.115053 -0.161166 0)
(-0.102283 -0.162512 0)
(-0.0891005 -0.161188 0)
(-0.0757314 -0.157007 0)
(-0.0624398 -0.149817 0)
(-0.0495264 -0.139515 0)
(-0.0373253 -0.126054 0)
(-0.0261982 -0.109454 0)
(-0.0165186 -0.0898067 0)
(-0.00864817 -0.067281 0)
(-0.00304411 -0.0421204 0)
(-0.000439603 -0.0146587 0)
(-0.000434298 0.0159993 0)
(-0.00295958 0.0453522 0)
(-0.00834436 0.0717487 0)
(-0.0158524 0.0949929 0)
(-0.0250304 0.114979 0)
(-0.0355325 0.13167 0)
(-0.0470135 0.145096 0)
(-0.0591489 0.155337 0)
(-0.0716482 0.162522 0)
(-0.0842556 0.166812 0)
(-0.0967511 0.168391 0)
(-0.108949 0.167463 0)
(-0.120698 0.164234 0)
(-0.131875 0.158917 0)
(-0.142384 0.151716 0)
(-0.152152 0.142832 0)
(-0.161125 0.132454 0)
(-0.169265 0.120759 0)
(-0.176544 0.107912 0)
(-0.182945 0.0940692 0)
(-0.188455 0.0793728 0)
(-0.193064 0.0639576 0)
(-0.196763 0.0479507 0)
(-0.199543 0.0314744 0)
(-0.201394 0.0146488 0)
(-0.202301 -0.00240586 0)
(-0.202246 -0.0195661 0)
(-0.201211 -0.0367024 0)
(-0.199171 -0.0536763 0)
(-0.196102 -0.0703381 0)
(-0.191981 -0.0865241 0)
(-0.186785 -0.102055 0)
(-0.180498 -0.116734 0)
(-0.173113 -0.130346 0)
(-0.164635 -0.142659 0)
(-0.155087 -0.153425 0)
(-0.144515 -0.162382 0)
(-0.132992 -0.169258 0)
(-0.120625 -0.173781 0)
(-0.107559 -0.175679 0)
(-0.0939806 -0.1747 0)
(-0.0801205 -0.170614 0)
(-0.0662554 -0.163228 0)
(-0.0527059 -0.152401 0)
(-0.0398333 -0.138053 0)
(-0.0280341 -0.120179 0)
(-0.0177221 -0.0988546 0)
(-0.0093017 -0.0742437 0)
(-0.00328343 -0.0465965 0)
(-0.000476593 -0.0162665 0)
(-0.000463537 0.0175552 0)
(-0.00314708 0.0496394 0)
(-0.00885295 0.0783681 0)
(-0.0167823 0.103541 0)
(-0.0264377 0.125061 0)
(-0.0374384 0.14291 0)
(-0.0494078 0.157143 0)
(-0.0619953 0.167874 0)
(-0.0748905 0.175268 0)
(-0.0878247 0.179523 0)
(-0.100571 0.180863 0)
(-0.112942 0.179526 0)
(-0.124789 0.175753 0)
(-0.135996 0.169786 0)
(-0.146477 0.161856 0)
(-0.15617 0.152184 0)
(-0.165034 0.140976 0)
(-0.173044 0.128426 0)
(-0.180185 0.114707 0)
(-0.18645 0.0999813 0)
(-0.19184 0.0843961 0)
(-0.196353 0.0680872 0)
(-0.19999 0.051181 0)
(-0.202748 0.0337978 0)
(-0.204621 0.0160542 0)
(-0.205596 -0.00193351 0)
(-0.205656 -0.0200461 0)
(-0.204781 -0.038158 0)
(-0.202941 -0.056134 0)
(-0.200106 -0.0738261 0)
(-0.196242 -0.0910705 0)
(-0.191315 -0.107685 0)
(-0.185296 -0.123466 0)
(-0.178161 -0.138189 0)
(-0.169898 -0.151607 0)
(-0.160513 -0.163452 0)
(-0.150033 -0.173435 0)
(-0.138515 -0.181255 0)
(-0.126053 -0.186599 0)
(-0.11278 -0.189157 0)
(-0.0988803 -0.188628 0)
(-0.0845858 -0.184733 0)
(-0.0701841 -0.177233 0)
(-0.0560152 -0.165939 0)
(-0.0424692 -0.15073 0)
(-0.0299805 -0.131568 0)
(-0.0190079 -0.108508 0)
(-0.0100049 -0.081703 0)
(-0.00354279 -0.0514097 0)
(-0.000517139 -0.0180021 0)
(-0.000495344 0.0192108 0)
(-0.00334909 0.0541879 0)
(-0.0093971 0.0853683 0)
(-0.0177697 0.112547 0)
(-0.0279189 0.135637 0)
(-0.039424 0.154644 0)
(-0.0518729 0.169653 0)
(-0.0648864 0.18082 0)
(-0.0781334 0.188352 0)
(-0.0913326 0.192492 0)
(-0.104251 0.193509 0)
(-0.116703 0.191681 0)
(-0.128546 0.187288 0)
(-0.139672 0.180604 0)
(-0.150009 0.17189 0)
(-0.159511 0.161389 0)
(-0.16815 0.149327 0)
(-0.175918 0.135908 0)
(-0.182815 0.121318 0)
(-0.188851 0.105724 0)
(-0.194035 0.0892753 0)
(-0.198381 0.0721077 0)
(-0.201897 0.0543454 0)
(-0.204588 0.0361044 0)
(-0.206454 0.0174959 0)
(-0.207485 -0.00137019 0)
(-0.207667 -0.0203812 0)
(-0.206974 -0.0394179 0)
(-0.205374 -0.0583511 0)
(-0.20283 -0.077037 0)
(-0.199298 -0.0953142 0)
(-0.194732 -0.113 0)
(-0.189085 -0.129887 0)
(-0.182317 -0.145743 0)
(-0.174395 -0.160307 0)
(-0.165305 -0.17329 0)
(-0.155051 -0.184379 0)
(-0.143671 -0.193238 0)
(-0.131238 -0.199515 0)
(-0.117872 -0.202852 0)
(-0.103747 -0.202896 0)
(-0.0890941 -0.199311 0)
(-0.0742087 -0.191799 0)
(-0.0594492 -0.180117 0)
(-0.0452359 -0.164092 0)
(-0.0320443 -0.143643 0)
(-0.0203834 -0.118796 0)
(-0.0107631 -0.0896911 0)
(-0.00382465 -0.0565857 0)
(-0.000561737 -0.0198764 0)
(-0.000530293 0.0209744 0)
(-0.00356872 0.0590168 0)
(-0.00998412 0.0927724 0)
(-0.0188257 0.122031 0)
(-0.0294869 0.146718 0)
(-0.0415009 0.166868 0)
(-0.0544154 0.182606 0)
(-0.0678199 0.194135 0)
(-0.081362 0.201714 0)
(-0.0947484 0.205641 0)
(-0.107743 0.206234 0)
(-0.120164 0.20382 0)
(-0.131877 0.198721 0)
(-0.14279 0.191249 0)
(-0.152847 0.181693 0)
(-0.162019 0.170324 0)
(-0.1703 0.157383 0)
(-0.177697 0.14309 0)
(-0.18423 0.127639 0)
(-0.189925 0.1112 0)
(-0.194807 0.0939257 0)
(-0.198901 0.0759483 0)
(-0.202227 0.057388 0)
(-0.2048 0.0383545 0)
(-0.206624 0.0189511 0)
(-0.207696 -0.000720819 0)
(-0.208 -0.0205579 0)
(-0.207512 -0.0404503 0)
(-0.206195 -0.0602771 0)
(-0.204003 -0.079902 0)
(-0.200883 -0.0991689 0)
(-0.196775 -0.117898 0)
(-0.191617 -0.135881 0)
(-0.185347 -0.152878 0)
(-0.177911 -0.168619 0)
(-0.169269 -0.182796 0)
(-0.1594 -0.195069 0)
(-0.148314 -0.205068 0)
(-0.136062 -0.212398 0)
(-0.122743 -0.216648 0)
(-0.108514 -0.217407 0)
(-0.0936023 -0.214273 0)
(-0.0783058 -0.206879 0)
(-0.0630002 -0.194913 0)
(-0.0481359 -0.17814 0)
(-0.0342331 -0.156424 0)
(-0.0218573 -0.129752 0)
(-0.0115828 -0.0982429 0)
(-0.00413204 -0.0621532 0)
(-0.000611006 -0.0219021 0)
(-0.000569147 0.0228562 0)
(-0.00381006 0.0641493 0)
(-0.0106235 0.100608 0)
(-0.0199646 0.132016 0)
(-0.0311583 0.158316 0)
(-0.0436837 0.179576 0)
(-0.0570434 0.195973 0)
(-0.0707928 0.207767 0)
(-0.0845575 0.21528 0)
(-0.0980339 0.218873 0)
(-0.110986 0.218923 0)
(-0.123239 0.215813 0)
(-0.134674 0.209913 0)
(-0.145218 0.201574 0)
(-0.154834 0.191118 0)
(-0.163517 0.178841 0)
(-0.171283 0.165004 0)
(-0.178162 0.149838 0)
(-0.184195 0.133545 0)
(-0.189423 0.1163 0)
(-0.193891 0.0982504 0)
(-0.197639 0.0795276 0)
(-0.200698 0.0602442 0)
(-0.203092 0.0405012 0)
(-0.204834 0.0203917 0)
(-0.205924 5.64538e-06 0)
(-0.206351 -0.0205654 0)
(-0.206087 -0.0412236 0)
(-0.205093 -0.0618598 0)
(-0.203318 -0.0823481 0)
(-0.200696 -0.102541 0)
(-0.197153 -0.122266 0)
(-0.192611 -0.141315 0)
(-0.186985 -0.159449 0)
(-0.180197 -0.176385 0)
(-0.172177 -0.191802 0)
(-0.162875 -0.205333 0)
(-0.15227 -0.216575 0)
(-0.140381 -0.225087 0)
(-0.127278 -0.2304 0)
(-0.113099 -0.232037 0)
(-0.0980549 -0.22952 0)
(-0.0824445 -0.222403 0)
(-0.0666563 -0.210289 0)
(-0.0511708 -0.192865 0)
(-0.0365558 -0.169926 0)
(-0.0234399 -0.141408 0)
(-0.012472 -0.107396 0)
(-0.00446875 -0.0681442 0)
(-0.00066573 -0.0240934 0)
(-0.000612924 0.0248686 0)
(-0.00407848 0.0696141 0)
(-0.0113276 0.108909 0)
(-0.0212048 0.14253 0)
(-0.0329538 0.170441 0)
(-0.0459907 0.192757 0)
(-0.0597666 0.209716 0)
(-0.0737999 0.221649 0)
(-0.087695 0.228955 0)
(-0.101141 0.232069 0)
(-0.113905 0.231438 0)
(-0.125827 0.227507 0)
(-0.136807 0.220699 0)
(-0.146796 0.211408 0)
(-0.155786 0.199992 0)
(-0.163797 0.186772 0)
(-0.170872 0.172027 0)
(-0.177066 0.156 0)
(-0.182442 0.138899 0)
(-0.187066 0.120897 0)
(-0.190997 0.102141 0)
(-0.194292 0.0827539 0)
(-0.196996 0.0628405 0)
(-0.199143 0.0424901 0)
(-0.200755 0.0217832 0)
(-0.201837 0.000795721 0)
(-0.202381 -0.0203955 0)
(-0.202359 -0.0417076 0)
(-0.20173 -0.0630461 0)
(-0.200435 -0.0842994 0)
(-0.1984 -0.105333 0)
(-0.195536 -0.125982 0)
(-0.191746 -0.146048 0)
(-0.186924 -0.165292 0)
(-0.180963 -0.183426 0)
(-0.173763 -0.200117 0)
(-0.165238 -0.214975 0)
(-0.155329 -0.227562 0)
(-0.144017 -0.237389 0)
(-0.131337 -0.24393 0)
(-0.117395 -0.24663 0)
(-0.102381 -0.244928 0)
(-0.0865836 -0.238279 0)
(-0.0704008 -0.226189 0)
(-0.0543411 -0.208246 0)
(-0.0390226 -0.18416 0)
(-0.0251443 -0.153794 0)
(-0.0134408 -0.117193 0)
(-0.00483963 -0.0745952 0)
(-0.00072692 -0.0264668 0)
(-0.000662986 0.0270276 0)
(-0.00438107 0.0754466 0)
(-0.0121125 0.117716 0)
(-0.0225699 0.153604 0)
(-0.0348997 0.183106 0)
(-0.0484438 0.206393 0)
(-0.062595 0.223783 0)
(-0.0768326 0.235695 0)
(-0.0907408 0.24262 0)
(-0.104005 0.245082 0)
(-0.116405 0.243608 0)
(-0.127799 0.238714 0)
(-0.138115 0.230882 0)
(-0.147336 0.220551 0)
(-0.155485 0.208117 0)
(-0.162615 0.193925 0)
(-0.1688 0.178271 0)
(-0.174123 0.161408 0)
(-0.178674 0.143544 0)
(-0.182539 0.124853 0)
(-0.185798 0.105476 0)
(-0.188525 0.0855257 0)
(-0.190779 0.065095 0)
(-0.192604 0.0442599 0)
(-0.194032 0.0230854 0)
(-0.195074 0.00163106 0)
(-0.195725 -0.0200438 0)
(-0.195959 -0.0418742 0)
(-0.195733 -0.0637838 0)
(-0.194982 -0.0856785 0)
(-0.193624 -0.10744 0)
(-0.191556 -0.128918 0)
(-0.188663 -0.149926 0)
(-0.184816 -0.17023 0)
(-0.179879 -0.189545 0)
(-0.173718 -0.207526 0)
(-0.166206 -0.223766 0)
(-0.157241 -0.237795 0)
(-0.146758 -0.249078 0)
(-0.134747 -0.257022 0)
(-0.121271 -0.260994 0)
(-0.106488 -0.260332 0)
(-0.090669 -0.254384 0)
(-0.0742104 -0.242534 0)
(-0.057646 -0.22425 0)
(-0.0416456 -0.199129 0)
(-0.0269863 -0.166944 0)
(-0.0145022 -0.127679 0)
(-0.00525091 -0.0815483 0)
(-0.000795896 -0.0290419 0)
(-0.00072117 0.0293531 0)
(-0.00472723 0.0816913 0)
(-0.0129992 0.127079 0)
(-0.02409 0.165276 0)
(-0.0370282 0.19632 0)
(-0.0510685 0.220458 0)
(-0.0655379 0.238105 0)
(-0.0798749 0.249795 0)
(-0.0936472 0.256127 0)
(-0.106544 0.257731 0)
(-0.118364 0.25523 0)
(-0.128995 0.249215 0)
(-0.138402 0.240234 0)
(-0.146606 0.228775 0)
(-0.153671 0.215269 0)
(-0.159687 0.200085 0)
(-0.164762 0.183534 0)
(-0.169012 0.165873 0)
(-0.172552 0.147313 0)
(-0.175493 0.12802 0)
(-0.177937 0.108126 0)
(-0.179972 0.0877331 0)
(-0.181672 0.0669188 0)
(-0.183095 0.0457429 0)
(-0.18428 0.0242525 0)
(-0.185244 0.0024883 0)
(-0.185988 -0.0195103 0)
(-0.186488 -0.0416991 0)
(-0.186699 -0.0640228 0)
(-0.186554 -0.0864084 0)
(-0.185962 -0.108758 0)
(-0.184809 -0.130942 0)
(-0.182962 -0.152787 0)
(-0.18027 -0.174075 0)
(-0.176567 -0.194524 0)
(-0.171681 -0.213789 0)
(-0.165445 -0.23145 0)
(-0.157706 -0.247008 0)
(-0.148344 -0.259882 0)
(-0.137292 -0.269417 0)
(-0.124561 -0.274889 0)
(-0.11026 -0.27553 0)
(-0.0946284 -0.270558 0)
(-0.078052 -0.259214 0)
(-0.0610818 -0.240819 0)
(-0.044439 -0.214827 0)
(-0.0289863 -0.18089 0)
(-0.0156727 -0.138905 0)
(-0.00571084 -0.0890525 0)
(-0.00087442 -0.0318419 0)
(-0.000789976 0.0318709 0)
(-0.00512943 0.0884043 0)
(-0.014015 0.13706 0)
(-0.0258032 0.17759 0)
(-0.0393789 0.21009 0)
(-0.0538932 0.234909 0)
(-0.0686005 0.25259 0)
(-0.0828987 0.263804 0)
(-0.0963453 0.269289 0)
(-0.108644 0.269796 0)
(-0.119622 0.266057 0)
(-0.129212 0.25875 0)
(-0.137424 0.248491 0)
(-0.144329 0.235818 0)
(-0.150036 0.221196 0)
(-0.154679 0.205014 0)
(-0.158405 0.187594 0)
(-0.161362 0.169196 0)
(-0.163696 0.150024 0)
(-0.16554 0.130237 0)
(-0.167018 0.109954 0)
(-0.168234 0.0892605 0)
(-0.169275 0.0682177 0)
(-0.170211 0.0468664 0)
(-0.171088 0.0252338 0)
(-0.171934 0.00333924 0)
(-0.172751 -0.0188 0)
(-0.173521 -0.0411626 0)
(-0.174199 -0.0637174 0)
(-0.174715 -0.0864158 0)
(-0.174973 -0.109185 0)
(-0.17485 -0.131917 0)
(-0.174199 -0.154464 0)
(-0.172845 -0.176624 0)
(-0.170596 -0.198132 0)
(-0.167241 -0.218646 0)
(-0.162568 -0.23774 0)
(-0.156369 -0.254895 0)
(-0.14846 -0.26949 0)
(-0.138708 -0.280804 0)
(-0.127054 -0.288025 0)
(-0.113543 -0.290265 0)
(-0.0983652 -0.286593 0)
(-0.0818785 -0.276083 0)
(-0.0646402 -0.257871 0)
(-0.0474188 -0.231233 0)
(-0.0311696 -0.195659 0)
(-0.0169741 -0.150931 0)
(-0.00623033 -0.0971663 0)
(-0.000964872 -0.0348951 0)
(-0.00087284 0.0346143 0)
(-0.0056044 0.0956572 0)
(-0.0151955 0.147734 0)
(-0.0277576 0.190595 0)
(-0.0419982 0.224417 0)
(-0.0569472 0.249686 0)
(-0.071779 0.267111 0)
(-0.0858551 0.277539 0)
(-0.0987337 0.28187 0)
(-0.110146 0.281005 0)
(-0.119968 0.275795 0)
(-0.128188 0.267015 0)
(-0.134876 0.255348 0)
(-0.140161 0.241384 0)
(-0.144207 0.225617 0)
(-0.147197 0.208452 0)
(-0.149318 0.190215 0)
(-0.150754 0.171162 0)
(-0.151679 0.15149 0)
(-0.152251 0.131341 0)
(-0.152611 0.110818 0)
(-0.152879 0.0899895 0)
(-0.153155 0.0688953 0)
(-0.153518 0.0475554 0)
(-0.154024 0.0259753 0)
(-0.154707 0.00415141 0)
(-0.155574 -0.0179229 0)
(-0.156612 -0.0402513 0)
(-0.157777 -0.0628287 0)
(-0.159002 -0.0856339 0)
(-0.160186 -0.108622 0)
(-0.161202 -0.131715 0)
(-0.161889 -0.154791 0)
(-0.162055 -0.177676 0)
(-0.161482 -0.200126 0)
(-0.159925 -0.221814 0)
(-0.157121 -0.242321 0)
(-0.152805 -0.261114 0)
(-0.146725 -0.27754 0)
(-0.138666 -0.290821 0)
(-0.128482 -0.300052 0)
(-0.116138 -0.304218 0)
(-0.101748 -0.302223 0)
(-0.0856222 -0.292942 0)
(-0.0683047 -0.275288 0)
(-0.0506028 -0.248307 0)
(-0.0335682 -0.211279 0)
(-0.018435 -0.16382 0)
(-0.00682415 -0.10596 0)
(-0.00107053 -0.0382366 0)
(-0.000974567 0.0376269 0)
(-0.00617477 0.103541 0)
(-0.0165875 0.159194 0)
(-0.0300132 0.204344 0)
(-0.0449402 0.239288 0)
(-0.0602559 0.264697 0)
(-0.0750517 0.281498 0)
(-0.0886618 0.290757 0)
(-0.100662 0.293577 0)
(-0.110834 0.291027 0)
(-0.119121 0.284094 0)
(-0.125585 0.273654 0)
(-0.130373 0.26046 0)
(-0.133682 0.245146 0)
(-0.135739 0.228229 0)
(-0.136777 0.210122 0)
(-0.137029 0.191149 0)
(-0.136711 0.171555 0)
(-0.136026 0.151519 0)
(-0.135153 0.131167 0)
(-0.134248 0.11058 0)
(-0.133446 0.0898041 0)
(-0.132856 0.0688567 0)
(-0.132565 0.0477353 0)
(-0.132637 0.0264219 0)
(-0.13311 0.00488903 0)
(-0.134 -0.0168947 0)
(-0.135296 -0.0389592 0)
(-0.136962 -0.061327 0)
(-0.13893 -0.0840063 0)
(-0.141103 -0.106983 0)
(-0.143351 -0.130213 0)
(-0.145506 -0.153609 0)
(-0.147365 -0.177029 0)
(-0.148686 -0.20026 0)
(-0.149192 -0.223004 0)
(-0.148577 -0.244856 0)
(-0.146514 -0.265287 0)
(-0.142674 -0.283626 0)
(-0.136754 -0.299044 0)
(-0.128504 -0.31055 0)
(-0.117781 -0.316997 0)
(-0.104598 -0.317109 0)
(-0.0891837 -0.309529 0)
(-0.0720445 -0.2929 0)
(-0.0540084 -0.26598 0)
(-0.0362221 -0.227768 0)
(-0.0200933 -0.177651 0)
(-0.00751248 -0.11552 0)
(-0.00119601 -0.0419107 0)
(-0.00110201 0.0409665 0)
(-0.00687153 0.112174 0)
(-0.0182522 0.171555 0)
(-0.0326444 0.218895 0)
(-0.0482634 0.254669 0)
(-0.0638334 0.279805 0)
(-0.0783648 0.295517 0)
(-0.0911827 0.303146 0)
(-0.101908 0.304038 0)
(-0.110402 0.299459 0)
(-0.1167 0.290541 0)
(-0.120963 0.278262 0)
(-0.123428 0.263441 0)
(-0.124373 0.246746 0)
(-0.124092 0.228708 0)
(-0.122872 0.209739 0)
(-0.120989 0.190147 0)
(-0.118692 0.170158 0)
(-0.116206 0.14993 0)
(-0.113728 0.129562 0)
(-0.111426 0.10911 0)
(-0.109445 0.0885968 0)
(-0.107899 0.0680144 0)
(-0.106882 0.047336 0)
(-0.106461 0.02652 0)
(-0.106682 0.0055147 0)
(-0.107564 -0.0157363 0)
(-0.109103 -0.0372893 0)
(-0.111268 -0.0591947 0)
(-0.114 -0.0814916 0)
(-0.117205 -0.1042 0)
(-0.120758 -0.12731 0)
(-0.124489 -0.150775 0)
(-0.128191 -0.174494 0)
(-0.131606 -0.198296 0)
(-0.134433 -0.22192 0)
(-0.136325 -0.244995 0)
(-0.136897 -0.267011 0)
(-0.135745 -0.287295 0)
(-0.132461 -0.304987 0)
(-0.126678 -0.319021 0)
(-0.11812 -0.328121 0)
(-0.106663 -0.330819 0)
(-0.0924155 -0.325496 0)
(-0.0758046 -0.310474 0)
(-0.0576489 -0.284141 0)
(-0.0391806 -0.245131 0)
(-0.0219992 -0.192507 0)
(-0.00832337 -0.125953 0)
(-0.00134794 -0.0459746 0)
(-0.00126523 0.0447103 0)
(-0.00773786 0.121707 0)
(-0.0202707 0.184952 0)
(-0.0357415 0.234299 0)
(-0.0520261 0.270487 0)
(-0.0676674 0.294805 0)
(-0.0816081 0.308845 0)
(-0.0931972 0.314295 0)
(-0.102141 0.31279 0)
(-0.108419 0.305812 0)
(-0.112194 0.294649 0)
(-0.113748 0.280376 0)
(-0.113426 0.263865 0)
(-0.111595 0.245805 0)
(-0.108619 0.226724 0)
(-0.10484 0.207016 0)
(-0.10057 0.186966 0)
(-0.096087 0.16677 0)
(-0.0916329 0.146554 0)
(-0.0874154 0.126387 0)
(-0.0836098 0.106297 0)
(-0.080362 0.0862765 0)
(-0.0777907 0.0662938 0)
(-0.0759897 0.0462974 0)
(-0.0750293 0.0262216 0)
(-0.0749576 0.00599152 0)
(-0.0758001 -0.0144732 0)
(-0.0775588 -0.0352541 0)
(-0.0802112 -0.0564293 0)
(-0.0837068 -0.078068 0)
(-0.0879634 -0.100224 0)
(-0.0928633 -0.122928 0)
(-0.0982468 -0.146174 0)
(-0.103907 -0.169909 0)
(-0.109585 -0.194014 0)
(-0.114963 -0.218281 0)
(-0.119665 -0.242387 0)
(-0.123255 -0.265862 0)
(-0.125252 -0.288057 0)
(-0.125146 -0.308103 0)
(-0.122437 -0.324883 0)
(-0.116685 -0.337007 0)
(-0.107592 -0.342809 0)
(-0.0950964 -0.340386 0)
(-0.0794875 -0.327678 0)
(-0.061526 -0.302618 0)
(-0.0425023 -0.263349 0)
(-0.0242203 -0.208487 0)
(-0.00929652 -0.137396 0)
(-0.00153616 -0.0505033 0)
(-0.00147945 0.0489637 0)
(-0.00883513 0.132337 0)
(-0.0227499 0.199547 0)
(-0.0394108 0.250589 0)
(-0.0562738 0.286606 0)
(-0.071693 0.309392 0)
(-0.0845774 0.321041 0)
(-0.094354 0.32367 0)
(-0.100874 0.31925 0)
(-0.104283 0.309501 0)
(-0.104913 0.295861 0)
(-0.103193 0.279486 0)
(-0.0995891 0.261282 0)
(-0.0945622 0.241934 0)
(-0.0885451 0.221949 0)
(-0.0819279 0.201687 0)
(-0.0750532 0.181392 0)
(-0.0682162 0.161219 0)
(-0.061667 0.141257 0)
(-0.0556152 0.121538 0)
(-0.0502347 0.102057 0)
(-0.0456676 0.0827776 0)
(-0.0420288 0.0636421 0)
(-0.0394092 0.044575 0)
(-0.0378779 0.0254884 0)
(-0.037484 0.00628597 0)
(-0.0382567 -0.0131344 0)
(-0.0402053 -0.0328772 0)
(-0.0433168 -0.0530458 0)
(-0.0475535 -0.0737382 0)
(-0.0528485 -0.0950415 0)
(-0.0591005 -0.117025 0)
(-0.0661664 -0.139729 0)
(-0.0738539 -0.163152 0)
(-0.0819125 -0.187236 0)
(-0.0900246 -0.211836 0)
(-0.097798 -0.236698 0)
(-0.104762 -0.261417 0)
(-0.11037 -0.285396 0)
(-0.114011 -0.307793 0)
(-0.115042 -0.327472 0)
(-0.112841 -0.342956 0)
(-0.10689 -0.352399 0)
(-0.0968914 -0.353597 0)
(-0.0829246 -0.344053 0)
(-0.065614 -0.321141 0)
(-0.0462536 -0.282361 0)
(-0.026847 -0.225696 0)
(-0.0104893 -0.150022 0)
(-0.00177579 -0.0555984 0)
(-0.00176876 0.0538728 0)
(-0.0102525 0.14432 0)
(-0.0258317 0.215522 0)
(-0.0437696 0.267752 0)
(-0.0610142 0.302779 0)
(-0.0757471 0.323111 0)
(-0.0869125 0.331495 0)
(-0.0941014 0.330577 0)
(-0.0973891 0.322705 0)
(-0.0971541 0.309838 0)
(-0.0939358 0.293547 0)
(-0.0883338 0.275042 0)
(-0.0809437 0.255227 0)
(-0.0723191 0.234756 0)
(-0.0629524 0.214085 0)
(-0.053269 0.193521 0)
(-0.0436283 0.173252 0)
(-0.0343292 0.153383 0)
(-0.0256176 0.133952 0)
(-0.0176936 0.114954 0)
(-0.0107195 0.0963492 0)
(-0.0048256 0.0780709 0)
(-0.000116273 0.060036 0)
(0.00332602 0.0421471 0)
(0.00543741 0.0242971 0)
(0.00617058 0.00637117 0)
(0.00549382 -0.011751 0)
(0.00339135 -0.030193 0)
(-0.000135168 -0.0490799 0)
(-0.00506367 -0.0685348 0)
(-0.0113473 -0.0886754 0)
(-0.0189081 -0.109608 0)
(-0.0276294 -0.131418 0)
(-0.0373457 -0.15416 0)
(-0.0478311 -0.177839 0)
(-0.0587862 -0.20239 0)
(-0.0698249 -0.227642 0)
(-0.0804619 -0.253281 0)
(-0.0901053 -0.278797 0)
(-0.098059 -0.303418 0)
(-0.103541 -0.326039 0)
(-0.10573 -0.345145 0)
(-0.103847 -0.358745 0)
(-0.0972901 -0.364341 0)
(-0.0858262 -0.358961 0)
(-0.0698299 -0.339303 0)
(-0.0504997 -0.302031 0)
(-0.0299994 -0.24424 0)
(-0.0119864 -0.164054 0)
(-0.00209099 -0.0614003 0)
(-0.00217291 0.0596458 0)
(-0.012123 0.15799 0)
(-0.0297011 0.233067 0)
(-0.0489305 0.285687 0)
(-0.066167 0.318589 0)
(-0.0794891 0.335287 0)
(-0.0880001 0.339375 0)
(-0.091584 0.334125 0)
(-0.0906453 0.322283 0)
(-0.0858662 0.306031 0)
(-0.0780333 0.287026 0)
(-0.067931 0.266483 0)
(-0.056281 0.245259 0)
(-0.0437147 0.223937 0)
(-0.0307657 0.202895 0)
(-0.0178738 0.18236 0)
(-0.00539492 0.16245 0)
(0.0063863 0.143208 0)
(0.0172446 0.124621 0)
(0.0270028 0.10664 0)
(0.0355213 0.0891893 0)
(0.0426909 0.0721752 0)
(0.048425 0.0554914 0)
(0.0526553 0.0390223 0)
(0.0553276 0.0226449 0)
(0.0563992 0.00623067 0)
(0.0558381 -0.010354 0)
(0.0536223 -0.027247 0)
(0.0497416 -0.0445894 0)
(0.0442002 -0.0625246 0)
(0.0370207 -0.0811953 0)
(0.0282509 -0.10074 0)
(0.0179717 -0.121288 0)
(0.00630872 -0.142947 0)
(-0.00655414 -0.16579 0)
(-0.0203577 -0.189836 0)
(-0.0347482 -0.215014 0)
(-0.0492563 -0.241126 0)
(-0.0632781 -0.267785 0)
(-0.0760612 -0.294341 0)
(-0.0867061 -0.319782 0)
(-0.0941934 -0.342629 0)
(-0.0974557 -0.360816 0)
(-0.0955134 -0.371598 0)
(-0.0876994 -0.371513 0)
(-0.0739777 -0.356477 0)
(-0.0552839 -0.322092 0)
(-0.0338345 -0.264207 0)
(-0.0139159 -0.17978 0)
(-0.00252214 -0.0681095 0)
(-0.00276059 0.0665878 0)
(-0.0146491 0.173779 0)
(-0.0345921 0.252343 0)
(-0.0549569 0.30411 0)
(-0.0714678 0.333333 0)
(-0.0822652 0.344927 0)
(-0.0868214 0.343557 0)
(-0.085494 0.33319 0)
(-0.0791432 0.316959 0)
(-0.068824 0.297204 0)
(-0.0555955 0.275595 0)
(-0.0404211 0.253277 0)
(-0.0241259 0.231002 0)
(-0.0073889 0.209235 0)
(0.0092478 0.188241 0)
(0.0253603 0.168149 0)
(0.0406227 0.148992 0)
(0.0547876 0.130743 0)
(0.0676688 0.113336 0)
(0.0791269 0.0966788 0)
(0.0890571 0.0806623 0)
(0.0973802 0.0651686 0)
(0.104035 0.0500729 0)
(0.108972 0.035246 0)
(0.112152 0.0205547 0)
(0.113539 0.0058621 0)
(0.113104 -0.00897264 0)
(0.110818 -0.0240952 0)
(0.106661 -0.0396564 0)
(0.100617 -0.0558124 0)
(0.0926819 -0.0727243 0)
(0.0828671 -0.0905565 0)
(0.0712101 -0.109473 0)
(0.057784 -0.12963 0)
(0.0427134 -0.151168 0)
(0.0261936 -0.17419 0)
(0.0085151 -0.198735 0)
(-0.00990764 -0.22474 0)
(-0.0285037 -0.251977 0)
(-0.0465139 -0.27997 0)
(-0.0629666 -0.307882 0)
(-0.0766758 -0.334365 0)
(-0.0862827 -0.35739 0)
(-0.0903726 -0.374064 0)
(-0.0877126 -0.380482 0)
(-0.0776436 -0.371716 0)
(-0.0605742 -0.342049 0)
(-0.0385463 -0.285617 0)
(-0.0164746 -0.197571 0)
(-0.00313962 -0.0760221 0)
(-0.00365484 0.0751628 0)
(-0.0181429 0.192231 0)
(-0.0407747 0.273396 0)
(-0.0617603 0.32241 0)
(-0.0762825 0.345869 0)
(-0.0828794 0.350601 0)
(-0.0817177 0.342552 0)
(-0.073862 0.3264 0)
(-0.0607577 0.305576 0)
(-0.0438788 0.282455 0)
(-0.0245479 0.258603 0)
(-0.00386885 0.235 0)
(0.0172806 0.212218 0)
(0.0382261 0.190558 0)
(0.0584638 0.170144 0)
(0.0776255 0.150984 0)
(0.0954481 0.133024 0)
(0.111747 0.116163 0)
(0.126394 0.100284 0)
(0.139302 0.0852537 0)
(0.150413 0.070938 0)
(0.159686 0.0571995 0)
(0.167091 0.0439013 0)
(0.172602 0.030907 0)
(0.176197 0.0180795 0)
(0.177853 0.00528046 0)
(0.177541 -0.00763172 0)
(0.175232 -0.0208033 0)
(0.170892 -0.034387 0)
(0.164488 -0.0485437 0)
(0.155986 -0.0634436 0)
(0.14536 -0.0792669 0)
(0.132597 -0.0962029 0)
(0.117708 -0.114447 0)
(0.100744 -0.134196 0)
(0.0818114 -0.155632 0)
(0.0611066 -0.178905 0)
(0.0389447 -0.204095 0)
(0.0158062 -0.231162 0)
(-0.00761217 -0.259854 0)
(-0.0303441 -0.289588 0)
(-0.0511093 -0.319272 0)
(-0.0683037 -0.347069 0)
(-0.0800638 -0.370113 0)
(-0.0844756 -0.384203 0)
(-0.0800047 -0.383588 0)
(-0.066147 -0.361018 0)
(-0.0443438 -0.308324 0)
(-0.0199676 -0.217883 0)
(-0.0040702 -0.0855922 0)
(-0.00508062 0.0861019 0)
(-0.0230811 0.21399 0)
(-0.0484813 0.295971 0)
(-0.0688632 0.339381 0)
(-0.0792608 0.354377 0)
(-0.0792139 0.350287 0)
(-0.0700436 0.334458 0)
(-0.0537779 0.312165 0)
(-0.0325384 0.286929 0)
(-0.00820289 0.260962 0)
(0.0177122 0.235564 0)
(0.0440511 0.211436 0)
(0.0699698 0.1889 0)
(0.0948735 0.168049 0)
(0.118357 0.148842 0)
(0.140156 0.131166 0)
(0.160104 0.114873 0)
(0.178104 0.0998003 0)
(0.194104 0.0857836 0)
(0.208083 0.072662 0)
(0.220036 0.0602811 0)
(0.229966 0.048494 0)
(0.237879 0.0371594 0)
(0.243776 0.0261413 0)
(0.247655 0.0153059 0)
(0.249504 0.00452038 0)
(0.249301 -0.00635031 0)
(0.247014 -0.0174455 0)
(0.242602 -0.0289117 0)
(0.236012 -0.0409054 0)
(0.227183 -0.0535956 0)
(0.216051 -0.0671665 0)
(0.202552 -0.0818197 0)
(0.186628 -0.0977749 0)
(0.168245 -0.115268 0)
(0.147406 -0.134548 0)
(0.124182 -0.155861 0)
(0.0987447 -0.179428 0)
(0.0714199 -0.205403 0)
(0.0427548 -0.233794 0)
(0.0136006 -0.264347 0)
(-0.0147944 -0.296352 0)
(-0.0407011 -0.328364 0)
(-0.0618798 -0.357805 0)
(-0.0756914 -0.380463 0)
(-0.0794833 -0.389967 0)
(-0.0713321 -0.377451 0)
(-0.0513592 -0.331802 0)
(-0.0248577 -0.241234 0)
(-0.00554554 -0.0975413 0)
(-0.00744547 0.100586 0)
(-0.0301495 0.239693 0)
(-0.0576635 0.31912 0)
(-0.0748826 0.352787 0)
(-0.0777 0.356054 0)
(-0.0676228 0.341247 0)
(-0.0476778 0.316993 0)
(-0.0210488 0.288807 0)
(0.00949492 0.259944 0)
(0.0418049 0.232169 0)
(0.0743324 0.206329 0)
(0.10602 0.182732 0)
(0.136181 0.161392 0)
(0.164394 0.142171 0)
(0.190422 0.124863 0)
(0.214149 0.109241 0)
(0.235538 0.0950802 0)
(0.2546 0.0821673 0)
(0.271371 0.070308 0)
(0.285902 0.0593251 0)
(0.298247 0.0490579 0)
(0.308453 0.0393594 0)
(0.316563 0.0300937 0)
(0.322605 0.0211328 0)
(0.326597 0.0123539 0)
(0.328539 0.00363653 0)
(0.328417 -0.00514085 0)
(0.326199 -0.0141035 0)
(0.321838 -0.0233837 0)
(0.315265 -0.0331245 0)
(0.306397 -0.0434831 0)
(0.295135 -0.0546353 0)
(0.281364 -0.0667793 0)
(0.264964 -0.0801401 0)
(0.245811 -0.0949735 0)
(0.223796 -0.111567 0)
(0.198845 -0.130238 0)
(0.17095 -0.151324 0)
(0.140222 -0.175157 0)
(0.106965 -0.202009 0)
(0.0717793 -0.231997 0)
(0.0356988 -0.264905 0)
(0.000361064 -0.299887 0)
(-0.0318294 -0.33499 0)
(-0.0576275 -0.366454 0)
(-0.0731405 -0.387775 0)
(-0.074479 -0.388711 0)
(-0.0593704 -0.35473 0)
(-0.0317944 -0.268062 0)
(-0.00798169 -0.113038 0)
(-0.0114286 0.120491 0)
(-0.0401362 0.269584 0)
(-0.0672886 0.340458 0)
(-0.0764365 0.358735 0)
(-0.0664237 0.346811 0)
(-0.0420182 0.320046 0)
(-0.00839852 0.287717 0)
(0.0301538 0.254886 0)
(0.0704952 0.224016 0)
(0.11052 0.196094 0)
(0.14892 0.171336 0)
(0.184946 0.149585 0)
(0.218218 0.130529 0)
(0.248584 0.113813 0)
(0.276037 0.099093 0)
(0.300646 0.0860563 0)
(0.322521 0.0744287 0)
(0.34179 0.0639732 0)
(0.35858 0.0544858 0)
(0.373011 0.0457905 0)
(0.385192 0.0377341 0)
(0.395213 0.0301811 0)
(0.403146 0.0230102 0)
(0.409046 0.0161095 0)
(0.412948 0.00937394 0)
(0.414863 0.00270136 0)
(0.414785 -0.0040102 0)
(0.412685 -0.0108658 0)
(0.40851 -0.017977 0)
(0.402184 -0.0254652 0)
(0.393606 -0.0334663 0)
(0.382651 -0.0421351 0)
(0.369165 -0.0516509 0)
(0.35297 -0.062224 0)
(0.333865 -0.0741034 0)
(0.311634 -0.0875842 0)
(0.286054 -0.103015 0)
(0.256923 -0.120803 0)
(0.224096 -0.14141 0)
(0.187554 -0.165332 0)
(0.147506 -0.193043 0)
(0.104553 -0.224866 0)
(0.059929 -0.260721 0)
(0.0158054 -0.299638 0)
(-0.0243653 -0.338921 0)
(-0.0556572 -0.372797 0)
(-0.0718787 -0.390505 0)
(-0.0670449 -0.374222 0)
(-0.0414577 -0.298281 0)
(-0.0120538 -0.133924 0)
(-0.0178757 0.148734 0)
(-0.0531241 0.302386 0)
(-0.0734459 0.354744 0)
(-0.0659341 0.35088 0)
(-0.0359417 0.321204 0)
(0.00735468 0.282965 0)
(0.0567612 0.244659 0)
(0.107508 0.209836 0)
(0.15673 0.179554 0)
(0.202887 0.153748 0)
(0.245278 0.131919 0)
(0.283694 0.113456 0)
(0.318193 0.0977766 0)
(0.34897 0.0843723 0)
(0.376275 0.0728201 0)
(0.400372 0.0627732 0)
(0.421515 0.0539498 0)
(0.439936 0.0461201 0)
(0.455842 0.0390958 0)
(0.469409 0.0327206 0)
(0.480786 0.026863 0)
(0.490097 0.0214104 0)
(0.497437 0.0162637 0)
(0.502878 0.0113341 0)
(0.506465 0.00653913 0)
(0.508223 0.00179963 0)
(0.508149 -0.00296284 0)
(0.506217 -0.00782896 0)
(0.502377 -0.0128846 0)
(0.49655 -0.0182243 0)
(0.488626 -0.0239547 0)
(0.478465 -0.0301997 0)
(0.465891 -0.037106 0)
(0.450689 -0.0448505 0)
(0.4326 -0.0536493 0)
(0.411322 -0.0637694 0)
(0.386511 -0.0755427 0)
(0.357784 -0.0893829 0)
(0.324739 -0.105803 0)
(0.286999 -0.125427 0)
(0.244283 -0.148991 0)
(0.19656 -0.177294 0)
(0.144293 -0.211049 0)
(0.0888548 -0.25052 0)
(0.0331256 -0.294717 0)
(-0.0177532 -0.339807 0)
(-0.0556826 -0.376242 0)
(-0.0700051 -0.384443 0)
(-0.0536337 -0.330066 0)
(-0.0185375 -0.163021 0)
(-0.0268206 0.190236 0)
(-0.0655643 0.332445 0)
(-0.064678 0.351156 0)
(-0.0273959 0.319386 0)
(0.0302477 0.27278 0)
(0.0952154 0.226975 0)
(0.159839 0.18738 0)
(0.220311 0.154857 0)
(0.275096 0.12864 0)
(0.323867 0.107574 0)
(0.366876 0.0905651 0)
(0.404617 0.076705 0)
(0.437645 0.0652836 0)
(0.466496 0.0557572 0)
(0.491655 0.0477123 0)
(0.513542 0.0408335 0)
(0.532519 0.0348782 0)
(0.548887 0.0296574 0)
(0.562901 0.0250222 0)
(0.574767 0.0208527 0)
(0.584656 0.0170507 0)
(0.592703 0.0135342 0)
(0.599015 0.0102327 0)
(0.60367 0.00708378 0)
(0.606718 0.00403037 0)
(0.608189 0.00101838 0)
(0.608084 -0.00200554 0)
(0.606384 -0.00509617 0)
(0.603042 -0.00831195 0)
(0.597982 -0.0117175 0)
(0.5911 -0.0153869 0)
(0.582256 -0.0194069 0)
(0.571271 -0.0238826 0)
(0.55792 -0.0289431 0)
(0.541922 -0.0347509 0)
(0.522935 -0.0415131 0)
(0.500538 -0.0494978 0)
(0.474228 -0.0590561 0)
(0.443407 -0.0706524 0)
(0.407381 -0.0849026 0)
(0.365391 -0.102621 0)
(0.316679 -0.124864 0)
(0.260664 -0.152936 0)
(0.197314 -0.188261 0)
(0.127847 -0.231903 0)
(0.0559889 -0.283181 0)
(-0.0101578 -0.336342 0)
(-0.0563143 -0.374106 0)
(-0.0641575 -0.356964 0)
(-0.0272107 -0.205042 0)
(-0.0329805 0.250119 0)
(-0.0618095 0.343609 0)
(-0.0118495 0.310252 0)
(0.0704804 0.251454 0)
(0.158842 0.196292 0)
(0.241892 0.152137 0)
(0.315293 0.11886 0)
(0.378351 0.0941651 0)
(0.431945 0.0757376 0)
(0.477397 0.0617858 0)
(0.516008 0.0510282 0)
(0.548909 0.0425727 0)
(0.577039 0.0358002 0)
(0.601155 0.0302784 0)
(0.621865 0.0257005 0)
(0.639657 0.0218451 0)
(0.65492 0.0185494 0)
(0.667967 0.015691 0)
(0.67905 0.0131762 0)
(0.688372 0.0109315 0)
(0.696092 0.00889835 0)
(0.702338 0.0070283 0)
(0.707207 0.00528062 0)
(0.71077 0.00361974 0)
(0.713077 0.00201353 0)
(0.714154 0.000431755 0)
(0.714006 -0.00115525 0)
(0.712617 -0.00277784 0)
(0.70995 -0.00446852 0)
(0.705941 -0.0062634 0)
(0.700503 -0.00820416 0)
(0.693514 -0.0103404 0)
(0.684816 -0.0127327 0)
(0.674207 -0.0154574 0)
(0.66143 -0.0186119 0)
(0.646157 -0.0223242 0)
(0.627974 -0.0267653 0)
(0.606356 -0.0321679 0)
(0.580636 -0.0388557 0)
(0.549966 -0.0472873 0)
(0.513275 -0.0581228 0)
(0.469237 -0.0723235 0)
(0.41627 -0.0912888 0)
(0.35266 -0.117012 0)
(0.277017 -0.152135 0)
(0.189514 -0.199415 0)
(0.0942278 -0.259384 0)
(0.00281364 -0.324195 0)
(-0.056628 -0.361962 0)
(-0.032139 -0.264019 0)
(0.00102828 0.294765 0)
(0.0166274 0.298381 0)
(0.15189 0.212806 0)
(0.282319 0.145217 0)
(0.387549 0.0996826 0)
(0.471031 0.070029 0)
(0.536933 0.0508526 0)
(0.589106 0.0382182 0)
(0.630874 0.0296062 0)
(0.664774 0.02351 0)
(0.692641 0.0190365 0)
(0.7158 0.0156466 0)
(0.735217 0.0130048 0)
(0.751607 0.0108956 0)
(0.765506 0.00917566 0)
(0.777321 0.00774647 0)
(0.787367 0.0065382 0)
(0.795888 0.00549999 0)
(0.803077 0.0045938 0)
(0.809084 0.00379043 0)
(0.814029 0.0030669 0)
(0.818003 0.00240464 0)
(0.821078 0.00178812 0)
(0.823305 0.00120399 0)
(0.824718 0.000640272 0)
(0.825338 8.57842e-05 0)
(0.82517 -0.000470377 0)
(0.824203 -0.00103942 0)
(0.822412 -0.0016333 0)
(0.819754 -0.00226541 0)
(0.816168 -0.00295129 0)
(0.81157 -0.0037096 0)
(0.805849 -0.00456346 0)
(0.79886 -0.00554231 0)
(0.790416 -0.00668452 0)
(0.780275 -0.00804141 0)
(0.768122 -0.00968334 0)
(0.753544 -0.0117094 0)
(0.735992 -0.0142633 0)
(0.714729 -0.0175606 0)
(0.688747 -0.0219364 0)
(0.656654 -0.0279314 0)
(0.616493 -0.0364493 0)
(0.565519 -0.04904 0)
(0.500028 -0.0683603 0)
(0.415587 -0.0987107 0)
(0.307325 -0.146199 0)
(0.170947 -0.217554 0)
(0.0269828 -0.307268 0)
(0.00517066 -0.30295 0)
(0.290223 0.152387 0)
(0.389407 0.128173 0)
(0.565155 0.0746705 0)
(0.682879 0.0421895 0)
(0.752444 0.0245178 0)
(0.797521 0.0149104 0)
(0.828849 0.00963579 0)
(0.851576 0.00664236 0)
(0.868721 0.00484403 0)
(0.882096 0.00369027 0)
(0.892795 0.00290261 0)
(0.901514 0.00233566 0)
(0.908716 0.00190974 0)
(0.914724 0.00157869 0)
(0.919769 0.0013142 0)
(0.924021 0.00109799 0)
(0.92761 0.000917652 0)
(0.930633 0.000764467 0)
(0.933166 0.000632072 0)
(0.935268 0.000515688 0)
(0.936985 0.000411623 0)
(0.938353 0.000316932 0)
(0.939399 0.000229196 0)
(0.940142 0.00014635 0)
(0.940596 6.65604e-05 0)
(0.940767 -1.18695e-05 0)
(0.940659 -9.05638e-05 0)
(0.940267 -0.000171252 0)
(0.939581 -0.000255745 0)
(0.938587 -0.000346084 0)
(0.93726 -0.000444665 0)
(0.93557 -0.000554401 0)
(0.933473 -0.00067895 0)
(0.930914 -0.000823039 0)
(0.927822 -0.000992953 0)
(0.9241 -0.00119729 0)
(0.919624 -0.00144816 0)
(0.914227 -0.00176328 0)
(0.907679 -0.00216965 0)
(0.899663 -0.00271066 0)
(0.889718 -0.00346025 0)
(0.87716 -0.00455258 0)
(0.860907 -0.00624605 0)
(0.839169 -0.00906101 0)
(0.808902 -0.0140568 0)
(0.764847 -0.0233245 0)
(0.696088 -0.0408251 0)
(0.577951 -0.0737693 0)
(0.397984 -0.12873 0)
(0.293831 -0.15375 0)
)
;
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0);
}
fixedWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
| |
292a505c3a571682f1c2de1a16b11c7eed03b5cd | a34c01b83159f591d30f49c96fc527232bc8939e | /OpenGL-CPP/BD Flag OpenGL/main.cpp | c84eb6c1db9a4d0fc56bf0adf239f191104215a0 | [
"MIT"
] | permissive | NSU-ACM-SC/BD-Flag-In-Different-Programming-Languages | 2f3c15793641ee857a02f61c2d29c98a52795f2b | d8cd67ec933f672a97eb9990bc18176efe7ceca5 | refs/heads/master | 2020-04-11T23:40:40.545784 | 2019-04-13T14:27:51 | 2019-04-13T14:27:51 | 162,175,125 | 3 | 12 | MIT | 2019-04-13T14:27:55 | 2018-12-17T18:45:29 | HTML | UTF-8 | C++ | false | false | 1,303 | cpp | main.cpp | //
// main.cpp
// BD Flag OpenGL
//
// Created by Shawon Ashraf on 12/16/17.
// Copyright © 2017 Shawon Ashraf. All rights reserved.
//
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0, 0, -30);
// red circle
glPushMatrix();
glColor3ub(244, 42, 65);
glTranslatef(-1, 0, 10);
glutSolidSphere(5, 50, 50);
glPopMatrix();
// green rect
glColor3ub(0, 106, 77);
glutSolidCube(25);
glFlush();
glutSwapBuffers();
}
void init(void)
{
glClearColor( 1, 1, 1, 1);
glClearDepth( 1.0 );
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_COLOR_MATERIAL);
}
void reshape(int w, int h)
{
float aspectRatio = (float)w/(float)h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, aspectRatio, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
glutInitWindowSize(500, 300);
glutCreateWindow("Flag of Bangladesh");
init();
glutReshapeFunc(reshape);
glutDisplayFunc(render);
glutMainLoop();
return 0;
}
|
82d90f2629c060f2db0327475014c3a3c2523e7a | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/collectd/gumtree/collectd_repos_function_2409_last_repos.cpp | faa7805adee1013abe464a9781aa73a87579544a | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 134 | cpp | collectd_repos_function_2409_last_repos.cpp | void module_register(void) {
plugin_register_complex_config("curl_json", cj_config);
plugin_register_init("curl_json", cj_init);
} |
b6d8d2572a84ccfb800d5440bb147cdb4fb4dd5a | 01259ef07bae6c4abb82606adc47afd50f6a7190 | /myCode/CGPSSensor.cpp | 4945980e1c2cc68c744a697d79e1a58b65ab9472 | [] | no_license | mueem624/navigationSystem | 8fff203778efec8cb0a597b8665bad1b87e1c06e | b66ca7bee613125239d8ebe1711c470dd0d5c9f9 | refs/heads/master | 2023-04-06T23:31:03.986679 | 2021-04-05T09:02:34 | 2021-04-05T09:02:34 | 354,769,687 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,022 | cpp | CGPSSensor.cpp | /*
* CGPSSensor.cpp
*
* Created on: Nov 4, 2018
* Author: Mueem
*/
#include<iostream>
#include<limits>
#include<string>
#include "CGPSSensor.h"
#include"CWaypoint.h"
using namespace std;
CGPSSensor::CGPSSensor() {
}
//Implement getCurrentPosition function that user manually enter to get coordinates.
CWaypoint CGPSSensor::getCurrentPosition() {
string name = " ";
double latitude = 0.0, longitude = 0.0;
cout << "Turning on GPS sensor" << endl;
bool loop = true;
while (loop) {
// user manually input latitude via keyboard.
cout << "Input your current latitude: " << flush;
cin >> latitude;
// user manually input longitude via keyboard.
cout << "Input your current longitude: " << flush;
cin >> longitude;
if (longitude >= -180 && longitude <= 180 && latitude >= -90
&& latitude <= 90) {
loop = false;
} else {
cout << "Invalid Input\n";
}
}
cout << endl;
CWaypoint GPSWP("GPS location", latitude, longitude);
return GPSWP;
}
CGPSSensor::~CGPSSensor() {
}
|
5110ff097738fda7204d3ddb20fa34d5c3ed71ff | b2dd99103a270dfab72f70f8dc6b606fe0860d2a | /include/Animations.h | 42551efbbf96a30b32e1043ccba980da36668cbc | [] | no_license | DeKinci/ledstrip | d6833872b1325ce1becab50371bc813f5fa4766b | c6f1693844f7ec8b8624aa004eab057db154f33b | refs/heads/master | 2023-02-24T08:39:08.282700 | 2021-01-30T00:29:42 | 2021-01-30T00:29:42 | 334,291,884 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 904 | h | Animations.h | #ifndef GARLAND_ANIMATIONS
#define GARLAND_ANIMATIONS
#include <Arduino.h>
#include "Animation.h"
#include <math.h>
#include "ShaderStorage.h"
class Rainbow : public Animation
{
private:
byte counter;
public:
void apply(CRGB *leds, size_t size)
{
for (int i = 0; i < size; i++)
{
leds[i] = CHSV(counter + i * 2, 255, 255);
}
counter++;
}
};
class SingleLed : public Animation
{
public:
void apply(CRGB *leds, size_t size)
{
for (int i = 0; i < size; i++)
leds[i] = CRGB(102, 255, 204);
}
};
class Fading : public Animation
{
private:
byte counter;
public:
void apply(CRGB *leds, size_t size)
{
byte value = 127 * (cos(counter * PI / 128.0) + 3);
for (int i = 0; i < size; i++)
leds[i] = CHSV(value, 255, 255);
counter++;
}
};
#endif //GARLAND_ANIMATIONS |
1962c3a1ffd86cb0000ad853be6a9bfad97cc4a7 | 60bd79d18cf69c133abcb6b0d8b0a959f61b4d10 | /libraries/AD524X/AD524X.h | 551614cad41c18027bc6a2cbe5bc7875520bde58 | [
"MIT"
] | permissive | RobTillaart/Arduino | e75ae38fa6f043f1213c4c7adb310e91da59e4ba | 48a7d9ec884e54fcc7323e340407e82fcc08ea3d | refs/heads/master | 2023-09-01T03:32:38.474045 | 2023-08-31T20:07:39 | 2023-08-31T20:07:39 | 2,544,179 | 1,406 | 3,798 | MIT | 2022-10-27T08:28:51 | 2011-10-09T19:53:59 | C++ | UTF-8 | C++ | false | false | 2,214 | h | AD524X.h | #pragma once
//
// FILE: AD524X.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.1
// PURPOSE: I2C digital PotentioMeter AD5241 AD5242
// DATE: 2013-10-12
// URL: https://github.com/RobTillaart/AD524X
#include "Arduino.h"
#include "Wire.h"
#define AD524X_LIB_VERSION (F("0.4.1"))
#define AD524X_OK 0
#define AD524X_ERROR 100
#define AD524X_MIDPOINT 127
class AD524X
{
public:
AD524X(const uint8_t address, TwoWire *wire = &Wire);
#if defined (ESP8266) || defined(ESP32)
bool begin(uint8_t sda, uint8_t scl);
#endif
bool begin();
bool isConnected();
// RESET
uint8_t reset(); // reset both channels to AD524X_MIDPOINT and O1/O2 to LOW
uint8_t zeroAll(); // set both channels to 0 and O1/O2 to LOW
// READ WRITE
uint8_t read(const uint8_t rdac);
uint8_t write(const uint8_t rdac, const uint8_t value);
uint8_t write(const uint8_t rdac, const uint8_t value, const uint8_t O1, const uint8_t O2);
// IO LINES
uint8_t setO1(const uint8_t value = HIGH); // HIGH (default) / LOW
uint8_t setO2(const uint8_t value = HIGH); // HIGH (default) / LOW
uint8_t getO1();
uint8_t getO2();
uint8_t midScaleReset(const uint8_t rdac);
uint8_t pmCount();
// DEBUGGING
uint8_t readBackRegister(); // returns the last value written in register.
// experimental - to be tested - use at own risk
uint8_t shutDown(); // datasheet P15
protected:
uint8_t _pmCount = 0;
uint8_t send(const uint8_t cmd, const uint8_t value);
uint8_t _address;
uint8_t _lastValue[2];
uint8_t _O1;
uint8_t _O2;
TwoWire* _wire;
};
//////////////////////////////////////////////////////////////
//
// DERIVED CLASSES
//
class AD5241 : public AD524X
{
public:
AD5241(const uint8_t address, TwoWire *wire = &Wire);
uint8_t write(const uint8_t value);
uint8_t write(const uint8_t value, const uint8_t O1, const uint8_t O2);
uint8_t write(const uint8_t rdac, const uint8_t value);
uint8_t write(const uint8_t rdac, const uint8_t value, const uint8_t O1, const uint8_t O2);
};
class AD5242 : public AD524X
{
public:
AD5242(const uint8_t address, TwoWire *wire = &Wire);
};
// -- END OF FILE --
|
a1b2d47dcb7c8af40fa4ca50b4ada1c0994f9739 | 0299ad5e35d00e0404f223b0fc0783ff87e39d3f | /src/include/logger/log.hpp | d622eeede5a8c3a17d12c998fbac681e38c1dff1 | [] | no_license | darbitman/logger | 3dc7c3795c84185e394a6c0b20b5acddbda413f7 | bd6edbb27dc8a3c7c6af462cc82c846124e94f58 | refs/heads/master | 2023-05-23T20:25:13.258557 | 2021-06-16T02:31:20 | 2021-06-16T02:31:20 | 377,337,976 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 57 | hpp | log.hpp | #pragma once
void logit(int, const char*, const char*);
|
d220b463024e47c964eb28cb97d00938710de424 | e37d0e2adfceac661fbd844912d22c25d91f3cc0 | /A-Tour-of-CPP/06-templates/5-template-examples/06-lambda-functions.cpp | 95e78b42d58f50c92c609d2ea792fd0bfb0aa9af | [] | no_license | mikechen66/CPP-Programming | 7638927918f59302264f40bbca4ffbfe17398ec6 | c49d6d197cad3735d60351434192938c95f8abe7 | refs/heads/main | 2023-07-11T20:27:12.236223 | 2021-08-26T08:50:37 | 2021-08-26T08:50:37 | 384,588,683 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,200 | cpp | 06-lambda-functions.cpp | #include <iostream>
#include <vector>
using std::cout;
using std::endl;
// Codes based on the book: Stephen Prata, "C++ Primer Plus", 6th edition (2012), chapter 18
// A Functor whose operator() checks if a given X is divisive by a pre-defined divisor (defined in the constructor)
class f_mod {
private:
int dv_;
public:
f_mod(int dv = 1) : dv_{dv} {}
// Is x divisive by dv_?
bool operator()(int x) {
return (x % dv_) == 0;
}
};
int main() {
std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// counting by Functor
f_mod fmod2{2};
int count2_by_functor = std::count_if(v.begin(), v.end(), fmod2);
cout << "count2_by_functor = " << count2_by_functor << endl;
// counting by Lambda Function: [](int x) {return x % 2 == 0;}
int count2_by_lambda = std::count_if(v.begin(), v.end(), [](int x) {return x % 2 == 0;});
cout << "count2_by_lambda = " << count2_by_lambda << endl << endl;
// counts how many numbers are divisive by 3
f_mod fmod3{3};
int count3_by_functor = std::count_if(v.begin(), v.end(), fmod3);
cout << "count3_by_functor = " << count3_by_functor << endl;
int count3_by_lambda = std::count_if(v.begin(), v.end(), [](int x) {return x % 3 == 0;});
cout << "count3_by_lambda = " << count3_by_lambda << endl << endl;
// In terms of brevity, the functor code is more verbose than the equivalent function or lambda code.
// Functions and lambdas are approximately equally brief.
// One apparent exception would be if you had to use a lambda twice:
int count5_by_lambda = std::count_if(v.begin(), v.end(), [](int x) {return x % 5 == 0;});
int count5_by_lambda_again = std::count_if(v.begin(), v.end(), [](int x) {return x % 5 == 0;});
cout << "count5_by_lambda = " << count5_by_lambda << endl;
cout << "count5_by_lambda_again = " << count5_by_lambda_again << endl << endl;
// But you don’t actually have to write out the lambda twice.
// Essentially, you can create a name for the anonymous lambda and then use the name twice:
auto lambda_mod7 = [](int x){return x % 7 == 0;}; // lambda_mod7 a name for the lambda
int count7_by_lambda = std::count_if(v.begin(), v.end(), lambda_mod7);
int count7_by_lambda_again = std::count_if(v.begin(), v.end(), lambda_mod7);
cout << "count7_by_lambda = " << count7_by_lambda << endl;
cout << "count7_by_lambda_again = " << count7_by_lambda_again << endl << endl;
// Thus, we even can use this no-longer-anonymous lambda as an ordinary function:
bool result = lambda_mod7(10); // result is true if 10 % 7 == 0
// We still can use auto for the parameter datatypes, so that the lambda function becomes more generic
// PS: it does not make sense for this problem, but it is just an example of how to use auto
auto lambda_mod8 = [](auto x){ return x % 8 == 0; };
// Unlike an ordinary function, however, a named lambda can be defined inside a function.
// The actual type for lambda_mod7 will be some implementation-dependent type that the compiler uses
// to keep track of lambdas.
return 0;
}
|
8d19523c18a19ca889896734433349999ba23c0a | e21b97b990604065d0e479337bad2e7b16e48e42 | /max_e1_examples/src/actuators_example.cpp | 934678d11856a7f1f7646531ecc3aa5da399b95b | [
"Apache-2.0"
] | permissive | ShotaAk/max_e1_apps | 1d4042d7eeb37e04831e9a2a459200adeabc42fd | 113f017b4c3f91c50343926371cbd32b44947368 | refs/heads/main | 2023-06-19T01:03:21.815347 | 2021-07-19T01:44:54 | 2021-07-19T01:44:54 | 365,092,004 | 2 | 1 | Apache-2.0 | 2021-07-19T01:44:55 | 2021-05-07T02:27:12 | C++ | UTF-8 | C++ | false | false | 2,308 | cpp | actuators_example.cpp |
#include <chrono>
#include <thread>
#include <iostream>
#include "max_e1.hpp"
int main() {
MaxE1 max_e1("/dev/ttyACM0", 1000000);
if(max_e1.connect()){
max_e1.init();
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout<<"LED on: R"<<std::endl;
max_e1.actuators->led(true, false, false);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: G"<<std::endl;
max_e1.actuators->led(false, true, false);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: B"<<std::endl;
max_e1.actuators->led(false, false, true);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: RG"<<std::endl;
max_e1.actuators->led(true, true, false);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: GB"<<std::endl;
max_e1.actuators->led(false, true, true);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: RB"<<std::endl;
max_e1.actuators->led(true, false, true);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED on: RGB"<<std::endl;
max_e1.actuators->led(true, true, true);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout<<"LED off"<<std::endl;
max_e1.actuators->led(false, false, false);
std::cout<<"Play scale 0, 3.0 seconds."<<std::endl;
max_e1.actuators->buzzer_scale(0, 3.0);
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
std::cout<<"Play scale 1, 2.0 seconds."<<std::endl;
max_e1.actuators->buzzer_scale(1, 2.0);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::cout<<"Play scale 2, 1.0 seconds."<<std::endl;
max_e1.actuators->buzzer_scale(2, 1.0);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
for(auto i=0; i <= 25; i++){
std::cout<<"Play melody: "<<std::to_string(i)<<std::endl;
max_e1.actuators->buzzer_melody(i);
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
}
}
max_e1.disconnect();
}
|
651552f7b911c93d3c7c16cda595c5e7993689f0 | c47c254ca476c1f9969f8f3e89acb4d0618c14b6 | /datasets/github_cpp_10/8/43.cpp | 56868c01c6dfc1076a6962e1abc60905624a98ac | [
"BSD-2-Clause"
] | permissive | yijunyu/demo | 5cf4e83f585254a28b31c4a050630b8f661a90c8 | 11c0c84081a3181494b9c469bda42a313c457ad2 | refs/heads/master | 2023-02-22T09:00:12.023083 | 2021-01-25T16:51:40 | 2021-01-25T16:51:40 | 175,939,000 | 3 | 6 | BSD-2-Clause | 2021-01-09T23:00:12 | 2019-03-16T07:13:00 | C | UTF-8 | C++ | false | false | 729 | cpp | 43.cpp | #include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN=100;
vector<pair<int ,int> > graph[MAXN];
bool visited[MAXN]={0};
vector<int> tpl;
void dfs2(int src){
visited[src]=true;
for(auto a:graph[src]){
if(!visited[a.first])
dfs2(a.first);
}
tpl.push_back(src);
}
int main() {
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++){
int x,y,w;
cin>>x>>y>>w;
graph[x].push_back(make_pair(y,w));
}
for (int i = 1; i <= n; ++i) {
if(!visited[i])
dfs2(i);
}
reverse(tpl.begin(),tpl.end());
cout<<"Topological Sort: ";
for(auto a:tpl)
cout<<a<<" ";
return 0;
} |
85bc57035c16c40f054f69b97bfdf693fffe859e | 7f62f204ffde7fed9c1cb69e2bd44de9203f14c8 | /DboClient/Tool/TSTool/Attr_ACT_ETimerS.cpp | e741eba5db09cae2dfa32abe782fefac176eca5a | [] | no_license | 4l3dx/DBOGLOBAL | 9853c49f19882d3de10b5ca849ba53b44ab81a0c | c5828b24e99c649ae6a2953471ae57a653395ca2 | refs/heads/master | 2022-05-28T08:57:10.293378 | 2020-05-01T00:41:08 | 2020-05-01T00:41:08 | 259,094,679 | 3 | 3 | null | 2020-04-29T17:06:22 | 2020-04-26T17:43:08 | null | UHC | C++ | false | false | 3,510 | cpp | Attr_ACT_ETimerS.cpp | // Attr_ACT_ETimerS.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "TSTool.h"
#include "Attr_ACT_ETimerS.h"
// CAttr_ACT_ETimerS 대화 상자입니다.
IMPLEMENT_SERIAL(CAttr_ACT_ETimerS, CAttr_Page, 1)
CAttr_ACT_ETimerS::CAttr_ACT_ETimerS()
: CAttr_Page(CAttr_ACT_ETimerS::IDD)
, m_taID(NTL_TS_TA_ID_INVALID)
, m_dwWaitTime(0xffffffff)
, m_tgID(1)
{
}
CAttr_ACT_ETimerS::~CAttr_ACT_ETimerS()
{
}
CString CAttr_ACT_ETimerS::GetPageData( void )
{
UpdateData( true );
CString strData;
strData += PakingPageData( _T("taid"), m_taID );
strData += PakingPageData( _T("sort"), (int)m_ctrTimerSort.GetItemData( m_ctrTimerSort.GetCurSel() ) );
strData += PakingPageData( _T("time"), m_dwWaitTime * 1000 );
strData += PakingPageData( _T("tgid"), m_tgID );
return strData;
}
void CAttr_ACT_ETimerS::UnPakingPageData( CString& strKey, CString& strValue )
{
if ( _T("taid") == strKey )
{
m_taID = atoi( strValue.GetBuffer() );
}
else if ( _T("sort") == strKey )
{
int nValue = atoi( strValue.GetBuffer() );
int nCnt = m_ctrTimerSort.GetCount();
for ( int i = 0; i < nCnt; ++i )
{
if ( m_ctrTimerSort.GetItemData( i ) == nValue )
{
m_ctrTimerSort.SetCurSel( i );
break;
}
}
}
else if ( _T("time") == strKey )
{
m_dwWaitTime = atoi( strValue.GetBuffer() ) / 1000;
}
else if ( _T("tgid") == strKey )
{
m_tgID = atoi( strValue.GetBuffer() );
}
}
void CAttr_ACT_ETimerS::DoDataExchange(CDataExchange* pDX)
{
CAttr_Page::DoDataExchange(pDX);
DDX_Text(pDX, IDC_TS_ACT_ATTR_EXCEPTTIMER_S_ID_EDITOR, m_taID);
DDV_MinMaxUInt(pDX, m_taID, 0, NTL_TS_TA_ID_INVALID);
DDX_Control(pDX, IDC_TS_ACT_ATTR_EXCEPTTIMER_TIMERSORT_COMBO, m_ctrTimerSort);
DDX_Text(pDX, IDC_TS_ACT_ATTR_EXCEPTTIMER_WTIME_EDITOR, m_dwWaitTime);
DDX_Text(pDX, IDC_TS_ACT_ATTR_EXCEPTTIMER_GROUPID_EDITOR, m_tgID);
if ( m_ctrTimerSort.GetSafeHwnd() )
{
DWORD_PTR dwData = m_ctrTimerSort.GetItemData( m_ctrTimerSort.GetCurSel() );
switch ( dwData )
{
case eEXCEPT_TIMER_SORT_LIMIT_TIMER:
{
DDV_MinMaxUInt(pDX, m_tgID, NTL_TS_EXCEPT_TLIMT_GROUP_ID_BEGIN, NTL_TS_EXCEPT_TLIMT_GROUP_ID_END );
}
break;
case eEXCEPT_TIMER_SORT_SERVER_TIMER:
{
DDV_MinMaxUInt(pDX, m_tgID, NTL_TS_EXCEPT_SERVER_GROUP_ID_BEGIN, NTL_TS_EXCEPT_SERVER_GROUP_ID_END );
}
break;
case eEXCEPT_TIMER_SORT_CLIENT_TIMER:
{
DDV_MinMaxUInt(pDX, m_tgID, NTL_TS_EXCEPT_CLIENT_GROUP_ID_BEGIN, NTL_TS_EXCEPT_CLIENT_GROUP_ID_END );
}
break;
default:
{
DDV_MinMaxUInt(pDX, m_tgID, 0, NTL_TS_TG_ID_INVALID);
}
break;
}
}
else
{
DDV_MinMaxUInt(pDX, m_tgID, 0, NTL_TS_TG_ID_INVALID);
}
}
BOOL CAttr_ACT_ETimerS::OnInitDialog()
{
CAttr_Page::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
m_ctrTimerSort.SetItemData( m_ctrTimerSort.AddString( _T("Server timer") ), eEXCEPT_TIMER_SORT_SERVER_TIMER );
m_ctrTimerSort.SetItemData( m_ctrTimerSort.AddString( _T("Client timer") ), eEXCEPT_TIMER_SORT_CLIENT_TIMER );
int nIdx = m_ctrTimerSort.AddString( _T("Time limit timer") );
m_ctrTimerSort.SetItemData( nIdx, eEXCEPT_TIMER_SORT_LIMIT_TIMER );
m_ctrTimerSort.SetCurSel( nIdx );
if ( m_strData.GetLength() > 0 ) SetPageData( m_strData );
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
BEGIN_MESSAGE_MAP(CAttr_ACT_ETimerS, CAttr_Page)
END_MESSAGE_MAP()
// CAttr_ACT_ETimerS 메시지 처리기입니다.
|
2103ae565bb573f2ce75733bb26c36bba235a485 | 4dcb5cc30037d49a3d5c7aeb2f0c9b5d0d1139d1 | /pol-core/pol/ssopt.cpp | 182aa9f72a69686baefe326c721a3e70d593cb20 | [] | no_license | zerodownedArchives/polserver-zulu | 40437258802631c4af070e478f418b737153a27c | 67922367ed7968c1d88274c352f140cef99890c6 | refs/heads/master | 2022-10-22T14:42:37.691311 | 2015-02-14T18:06:32 | 2015-02-14T18:06:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,604 | cpp | ssopt.cpp | /*
History
=======
2005/02/23 Shinigami: ServSpecOpt DecayItems to enable/disable item decay
2005/03/05 Shinigami: ServSpecOpt UseAAnTileFlags to enable/disable "a"/"an" via Tiles.cfg in formatted Item Names
2005/06/15 Shinigami: ServSpecOpt UseWinLFH to enable/disable Windows XP/2003 low-fragmentation Heap
2005/08/29 Shinigami: ServSpecOpt UseAAnTileFlags renamed to UseTileFlagPrefix
2005/12/05 MuadDib: ServSpecOpt InvulTage using 0, 1, 2 for method of invul showing.
2009/07/31 Turley: ServSpecOpt ResetSwingOnTurn=true/false Should SwingTimer be reset with projectile weapon on facing change
ServSpecOpt SendSwingPacket=true/false Should packet 0x2F be send on swing.
2009/09/03 MuadDib: Moved combat related settings to Combat Config.
2009/09/09 Turley: ServSpecOpt CarryingCapacityMod as * modifier for Character::carrying_capacity()
2009/10/12 Turley: whisper/yell/say-range ssopt definition
2009/11/19 Turley: ssopt.core_sends_season & .core_handled_tags - Tomi
2009/12/02 Turley: added ssopt.support_faces
Notes
=======
*/
#include "../clib/stl_inc.h"
#include "../clib/cfgelem.h"
#include "../clib/cfgfile.h"
#include "../clib/fileutil.h"
#include "../clib/logfile.h"
#include "ssopt.h"
#include "mobile/attribute.h"
ServSpecOpt ssopt;
void read_servspecopt()
{
ConfigFile cf;
ConfigElem elem;
if (FileExists( "config/servspecopt.local.cfg" ))
{
cf.open( "config/servspecopt.local.cfg" );
cf.readraw( elem );
}
else if (FileExists( "config/servspecopt.cfg" ))
{
cf.open( "config/servspecopt.cfg" );
cf.readraw( elem );
}
ssopt.allow_secure_trading_in_warmode = elem.remove_bool( "AllowSecureTradingInWarMode", false );
ssopt.dblclick_wait = elem.remove_ulong("DoubleClickWait", 0);
ssopt.decay_items = elem.remove_bool( "DecayItems", true );
ssopt.default_decay_time = elem.remove_ulong( "DefaultDecayTime", 10 );
ssopt.default_doubleclick_range = elem.remove_ushort( "DefaultDoubleclickRange", 2 );
ssopt.default_light_level = elem.remove_ushort( "DefaultLightLevel", 10 );
ssopt.event_visibility_core_checks = elem.remove_bool("EventVisibilityCoreChecks", false);
ssopt.max_pathfind_range = elem.remove_ulong( "MaxPathFindRange", 50 );
ssopt.movement_uses_stamina = elem.remove_bool( "MovementUsesStamina", false );
ssopt.use_tile_flag_prefix = elem.remove_bool( "UseTileFlagPrefix", true );
ssopt.default_container_max_items = elem.remove_ushort( "DefaultContainerMaxItems", 125 );
ssopt.default_container_max_weight = elem.remove_ushort( "DefaultContainerMaxWeight", 250 );
ssopt.hidden_turns_count = elem.remove_bool("HiddenTurnsCount", true);
ssopt.invul_tag = elem.remove_ushort("InvulTag", 1);
ssopt.uo_feature_enable = elem.remove_ushort( "UOFeatureEnable", 0);
ssopt.starting_gold = elem.remove_ushort("StartingGold", 100);
ssopt.item_color_mask = elem.remove_ushort("ItemColorMask", 0xFFF);
ssopt.use_win_lfh = elem.remove_bool( "UseWinLFH", false );
ssopt.privacy_paperdoll = elem.remove_bool("PrivacyPaperdoll",false);
ssopt.force_new_objcache_packets = elem.remove_bool("ForceNewObjCachePackets",false);
ssopt.allow_moving_trade = elem.remove_bool("AllowMovingTrade",false);
ssopt.core_handled_locks = elem.remove_bool("CoreHandledLocks",false);
ssopt.default_attribute_cap = elem.remove_ushort("DefaultAttributeCap", 1000); // 100.0
ssopt.default_max_slots = static_cast<unsigned char>(elem.remove_ushort("MaxContainerSlots", 125));
ssopt.use_slot_index = elem.remove_bool("UseContainerSlots",false);
ssopt.use_edit_server = elem.remove_bool("EditServer",false);
ssopt.carrying_capacity_mod = elem.remove_double("CarryingCapacityMod",1.0);
ssopt.core_sends_caps = elem.remove_bool("CoreSendsCaps",false);
ssopt.send_stat_locks = elem.remove_bool("SendStatLocks",false);
ssopt.speech_range = elem.remove_ushort("SpeechRange",12);
ssopt.whisper_range = elem.remove_ushort("WhisperRange",2);
ssopt.yell_range = elem.remove_ushort("YellRange",25);
ssopt.core_sends_season = elem.remove_bool("CoreSendsSeason",true);
ssopt.core_handled_tags = elem.remove_ushort("CoreHandledTags",0xFFFF);
ssopt.support_faces = static_cast<unsigned char>(elem.remove_ushort("SupportFaces",0));
ssopt_parse_totalstats(elem);
ssopt.mobiles_block_npc_movement = elem.remove_bool("MobilesBlockNpcMovement",true);
// Turley 2009/11/06 u8 range...
// if ( ssopt.default_max_slots > 255 )
// {
// cerr << "Invalid MaxContainerSlots value '"
// << ssopt.default_max_slots << "', using '255'" << endl;
// Log( "Invalid MaxContainerSlots value '%d', using '255'\n",
// ssopt.default_max_slots );
// ssopt.default_max_slots = 255;
// }
}
void ssopt_parse_totalstats(ConfigElem& elem)
{
static char tmp[100], tmpcopy[256];
std::string total_stats = elem.remove_string( "TotalStatsAtCreation", "65,80" );
strncpy(tmpcopy, total_stats.c_str(), 256);
char *token, *valmax, *valend;
unsigned long statmin, statmax;
// Stat values must be comma-delimited.
// Ranges can be specified using the syntax: <min>-<max>
// <max> must be higher than <min>
bool valok = true;
ssopt.total_stats_at_creation.clear();
token = strtok(tmpcopy, ",");
while( token != NULL && valok )
{
valok = false;
statmin = strtoul(token, &valmax, 0);
if ( valmax == token )
break; // invalid value
if ( *valmax != '\0' )
{
// second value given?
if ( *(valmax++) != '-' || !isdigit(*valmax) )
break; // invalid second value
statmax = strtoul(valmax, &valend, 0);
if ( *valend != '\0' || valend == valmax || statmax < statmin )
break; // invalid second value
if ( statmax == statmin )
sprintf(tmp, "%lu", statmin);
else
sprintf(tmp, "%lu-%lu", statmin, statmax);
}
else
sprintf(tmp, "%lu", statmin);
ssopt.total_stats_at_creation.push_back(tmp);
valok = true;
token = strtok(NULL, ",");
}
if ( !valok || ssopt.total_stats_at_creation.empty() )
{
ssopt.total_stats_at_creation.clear();
ssopt.total_stats_at_creation.push_back("65");
ssopt.total_stats_at_creation.push_back("80");
cerr << "Invalid TotalStatsAtCreation value '"
<< total_stats << "', using '65,80'" << endl;
Log( "Invalid TotalStatsAtCreation value '%s', using '65,80'\n",
total_stats.c_str() );
}
/*
// DEBUG OUTPUT
std::vector<std::string>::const_iterator itr = ssopt.total_stats_at_creation.begin();
for( ; itr != ssopt.total_stats_at_creation.end() ; itr++ )
cout << "* Stats-at-creation entry: " << *itr << endl;
*/
}
|
1a1e60919a2aef0f86ddad48cdca92582cdbe0d6 | 45f78ef0c270d16952d8db884278faa6691de399 | /codebase/libs/radar/src/moments/GateData.cc | 30816127a3c52a64da8dfa6df76609379762ee4a | [
"BSD-3-Clause"
] | permissive | bgin/lrose-core | 6da3e856c099cbb2fc273795653da39bee472869 | 2bff382ccaa9e927a922b2d545dd418a3ba791fc | refs/heads/master | 2021-06-09T05:33:52.806917 | 2016-11-17T13:13:38 | 2016-11-17T13:13:38 | 75,398,778 | 1 | 0 | null | 2016-12-02T13:39:13 | 2016-12-02T13:39:13 | null | UTF-8 | C++ | false | false | 9,507 | cc | GateData.cc | // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1990 - 2016
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Boulder, Colorado, USA
// ** BSD licence applies - redistribution and use in source and binary
// ** forms, with or without modification, are permitted provided that
// ** the following conditions are met:
// ** 1) If the software is modified to produce derivative works,
// ** such modified software should be clearly marked, so as not
// ** to confuse it with the version available from UCAR.
// ** 2) Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// ** 3) 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.
// ** 4) Neither the name of UCAR nor the names of its contributors,
// ** if any, may be used to endorse or promote products derived from
// ** this software without specific prior written permission.
// ** DISCLAIMER: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
// ** OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
///////////////////////////////////////////////////////////////
// GateData.cc
//
// Container for memory for IQ gate data.
//
// Mike Dixon, RAP, NCAR, P.O.Box 3000, Boulder, CO, 80307-3000, USA
//
// July 2007
//
////////////////////////////////////////////////////////////////
//
// Field data and IQ data for a single gate.
//
////////////////////////////////////////////////////////////////
#include <iostream>
#include <radar/GateData.hh>
using namespace std;
// Default constructor.
// Initializes all arrays to NULL.
// Call allocArrays() before using.
GateData::GateData() :
flds(fields),
fldsF(fieldsF)
{
_nSamples = 0;
_nSamplesHalf = 0;
_nSamplesAlloc = 0;
_initArraysToNull();
}
// destructor
GateData::~GateData()
{
_freeArrays();
}
// clear the field data
void GateData::initFields()
{
fields.init();
fieldsF.init();
specHcComputed = false;
specVcComputed = false;
}
// set field references
void GateData::setFieldsToNormalTrip()
{
flds = fields;
fldsF = fieldsF;
}
void GateData::setFieldsToSecondTrip()
{
flds = secondTrip;
fldsF = secondTripF;
}
//////////////////////////////////////
// init arrays to NULL
void GateData::_initArraysToNull()
{
iqhcOrig = NULL;
iqvcOrig = NULL;
iqhxOrig = NULL;
iqvxOrig = NULL;
iqhc = NULL;
iqvc = NULL;
iqhx = NULL;
iqvx = NULL;
specHc = NULL;
specVc = NULL;
iqhcF = NULL;
iqvcF = NULL;
iqhxF = NULL;
iqvxF = NULL;
iqhcPrtShortOrig = NULL;
iqhcPrtLongOrig = NULL;
iqvcPrtShortOrig = NULL;
iqvcPrtLongOrig = NULL;
iqhxPrtShortOrig = NULL;
iqhxPrtLongOrig = NULL;
iqvxPrtShortOrig = NULL;
iqvxPrtLongOrig = NULL;
iqhcPrtShort = NULL;
iqhcPrtLong = NULL;
iqvcPrtShort = NULL;
iqvcPrtLong = NULL;
iqhxPrtShort = NULL;
iqhxPrtLong = NULL;
iqvxPrtShort = NULL;
iqvxPrtLong = NULL;
iqhcPrtShortF = NULL;
iqhcPrtLongF = NULL;
iqvcPrtShortF = NULL;
iqvcPrtLongF = NULL;
iqhxPrtShortF = NULL;
iqhxPrtLongF = NULL;
iqvxPrtShortF = NULL;
iqvxPrtLongF = NULL;
iqStrong = NULL;
iqWeak = NULL;
iqStrongF = NULL;
iqWeakF = NULL;
iqMeas = NULL;
iqTrip1 = NULL;
iqTrip2 = NULL;
iqTrip3 = NULL;
iqTrip4 = NULL;
}
/////////////////////////////////////////////
// Allocate all arrays.
// On object allocated in this way can be used for any
// computation in any mode.
void GateData::allocArrays(int nSamples,
bool needFiltering,
bool isStagPrt,
bool isSz)
{
// do not reallocate if nsamples is between (0.8 * alloc) and (1.0 * alloc)
// and other requirements are unchanged
if (nSamples <= _nSamplesAlloc &&
nSamples >= (int) ((double) _nSamplesAlloc * 0.8) &&
needFiltering == _needFiltering &&
isStagPrt == _isStagPrt &&
isSz == _isSz) {
return;
}
// save requirements
_nSamples = nSamples;
_nSamplesHalf = _nSamples / 2;
_nSamplesAlloc = nSamples;
_needFiltering = needFiltering;
_isStagPrt = isStagPrt;
_isSz = isSz;
// perform allocation
_allocArray(iqhcOrig, _nSamples);
_allocArray(iqvcOrig, _nSamples);
_allocArray(iqhxOrig, _nSamples);
_allocArray(iqvxOrig, _nSamples);
_allocArray(iqhc, _nSamples);
_allocArray(iqvc, _nSamples);
_allocArray(iqhx, _nSamples);
_allocArray(iqvx, _nSamples);
_allocArray(specHc, _nSamples);
_allocArray(specVc, _nSamples);
if (_needFiltering) {
_allocArray(iqhcF, _nSamples);
_allocArray(iqvcF, _nSamples);
_allocArray(iqhxF, _nSamples);
_allocArray(iqvxF, _nSamples);
} else {
_freeArray(iqhcF);
_freeArray(iqvcF);
_freeArray(iqhxF);
_freeArray(iqvxF);
}
if (_isStagPrt) {
_allocArray(iqhcPrtShortOrig, _nSamplesHalf);
_allocArray(iqhcPrtLongOrig, _nSamplesHalf);
_allocArray(iqvcPrtShortOrig, _nSamplesHalf);
_allocArray(iqvcPrtLongOrig, _nSamplesHalf);
_allocArray(iqhxPrtShortOrig, _nSamplesHalf);
_allocArray(iqhxPrtLongOrig, _nSamplesHalf);
_allocArray(iqvxPrtShortOrig, _nSamplesHalf);
_allocArray(iqvxPrtLongOrig, _nSamplesHalf);
_allocArray(iqhcPrtShort, _nSamplesHalf);
_allocArray(iqhcPrtLong, _nSamplesHalf);
_allocArray(iqvcPrtShort, _nSamplesHalf);
_allocArray(iqvcPrtLong, _nSamplesHalf);
_allocArray(iqhxPrtShort, _nSamplesHalf);
_allocArray(iqhxPrtLong, _nSamplesHalf);
_allocArray(iqvxPrtShort, _nSamplesHalf);
_allocArray(iqvxPrtLong, _nSamplesHalf);
} else {
_freeArray(iqhcPrtShortOrig);
_freeArray(iqhcPrtLongOrig);
_freeArray(iqvcPrtShortOrig);
_freeArray(iqvcPrtLongOrig);
_freeArray(iqhxPrtShortOrig);
_freeArray(iqhxPrtLongOrig);
_freeArray(iqvxPrtShortOrig);
_freeArray(iqvxPrtLongOrig);
_freeArray(iqhcPrtShort);
_freeArray(iqhcPrtLong);
_freeArray(iqvcPrtShort);
_freeArray(iqvcPrtLong);
_freeArray(iqhxPrtShort);
_freeArray(iqhxPrtLong);
_freeArray(iqvxPrtShort);
_freeArray(iqvxPrtLong);
}
if (_isStagPrt && _needFiltering) {
_allocArray(iqhcPrtShortF, _nSamplesHalf);
_allocArray(iqhcPrtLongF, _nSamplesHalf);
_allocArray(iqvcPrtShortF, _nSamplesHalf);
_allocArray(iqvcPrtLongF, _nSamplesHalf);
_allocArray(iqhxPrtShortF, _nSamplesHalf);
_allocArray(iqhxPrtLongF, _nSamplesHalf);
_allocArray(iqvxPrtShortF, _nSamplesHalf);
_allocArray(iqvxPrtLongF, _nSamplesHalf);
} else {
_freeArray(iqhcPrtShortF);
_freeArray(iqhcPrtLongF);
_freeArray(iqvcPrtShortF);
_freeArray(iqvcPrtLongF);
_freeArray(iqhxPrtShortF);
_freeArray(iqhxPrtLongF);
_freeArray(iqvxPrtShortF);
_freeArray(iqvxPrtLongF);
}
if (_isSz) {
_allocArray(iqStrong, _nSamples);
_allocArray(iqWeak, _nSamples);
_allocArray(iqStrongF, _nSamples);
_allocArray(iqWeakF, _nSamples);
_allocArray(iqMeas, _nSamples);
_allocArray(iqTrip1, _nSamples);
_allocArray(iqTrip2, _nSamples);
_allocArray(iqTrip3, _nSamples);
_allocArray(iqTrip4, _nSamples);
} else {
_freeArray(iqStrong);
_freeArray(iqWeak);
_freeArray(iqStrongF);
_freeArray(iqWeakF);
_freeArray(iqMeas);
_freeArray(iqTrip1);
_freeArray(iqTrip2);
_freeArray(iqTrip3);
_freeArray(iqTrip4);
}
}
///////////////////////////////////////////////////
// free up all field arrays
void GateData::_freeArrays()
{
_freeArray(iqhcOrig);
_freeArray(iqhxOrig);
_freeArray(iqvcOrig);
_freeArray(iqvxOrig);
_freeArray(iqhc);
_freeArray(iqhx);
_freeArray(iqvc);
_freeArray(iqvx);
_freeArray(specHc);
_freeArray(specVc);
_freeArray(iqhcF);
_freeArray(iqhxF);
_freeArray(iqvcF);
_freeArray(iqvxF);
_freeArray(iqhcPrtShortOrig);
_freeArray(iqhcPrtLongOrig);
_freeArray(iqvcPrtShortOrig);
_freeArray(iqvcPrtLongOrig);
_freeArray(iqhxPrtShortOrig);
_freeArray(iqhxPrtLongOrig);
_freeArray(iqvxPrtShortOrig);
_freeArray(iqvxPrtLongOrig);
_freeArray(iqhcPrtShort);
_freeArray(iqhcPrtLong);
_freeArray(iqvcPrtShort);
_freeArray(iqvcPrtLong);
_freeArray(iqhxPrtShort);
_freeArray(iqhxPrtLong);
_freeArray(iqvxPrtShort);
_freeArray(iqvxPrtLong);
_freeArray(iqhcPrtShortF);
_freeArray(iqhcPrtLongF);
_freeArray(iqvcPrtShortF);
_freeArray(iqvcPrtLongF);
_freeArray(iqhxPrtShortF);
_freeArray(iqhxPrtLongF);
_freeArray(iqvxPrtShortF);
_freeArray(iqvxPrtLongF);
_freeArray(iqStrong);
_freeArray(iqWeak);
_freeArray(iqStrongF);
_freeArray(iqWeakF);
_freeArray(iqMeas);
_freeArray(iqTrip1);
_freeArray(iqTrip2);
_freeArray(iqTrip3);
_freeArray(iqTrip4);
}
|
7339914ea86d5a3767cf18430d99d2eefe8a9691 | 21857d368a4f50989dbeff8d0be6d9dfd794a4a6 | /src/scene/SceneStory.h | d7b798e6e57e53697bf1aee2c0baf85d2e32a8cb | [] | no_license | chuchong/IM_INSAN | 81e16741a7666119f74f52af536f7838f2ce3eac | ce010ec976c9680cdb715f739bb9b89f0d96ee5a | refs/heads/master | 2020-03-28T02:01:25.127991 | 2018-09-14T12:00:14 | 2018-09-14T12:00:14 | 147,542,170 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 674 | h | SceneStory.h | #ifndef SCENESTORY_H
#define SCENESTORY_H
#include <QSettings>
#include <QDebug>
#include "Scene.h"
class SceneStory : public Scene
{
private:
BlockObject *background;
ObjectScript *script;
QString script_url;
public:
~SceneStory(){ qDebug() << "delete story";}
SceneStory();
virtual void parseFromFile(QString url);
virtual void update();
virtual void redraw();
virtual void load();
virtual void unload();
virtual void getIn();
void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual SCENE_TYPE getSceneType(){
return STORY;
}
// virtual Scene *duplicateScene(Scene *);
};
#endif // SCENESTORY_H
|
107d7bbe0aefa1df537843def4d855d5865abc71 | 9be246df43e02fba30ee2595c8cec14ac2b355d1 | /cl_dll/hl1/hl1_c_rpg_rocket.cpp | 0097070bb108f93cd3d45bfa488d9122d9b2e6af | [] | no_license | Clepoy3/LeakNet | 6bf4c5d5535b3824a350f32352f457d8be87d609 | 8866efcb9b0bf9290b80f7263e2ce2074302640a | refs/heads/master | 2020-05-30T04:53:22.193725 | 2019-04-12T16:06:26 | 2019-04-12T16:06:26 | 189,544,338 | 18 | 5 | null | 2019-05-31T06:59:39 | 2019-05-31T06:59:39 | null | WINDOWS-1252 | C++ | false | false | 1,032 | cpp | hl1_c_rpg_rocket.cpp | //====== Copyright © 1996-2003, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "dlight.h"
#include "tempent.h"
#include "iefx.h"
#include "c_te_legacytempents.h"
#include "basegrenade_shared.h"
class C_RpgRocket : public C_BaseGrenade
{
public:
DECLARE_CLASS( C_RpgRocket, C_BaseGrenade );
DECLARE_CLIENTCLASS();
public:
C_RpgRocket( void ) { }
C_RpgRocket( const C_RpgRocket & );
public:
void CreateLightEffects( void );
};
IMPLEMENT_CLIENTCLASS_DT( C_RpgRocket, DT_RpgRocket, CRpgRocket )
END_RECV_TABLE()
void C_RpgRocket::CreateLightEffects( void )
{
dlight_t *dl;
if ( m_fEffects & EF_DIMLIGHT )
{
dl = effects->CL_AllocDlight ( index );
dl->origin = GetAbsOrigin();
dl->color.r = dl->color.g = dl->color.b = 100;
dl->radius = 200;
dl->die = gpGlobals->curtime + 0.001;
tempents->RocketFlare( GetAbsOrigin() );
}
}
|
5c3f1ada2e5cfa23e8074f3b9bb3d207c9755442 | 01b1f86aa05da3543a2399ffc34a8ba91183e896 | /modules/core/generative/include/nt2/core/functions/common/repvert.hpp | e383db6acd9afa27e92a419a58d7d6d2b1cdb087 | [
"BSL-1.0"
] | permissive | jtlap/nt2 | 8070b7b3c4b2f47c73fdc7006b0b0eb8bfc8306a | 1b97350249a4e50804c2f33e4422d401d930eccc | refs/heads/master | 2020-12-25T00:49:56.954908 | 2015-05-04T12:09:18 | 2015-05-04T12:09:18 | 1,045,122 | 35 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 2,178 | hpp | repvert.hpp | //==============================================================================
// Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef NT2_CORE_FUNCTIONS_COMMON_REPVERT_HPP_INCLUDED
#define NT2_CORE_FUNCTIONS_COMMON_REPVERT_HPP_INCLUDED
#include <nt2/core/functions/repvert.hpp>
#include <nt2/core/utility/as_subscript.hpp>
#include <nt2/core/utility/as_index.hpp>
#include <nt2/include/functions/run.hpp>
#include <nt2/include/functions/simd/splat.hpp>
#include <nt2/include/functions/simd/modulo.hpp>
#include <nt2/include/functions/simd/enumerate.hpp>
#include <nt2/sdk/meta/as_index.hpp>
namespace nt2 { namespace ext
{
BOOST_DISPATCH_IMPLEMENT ( run_, tag::cpu_
, (A0)(State)(Data)(N)
, ((node_ < A0, nt2::tag::repvert_
, N , nt2::container::domain
>
))
(generic_< integer_<State> >)
((unspecified_<Data>))
)
{
typedef typename Data::type result_type;
BOOST_FORCEINLINE result_type
operator()(A0 const& a0, State const& p, Data const& t) const
{
typedef typename meta::as_index<result_type>::type i_t;
typedef typename result_of::as_subscript<_2D, i_t>::type sub_t;
// Retrieve pattern and its extent
_2D in_sz = boost::proto::child_c<0>(a0).extent();
_2D out_sz = a0.extent();
sub_t pos = as_subscript(out_sz, nt2::enumerate<i_t>(p));
pos[0] = pos[0] % splat<i_t>(in_sz[0]);
return nt2::run ( boost::proto::child_c<0>(a0)
, as_index(in_sz, pos)
, t
);
}
};
} }
#endif
|
7820741b7906d6ba9278dfd3ab4fbc233cb02bfe | 1436bb6351777226d058cd7696f22ecd0b485cd7 | /Thesis_091218/Thesis_091218.ino | 2dfb64cbe0806acb2aca91c104d2e0f71862d631 | [] | no_license | NguyeVietAnh/NodeMCU | af2bc5a09fdcbc4712852ff7993f8d1a5f0f22c2 | 0fd8a6db1519e854a1e9b41b2446766ef2165f03 | refs/heads/master | 2020-04-11T03:24:38.064419 | 2018-12-13T04:25:32 | 2018-12-13T04:25:32 | 161,477,023 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,071 | ino | Thesis_091218.ino | /***************************************************************************************************************
* Servo Control using NodeMCU ESP-12 Develop Kit V1.0
* Including Blynk Control
* Including 128x64 OLED Display
* Libraries needed:
* SSD1306Wire.h: https://github.com/squix78/esp8266-oled-ssd1306
* ESP8266WiFi.h: https://github.com/ekstrand/ESP8266wifi
* BlynkSimpleEsp8266.h: http://www.blynk.cc
*
* Servo connected to NodeMCU pin D2
* OLED pinout:
* - GND goes to ground
* - Vin goes to 3.3V
* - Data to I2C SDA (GPIO 0 ==>D3)
* - Clk to I2C SCL (GPIO 2 ==>D4)
*
* Developed by MJRovai V.1 08 May 2017
********************************************************************************************************************************/
#define SW_VERSION "ServoCtrlBlynk_V.1"
/*NodeMCU */
#include <ESP8266WiFi.h>
char ssid [] = "NgocChau";
char pass [] = "67689606";
/* Blynk */
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
char auth [] = "784fc5249758459e848f8352ab353f33"; // Servo Control Project // Servo Control Project
/* OLED */
//#include "SSD1306Wire.h"
//#include "Wire.h"
//const int I2C_DISPLAY_ADDRESS = 0x3c;
//const int SDA_PIN = 0;
//const int SCL_PIN = 2;
//SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);
/* Servo */
#define servo1Pin D2
#include <Servo.h>
Servo servo1;
/* Initial pot reading and servo position set the position to neutral */
#define potPin A0
int potReading = 1023/2;
int dutycycle = 1 ;
/* Reads slider in the Blynk app and writes the value to "potReading" variable */
BLYNK_WRITE(V0)
{
potReading = param.asInt();
}
/* Display servo position on Blynk app */
BLYNK_READ(V1)
{
Blynk.virtualWrite(V1, dutycycle);
}
void setup ()
{
Serial.begin(9600);
servo1.attach(servo1Pin);
//displaySetup();
Blynk.begin(auth, ssid, pass);
analogWrite(servo1Pin, 512);
}
void loop()
{
Blynk.run();
//PotReading = analogRead(potPin); // Read Analog data from potenciometer not used here
//servo1Angle = map(potReading, 0, 1023, 0, 180); // Map the pot reading to an angle from 0 to 180
// servo1.write(servo1Angle); // Move the servo to a position
//displayAngle();
// if(dutycycle > 1023) dutycycle = 1023;/* limit dutycycle to 1023 if POT read cross it */
// Serial.print("Duty Cycle: ");
// Serial.println(dutycycle);
analogWrite(servo1Pin, 512);
delayMicroseconds(100);
}
/* Initiate and display setup data on OLED */
//void displaySetup()
//{
// display.init(); // initialize display
// display.clear(); // Clear display
// display.display(); // Put data on display
//}
/* Display Servo position */
//void displayAngle()
//{
// display.clear();
// display.setFont(ArialMT_Plain_16);
// display.drawString(10, 0, "Servo Control");
// display.drawString(0, 45, "POSITION:" );
// display.setFont(ArialMT_Plain_24);
// display.drawString(80, 40, String(servo1Angle));
//display.display();
//}
|
f9b0e532b08572d08534c199444b05b9332c44af | 4c3adff3fcc54eafef3a30375a7769d96181d204 | /Cpp_Sorting/NodeList.h | 7754b178e5bcba74e12204a6d80a81add1cc2cbf | [] | no_license | georgebzhang/Cpp_Algorithms | b11791c197655f4389014a7835b469492dac102f | 774939491f830978105df267ff55a965dd41c881 | refs/heads/master | 2020-04-24T02:33:09.169843 | 2019-03-07T03:10:04 | 2019-03-07T03:10:04 | 171,641,057 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,193 | h | NodeList.h | #pragma once
#include "List.h"
template<typename T>
class NodeList : List<T>
{
private:
struct Node {
T data;
Node* prev;
Node* next;
~Node() {
std::cout << "called Node destructor" << std::endl;
}
};
Node* head = nullptr;
Node* tail = nullptr;
int length = 0;
Node* find(int index) { // helper function for insert(...) and remove(...)
Node* ptr = head;
for (int i = 0; i < index; ++i) { // not <= index, since we do ->next during i = 0
ptr = ptr->next;
}
return ptr;
}
public:
void insert_front(T t) {
Node* n = new Node();
n->data = t;
if (empty()) {
head = n;
tail = n;
}
else {
n->next = head;
head->prev = n;
head = n;
}
++length;
}
void insert_back(T t) {
Node* n = new Node();
n->data = t;
if (empty()) {
head = n;
tail = n;
}
else {
n->prev = tail;
tail->next = n;
tail = n;
}
++length;
}
void remove_front() {
if (empty())
throw "List is empty";
if (length == 1) {
delete head; // head is same as tail
head = nullptr;
tail = nullptr;
}
else {
Node* ptr = head;
head = head->next;
delete ptr;
}
--length;
}
void remove_back() {
if (empty())
throw "List is empty";
if (length == 1) {
delete tail; // head is same as tail
head = nullptr;
tail = nullptr;
}
else {
Node* ptr = tail;
tail = tail->prev;
delete ptr;
}
--length;
}
void insert(int index, T t) {
if (index > length) // if length == 0 and index == 0, we should insert
throw "Index exceeds length";
if (index == 0) {
insert_front(t);
}
else if (index == length) {
insert_back(t);
}
else { // if index is between front and back
Node* n = new Node();
n->data = t;
Node* n_index = find(index);
n_index->prev->next = n;
n->prev = n_index->prev;
n->next = n_index;
n_index->prev = n;
++length; // not outside of else, since length is incremented in insert_front(...) and insert_back(...)
}
}
void remove(int index) {
if (empty())
throw "List is empty";
if (index >= length)
throw "Index exceeds length";
if (index == 0) {
remove_front();
}
else if (index == length - 1) {
remove_back();
}
else { // if index is between front and back
Node* n_index = find(index);
n_index->prev->next = n_index->next;
n_index->next->prev = n_index->prev;
delete n_index;
--length; // not outside of else, since length is decremented in insert_front(...) and insert_back(...)
}
}
T front() {
if (empty())
throw "List is empty";
return head->data;
}
T back() {
if (empty())
throw "List is empty";
return tail->data;
}
int size() {
return length;
}
bool empty() {
return length == 0;
}
void print() {
if (empty())
std::cout << "List is empty" << std::endl;
else if (length == 1)
std::cout << head->data << std::endl;
else {
Node* iter = head;
for (int i = 0; i < length; ++i) {
std::cout << iter->data << " ";
iter = iter->next;
}
std::cout << std::endl;
}
}
~NodeList() {
std::cout << "called NodeList destructor" << std::endl;
while (!empty()) {
Node* ptr = head;
head = head->next;
delete ptr;
}
}
}; |
dcb549c754b4e4da5adeca40b892dbf935bf10dd | f33886602458e5198df3084ec783d4ac2d01c923 | /boj2331.cpp | d6b5f4f77cba8470c9329d8120b9b4f20b556f00 | [] | no_license | andongjoo/algorithm | 4effa845698060dc6079638cff4c73752f3fc792 | 22622d1fc5cef10beabbf0b1c5ac3f2136664cfa | refs/heads/master | 2021-06-18T12:31:47.259169 | 2021-02-15T11:54:18 | 2021-02-15T11:54:18 | 176,703,891 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 790 | cpp | boj2331.cpp | #include <iostream>
#include <vector>
#include <string>
#include <stack>
using namespace std;
int n;
vector<int> v[1000000];
vector<string> cnt;
bool visit[1000000];
stack<string> stck;
int pow(int n,int m)
{
if(m==1)
return n;
else
return n*pow(n,m-1);
}
void dfs(string node)
{
stck.push(node);
visit[stoi(node)]=true;
int sum=0;
string temp=node;
for(int i=0;i<temp.size();i++)
{
int num=temp[i]-'0';
sum+=pow(num,n);
}
if(visit[sum])
{
while(to_string(sum)!=stck.top())
{
stck.pop();
}
stck.pop();
}
else{
temp=to_string(sum);
dfs(temp);
}
}
int main(int argc, char** argv) {
string str;
cin>>str;
cin>>n;
dfs(str);
printf("%d",stck.size());
return 0;
}
|
fb852b98c63216d6132c3e7a04ee4bdc1c7068fe | ba90cba096ba4e1a1de31af346e0b769c17ccc9e | /tests/DataStructures/LListUT.cpp | e9d06cd84460771e38eb9fe52502fe8ea7ea073e | [
"MIT"
] | permissive | KaravolisL/ARM-ISA-Simulator | f5ed222eff2d82c6fdad8ec822fec856570419c9 | cc5b927ff40054d912e208a469545089125e6911 | refs/heads/master | 2023-01-02T03:35:05.483981 | 2020-10-21T00:35:37 | 2020-10-21T00:35:37 | 253,665,149 | 0 | 0 | MIT | 2020-09-11T21:59:09 | 2020-04-07T02:19:19 | C++ | UTF-8 | C++ | false | false | 2,584 | cpp | LListUT.cpp | /////////////////////////////////
/// DLListUT.cpp
///
/// @brief Unit Test for DLList
/////////////////////////////////
// SYSTEM INCLUDES
// (None)
// C PROJECT INCLUDES
// (None)
// C++ PROJECT INCLUDES
#include <catch2/catch.hpp>
#include "DLList.hpp" // Test class
#include "SLList.hpp"
TEMPLATE_TEST_CASE("Linked List Basic Functionality", "[data_structure]", (DLList<uint32_t>), (SLList<uint32_t>))
{
TestType list = TestType();
SECTION("Insert Front")
{
for (uint32_t i = 0; i < 10; i++)
{
list.InsertBack(i);
}
for (uint32_t i = 0; i < 10; i++)
{
REQUIRE(i == list.Get(i));
}
REQUIRE(list.GetLength() == 10);
list.Clear();
REQUIRE(list.GetLength() == 0);
}
SECTION("Insert Back")
{
for (int i = 9; i >= 0; i--)
{
list.InsertFront(static_cast<uint32_t>(i));
}
for (int i = 9; i >= 0; i--)
{
REQUIRE(static_cast<uint32_t>(i) == list.Get(i));
}
REQUIRE_THROWS_AS(list.Get(100), IndexOutOfBoundsException);
REQUIRE(list.GetLength() == 10);
}
SECTION("Removal")
{
for (uint32_t i = 0; i < 10; i++)
{
list.InsertBack(i);
}
for (int i = 9; i >= 0; i--)
{
REQUIRE(list.GetLength() == static_cast<uint32_t>(i) + 1);
REQUIRE(static_cast<uint32_t>(i) == list.Remove(i));
}
REQUIRE_THROWS_AS(list.Remove(100), IndexOutOfBoundsException);
}
}
TEST_CASE("SLList Iterator Test", "[data_structure][extended]")
{
SLList<int> list = SLList<int>();
SLList<int>::SLListIterator iterator;
for (int i = 0; i < 10; i++)
{
list.InsertBack(i);
}
int i = 0;
for (iterator = list.GetBegin();
iterator != list.GetEnd();
iterator++)
{
REQUIRE(i == *iterator);
i++;
}
REQUIRE(i == 10);
}
TEST_CASE("DLList Iterator Test", "[data_structure][extended]")
{
DLList<int> list = DLList<int>();
DLList<int>::DLListIterator iterator;
for (int i = 0; i < 10; i++)
{
list.InsertBack(i);
}
int i = 0;
for (iterator = list.GetBegin();
iterator != list.GetEnd();
iterator++)
{
REQUIRE(i == *iterator);
i++;
}
REQUIRE(i == 10);
for (iterator = list.GetReverseBegin();
iterator != list.GetReverseEnd();
iterator--)
{
i--;
REQUIRE(i == *iterator);
}
REQUIRE(i == 0);
}
|
4e43a6f61b658c94793f9188da286eb59c17d52d | 7f951ce7cf4cba882be4c610dec973b58c9a5d5b | /2019/luogu/1738_2.cpp | e5260608ddfa6b4740e63480a3603535912262c1 | [] | no_license | weathon/USACO | 9d1b0e23a7181a7fbe50e7870771d97f7b607d2f | 4f3cbd445886387839aecbd86852d1e3e510c91f | refs/heads/master | 2021-08-08T02:04:57.968221 | 2020-12-17T06:36:21 | 2020-12-17T06:36:21 | 231,851,628 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 203 | cpp | 1738_2.cpp | #include<iostream>
using namespace std;
string list[1005];
string thisline;
int main()
{
int N;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>thisline;
for()
}
return 0;
} |
7614732cb5b9bf876ff648555cc330cc3abe1441 | 0bac9d200f6662dfee0ca4c12fc800a90fc00d64 | /Lab6/poly_class_v2.cpp | 1054ef1cccae52111f69ab58daa1c5deb815b1c2 | [] | no_license | mdesroches0501/CS202-CompSciII | 8093f0d939701b7a5a5f1862084314f5e9b349ef | f5aef8a3a07d3d62899089cc4d6f16260d880e27 | refs/heads/main | 2023-01-24T16:30:37.422154 | 2020-12-09T05:32:54 | 2020-12-09T05:32:54 | 319,850,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 305 | cpp | poly_class_v2.cpp | // polyclass
// Test
#include "Polynomial.h"
//#include "Polynomial.cpp"
int main(int argc, char * argv[])
{
Polynomial poly[3];
for (int n = 0; n<2; n++)
{
poly[n].get_poly();
poly[n].display_poly();
}
poly[2].Add_2_Polynomials(poly[0], poly[1]);
poly[2].display_poly();
return 0;
}
|
2bb988858f770278039d67b61f235a65d8534d7b | 3f82741c5528b768ff93c75eb69aa880c0fe5b42 | /nc_bytedance2018_2.cpp | 553300604199567eb1e7286dab2ffbbb1f7215b1 | [] | no_license | Wavator/LC | 196d628257f2bb0d8b527895fd9787e9545ab409 | b144fd7708cfae331dd3b2f8f7ba38a9f4cd8d94 | refs/heads/master | 2022-11-30T04:21:24.421981 | 2020-08-17T15:15:36 | 2020-08-17T15:15:36 | 280,210,968 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,265 | cpp | nc_bytedance2018_2.cpp | //
// Created by Zhao on 2020/7/24.
//
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m, c;
scanf("%d%d%d", &n, &m, &c);
vector<vector<int> > nodes(n, vector<int>());
for (int i = 0; i < n; ++i) {
int x, y;
scanf("%d", &x);
while (x--) {
scanf("%d", &y);
nodes[i].push_back(y);
}
}
for (int i = 0; i < m - 1; ++i) {
nodes.push_back(nodes[i]);
}
vector<bool> suitable(c + 1, true);
vector<int> last_occur(c + 1, -1000005);
for (int i = 0; i < nodes.size(); ++i) {
for (auto color: nodes[i]) {
//cerr << color << ' ' << last_occur[color] << ' ' << i << endl;
if (i - last_occur[color] + 1 <= m) {
suitable[color] = false;
}
last_occur[color] = i;
}
}
int ans(0);
for (int i = 1; i <= c; ++i) {
if (!suitable[i]) {
++ans;
}
}
cout << ans << endl;
}
/*
int main() {
solve();
return 0;
}
* */
/*
作为一个手串艺人,有金主向你订购了一条包含n个杂色串珠的手串——每个串珠要么无色,要么涂了若干种颜色。为了使手串的色彩看起来不那么单调,金主要求,手串上的任意一种颜色(不包含无色),在任意连续的m个串珠里至多出现一次(注意这里手串是一个环形)。手串上的颜色一共有c种。现在按顺时针序告诉你n个串珠的手串上,每个串珠用所包含的颜色分别有哪些。请你判断该手串上有多少种颜色不符合要求。即询问有多少种颜色在任意连续m个串珠中出现了至少两次。
输入描述:
第一行输入n,m,c三个数,用空格隔开。(1 <= n <= 10000, 1 <= m <= 1000, 1 <= c <= 50) 接下来n行每行的第一个数num_i(0 <= num_i <= c)表示第i颗珠子有多少种颜色。接下来依次读入num_i个数字,每个数字x表示第i颗柱子上包含第x种颜色(1 <= x <= c)
输出描述:
一个非负整数,表示该手链上有多少种颜色不符需求。
输入例子1:
5 2 3
3 1 2 3
0
2 2 3
1 2
1 3
输出例子1:
2
把一串后面拼m-1个头部的柱子,维护每个颜色上次出现的位置。
* */
|
4a9c053b1571c843bc19a831068de5ec8607fdff | 3fb749d3f485a82758a3b0d7a3db9e8eb97ae2be | /coinbase.cpp | 66f5853e4180664ef593c9416bdf54297dbb9c9e | [] | no_license | alveraboquet/exchange | 0760d732c19935843a90a44f145a3197f878bf0c | 42204b21783d9833cefda7065657c99a13e62cfd | refs/heads/master | 2023-03-15T17:08:34.775914 | 2017-02-15T16:47:42 | 2017-02-15T16:47:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,458 | cpp | coinbase.cpp | #include "coinbase.h"
CoinBase::CoinBase(QString currency, QString apiKey, QString secretKey, QString passphrase, QSqlQuery *query) : BTCexchange(currency, apiKey, secretKey, query)
{
m_apiUrl = "https://api-public.sandbox.gdax.com";
orderBookAddr = m_apiUrl + "/products/BTC-" + currentCurrencyMinor + "/book?level=2";
m_passphrase = passphrase;
m_siteName = "coinbase";
m_feeMaker = 0.00;
m_feeTaker = 0.25;
}
void CoinBase::signerHeaders(QNetworkRequest *requete, QString timeStamp, QString method, QString *requestPath, QByteArray *parameters){
QByteArray message = (timeStamp + method + *requestPath + QString(*parameters)).toLatin1();
requete->setRawHeader("content-type", "application/json");
requete->setRawHeader("CB-ACCESS-KEY", apiKey.toLatin1());
requete->setRawHeader("CB-ACCESS-SIGN", (*hmacSignature(&message,QCryptographicHash::Sha256,true)).toBase64());
requete->setRawHeader("CB-ACCESS-TIMESTAMP", (timeStamp).toLatin1());
requete->setRawHeader("CB-ACCESS-PASSPHRASE", m_passphrase.toLatin1());
}
void CoinBase::loadBalance(){
QByteArray jsonString = "";
// Url de la requete
QString urlPath = "/accounts";
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("GET"), &urlPath, &jsonString);
interpreterLoadBalance(&request);
}
void CoinBase::viewOpenOrder()
{
/*
QString urlPath = "/orders";
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
QByteArray jsonString = "";
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("GET"), &urlPath, &jsonString);
QNetworkAccessManager *m_qnam = new QNetworkAccessManager();
connect(m_qnam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(interpreterCrap(QNetworkReply*)));
m_qnam->get(request);
*/
QByteArray jsonString = "";
// Url de la requete
QString urlPath = "/orders";
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("GET"), &urlPath, &jsonString);
interpreterLookOrders(&request, &jsonString, QNetworkAccessManager::GetOperation);
}
int CoinBase::buyOrder(double amount, double price)
{
QByteArray jsonString;
if (price != 0)
{
jsonString = "{\"product_id\": \"BTC-"+currentCurrencyMinor.toLatin1()+"\""
", \"size\": " + QString::number(amount).toLatin1() + ""
", \"price\": " + QString::number(price).toLatin1() + ""
" ,\"side\": \"buy\"}";
}
else
{
jsonString = "{\"product_id\": \"BTC-"+currentCurrencyMinor.toLatin1()+"\""
", \"funds\": " + QString::number(amount).toLatin1() + ""
", \"type\": \"market\""
" ,\"side\": \"buy\"}";
}
// Url de la requete
QString urlPath = "/orders";
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("POST"), &urlPath, &jsonString);
return interpreterBuySell(&request, BTCexchange::typeBuy, &price, &amount, &jsonString);
}
int CoinBase::sellOrder(double amount, double price)
{
QByteArray jsonString;
if (price != 0)
{
jsonString = "{\"product_id\": \"BTC-"+currentCurrencyMinor.toLatin1()+"\""
", \"size\": " + QString::number(amount).toLatin1() + ""
", \"price\": " + QString::number(price).toLatin1() + ""
" ,\"side\": \"sell\"}";
}
else
{
jsonString = "{\"product_id\": \"BTC-"+currentCurrencyMinor.toLatin1()+"\""
", \"size\": " + QString::number(amount).toLatin1() + ""
", \"type\": \"market\""
" ,\"side\": \"sell\"}";
}
// Url de la requete
QString urlPath = "/orders";
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("POST"), &urlPath, &jsonString);
return interpreterBuySell(&request, BTCexchange::typeSell, &price, &amount, &jsonString);
}
bool CoinBase::cancelOrder(QString orderID)
{
QString urlPath;
if (orderID == "")
urlPath = "/orders/";
else
urlPath = "/orders/" + orderID;
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
QByteArray jsonString = "";
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("DELETE"), &urlPath, &jsonString);
return interpreterCancelOrders(&request, &jsonString, &orderID, QNetworkAccessManager::DeleteOperation);
}
void CoinBase::lookOrder(QString orderID)
{
QString urlPath = "/orders/" + orderID;
QNetworkRequest request(QUrl(m_apiUrl + urlPath));
QByteArray jsonString = "";
signerHeaders(&request, QString(QString::number(QDateTime::currentMSecsSinceEpoch() / 1000)), QString("GET"), &urlPath, &jsonString);
QNetworkAccessManager *m_qnam = new QNetworkAccessManager();
connect(m_qnam, SIGNAL(finished(QNetworkReply*)),
this, SLOT(interpreterCrap(QNetworkReply*)));
m_qnam->get(request);
}
void CoinBase::interpreterLoadBalance(QNetworkRequest* request)
{
QEventLoop eventLoop;
// "quit()" the event-loop, when the network request "finished()"
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkReply *reply = mgr.get(*request);
eventLoop.exec(); // blocks stack until "finished()" has been called
QString reponse = reply->readAll();
// Crée un object Json avec la réponse obtenure
QJsonDocument jsonDocument = QJsonDocument::fromJson(reponse.toUtf8());
QJsonArray json_array = jsonDocument.array();
foreach (const QJsonValue &value, json_array)
{
QJsonObject json_obj = value.toObject();
if (json_obj["currency"].toString() == currentCurrencyMinor)
{
m_balance_fiat = json_obj["available"].toString().replace(',','.').toDouble();
m_balance_fiatHold = json_obj["hold"].toString().replace(',','.').toDouble();
}
else if (json_obj["currency"].toString() == "BTC")
{
m_balance_btc = json_obj["available"].toString().replace(',','.').toDouble();
m_balance_btcHold = json_obj["hold"].toString().replace(',','.').toDouble();
}
}
qDebug() << "CoinBase";
qDebug() << "btc" << m_balance_btc;
qDebug() << "btcHold" << m_balance_btcHold;
qDebug() << "fiat" << m_balance_fiat;
qDebug() << "fiatHold" << m_balance_fiatHold;
delete reply;
}
void CoinBase::interpreterCrap(QNetworkReply* reply)
{
// Gestion des erreurs
if(reply->error())
{
QMessageBox msgBox;
msgBox.setText("Erreur lors de la requete : " + reply->errorString());
msgBox.exec();
return;
}
// Laleur de reply->readAll() se vide apres usage
QString reponse = reply->readAll();
qDebug() << reponse;
// Crée un object Json avec la réponse obtenure
QJsonDocument jsonDocument = QJsonDocument::fromJson(reponse.toUtf8());
QJsonObject jsonObject = jsonDocument.object();
qDebug() << jsonObject["date"].toString();
delete reply;
}
|
cacac3cef692b7318dd04e4421a58c122191cf52 | 7e38fc9705e48e4a7e6a003a8c414e8c3999424b | /FabianLib/XAnalogClock.cpp | bc51a1c85e122b6f70bc950616a02731bf068f8e | [] | no_license | vivianng30/rainer-fabian-gui | e5118df24ed6eab51b819499e0680b804e7eb87a | 2ca6f43513487fdf9a10c9354736449b300e21b5 | refs/heads/master | 2020-03-28T11:11:26.391374 | 2018-09-20T13:48:54 | 2018-09-20T13:48:54 | 148,186,875 | 0 | 0 | null | null | null | null | ISO-8859-3 | C++ | false | false | 23,858 | cpp | XAnalogClock.cpp | // XAnalogClock.cpp Version 1.0
//
// Author: Hans Dietrich
// hdietrich@gmail.com
//
// Description:
// XAnalogClock implements CXAnalogClock, a skinnable analog clock control.
//
// History
// Version 1.0 - 2006 March 23
// - Initial public release
//
// Public APIs:
// NAME DESCRIPTION
// --------------------- -------------------------------------------
// GetTime() Get currently displayed time
// GetWindowSize() Get control size
// IsClockRunning() Returns run state of clock
// SetBackgroundColor() Set background color
// SetBitmaps() Set bitmap resource IDs
// SetGmtAdjust() Not currently used
// SetHourHandColor() Set color of hour hand
// SetMinuteHandColor() Set color of minute hand
// SetSecondHandColor() Set color of second hand
// SetTime() Set starting time (if system time not used)
// SetTransparentColor() Set transparent color
// ShowDate() Show/hide date
// ShowSecondHand() Show/hide second hand
// Run() Start the clock
// Stop() Stop the clock
// UseSystemTime() Use system time, or user-supplied time (see
// SetTime()
//
// License:
// This software is released into the public domain. You are free to use
// it in any way you like, except that you may not sell this source code.
//
// This software is provided "as is" with no expressed or implied warranty.
// I accept no liability for any damage or loss of business that this
// software may cause.
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "XAnalogClock.h"
#include "math.h"
#include "WuLine.h"
#include "globDefs.h"
#ifdef _DEBUG
/**********************************************************************************************//**
* A macro that defines new
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__; ///< this file[]
#endif
/**********************************************************************************************//**
* /////////////////////////////////////////////////////////////////////////////
* some definitions
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define DATE_BOX_WIDTH 18
/**********************************************************************************************//**
* A macro that defines date box height
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define DATE_BOX_HEIGHT 14
/**********************************************************************************************//**
* A macro that defines date box xpos
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define DATE_BOX_XPOS 67
/**********************************************************************************************//**
* A macro that defines date box ypos
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define DATE_BOX_YPOS 43
/**********************************************************************************************//**
* #define SECOND_HAND_LENGTH 35.0
* #define MINUTE_HAND_LENGTH 39.0
* #define HOUR_HAND_LENGTH 28.0
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define SECOND_HAND_LENGTH 17.0
/**********************************************************************************************//**
* A macro that defines minute hand length
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define MINUTE_HAND_LENGTH 17.0
/**********************************************************************************************//**
* A macro that defines hour hand length
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define HOUR_HAND_LENGTH 11.0
/**********************************************************************************************//**
* A macro that defines second hand color
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define SECOND_HAND_COLOR RGB(220,20,60)
/**********************************************************************************************//**
* A macro that defines minute hand color
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define MINUTE_HAND_COLOR RGB(0,0,0)
/**********************************************************************************************//**
* A macro that defines hour hand color
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define HOUR_HAND_COLOR RGB(0,0,0)
/**********************************************************************************************//**
* A macro that defines pi
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
#define PI 3.1415926535
BEGIN_MESSAGE_MAP(CXAnalogClock, CStatic)
//{{AFX_MSG_MAP(CXAnalogClock)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_TIMER()
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/**********************************************************************************************//**
* Initializes a new instance of the CXAnalogClock class
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
CXAnalogClock::CXAnalogClock()
{
m_nPrevMinute = -1;
m_bShowDate = TRUE;
m_bShowSecondHand = TRUE;
m_bUseSystemTime = TRUE;
m_bStopped = TRUE;
//m_time = CTime::GetCurrentTime();
SYSTEMTIME st;
GetLocalTime(&st);
COleDateTime dtTime(st);
m_dtTime =dtTime;
//m_dtTime =COleDateTime::GetCurrentTime();
//m_time = CTime(2006, 1, 15, 8, 40, 0);
m_dGmtAdjust = 0.0;
m_rgbBackground = RGB(255,0,255);
m_rgbTransparent = RGB(255,0,255);
m_rgbSecondHand = SECOND_HAND_COLOR;
m_rgbMinuteHand = MINUTE_HAND_COLOR;
m_rgbHourHand = HOUR_HAND_COLOR;
m_nFaceBitmapId = 0;
//m_nDateBitmapId = 0;
m_iPrevDay=GetDay();
}
/**********************************************************************************************//**
* Finalizes an instance of the CXAnalogClock class
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
CXAnalogClock::~CXAnalogClock()
{
}
/**********************************************************************************************//**
* Pre subclass window
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
void CXAnalogClock::PreSubclassWindow()
{
CClientDC dc(NULL);
LoadBitmaps(&dc);
CStatic::PreSubclassWindow();
}
/**********************************************************************************************//**
* Gets window size
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \return The window size.
**************************************************************************************************/
CSize CXAnalogClock::GetWindowSize()
{
CClientDC dc(NULL);
LoadBitmaps(&dc);
return m_cdcClockFace.m_sizeBitmap;
}
/**********************************************************************************************//**
* Loads the bitmaps
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param [in,out] pDC If non-null, the device-context.
**************************************************************************************************/
void CXAnalogClock::LoadBitmaps(CDC *pDC)
{
if ((m_nFaceBitmapId == 0) /*|| (m_nDateBitmapId == 0)*/)
{
return;
}
// load clockface.bmp
if (!m_cdcClockFace.IsValid())
VERIFY(m_cdcClockFace.LoadBitmap(m_nFaceBitmapId, pDC));
// load date.bmp
/*if (!m_cdcDate.IsValid())
VERIFY(m_cdcDate.LoadBitmap(m_nDateBitmapId, pDC));*/
if (!m_cdcPrevious.IsValid())
VERIFY(m_cdcPrevious.LoadBitmap(m_nFaceBitmapId, pDC));
}
/**********************************************************************************************//**
* Paints this window
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
void CXAnalogClock::OnPaint()
{
if ((m_nFaceBitmapId == 0) /*|| (m_nDateBitmapId == 0)*/)
{
return;
}
CPaintDC dc(this); // device context for painting
LoadBitmaps(&dc);
if (m_bUseSystemTime)
{
//m_time = CTime::GetCurrentTime();
//m_dtTime =COleDateTime::GetCurrentTime();
SYSTEMTIME st;
GetLocalTime(&st);
COleDateTime dtTime(st);
m_dtTime=dtTime;
}
CRect rect;
GetClientRect(&rect);
if ((rect.Width() < m_cdcClockFace.m_sizeBitmap.cx) ||
(rect.Height() < m_cdcClockFace.m_sizeBitmap.cy))
{
}
CDC memDC;
memDC.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
CBitmap *pOldBitmap = memDC.SelectObject(&bitmap);
// fill in background color
CBrush brush(m_rgbBackground);
memDC.FillRect(&rect, &brush);
//if (m_nPrevMinute != GetMinute())
{
// draw clock face
BitBlt(memDC.m_hDC,
0, 0,
m_cdcClockFace.m_sizeBitmap.cx, m_cdcClockFace.m_sizeBitmap.cy,
m_cdcClockFace.m_dcMemory.m_hDC,
0, 0,
SRCCOPY);
/*if (m_bShowDate)
PaintDate(&memDC);*/
PaintMinuteAndHourHands(&memDC);
// save clock face & hands for this minute
m_cdcPrevious.m_dcMemory.BitBlt(0, 0,
m_cdcClockFace.m_sizeBitmap.cx, m_cdcClockFace.m_sizeBitmap.cy,
&memDC, 0, 0, SRCCOPY);
m_nPrevMinute = GetMinute();
}
//else
//{
// // minute hasn't changed, so use previous clock face & hands
// memDC.BitBlt(0, 0,
// rect.Width(), rect.Height(),
// &m_cdcPrevious.m_dcMemory,
// 0, 0, SRCCOPY);
//}
if (m_bShowSecondHand)
PaintSecondHand(&memDC);
// finally blt to screen
BitBlt(dc.m_hDC,
0, 0,
rect.Width(), rect.Height(),
memDC.m_hDC,
0, 0,
SRCCOPY);
memDC.SelectObject(pOldBitmap);
//DeleteObject(brush);//rkuNEWFIX
// Do not call CStatic::OnPaint() for painting messages
}
/**********************************************************************************************//**
* Converts a dTime to the degrees
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param dTime The time.
*
* \return The given data converted to the degrees.
**************************************************************************************************/
float CXAnalogClock::ConvertToDegrees(float dTime)
{
float degrees = (float)(90. - dTime * 6.0);
if (degrees < 0.0)
degrees = (float)360. + degrees;
return degrees;
}
//void CXAnalogClock::PaintDate(CDC *pDC)
//{
// LOGFONT lf;
// CFont *pFont = GetFont();
// if (pFont == NULL)
// pFont = GetParent()->GetFont();
// if (pFont)
// {
// pFont->GetLogFont(&lf);
// //_tcscpy(lf.lfFaceName, _T("MS Sans Serif"));
// _tcscpy(lf.lfFaceName, _T("Arial"));
// //lf.lfWeight = FW_BOLD;
// if (lf.lfHeight < 0)
// lf.lfHeight += 1;
// else
// lf.lfHeight -= 1;
//
// CFont font;
// font.CreateFontIndirect(&lf);
//
// CString strDate = _T("");
// strDate.Format(_T("%2d"), GetDay());
//
// CRect rect(0, 0, DATE_BOX_WIDTH, DATE_BOX_HEIGHT);
//
// // create temporary dc to hold the date numerals
// CDCBuffer cdcTemp;
// VERIFY(cdcTemp.LoadBitmap(m_nDateBitmapId, pDC));
// CFont *pOldFont = cdcTemp.m_dcMemory.SelectObject(&font);
// CBrush brush(RGB(255,0,255));
// cdcTemp.m_dcMemory.FillRect(&rect, &brush);
// cdcTemp.m_dcMemory.SetBkColor(RGB(255,0,255));
// cdcTemp.m_dcMemory.ExtTextOut(3, 1, 0, &rect, strDate, NULL);
//
// // draw date box template
// /*pDC->BitBlt(DATE_BOX_XPOS, DATE_BOX_YPOS, DATE_BOX_WIDTH, DATE_BOX_HEIGHT,
// &m_cdcDate.m_dcMemory, 0, 0, SRCCOPY);*/
//
// // overlay with date numerals
// BitBlt(pDC->m_hDC,
// DATE_BOX_XPOS+1, DATE_BOX_YPOS-1,
// DATE_BOX_WIDTH, DATE_BOX_HEIGHT,
// cdcTemp.m_dcMemory.m_hDC,
// 0, 0,
// SRCCOPY);
//
// cdcTemp.m_dcMemory.SelectObject(pOldFont);
//
// DeleteObject(brush);
//
// }
//}
/**********************************************************************************************//**
* Paints the minute and hour hands described by pDC
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param [in,out] pDC If non-null, the device-context.
**************************************************************************************************/
void CXAnalogClock::PaintMinuteAndHourHands(CDC *pDC)
{
///////////////////////////////////////////////////////////////////////////
// draw minute hand
int minute = GetMinute();
float degrees, radians, cosine, sine;
short x1, y1, x2, y2;
degrees = ConvertToDegrees((float)minute);
radians = (float) ((PI * degrees)/180.);
cosine = (float)cos(radians);
sine = (float)sin(radians);
x1 = (short)(MINUTE_HAND_LENGTH * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)(-MINUTE_HAND_LENGTH * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
//x2 = (short)(5.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
//y2 = (short)(-5.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
x2 = (short)(1.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y2 = (short)(-1.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
if (((minute >= 10) && (minute <= 20)) || ((minute >= 40) && (minute <= 50)))
{
x1 = (short)(MINUTE_HAND_LENGTH * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)(-MINUTE_HAND_LENGTH * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2, y2, m_rgbMinuteHand);
x1 = (short)((MINUTE_HAND_LENGTH-4) * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)((-MINUTE_HAND_LENGTH+4) * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2, y2-1, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2, y2-0, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2, y2+0, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2, y2+1, m_rgbMinuteHand);
}
else
{
x1 = (short)(MINUTE_HAND_LENGTH * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)(-MINUTE_HAND_LENGTH * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2, y2, m_rgbMinuteHand);
x1 = (short)((MINUTE_HAND_LENGTH-4) * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)((-MINUTE_HAND_LENGTH+4) * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2-1, y2, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2-0, y2, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2+0, y2, m_rgbMinuteHand);
DrawWuLine(pDC, x1, y1, x2+1, y2, m_rgbMinuteHand);
}
///////////////////////////////////////////////////////////////////////////
// draw hour hand
int hour = GetHour();
if (hour > 12)
hour -= 12;
hour = hour*5 + GetMinute()/12;
degrees = ConvertToDegrees((float)hour);
radians = (float) ((PI * degrees)/180.);
cosine = (float)cos(radians);
sine = (float)sin(radians);
x1 = (short)(HOUR_HAND_LENGTH * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)(-HOUR_HAND_LENGTH * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
//x2 = (short)(5.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
//y2 = (short)(-5.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
x2 = (short)(1.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y2 = (short)(-1.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
if (((hour >= 10) && (hour <= 20)) || ((hour >= 40) && (hour <= 50)))
{
DrawWuLine(pDC, x1, y1, x2, y2, m_rgbHourHand);
x1 = (short)((HOUR_HAND_LENGTH-4) * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)((-HOUR_HAND_LENGTH+4) * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2, y2-1, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2, y2-0, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2, y2+0, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2, y2+1, m_rgbHourHand);
}
else
{
DrawWuLine(pDC, x1, y1, x2, y2, m_rgbHourHand);
x1 = (short)((HOUR_HAND_LENGTH-4) * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)((-HOUR_HAND_LENGTH+4) * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2-1, y2, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2-0, y2, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2+0, y2, m_rgbHourHand);
DrawWuLine(pDC, x1, y1, x2+1, y2, m_rgbHourHand);
}
}
/**********************************************************************************************//**
* Paints the second hand described by pDC
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param [in,out] pDC If non-null, the device-context.
**************************************************************************************************/
void CXAnalogClock::PaintSecondHand(CDC *pDC)
{
if (m_bShowSecondHand)
{
// draw second hand
float degrees, radians, cosine, sine;
short x1, y1, x2, y2;
degrees = ConvertToDegrees((float)GetSecond());
radians = (float)((PI * degrees)/180.);
cosine = (float)cos(radians);
sine = (float)sin(radians);
x1 = (short)(SECOND_HAND_LENGTH * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y1 = (short)(-SECOND_HAND_LENGTH * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
//x2 = (short)(5.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
//y2 = (short)(-5.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
x2 = (short)(1.0 * cosine + (float)m_cdcClockFace.m_sizeBitmap.cx/2);
y2 = (short)(-1.0 * sine + (float)m_cdcClockFace.m_sizeBitmap.cy/2);
DrawWuLine(pDC, x1, y1, x2, y2, m_rgbSecondHand);
DrawWuLine(pDC, x1+1, y1, x2+1, y2, m_rgbSecondHand);
}
}
/**********************************************************************************************//**
* Executes the erase bkgnd action
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param [in,out] pDC If non-null, the device-context.
*
* \return True if it succeeds, false if it fails.
**************************************************************************************************/
BOOL CXAnalogClock::OnEraseBkgnd(CDC* pDC)
{
return CStatic::OnEraseBkgnd(pDC);
}
/**********************************************************************************************//**
* Executes the timer action
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param nIDEvent The identifier event.
**************************************************************************************************/
void CXAnalogClock::OnTimer(UINT nIDEvent)
{
if (!m_bUseSystemTime)
{
/*CTimeSpan ts(0, 0, 0, 1);
m_time = m_time + ts;*/
COleDateTimeSpan ts(0, 0, 0, 1);
m_dtTime = m_dtTime + ts;
}
if(m_iPrevDay!=GetDay())
{
m_iPrevDay=GetDay();
if(GetParent())
GetParent()->PostMessage(WM_DATE_CHANGED);
}
Invalidate(FALSE);
CStatic::OnTimer(nIDEvent);
}
/**********************************************************************************************//**
* Runs this instance
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
void CXAnalogClock::Run()
{
m_nPrevMinute = -1;
SetTimer(1, 1000, NULL);
Invalidate();
UpdateWindow();
m_bStopped = FALSE;
}
/**********************************************************************************************//**
* Stops this instance
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
void CXAnalogClock::Stop()
{
KillTimer(1);
m_bStopped = TRUE;
}
/**********************************************************************************************//**
* Gets the second
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \return The second.
**************************************************************************************************/
int CXAnalogClock::GetSecond()
{
//return m_time.GetSecond();
return m_dtTime.GetSecond();
}
/**********************************************************************************************//**
* Gets the minute
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \return The minute.
**************************************************************************************************/
int CXAnalogClock::GetMinute()
{
//return m_time.GetMinute();
return m_dtTime.GetMinute();
}
/**********************************************************************************************//**
* Gets the hour
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \return The hour.
**************************************************************************************************/
int CXAnalogClock::GetHour()
{
//int hour = m_time.GetHour();
int hour = m_dtTime.GetHour();
if (hour > 12)
hour -= 12;
return hour;
}
/**********************************************************************************************//**
* Gets the day
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \return The day.
**************************************************************************************************/
int CXAnalogClock::GetDay()
{
//int day = m_time.GetDay();
int day = m_dtTime.GetDay();
return day;
}
/**********************************************************************************************//**
* Translates all messages before they are processed by the main message loop
*
* \author Rainer Kühner
* \date 26.02.2018
*
* \param [in,out] pMsg If non-null, the message.
*
* \return True if it succeeds, false if it fails.
**************************************************************************************************/
BOOL CXAnalogClock::PreTranslateMessage(MSG* pMsg)
{
return CStatic::PreTranslateMessage(pMsg);
}
/**********************************************************************************************//**
* Executes the destroy action
*
* \author Rainer Kühner
* \date 26.02.2018
**************************************************************************************************/
void CXAnalogClock::OnDestroy()
{
Stop();
CStatic::OnDestroy();
}
|
ed519a0390965c2ed96d7fc81b0d09f4e5254844 | 9f0e4c0d85a78db555f69bb30cede63a6d19fa6b | /problems/easy/7-reverse-integer.cpp | 20b23a2d6bf0de3a6d46ce50e324d5a31ab2e3ff | [
"MIT"
] | permissive | azartheen/leetcode | d00e4c4e02214f275d53895ad38c6f80fef5a3cd | 4610507de3a45be074c414016dddbe2867e470a1 | refs/heads/master | 2022-12-10T09:13:39.809615 | 2020-08-26T12:28:00 | 2020-08-26T12:28:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 809 | cpp | 7-reverse-integer.cpp | /*
Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1].
For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
*/
class Solution {
public:
int reverse(int x) {
long long ans=0;
while(x){
int m=x%10;
ans=ans*10+m;
x/=10;
}
if(ans>INT_MAX||ans<INT_MIN) return 0;
return ans;
}
};
static const auto io_sync_off = []() {std::ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);return 0;}(); |
73a4894fccf46091380e971287492d3a66984bc5 | 02a4b20c95f0758c7a0acd993f2d4f457522bb83 | /sandbox/data-cleaning.cc | f6d1bae422e96c90c755bda515b15037d60d5195 | [] | no_license | rafaellopesdesa/LAT | cf689d593f8835237fd210030c41c167dc9e7eb1 | a41753df7d7330e4bb470fd7bb9362c2cb55a6a7 | refs/heads/master | 2021-10-23T08:30:53.532962 | 2019-03-15T18:38:31 | 2019-03-15T18:38:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,443 | cc | data-cleaning.cc | // Data cleaning.
// Creates plots to justify TCuts.
// C. Wiseman, 12/11/2016
#include <iostream>
#include <fstream>
#include "TFile.h"
#include "TROOT.h"
#include "TChain.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TLegend.h"
#include "TStyle.h"
#include "TEntryList.h"
#include "GATDataSet.hh"
using namespace std;
void LargeFileCuts(int dsNum);
void TCutSkimmer(int dsNum);
void GetExposure(int dsNum, double &enrExpo, double &natExpo);
void GenerateSpectra(int dsNum);
void CombineSpectra();
void ThresholdCut(int dsNum);
void LowESpectra(int dsNum);
// ====================================================================================
int main(int argc, char** argv)
{
gStyle->SetOptStat(0);
gROOT->ProcessLine(".x ~/env/MJDClintPlotStyle.C");
gROOT->ForceStyle();
// gROOT->ProcessLine( "gErrorIgnoreLevel = 2001;");
int dsNum = 0;
if (argc > 1) dsNum = stoi(argv[1]);
// LargeFileCuts(dsNum);
// TCutSkimmer(dsNum);
// GenerateSpectra(dsNum);
CombineSpectra();
// LowESpectra(dsNum);
// ThresholdCut(dsNum);
}
// ====================================================================================
char theCut[1000];
char basicCut[1000] = "trapENFCal > 0 && trapENFCal < 3000 && gain==0 && isGood && !muVeto && !wfDCBits && !isLNFill1 && !isLNFill2 && channel!=596 && channel!=676 && channel!=676 && channel!=612 && channel!=1104 && channel!=1200 && channel!=1334 && channel!=1336";
char ds1burstCut[1000] = "!(time_s > 2192e3 && time_s < 2195e3) && !(time_s > 7370e3 && time_s <7371e3) && !(time_s > 7840e3 && time_s < 7860e3) && !(time_s > 8384e3 && time_s < 8387e3) && !(time_s > 8984e3 && time_s < 8985e3) && !(time_s > 9002e3 && time_s < 9005e3) && run != 13075 && run != 13093 && run != 13116";
char ds1noisyRunsCut[1000] = "run!=9648 && run!=10663 && run!=10745 && run!=11175 && run!=12445 && run!=12723 && run!=12735 && run!=12745 && run!=12746 && run!=12765 && run!=12766 && run!=12767 && run!=13004";
char ds0_toeCut[1000] = "(kvorrT/trapENFCal) >= 1.2 && (kvorrT/trapENFCal) <= 2.1";
char ds1_toeCut[1000] = "(((kvorrT/trapENFCal) >= 1.2 && (kvorrT/trapENFCal) <= 2.1) || (channel==580 && ((kvorrT/trapENFCal) >= 0.9 && (kvorrT/trapENFCal) <= 2.1)) || (channel==664 && ((kvorrT/trapENFCal) >= 1.1 && (kvorrT/trapENFCal) <= 2.1)))";
char ds1standardCut[1000] = "trapENFCal > 0 && trapENFCal < 3000 && gain==0 && mH==1 && isGood && !muVeto && !wfDCBits && !isLNFill1 && !isLNFill2 && channel!=596 && channel!=676 && channel!=676 && channel!=612 && channel!=1104 && channel!=1200 && channel!=1334 && channel!=1336 && trapETailMin < 0";
void LargeFileCuts(int dsNum)
{
cout << "DS-" << dsNum << endl;
string inFile = Form("~/project/skim-files/skimDS%i*",dsNum);
string outFile = Form("./data/skimDS%i_pt8_basicCutSpec.root",dsNum);
double bins=299, xlo=100, xhi=3000;
TFile *f = new TFile(outFile.c_str(),"RECREATE");
TChain *skimTree = new TChain("skimTree");
skimTree->Add(inFile.c_str());
cout << "Found " << skimTree->GetEntries() << " entries.\n";
// 1 basic cut - raw HG energy spectrum
TH1D *h1 = new TH1D("basicCut","h1",bins,xlo,xhi);
sprintf(theCut,"%s",basicCut);
int cts = skimTree->Project("basicCut","trapENFCal",theCut);
h1->Write();
// 2 trapETailMin cut - significantly cut down on file size for DS-1.
TH1D *h2 = new TH1D("basicTETMCut","h2",bins,xlo,xhi);
sprintf(theCut,"%s && trapETailMin < 0",basicCut);
int cts2 = skimTree->Project("basicTETMCut","trapENFCal",theCut);
h2->Write();
cout << "basic cut: " << cts << " basic+TETM cut: " << cts2 << endl;
f->Close();
}
void TCutSkimmer(int dsNum)
{
cout << "DS-" << dsNum << endl;
string inFile = Form("~/project/skim-files/skimDS%i*",dsNum);
string outFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
sprintf(theCut,"%s && trapETailMin < 0",basicCut);
cout << "Skimming file " << inFile << " using this cut: " << theCut << "\n\n";
TChain *skim = new TChain("skimTree");
skim->Add(inFile.c_str());
skim->Draw(">>entList",theCut,"entrylist GOFF");
TEntryList *entList = (TEntryList*)gDirectory->Get("entList");
skim->SetEntryList(entList);
TFile *f2 = new TFile(outFile.c_str(),"recreate");
TTree *small = skim->CopyTree("");
small->Write();
cout << "Wrote " << small->GetEntries() << " entries.\n";
TNamed thisCut("cutUsedHere",theCut); // save the cut used into the file.
thisCut.Write();
f2->Close();
}
void GetExposure(int dsNum, double &enrExpo, double &natExpo)
{
// NOTE: This is CALCULATED from the code in ds_livetime.cc,
// NOT using the official numbers !
if (dsNum == 0) { enrExpo = 508.6206; natExpo = 186.0343; }
else if (dsNum == 1) { enrExpo = 679.9394; natExpo = 67.3326; }
else if (dsNum == 2) { enrExpo = 114.8518; natExpo = 10.8183; }
else if (dsNum == 3) { enrExpo = 377.6657; natExpo = 83.1516; }
else if (dsNum == 4) { enrExpo = 128.9845; natExpo = 93.1219; }
else if (dsNum == 5) { enrExpo = 1513.5387; natExpo = 603.2865; }
}
void GenerateSpectra(int dsNum)
{
string inFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
double bins=290, xlo=100, xhi=3000;
double enrExp=0, natExp=0;
GetExposure(dsNum,enrExp,natExp);
TCanvas *c1 = new TCanvas("c1","Bob Ross's Canvas",800,600);
TFile *f1 = new TFile(inFile.c_str());
TTree *skim = (TTree*)f1->Get("skimTree");
// ======= "Raw" (basic cut) Spectrum =======
sprintf(theCut,"%s && trapETailMin < 0 && isEnr",basicCut);
TH1D *h1 = new TH1D("h1","h1",bins,xlo,xhi);
skim->Project("h1","trapENFCal",theCut);
h1->GetXaxis()->SetTitle("Energy (trapENFCal)");
h1->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h1->GetYaxis()->SetTitleOffset(1.2);
h1->SetLineColor(kBlue);
h1->Scale(1/enrExp);
h1->SetMaximum(0.25); // 0.25 for 10 kev bins, 0.12 for 2 kev bins
h1->Draw("hist");
c1->Print(Form("./plots/ds%ienr_basicCut.pdf",dsNum));
// ======= R + AvE =======
sprintf(theCut,"%s && trapETailMin < 0 && avse>-1 && isEnr",basicCut);
TH1D *h2 = new TH1D("h2","h2",bins,xlo,xhi);
skim->Project("h2","trapENFCal",theCut);
h2->GetXaxis()->SetTitle("Energy (trapENFCal)");
h2->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h2->GetYaxis()->SetTitleOffset(1.2);
h2->SetLineColor(kRed);
h2->Scale(1/enrExp);
h1->Draw("hist");
h2->Draw("hist same");
TLegend* l1 = new TLegend(0.5,0.65,0.87,0.92);
l1->AddEntry(h1,"basic cut","l");
l1->AddEntry(h2,"basic + avse","l");
l1->Draw("SAME");
c1->Update();
c1->Print(Form("./plots/ds%ienr_avse.pdf",dsNum));
// ======= R + DCR =======
if (dsNum !=2 && dsNum !=5)
{
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && isEnr",basicCut);
TH1D *h3 = new TH1D("h3","h3",bins,xlo,xhi);
skim->Project("h3","trapENFCal",theCut);
h3->GetXaxis()->SetTitle("Energy (trapENFCal)");
h3->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h3->SetLineColor(kRed);
h3->Scale(1/enrExp);
h1->SetMaximum(0.25); // 0.1 for 2 kev bins
h1->Draw("hist");
h3->Draw("hist same");
TLegend* l2 = new TLegend(0.5,0.65,0.87,0.92);
l2->AddEntry(h1,"basic cut","l");
l2->AddEntry(h3,"basic + dcr","l");
l2->Draw("SAME");
c1->Update();
c1->Print(Form("./plots/ds%ienr_dcr.pdf",dsNum));
}
// ======= R + AvE + DCR =======
if (dsNum !=2 && dsNum !=5)
{
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && avse>-1 && isEnr",basicCut);
TH1D *h4 = new TH1D("h4","h4",bins,xlo,xhi);
skim->Project("h4","trapENFCal",theCut);
h4->GetXaxis()->SetTitle("Energy (trapENFCal)");
h4->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h4->GetYaxis()->SetTitleOffset(1.2);
h4->SetLineColor(kRed);
h4->Scale(1/enrExp);
h1->SetMaximum(0.25);
h1->Draw("hist");
h4->Draw("hist same");
TLegend* l3 = new TLegend(0.35,0.65,0.87,0.92);
l3->AddEntry(h1,"basic cut","l");
l3->AddEntry(h4,"basic + avse + dcr","l");
l3->Draw("SAME");
c1->Update();
c1->Print(Form("./plots/ds%ienr_avse_dcr.pdf",dsNum));
}
// ======= Enriched vs. natural, normalized =======
TH1D *h5 = new TH1D("h5","h5",bins,xlo,xhi);
sprintf(theCut,"%s && !isEnr && avse>-1",basicCut);
skim->Project("h5","trapENFCal",theCut);
h5->GetXaxis()->SetTitle("Energy (trapENFCal)");
h5->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h5->GetYaxis()->SetTitleOffset(1.2);
h5->SetLineColor(kBlue);
h5->Scale(1/natExp);
h5->Draw("hist");
TH1D *h6 = new TH1D("h6","h6",bins,xlo,xhi);
sprintf(theCut,"%s && isEnr && avse>-1",basicCut);
skim->Project("h6","trapENFCal",theCut);
h6->Scale(1/enrExp);
h6->SetLineColor(kRed);
h6->Draw("hist same");
TLegend* l4 = new TLegend(0.3,0.7,0.87,0.92);
l4->AddEntry(h5,Form("DS-%i Natural+avse: %.4f kg-d",dsNum,natExp),"l");
l4->AddEntry(h6,Form("DS-%i Enriched+avse: %.4f kg-d",dsNum,enrExp),"l");
l4->Draw("SAME");
c1->Update();
c1->Print(Form("./plots/ds%i_enrVsNat_avse.pdf",dsNum));
}
void CombineSpectra()
{
double bins=290, xlo=100, xhi=3000;
TCanvas *c1 = new TCanvas("c1","Bob Ross's Canvas",800,600);
double ds34enrExp=0, ds34natExp=0;
TH1D *h1 = new TH1D("h1","h1",bins,xlo,xhi); // === R + DCR, Enr ===
TH1D *h2 = new TH1D("h2","h2",bins,xlo,xhi); // === R + DCR, Nat ===
TH1D *h3 = new TH1D("h3","h3",bins,xlo,xhi); // === R + DCR + AvE, Enr ===
TH1D *h4 = new TH1D("h4","h4",bins,xlo,xhi); // === R + DCR + AvE, Nat ===
vector<int> ds = {3,4};
for (auto dsNum : ds)
{
cout << "drawing ds " << dsNum << endl;
string inFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
TFile *f1 = new TFile(inFile.c_str());
TTree *skim = (TTree*)f1->Get("skimTree");
double enrExp=0, natExp=0;
GetExposure(dsNum,enrExp,natExp);
ds34enrExp+=enrExp;
ds34natExp+=natExp;
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && isEnr",basicCut);
TH1D *h5 = new TH1D("h5","h5",bins,xlo,xhi);
skim->Project("h5","trapENFCal",theCut);
h5->Scale(1/enrExp);
h1->Add(h5);
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && !isEnr",basicCut);
TH1D *h6 = new TH1D("h6","h6",bins,xlo,xhi);
skim->Project("h6","trapENFCal",theCut);
h6->Scale(1/natExp);
h2->Add(h6);
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && avse>-1 && isEnr",basicCut);
TH1D *h7 = new TH1D("h7","h7",bins,xlo,xhi);
skim->Project("h7","trapENFCal",theCut);
h7->Scale(1/enrExp);
h3->Add(h7);
sprintf(theCut,"%s && trapETailMin < 0 && dcrctc90 < 0 && avse>-1 && !isEnr",basicCut);
TH1D *h8 = new TH1D("h8","h8",bins,xlo,xhi);
skim->Project("h8","trapENFCal",theCut);
h8->Scale(1/natExp);
h4->Add(h8);
delete h5;
delete h6;
delete h7;
delete h8;
delete f1;
}
// === R + DCR, Enr ===
h1->SetLineColor(kBlue);
h1->GetXaxis()->SetTitle("Energy (trapENFCal)");
h1->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h1->GetYaxis()->SetTitleOffset(1.2);
h1->Draw("hist");
TLegend* l1 = new TLegend(0.4,0.7,0.87,0.92);
l1->AddEntry(h1,Form("DS3,4 enr dcr: %.4f kg-d",ds34enrExp),"l");
l1->Draw("same");
c1->Update();
c1->Print("./plots/sum_enr_dcr.pdf");
// === R + DCR, Nat ===
h2->SetLineColor(kBlue);
h2->GetXaxis()->SetTitle("Energy (trapENFCal)");
h2->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h2->GetYaxis()->SetTitleOffset(1.2);
h2->Draw("hist");
TLegend* l2 = new TLegend(0.4,0.7,0.87,0.92);
l2->AddEntry(h2,Form("DS3,4 nat dcr: %.4f kg-d",ds34natExp),"l");
l2->Draw("same");
c1->Update();
c1->Print("./plots/sum_nat_dcr.pdf");
// === R + DCR + AvE, Enr ===
h3->SetLineColor(kBlue);
h3->GetXaxis()->SetTitle("Energy (trapENFCal)");
h3->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h3->GetYaxis()->SetTitleOffset(1.2);
h3->Draw("hist");
TLegend* l3 = new TLegend(0.4,0.7,0.87,0.92);
l3->AddEntry(h3,Form("DS3,4 enr dcr+avse: %.4f kg-d",ds34enrExp),"l");
l3->Draw("same");
c1->Update();
c1->Print("./plots/sum_enr_dcr_avse.pdf");
// === R + DCR + AvE, Nat ===
h4->SetLineColor(kBlue);
h4->GetXaxis()->SetTitle("Energy (trapENFCal)");
h4->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h4->GetYaxis()->SetTitleOffset(1.2);
h4->Draw("hist");
TLegend* l4 = new TLegend(0.4,0.7,0.87,0.92);
l4->AddEntry(h4,Form("DS3,4 nat dcr+avse: %.4f kg-d",ds34natExp),"l");
l4->Draw("same");
c1->Update();
c1->Print("./plots/sum_nat_dcr_avse.pdf");
// ================= R + AvE (0vBB) ==================
double ds1234enrExp=0, ds1234natExp=0;
TH1D *h9 = new TH1D("h9","h9",bins,xlo,xhi); // === R + AvE, Nat ===
TH1D *h10 = new TH1D("h10","h10",bins,xlo,xhi); // === R + AvE, Enr ===
vector<int> ds_a = {1,2,3,4};
for (auto dsNum : ds_a)
{
cout << "drawing ds " << dsNum << endl;
string inFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
TFile *f1 = new TFile(inFile.c_str());
TTree *skim = (TTree*)f1->Get("skimTree");
double enrExp=0, natExp=0;
GetExposure(dsNum,enrExp,natExp);
ds1234enrExp+=enrExp;
ds1234natExp+=natExp;
sprintf(theCut,"%s && trapETailMin < 0 && avse>-1 && !isEnr",basicCut);
TH1D *h11 = new TH1D("h11","h11",bins,xlo,xhi);
skim->Project("h11","trapENFCal",theCut);
h11->Scale(1/natExp);
h9->Add(h11);
sprintf(theCut,"%s && trapETailMin < 0 && avse>-1 && isEnr",basicCut);
TH1D *h12 = new TH1D("h12","h12",bins,xlo,xhi);
skim->Project("h12","trapENFCal",theCut);
h12->Scale(1/enrExp);
h10->Add(h12);
delete h11;
delete h12;
delete f1;
}
// === R + AvE, Nat ===
h9->SetLineColor(kBlue);
h9->GetXaxis()->SetTitle("Energy (trapENFCal)");
h9->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h9->GetYaxis()->SetTitleOffset(1.2);
h9->Draw("hist");
TLegend* l5 = new TLegend(0.4,0.7,0.87,0.92);
l5->AddEntry(h9,Form("DS1-4 nat avse: %.4f kg-d",ds1234natExp),"l");
l5->Draw("same");
c1->Update();
c1->Print("./plots/sum_nat_avse.pdf");
// === R + AvE, Enr ===
h10->SetLineColor(kBlue);
h10->GetXaxis()->SetTitle("Energy (trapENFCal)");
h10->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h10->GetYaxis()->SetTitleOffset(1.2);
h10->Draw("hist");
TLegend* l6 = new TLegend(0.4,0.7,0.87,0.92);
l6->AddEntry(h10,Form("DS1-4 enr avse: %.4f kg-d",ds1234enrExp),"l");
l6->Draw("same");
c1->Update();
c1->Print("./plots/sum_enr_avse.pdf");
}
void ThresholdCut(int dsNum)
{
string inFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
TFile *f1 = new TFile(inFile.c_str());
TTree *skim = (TTree*)f1->Get("skimTree");
double bins=100, xlo=0, xhi=20;
double enrExp=0, natExp=0;
GetExposure(dsNum,enrExp,natExp);
TCanvas *c1 = new TCanvas("c1","Bob Ross's Canvas",800,600);
// skim->Draw("threshkeV:run>>h3",ds1standardCut,"GOFF");
// TH2D *h3 = (TH2D*)gDirectory->Get("h3");
// h3->Draw("COLZ");
// m1 channel boundaries: 575 - 700, m2 channel boundaries:
// keep a list of run boundaries
map<int,pair<int,int>> runMap = { {0,make_pair(2580,6963)}, {1,make_pair(9422,14387)}, {2,make_pair(14775,15803)}, {3,make_pair(16797,17980)}, {4,make_pair(60000802,60001888)}, {5,make_pair(18623,22142)} };
double firstRun = runMap[dsNum].first;
double lastRun = runMap[dsNum].second;
int runBins = lastRun-firstRun;
TH2D *h3 = new TH2D("h3","h3",280,0,70,runBins,firstRun,lastRun);
skim->Project("h3","run:threshkeV",ds1standardCut);
h3->Draw("");
c1->Print(Form("./plots/ds%iLow_thresh.pdf",dsNum));
}
// Develop the "standard cut" for each dataset:
// Basic Cut, Burst Cut, Noisy Run Cut, Threshold Cut
// Will the wavelet denoising make the noisy run / burst cuts unnecessary?
void LowESpectra(int dsNum)
{
string inFile = Form("./data/skimDS%i_pt8_basicCuts.root",dsNum);
double bins=100, xlo=0, xhi=20;
double enrExp=0, natExp=0;
GetExposure(dsNum,enrExp,natExp);
// ==== Standard DC Cut spectrum ====
TCanvas *c1 = new TCanvas("c1","Bob Ross's Canvas",800,600);
TFile *f1 = new TFile(inFile.c_str());
TTree *skim = (TTree*)f1->Get("skimTree");
sprintf(theCut,"%s && !isEnr",ds1standardCut);
TH1D *h1 = new TH1D("h1","h1",bins,xlo,xhi);
skim->Project("h1","trapENFCal",theCut);
h1->GetXaxis()->SetTitle("Energy (trapENFCal)");
h1->GetYaxis()->SetTitle(Form("Counts/%.1fkev-kg-days",(xhi-xlo)/bins));
h1->GetYaxis()->SetTitleOffset(1.2);
h1->SetLineColor(kBlue);
h1->Scale(1/natExp);
sprintf(theCut,"%s && isEnr",ds1standardCut);
TH1D *h2 = new TH1D("h2","h2",bins,xlo,xhi);
skim->Project("h2","trapENFCal",theCut);
h2->SetLineColor(kRed);
h2->Scale(1/enrExp);
c1->SetLogy();
h1->Draw("hist");
h2->Draw("hist same");
TLegend* l1 = new TLegend(0.4,0.7,0.87,0.92);
l1->AddEntry(h1,Form("DS-%i Nat: %.4f kg-d",dsNum,natExp),"l");
l1->AddEntry(h2,Form("DS-%i Enr: %.4f kg-d",dsNum,enrExp),"l");
l1->Draw("same");
c1->Update();
c1->Print(Form("./plots/ds%iLow_standard.pdf",dsNum));
}
// Then finally generate your cleaned files you pull the waveforms for.
// But don't make too many low-energy cosmogenic plots here,
// because you don't have enough data cleaning power without the waveforms. |
876217b7a2442086e09f75eb8d3b2d3ed738a9d0 | df56c3d9f44132d636c0cef1b70e40034ff09022 | /tcpiputils/dnd/Test/TE_LLMNR/SRC/LlmnrTestQueries.h | 576a03b28f4565556276c899196cab00d00b0787 | [] | no_license | SymbianSource/oss.FCL.sf.os.networkingsrv | e6317d7ee0ebae163572127269c6cf40b98e3e1c | b283ce17f27f4a95f37cdb38c6ce79d38ae6ebf9 | refs/heads/master | 2021-01-12T11:29:50.765762 | 2010-10-14T06:50:50 | 2010-10-14T06:50:50 | 72,938,071 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,420 | h | LlmnrTestQueries.h | // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
#ifndef __LLMNR_TEST_QUERIES_H__
#define __LLMNR_TEST_QUERIES_H__
#include "TestStepLLMNR.h"
#include "dns_qry.h"
/**
* Multicast DNS queries test
*/
class CTestStepLLMNR_Queries : public CTestStepLLMNR
{
public:
CTestStepLLMNR_Queries(CLlmnrTestServer *apLlmnrTestServer = NULL);
~CTestStepLLMNR_Queries();
virtual TVerdict doTestStepL( void );
private:
void TestDNSqueriesIP4L(const TNodeInfo& aNodeInfo);
void TestDNSqueriesIP6L(const TNodeInfo& aNodeInfo);
};
/**
* A slight extention in order to make using this class more convenient
* This makes TDnsQuery accept unicode string parameters.
*/
class TDnsQueryEx : public TDnsQuery
{
public:
void SetData(const TDesC& aData) {iQryData.Copy(aData);}
};
typedef TPckgBuf<TDnsQueryEx> TDnsQueryBufEx;
_LIT(KTestStepLLMNR_Queries,"TestStepLLMNR_Queries");
#endif //__LLMNR_TEST_QUERIES_H__
|
c5521c66e13bff82309d2a23ae5f821db3d30086 | 4a1b388fc7254e7f8fa2b72df9d61999bf7df341 | /Source/rclUE/Private/Msgs/ROS2GridCells.cpp | 21f14deccb85e94d450383d912e43608e3b783b0 | [
"Apache-2.0"
] | permissive | rapyuta-robotics/rclUE | a2055cf772d7ca4d7c36e991ee9c8920e0475fd2 | 7613773cd4c1226957603d705d68a2d2b4a69166 | refs/heads/devel | 2023-08-19T04:06:31.306109 | 2023-07-24T15:23:29 | 2023-07-24T15:23:29 | 334,819,367 | 75 | 17 | Apache-2.0 | 2023-09-06T02:34:56 | 2021-02-01T03:29:17 | C++ | UTF-8 | C++ | false | false | 919 | cpp | ROS2GridCells.cpp | // Copyright 2023 Rapyuta Robotics Co., Ltd.
// This code has been autogenerated from nav_msgs/msg/GridCells.msg - do not modify
#include "Msgs/ROS2GridCells.h"
#include "Kismet/GameplayStatics.h"
void UROS2GridCellsMsg::Init()
{
nav_msgs__msg__GridCells__init(&grid_cells_msg);
}
void UROS2GridCellsMsg::Fini()
{
nav_msgs__msg__GridCells__fini(&grid_cells_msg);
}
const rosidl_message_type_support_t* UROS2GridCellsMsg::GetTypeSupport() const
{
return ROSIDL_GET_MSG_TYPE_SUPPORT(nav_msgs, msg, GridCells);
}
void UROS2GridCellsMsg::SetMsg(const FROSGridCells& Inputs)
{
Inputs.SetROS2(grid_cells_msg);
}
void UROS2GridCellsMsg::GetMsg(FROSGridCells& Outputs) const
{
Outputs.SetFromROS2(grid_cells_msg);
}
void* UROS2GridCellsMsg::Get()
{
return &grid_cells_msg;
}
FString UROS2GridCellsMsg::MsgToString() const
{
/* TODO: Fill here */
checkNoEntry();
return FString();
}
|
2966adc1aedda68c1f0cfd93b5dab7d220c434fb | 6432ea7a083ff6ba21ea17af9ee47b9c371760f7 | /stage0/src/library/projection.cpp | 62a2319022dde85e1d985ba31c5bd2d0ef0eac7e | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"LGPL-3.0-only",
"LicenseRef-scancode-inner-net-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Spencer-94",
"LGPL-2.1-or-later",
"HPND",
"LicenseRef-scancode-pcre",
"ISC",
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"SunPro",
"CMU-Mach"... | permissive | leanprover/lean4 | 4bdf9790294964627eb9be79f5e8f6157780b4cc | f1f9dc0f2f531af3312398999d8b8303fa5f096b | refs/heads/master | 2023-08-30T01:57:45.786981 | 2023-08-29T23:14:28 | 2023-08-29T23:14:28 | 129,571,436 | 2,827 | 311 | Apache-2.0 | 2023-09-14T18:29:16 | 2018-04-15T02:49:20 | Lean | UTF-8 | C++ | false | false | 1,585 | cpp | projection.cpp | /*
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <string>
#include "runtime/sstream.h"
#include "kernel/kernel_exception.h"
#include "kernel/instantiate.h"
#include "kernel/inductive.h"
#include "library/util.h"
#include "library/projection.h"
namespace lean {
extern "C" object * lean_mk_projection_info(object * ctor_name, object * nparams, object * i, uint8 from_class);
extern "C" uint8 lean_projection_info_from_class(object * info);
projection_info::projection_info(name const & c, unsigned nparams, unsigned i, bool inst_implicit):
object_ref(lean_mk_projection_info(c.to_obj_arg(), nat(nparams).to_obj_arg(), nat(i).to_obj_arg(), inst_implicit)) {
}
bool projection_info::is_inst_implicit() const { return lean_projection_info_from_class(to_obj_arg()); }
extern "C" object* lean_add_projection_info(object* env, object* p, object* ctor, object* nparams, object* i, uint8 fromClass);
extern "C" object* lean_get_projection_info(object* env, object* p);
environment save_projection_info(environment const & env, name const & p, name const & mk, unsigned nparams, unsigned i, bool inst_implicit) {
return environment(lean_add_projection_info(env.to_obj_arg(), p.to_obj_arg(), mk.to_obj_arg(), mk_nat_obj(nparams), mk_nat_obj(i), inst_implicit));
}
optional<projection_info> get_projection_info(environment const & env, name const & p) {
return to_optional<projection_info>(lean_get_projection_info(env.to_obj_arg(), p.to_obj_arg()));
}
}
|
43d8ce0ae33fac20d87f605165ab1437e1d5b7b5 | 11cb78f18cc9ada0a5c73f513bf937661734009d | /src_temp/b6.observer/main.cc | 9965a815d607bd5a30df34d37a54f970c5762d0d | [] | no_license | FeiMiao-github/design_pattern | abb0ca7c6bd04b1e87b9b5abc9b67be70623dcae | 71eecd4d58ab50ded06f6609215752f08c02afd4 | refs/heads/master | 2023-08-30T22:29:24.018838 | 2021-09-22T08:30:13 | 2021-09-22T08:30:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,016 | cc | main.cc | /**
* 观察者模式是一种行为模式,用于定义对象之间一种一对多的依赖关系.一旦一个对象的
* 某种状态发生变化时,所有依赖它的对象都得到通知将被更新
*/
#include <iostream>
#include <unordered_set>
class Subject;
class Observer
{
public:
virtual void Update() = 0;
};
class Subject
{
public:
virtual void Attach(Observer *observer)
{
_observers.insert(observer);
}
virtual void Detach(Observer *observer)
{
_observers.erase(observer);
}
virtual void Notify()
{
for (auto &&ob : _observers)
{
ob->Update();
}
}
virtual ~Subject() = default;
protected:
std::unordered_set<Observer*> _observers;
};
class ConcreteSubject
: public Subject
{
public:
typedef std::string State;
void SetState(const State& s)
{
_state = s;
std::cout << "[subject] set state: " << s << "\n";
Notify();
}
const State& GetState()
{
return _state;
}
private:
std::string _state;
};
class ConcreteObserver
: public Observer
{
public:
ConcreteObserver(const std::string &n, ConcreteSubject *subject)
: _name(n),
_subject(subject)
{}
void Update() override
{
std::cout << "[" << _name << "] I know that subject's state is "
<< _subject->GetState() << "\n";
}
private:
const std::string _name;
ConcreteSubject *_subject;
};
void Client()
{
ConcreteSubject subject;
ConcreteObserver observer1("observer1", &subject);
ConcreteObserver observer2("observer2", &subject);
ConcreteObserver observer3("observer3", &subject);
subject.SetState("Hello World\n");
subject.Attach(&observer1);
subject.SetState("Hello XiaoMing\n");
subject.Attach(&observer1);
subject.Attach(&observer2);
subject.Attach(&observer3);
subject.SetState("Hello XiaoWangba\n");
}
int main()
{
Client();
return 0;
} |
9996557165117c0ed4bec55f63f95440a79ea2b0 | 337c9311a4e81368d434bb511a9a6bcfce9534e4 | /SlothEngine/SlothEngine/Source/Logic/Components/RigidBodyComponent.gen.h | e9d3c4375c912b290b029f2301c866d34859be7d | [] | no_license | mylescardiff/PCGUniverse | 8c28a204e25725544d5d0078e18bdc92b19037e6 | 6ca222f96cacf4ade8efd639aa6106cbcd6e2c0d | refs/heads/master | 2023-01-23T23:56:42.935881 | 2020-12-07T21:25:16 | 2020-12-07T21:25:16 | 263,781,376 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 116 | h | RigidBodyComponent.gen.h | #pragma once
struct lua_State;
namespace glua
{
int RigidBodyComponent_ApplyLinearImpulse(lua_State* pState);
} |
255cbb4e2eca82e3ccf7e084d01378a87b0fab42 | 358f42f77bc7b099906d800c900478c23d4404ee | /LAB5/priority_queue.cpp | 387b3eb21e931b0c0068bf6453a0a40ad846b2e9 | [] | no_license | kalli-bonin/Algorithms-and-Data-Structures-Projects | f208b66720d8b4eeb9f09d8ba74b2c404bd5fed2 | 7f53a216bd0dc755ca534cfa968329883b78d97d | refs/heads/master | 2020-04-17T20:38:42.956883 | 2019-01-22T02:50:28 | 2019-01-22T02:50:28 | 166,914,771 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,527 | cpp | priority_queue.cpp | // Alex Petkovic (20728032) and Kalli Bonin (20706260)
#include <iostream>
#include "priority_queue.hpp"
using namespace std;
// Constructor initializes heap to an array of (capacity + 1) size,
// so that there are at most capacity elements in the priority queue.
// Elements should be stored into index 1 and higher.
PriorityQueue::PriorityQueue(unsigned int capacity) {
cout << "TEST";
capacity_ = capacity;
size_ = 0;
heap_ = new TaskItem*[capacity + 1]();
}
// Destructor of the class PriorityQueue.
// It deallocates the memory space allocated for the priority queue.
PriorityQueue::~PriorityQueue() {
for (int i = 0; i <= size_; i++) {
if (heap_[i]) delete heap_[i];
}
delete [] heap_;
}
// Returns the number of elements in the priority queue.
unsigned int PriorityQueue::size() const {
return size_;
}
// Returns true if the priority queue is empty, and false otherwise.
bool PriorityQueue::empty() const {
return size_ == 0;
}
// Returns true if the priority queue is full, and false otherwise.
bool PriorityQueue::full() const {
return size_ == capacity_;
}
// Prints the contents of the priority queue. Format is not specified.
void PriorityQueue::print() const {
for(int i = 1; i <= size_; ++i) {
if(heap_[i])
cout << "heap[" << i << "] = (Priority: " << heap_[i]->priority << ", Description: " << heap_[i]->description << ")" << endl;
}
}
// Returns the max element of the priority queue, but does not remove it.
// If the priority queue is empty, it returns (-1, "NULL").
PriorityQueue::TaskItem PriorityQueue::max() const {
if (empty())
return TaskItem(-1, "NULL");
return *heap_[1];
}
// Inserts the given value into the priority queue.
// Returns true if successful, and false otherwise.
// Priority queue does not change in capacity.
bool PriorityQueue::enqueue( TaskItem val ) {
if (full())
return false;
if (empty()){
heap_[1] = new TaskItem(val);
} else {
int index = size_ + 1;
heap_[index] = new TaskItem(val);
// Ensures heap compliance, by iterating through the heap, moving new TaskItem up
// the heap while its parent's priority is less than its priority.
while (index > 1 && heap_[index / 2]->priority < heap_[index]->priority) {
TaskItem* temp = heap_[index];
heap_[index] = heap_[index/2];
heap_[index/2] = temp;
index /= 2;
}
}
size_++;
return true;
}
// Removes the top element with the maximum value (priority) and rearranges
// the resulting heap. Returns true if successful, and false otherwise.
// Priority queue does not change in capacity.
bool PriorityQueue::dequeue() {
if (empty())
return false;
delete heap_[1];
heap_[1] = heap_[size_];
size_--;
int index = 1;
// Ensures heap compliance, by iterating through the heap, moving the new root TaskITem down the heap
// while its priority is less than its largest child's priority.
while (index < size_ / 2 && index * 2 + 1 < size_ && heap_[index]->priority < std::max(heap_[index * 2]->priority, heap_[index * 2 + 1]->priority)) {
int swapIndex = 0;
if (heap_[index * 2]->priority > heap_[index * 2 + 1]->priority)
swapIndex = index * 2;
else
swapIndex = index * 2 + 1;
TaskItem* temp = heap_[index];
heap_[index] = heap_[swapIndex];
heap_[swapIndex] = temp;
index = swapIndex;
}
return true;
}
|
8c2d1087f049468fe9d47c7eed8ac345c58899ad | 19acb12e2b5552d22464a17b676c5127afadbffa | /WS2812B_BME280_serial_wifi_demo.ino | 37d982e8ebabbe615e39afb94b9da55c99138b84 | [] | no_license | azil3/Mechatronika | 5f89736a4b937257e17ba9db54c41ee943319036 | 55699d53b8fbdf1b176abdf15d6d951ba8b92ebb | refs/heads/main | 2023-04-12T04:40:09.722025 | 2021-04-22T20:25:47 | 2021-04-22T20:25:47 | 360,562,153 | 0 | 0 | null | 2021-04-22T20:25:48 | 2021-04-22T15:12:48 | C++ | UTF-8 | C++ | false | false | 7,944 | ino | WS2812B_BME280_serial_wifi_demo.ino | /*
* Credits / inspiracje i fragmenty kodu zaczerpniete z:
* - serwer WWW: https://randomnerdtutorials.com/esp32-web-server-arduino-ide/
* - obsługa paskow LED WS2812B: https://github.com/adafruit/Adafruit_NeoPixel
* - obsluga zintegrowanego czujnika BME280: https://github.com/adafruit/Adafruit_BME280_Library
*/
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <WiFi.h>
//enter SSID and password to your local Wi-Fi
const char* ssid = "esp";
const char* password = "haslo8266";
#define NEOPIXEL_PIN 12
#define NUMPIXELS 8 //enter the number of pixels (LEDs in your stripe)
#define BME_SDA 21
#define BME_SCL 22
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
TwoWire I2C_BME280 = TwoWire(1);
WiFiServer server(80);
String header; //request will be stored here
unsigned long currentTime = millis();
unsigned long previousTime = 0;
const long timeoutTime = 2000;
//temperature, pressure, and humidity are stored here
float T,P,H;
Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 250
uint8_t LED_r = 0;
uint8_t LED_g = 150;
uint8_t LED_B =1 ;
void startServer()
{
// Connect to Wi-Fi network with SSID and password
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void processServer(){
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
currentTime = millis();
previousTime = currentTime;
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected
currentTime = millis();
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// turns the GPIOs on and off
if (header.indexOf("GET /3/red") >= 0) {
Serial.println("Red color");
LED_r = 150;
LED_g = 0;
LED_b = 0;
} else if (header.indexOf("GET /3/green") >= 0) {
Serial.println("Green color");
LED_r = 0;
LED_g = 150;
LED_b = 0;
} else if (header.indexOf("GET /3/blue") >= 0) {
Serial.println("Blue color");
LED_r = 0;
LED_g = 0;
LED_b = 150;
}
// Display the HTML web page
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
// CSS to style the on/off buttons
// Feel free to change the background-color and font-size attributes to fit your preferences
client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
client.println(".button { background-color: #C0C0C0; border: none; color: black; padding: 5px 5px;");
client.println("text-decoration: none; font-size: 20px; margin: 2px; cursor: pointer;}");
client.println(".buttonr {background-color: #EE0000;}");
client.println(".buttong {background-color: #00EE00;}");
client.println(".buttonb {background-color: #A0A0FF;}</style></head>");
// Web Page Heading
client.println("<body><h1>ESP32 Web Server</h1>");
// Display current state, and ON/OFF buttons for GPIO 26
client.println("<p>Temperature " + String(T) + " deg. C</p>");
client.println("<p>Humidity " + String(H) + " %RH</p>");
client.println("<p>Pressure " + String(P) + " hPa</p>");
// If the output26State is off, it displays the ON button
client.println("<p><a href=\"/3/red\"><button class=\"button buttonr\">RED</button></a></p>");
client.println("<p><a href=\"/3/green\"><button class=\"button buttong\">GREEN</button></a></p>");
client.println("<p><a href=\"/3/blue\"><button class=\"button buttonb\">BLUE</button></a></p>");
client.println("</body></html>");
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
void setup() {
delay(2);
Serial.begin(115200);
delay(2);
//Serial.begin(115200,SERIAL_8N1,U0RX,U0TX,false,1000); //console
while(!Serial); // time to get serial running
Serial.println("WS2812B, BME280, and Web server test");
if( I2C_BME280.begin(BME_SDA,BME_SCL,100000) == false ) Serial.println("I2C_BME280.begin returned false"); else Serial.println("I2C_BME280.begin returned true");
pixels.begin();
unsigned status;
status = bme.begin(0x76, &I2C_BME280); //try 0x77 or 0x76
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
while (1) delay(10);
}
else
{
Serial.println("bme.begin returned true");
}
startServer();
}
int seqNb = 0;
unsigned long blinkCntr_last;
const unsigned long BLINK_TIME = 250;
void handleLedBlink()
{
blinkCntr_last = millis();
Serial.println("blink!");
pixels.clear();
if(seqNb<NUMPIXELS) {
seqNb++;
}
else
{
seqNb = 0;
}
pixels.setPixelColor(seqNb, pixels.Color(LED_r, LED_g, LED_b));
pixels.show();
}
void loop() {
processServer();
if( (millis() - blinkCntr_last) > BLINK_TIME )
{
handleLedBlink();
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
T = bme.readTemperature();
Serial.print("Temperature = ");
Serial.print(T);
Serial.println(" *C");
Serial.print("Pressure = ");
P=bme.readPressure() / 100.0F;
Serial.print(P);
Serial.println(" hPa");
H=bme.readHumidity();
Serial.print("Humidity = ");
Serial.print(H);
Serial.println(" %");
}
}
|
eba1cda90eaeea3545a9e0f0ab97bcdd018ac4de | ea23446065b40fb50d8091f702b83af156a9f9e6 | /scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_kurinnaxx.cpp | 30affa7bee3a23143c33b29c2c34b8de2601bf42 | [] | no_license | IldebrandoS/brandonie-craft | 569fd1d0b85da8209ebba9ce23b6dc933a9e27e6 | 7fc20120710f656b9f2fd91ade058559331a2aeb | refs/heads/master | 2022-11-11T20:27:11.940930 | 2020-07-04T00:56:06 | 2020-07-04T00:56:06 | 265,663,548 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,016 | cpp | boss_kurinnaxx.cpp | /* Copyright (C) 2006 - 2010 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Boss_Kurinnaxx
SD%Complete: 100
SDComment: Set in DB trap Despawn Time
SDCategory: Ruins of Ahn'Qiraj
EndScriptData */
#include "scriptPCH.h"
#include "ruins_of_ahnqiraj.h"
enum
{
GO_TRAP = 180647,
SPELL_MORTALWOUND = 25646,
SPELL_SUMMON_SANDTRAP = 25648,
SPELL_SANDTRAP_EFFECT = 25656,
SPELL_ENRAGE = 26527,
SPELL_WIDE_SLASH = 25814,
SPELL_TRASH = 3391,
SPELL_INVOCATION = 26446,
SAY_BREACHED = 11720
};
struct boss_kurinnaxxAI : public ScriptedAI
{
boss_kurinnaxxAI(Creature* pCreature) : ScriptedAI(pCreature)
{
m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData();
Reset();
}
ScriptedInstance* m_pInstance;
uint32 m_uiInvocation_Timer;
uint32 m_uiMortalWound_Timer;
uint32 m_uiSandTrap_Timer;
uint32 m_uiCleanSandTrap_Timer;
uint32 m_uiTrash_Timer;
uint32 m_uiWideSlash_Timer;
bool m_bHasEnraged;
void Reset() override
{
m_uiInvocation_Timer = 10000;
m_uiMortalWound_Timer = 7000;
m_uiSandTrap_Timer = 7000;
m_uiCleanSandTrap_Timer = 0;
m_uiTrash_Timer = 10000;
m_uiWideSlash_Timer = 15000;
m_bHasEnraged = false;
if (m_pInstance)
m_pInstance->SetData(TYPE_KURINNAXX, NOT_STARTED);
}
void Aggro(Unit* pPuller) override
{
m_creature->SetInCombatWithZone();
if (m_pInstance)
m_pInstance->SetData(TYPE_KURINNAXX, IN_PROGRESS);
}
void JustDied(Unit* pKiller) override
{
if (!m_pInstance)
return;
DoOrSimulateScriptTextForMap(SAY_BREACHED, NPC_OSSIRIAN, m_creature->GetMap());
m_pInstance->SetData(TYPE_KURINNAXX, DONE);
}
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) override
{
if (!m_bHasEnraged && ((m_creature->GetHealth() * 100) / m_creature->GetMaxHealth()) <= 30 && !m_creature->IsNonMeleeSpellCasted(false))
{
DoCast(m_creature->GetVictim(), SPELL_ENRAGE);
m_bHasEnraged = true;
}
}
void UpdateAI(const uint32 uiDiff) override
{
// if no one gets to the trap in 5 seconds delete the trap
if (m_uiCleanSandTrap_Timer < uiDiff)
{
if (GameObject* pTrap = GetClosestGameObjectWithEntry(m_creature, GO_TRAP, DEFAULT_VISIBILITY_DISTANCE))
{
m_creature->SendObjectDeSpawnAnim(pTrap->GetGUID());
pTrap->Delete();
}
}
else
m_uiCleanSandTrap_Timer -= uiDiff;
if (!m_creature->SelectHostileTarget() || !m_creature->GetVictim())
return;
/* Moral wound */
if (m_uiMortalWound_Timer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->GetVictim(), SPELL_MORTALWOUND) == CAST_OK)
m_uiMortalWound_Timer = 9000;
}
else
m_uiMortalWound_Timer -= uiDiff;
/* Summon trap */
if (m_uiSandTrap_Timer < uiDiff)
{
if (Unit* pUnit = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
if (GameObject* trap = m_creature->SummonGameObject(GO_TRAP, pUnit->GetPositionX(), pUnit->GetPositionY(), pUnit->GetPositionZ(), 0, 0, 0, 0, 0, 0))
trap->SetOwnerGuid(m_creature->GetObjectGuid());
m_uiSandTrap_Timer = urand(5100, 7000); /** Random timer for sandtrap between 1 and 7s */
m_uiCleanSandTrap_Timer = 5000;
}
}
else
m_uiSandTrap_Timer -= uiDiff;
/* WideSlash */
if (m_uiWideSlash_Timer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->GetVictim(), SPELL_WIDE_SLASH) == CAST_OK)
m_uiWideSlash_Timer = 10000 + (rand() % 10000);
}
else
m_uiWideSlash_Timer -= uiDiff;
/** Invoque player in front of him */
if (m_uiInvocation_Timer < uiDiff)
{
if (Unit* pUnit = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, nullptr, SELECT_FLAG_PLAYER))
{
float x, y, z;
m_creature->SendSpellGo(pUnit, 25681);
m_creature->GetRelativePositions(10.0f, 0.0f, 0.0f, x, y, z);
pUnit->NearLandTo(x, y, z+3.5f, pUnit->GetOrientation());
m_uiInvocation_Timer = urand(5000, 10000);
}
}
else
m_uiInvocation_Timer -= uiDiff;
/* Trash */
if (m_uiTrash_Timer < uiDiff)
{
if (DoCastSpellIfCan(m_creature->GetVictim(), SPELL_TRASH) == CAST_OK)
m_uiTrash_Timer = 10000 + (rand() % 10000);
}
else
m_uiTrash_Timer -= uiDiff;
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_boss_kurinnaxx(Creature* pCreature)
{
return new boss_kurinnaxxAI(pCreature);
}
void AddSC_boss_kurinnaxx()
{
Script *newscript;
newscript = new Script;
newscript->Name = "boss_kurinnaxx";
newscript->GetAI = &GetAI_boss_kurinnaxx;
newscript->RegisterSelf();
}
|
5f8e652238c26737f4c08b7adce9c58d12b1501f | 335afb4b6b6c1a59f15abd5522cfefcd42aaa071 | /xcomm/src/atomic_rw/rdma_rw_op.hh | 5d2b5fa404466bd3dd65ae404d1f46ded577a012 | [] | no_license | HXLLL/xstore | 669ef8908899a64e614161559efc6e85abc290a4 | 59706c8493c59fc8cd2852790ca8b2cb547d2127 | refs/heads/main | 2023-08-13T06:41:52.484715 | 2021-09-08T00:50:50 | 2021-09-08T00:50:50 | 399,640,738 | 0 | 0 | null | 2021-08-25T00:25:25 | 2021-08-25T00:25:24 | null | UTF-8 | C++ | false | false | 1,198 | hh | rdma_rw_op.hh | #pragma once
#include "./rw_trait.hh"
#include "../../../deps/r2/src/rdma/async_op.hh"
namespace xstore {
namespace xcomm {
namespace rw {
using namespace r2::rdma;
using namespace rdmaio;
class RDMARWOp : public ReadWriteTrait<RDMARWOp> {
AsyncOp<1> op;
Arc<RC> qp;
public:
explicit RDMARWOp(Arc<RC> qp) : qp(qp) {}
/*!
In an RDMA context, the src buf ptr is a remote addr that can be
passed tp r2::rdma::SROp. Basically, it is a wrapper over SROp,
implemented ReadWriteTrait.
*/
auto read_impl(const MemBlock &src, const MemBlock &dest) -> Result<> {
if (unlikely(src.sz > dest.sz)) {
// size not match
return ::rdmaio::Err();
}
op.set_rdma_addr(reinterpret_cast<u64>(src.mem_ptr), qp->remote_mr.value())
.set_read()
.set_payload(static_cast<const u64 *>(dest.mem_ptr), dest.sz,
qp->local_mr.value().lkey);
auto ret = op.execute(this->qp, IBV_SEND_SIGNALED);
if (unlikely(ret != IOCode::Ok)) {
return ::rdmaio::transfer_raw(ret);
}
auto res_p = qp->wait_one_comp();
return ::rdmaio::transfer_raw(res_p);
}
};
} // namespace rw
} // namespace xcomm
} // namespace xstore
|
c4e6d0dbf649310227a964e8ef2f5c707d74ab56 | 3e4fd5153015d03f147e0f105db08e4cf6589d36 | /Cpp/SDK/PlayerNameplate_parameters.h | 36bb26fee515f966b92c3698d79edfa998933c48 | [] | no_license | zH4x-SDK/zTorchlight3-SDK | a96f50b84e6b59ccc351634c5cea48caa0d74075 | 24135ee60874de5fd3f412e60ddc9018de32a95c | refs/heads/main | 2023-07-20T12:17:14.732705 | 2021-08-27T13:59:21 | 2021-08-27T13:59:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,454 | h | PlayerNameplate_parameters.h | #pragma once
// Name: Torchlight3, Version: 4.26.1
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Parameters
//---------------------------------------------------------------------------
// Function PlayerNameplate.PlayerNameplate_C.GetDungeonDecorativeWidgets
struct UPlayerNameplate_C_GetDungeonDecorativeWidgets_Params
{
TArray<class UWidget*> ReturnValue; // (Parm, OutParm, ReturnParm, ContainsInstancedReference)
};
// Function PlayerNameplate.PlayerNameplate_C.GetDifficultyIcon
struct UPlayerNameplate_C_GetDifficultyIcon_Params
{
class UTLImage* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function PlayerNameplate.PlayerNameplate_C.GetLevelText
struct UPlayerNameplate_C_GetLevelText_Params
{
class UTLTextBlock* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function PlayerNameplate.PlayerNameplate_C.GetHardcoreWidget
struct UPlayerNameplate_C_GetHardcoreWidget_Params
{
class UWidget* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function PlayerNameplate.PlayerNameplate_C.GetAccountNameText
struct UPlayerNameplate_C_GetAccountNameText_Params
{
class UTLTextBlock* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
// Function PlayerNameplate.PlayerNameplate_C.GetDisplayNameText
struct UPlayerNameplate_C_GetDisplayNameText_Params
{
class UTLTextBlock* ReturnValue; // (Parm, OutParm, ZeroConstructor, ReturnParm, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
e3aa3200a1e4b2c1cefbd2f1c925497f5b72d9b4 | 93aba8b4e946c81000a5483510db481380895d88 | /include/HumanPlayer.h | 25d4ee7d490e50d3fa62da033b6e6ff2c14ad7af | [] | no_license | keoliva/Mahjong | ca7f4d11dd8a9612c850f7ce02e09c67e48b3dda | f43a8023805534ac81dd7a8a70943c4860fef00e | refs/heads/master | 2021-01-10T08:21:09.219584 | 2018-07-08T06:15:56 | 2018-07-08T06:15:56 | 53,150,576 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 732 | h | HumanPlayer.h | #ifndef HUMANPLAYER_H
#define HUMANPLAYER_H
#include "Player.h"
enum class PlayerStatus {
NONE,
DREW_TILE, DISCARDED_TILE,
DECLARING_MELD
};
class HumanPlayer : public Player
{
public:
bool providedInput;
bool hasProvidedInput();
HumanPlayer();
void setStatus(PlayerStatus status) { curr_status = status; };
Tile * discardTile(int selected_index=0);
void takeTile(tile_t tile);
void setDeclaration(std::pair<Declaration, int> declaration);
void makeMeld(player_tile_t discardedTile=nullptr);
PlayerStatus getStatus() { return curr_status; };
~HumanPlayer();
private:
PlayerStatus curr_status;
};
#endif // HUMANPLAYER_H
|
33d909e9eb5ba3a814948841d0f1d1cb2523b58f | 048fddf3e02996a50163d014987d2a1e0f852b05 | /20140120/c.cpp | ebc7783495ee5dc35c2489c1782d282d43b3e35c | [] | no_license | muhammadali493/Competitive-coding | 2a226d4214ea2a9c39dcd078d449d8791d80a033 | 0a6bb332fb2d05a4e647360a4c933e912107e581 | refs/heads/master | 2023-07-17T08:40:06.201930 | 2020-06-07T07:41:39 | 2020-06-07T07:41:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,474 | cpp | c.cpp | #include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 55;
char maz[N][N];
int color[N][N];
int area1, area2;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int n, m;
bool check(int x, int y) {
return x >= 0 && x < n && y >= 0 && y < m;
}
void bfs(int c, char id, int &area) {
queue<int> que;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (color[i][j] == c) {
que.push(i);
que.push(j);
}
}
}
//cout << c << " " << id << " " << area << endl;
while (!que.empty()) {
int x = que.front(); que.pop();
int y = que.front(); que.pop();
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (!check(nx, ny)) continue;
if (color[nx][ny]) continue;
if (maz[nx][ny] == id) {
area++;
color[nx][ny] = c;
que.push(nx);
que.push(ny);
}
}
}
}
int main() {
while (~scanf("%d%d", &n, &m)) {
for (int i = 0; i < n; i++) { scanf("%s", maz[i]); }
int k, id;
int area1 = 1, area2 = 1;
memset(color, 0, sizeof(color));
color[n - 1][0] = 1;
color[0][m - 1] = 2;
bfs(1, maz[n - 1][0], area1);
bfs(2, maz[0][m - 1], area2);
scanf("%d", &k);
//cout << area1 << " " << area2 << endl;
for (int i = 0; i < k; i++) {
scanf("%d", &id);
if (i & 1) bfs(2, id + '0', area2);
else bfs(1, id + '0', area1);
//cout << area1 << " " << area2 << endl;
}
cout << area1 << endl;
cout << area2 << endl;
}
return 0;
}
|
06800df7b0009bceac2fbc9d88019841c559fc63 | fe30d4efb19a178d66ad60d2cad99c5d4bb51809 | /b.hpp | a4ea3419fa8536a4461cecbcce28adc911e8abbb | [] | no_license | njlr/test-lib-b | eb1160cd42f91e3717d242753214f2856c28520c | 951b2a50a0c6bb38fab689f269fc6725798bb6e9 | refs/heads/master | 2021-01-21T18:43:42.212721 | 2018-11-08T03:06:40 | 2018-11-08T03:06:40 | 92,078,164 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 93 | hpp | b.hpp | #ifndef B_HPP
#define B_HPP
#include <string>
std::string getB() {
return "B";
}
#endif
|
be16e4f85948ea201151dcf1d317ad5bb6a14101 | c922fe81482e55c27a47cefe389543a8efaa1c9a | /functions.cpp | d0fae16eb322b69c5440812ee780099da390cc5b | [] | no_license | UCR-UAS-2020/UCR_UAS_routeCreation_2020 | 8729e7a5023f6855a6d7a558441a26f62ba39838 | 88c6c768911a64fcd5c1e338b6bf2a621a40cb99 | refs/heads/master | 2020-08-12T06:38:42.778981 | 2020-03-24T18:44:05 | 2020-03-24T18:44:05 | 214,707,939 | 0 | 3 | null | 2020-03-24T18:44:06 | 2019-10-12T20:03:25 | C++ | UTF-8 | C++ | false | false | 16,472 | cpp | functions.cpp | #include <vector>
#include <fstream>
#include <string>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <list>
#include <stack>
using namespace std;
#include "prototypes.h"
double EXTRA_FEET_TO_ROUTE = 0; // TODO: Add real value to
// acount for wingspan
double TURN_RADIUS_FT = 150;
double DEFAULT_ALTITUDE = 200;
vector<obstacle> readObstacles(string fileName) {
obstacle temp;
vector<obstacle> temps;
ifstream read(fileName);
if(!read.is_open()){
cout << "Error opening file" << endl;
exit(1);
}
double la;//reads in lattitude val
double lo;//reads in longitude val
int rad;//reads in radius
char com;//will trash commas
while(read >> la >> com >> lo >> com >> rad) {//uses inherent boolean
temp.lat = la;
temp.log = lo; //reads in val
temp.radius = rad;
temps.push_back(temp); //adds to vector
}
read.close();
return temps;
}
vector<obstacle> readObstacles2(string fileName){
obstacle temp;
vector<obstacle> temps;
ifstream read(fileName);
if(!read.is_open()){
cout << "Error opening file" << endl;
exit(1);
}
double deg;//reads in degrees
double min;//reads in minutes
double sec;//reads in
double rad;
char head;
char rand;//will trash commas
bool first = true;
double tempNum = 0;
while(read >> head >> deg >> rand >> min >> rand >> sec){ //uses inherent boolean
if((head == 'S') || (head == 'W')){
tempNum = (deg + (min/60) + (sec/3600)) * -1;
}
else{
tempNum = (deg + (min/60) + (sec/3600));
}
if(first){
temp.lat = tempNum;
first = false;
}
else{
temp.log = tempNum;
first = true;
read >> rad;
temp.radius = rad;
temps.push_back(temp);
}
}
read.close();
return temps;
}
std::list<point> readPoints(string fileName){
point temp;
list<point> temps;
ifstream read(fileName);
if(!read.is_open()) {
cout << "Error opening file" << endl;
exit(1);
}
double la;//reads in lattitude val
double lo;//reads in longitude val
double he;//reads in height
char com;//will trash commas
while(read >> la >> com >> lo >> com >> he) {//uses inherent boolean
temp.lat = la;
temp.log = lo; //reads in val
temp.height = he;
temp.crit = true;
temps.push_back(temp); //adds to list
}
read.close();
return temps;
}
std::list<point> readPoints2(string fileName){
point temp;
list<point> temps;
ifstream read(fileName);
if(!read.is_open()) {
cout << "Error opening file" << endl;
exit(1);
}
double deg;//reads in degrees
double min;//reads in minutes
double sec;//reads in
char head;
char rand;//will trash commas
bool first = true;
double tempNum = 0;
while(read >> head >> deg >> rand >> min >> rand >> sec){ //uses inherent boolean
if((head == 'S') || (head == 'W')){
tempNum = (deg + (min/60) + (sec/3600)) * -1;
}
else{
tempNum = (deg + (min/60) + (sec/3600));
}
if(first){
temp.lat = tempNum;
first = false;
}
else{
temp.log = tempNum;
first = true;
temp.crit = true;
temps.push_back(temp);
}
}
read.close();
return temps;
}
int collides(const point& toCheck, const vector<obstacle>& obstacles){ // int, not bool, returns coliding obstacle index
double x = 0, y = 0;
x = toCheck.log;
y = toCheck.lat;
double h = 0, k = 0, r = 0;
for(unsigned i = 0; i < obstacles.size(); ++i){
h = obstacles.at(i).log;
k = obstacles.at(i).lat;
r = obstacles.at(i).radius;
if(pow((x-h), 2) + pow((y-k), 2) <= pow(r, 2)){
return i;
}
}
return -1;
}
double distanceFt(const point& one, const point& two){
// Using Haversine formula in order to acount for curvature
// likely irrelevant due to actual distances but included just in case
// Note: in the case of resource concervation being an issue, this is one place
// to consider slimming
double distLat = (two.lat - one.lat) * M_PI / 180.0;
double distLon = (two.log - one.log) * M_PI / 180.0;
// convert to radians
double lat1 = (one.lat) * M_PI / 180.0;
double lat2 = (two.lat) * M_PI / 180.0;
// formula
double a = pow(sin(distLat / 2), 2) +
pow(sin(distLon / 2), 2) * cos(lat1) * cos(lat2);
double rad = 20925197 ; // ft. rad of earth
double c = 2 * asin(sqrt(a)); // asin == arcsine
return rad * c;
}
point midpoint(const point& one, const point& two){
point mid;
mid.lat = (one.lat + two.lat) / 2;
mid.log = (one.log + two.log) / 2;
return mid;
}
//Assuming number of div.(variable n) >= 3
//x,y vals; radius; #of sides for poly.
std::list<point> subdivideCircle(const obstacle& o, int n) {
std::list<point> points;
point pt;
for(int i = 0; i < n; ++i) {
pt.log = o.radius * cos(((2 * M_PI) / n) * i) + o.log;
pt.lat = o.radius * sin(((2 * M_PI) / n) * i) + o.lat;
points.push_front(pt);
}
return points;
}
// Given the center of the obstacle,
// its radius, and the number of points we want
// this function will create and return a list
// of said points
// this shoudl be in clockwise order,
// the lat and log of the point will be used
// to find the geographical loc. of the points
// and not just their relation to the circle (which was
// found using simple trig.)
// Distance from a point to a line, will return true for clear
// latitude used as y, longitude as x. Since theire is "no constraint on height" it shall be ignored.
bool pathCheckClear(const point& first, const point& second, const obstacle& toTest){
if(distanceFt(first,second) == 0){
return true;
}
return (toTest.radius + EXTRA_FEET_TO_ROUTE) < (abs(((second.lat - first.lat)*toTest.log) - ((second.log - first.log)*toTest.lat) + (second.log*first.lat) - (second.lat*first.log))) / distanceFt(first, second);
}
// Above: rad+wingspan&misc < 2Area/distance.
// If true, the distance from the center of the obstacle to its perimiter is less than
// the distance from the center to the path, thus the path clears the obstacle.
// Checks if points will requite a turn
bool turnAhead(const point& first, const point& second, const point& third){
trajectory ogPath(first, second);
trajectory potPath(second, third);
double hypoAng = ogPath.angleBetween(potPath);
double maxTurn = turnAngleMax(second, third);
return hypoAng > maxTurn;
}
trajectory::trajectory():coefficientI(0), coefficientJ(0), coefficientK(0){};
trajectory::trajectory(double i, double j, double k):coefficientI(i), coefficientJ(j), coefficientK(k){};
// latitude used as y, longitude as x, height as z
trajectory::trajectory(const point& tail, const point& head): coefficientI(head.log - tail.log), coefficientJ(head.lat - tail.lat), coefficientK(head.height - tail.height){}
double trajectory::angleBetween(const trajectory& second){
double crossScalar = (this->coefficientI * second.coefficientI) + (this->coefficientJ * second.coefficientJ) + (this->coefficientK * second.coefficientK);
double magFirst = sqrt((this->coefficientI * this->coefficientI) + (this->coefficientJ * this->coefficientJ) + (this->coefficientK * this->coefficientK));
double magSecond = sqrt((second.coefficientI * second.coefficientI) + (second.coefficientJ * second.coefficientJ) + (second.coefficientK * second.coefficientK));
return acos(crossScalar/(magFirst*magSecond));
}
double turnAngleMax(const point& center, const point& edge){
double radLength = distanceFt(center, edge) / 2;
return (M_PI / 2) - acos(radLength/TURN_RADIUS_FT);
}
vector<point> arcTurn(point& beg, point& mid, point& end){
vector <point> toReturn(11);
toReturn.at(0) = beg;
toReturn.at(5) = mid;
toReturn.at(10) = end;
point comp1 = midpoint(beg, mid);
point comp2 = midpoint(mid, end);
point center = midpoint(comp1, comp2);
double radiusOfArc = distanceFt(center, comp1);
// find angle between beg, mid, split arc up into points, add
// do the same between mid and end, add
// return
trajectory centBeg(center, beg);
trajectory centMid(center, mid);
trajectory centEnd(center, end);
double begMidAng = centBeg.angleBetween(centMid);
double midEndAng = centMid.angleBetween(centEnd);
double partSpacing1 = (begMidAng * radiusOfArc) / 4;
double partSpacing2 = (midEndAng * radiusOfArc) / 4;
double angToUse1 = partSpacing1 / radiusOfArc;
double angToUse2 = partSpacing2 / radiusOfArc;
for(unsigned i = 1; i <= 4; i++){
point tempPoint1;
point tempPoint2;
angToUse1 = angToUse2 * i;
angToUse2 = angToUse2 * i;
tempPoint1.log = beg.log + (radiusOfArc * sin(angToUse1));
tempPoint1.lat = beg.lat - (radiusOfArc * (1 - cos(angToUse1)));
toReturn.at(i) = tempPoint1;
tempPoint2.log = mid.log + (radiusOfArc * sin(angToUse2));
tempPoint2.lat = mid.lat - (radiusOfArc * (1 - cos(angToUse2)));
toReturn.at(i + 5) = tempPoint2;
}
return toReturn;
}
// Vector -> * length -> add vector to original point for new point
vector<point> radialRevision(point& clearB, point& conf, point& clearE, obstacle& inWay){
point centObs(inWay.lat, inWay.log);
trajectory radExt(centObs, conf);
radExt.coefficientI = (radExt.coefficientI * (inWay.radius + 50));
radExt.coefficientJ = (radExt.coefficientJ * (inWay.radius + 50));
point confExt((radExt.coefficientI + inWay.lat), (radExt.coefficientJ + inWay.log), conf.height);
//if(URGENT: must check if out of bounds) {
// radExt.coefficientI *= -1;
// radExt.coefficientJ *= -1;
// confExt.lat = radExt.coefficientI + inWay.lat;
// confExt.log = radExt.coefficientJ + inWay.log;
// }
// check if in other obstacles?
return arcTurn(clearB, confExt, clearE);
}
void routeWritter(list<waypoint>& wayPointsFin){
cout << "Writing file OwO\n";
ofstream write(finFileName());
if(!write.is_open()){
cout << "\nError opening file for final output. Terminating...\n";
exit(1);
}
write << "{\n\t\"fileType\": \"Plan\",\n";
write << "\"geoFence\": {\n";
write << "\t\t\"cirarcTurncles\": [";
write << "\t\t],\n";
write << "\t\t\"polygons\": [";
write << "\t\t],\n";
write << "\n\"version\": 2\n\t},\n";
write << "\t\"groundStation\": \"QGroundControl\",\n";
write << "\t\"mission\": {\n";
write << "\t\t\"cruiseSpeed\": 12.0,\n";
write << "\t\t\"firmwareType\": 3,\n";
write << "\t\t\"hoverSpeed\": 5,";
write << "\t\t\"items\": [\n";
write << "\t\t\t{\n";
write << "\t\t\t\t\"autoContinue\": true,\n";
write << "\t\t\t\t\"command\": 22,\n";
write << "\t\t\t\t\"doJumpId\": 1,\n";
write << "\t\t\t\t\"frame\": 3,\n";
write << "\t\t\t\t\"params\": [\n";
write << "\t\t\t\t\t 15,\n"; // takeoff pitch
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t null,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 60.96,\n"; // height in meters
write << "\t\t\t\t],\n";
write << "\t\t\t\t\"type\": \"SimpleItem\"\n";
write << "\t\t\t},\n";
int lastTemp = 1;
for(std::list<waypoint>::iterator it= wayPointsFin.begin(); it != wayPointsFin.end(); ++it){
pointWriter(write,*it);
lastTemp = it->sequenceNumber;
}
write << "\t\t\t{\n";
write << "\t\t\t\t\"autoContinue\": true,\n";
write << "\t\t\t\t\"command\": 22,\n";
write << "\t\t\t\t\"doJumpId\": ";
write << lastTemp << ",\n";
write << "\t\t\t\t\"frame\": 3,\n";
write << "\t\t\t\t\"params\": [\n";
write << "\t\t\t\t\t 15,\n"; // takeoff pitch
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t null,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 0,\n";
write << "\t\t\t\t\t 60.96,\n"; // height in meters
write << "\t\t\t\t],\n";
write << "\t\t\t\t\"type\": \"SimpleItem\"\n";
write << "\t\t\t}\n";
write << "\t\t],\n";
write << "\t\t\"plannedHomePosition\": [\n";
write << "\t\t\t38.14575538617687,\n";
write << "\t\t\t-76.42885386,\n";
write << "\t\t\t3\n";
write << "\t\t\"vehicleType\": 1,\n";
write << "\t\t\"versio\": 2\n";
write << "\t},\n";
write << "\t\"rallyPoints\": {\n";
write << "\t\t\"points\": [\n";
write << "\t\t],\n";
write << "\t\t\"version\": 2\n";
write << "\t},\n";
write << "\t\"version\": 1\n";
write << "}\n";
write.close();
cout << "File written :D. Happy Travels" << endl;
}
void pointWriter(ostream& out, const waypoint& toWriteq){
out << "\t\t\t{\n";
out << "\t\t\t\t\"AMSLAltAboveTerrain\": ";
out << toWriteq.height/3.2808 << ',' << endl;
out << "\t\t\t\t\"Altitude\": ";
out << toWriteq.height/3.2808 << ',' << endl;
out << "\t\t\t\t\"AltitudeMode\": 1,\n";
out << "\t\t\t\t\"autoContinue\": true,\n";
out << "\t\t\t\t\"command\": 16,\n";
out << "\t\t\t\t\"doJumpId\": " << toWriteq.sequenceNumber;
out << ",\n";
out << "\t\t\t\t\"frame\": 3,\n";
out << "\t\t\t\t\"params\": [\n";
out << "\t\t\t\t\t0,\n";
out << "\t\t\t\t\t0,\n";
out << "\t\t\t\t\t0,\n";
out << "\t\t\t\t\tnull,\n";
out << "\t\t\t\t\t" << toWriteq.lat << endl; // latitude, y
out << "\t\t\t\t\t" << toWriteq.log << endl; // longitude, x
out << "\t\t\t\t\t" << toWriteq.height/3.2808 << endl;
out << "\t\t\t\t],\n";
out << "\t\t\t\t\"type\": \"SimpleItem\"\n";
out << "\t\t\t},\n";
}
string finFileName(){
cout << "What would you like to call the file? (No spaces, just the name)\nDo not include an extension!\n" << endl;
string temp;
getline(cin, temp);
temp += ".plan";
return temp;
}
vector<point> boundaryReader(string fileName){
point temp;
vector<point> temps;
ifstream read(fileName);
if(!read.is_open()){
cout << "Error opening file. Terminating..." << endl;
exit(1);
}
double deg;//reads in degrees
double min;//reads in minutes
double sec;//reads in seconds
char head;
char rand;//will trash commas
bool first = true;
double tempNum = 0;
while(read >> head >> deg >> rand >> min >> rand >> sec){ //uses inherent boolean
if((head == 'S') || (head == 'W')){
tempNum = (deg + (min/60) + (sec/3600)) * -1;
}
else{
tempNum = (deg + (min/60) + (sec/3600));
}
if(first){
temp.lat = tempNum;
first = false;
}
else{
temp.log = tempNum;
first = true;
temps.push_back(temp);
}
}
read.close();
return temps;
}
double findIntercept(double distance, point& point)
{
double y = point.lat;
double x = point.log;
double intercept = y - (distance * x);
return intercept;
}
bool intersection(point& begPath, point& endPath, point& begBound, point& endBound)
{
double m1;
double m2;
double b1;
double b2;
m1 = distanceFt(begPath, endPath);
m2 = distanceFt(begBound, endBound);
if (m1 == m2)
{
cout << "They do not intersect, they are parallel" << endl;
return false;
}
b1 = findIntercept(m1, endPath);
b2 = findIntercept(m2, endBound);
double x = (b2-b1)/(m1-m2);
double y = (m1*x) + b1;
point intersect;
intersect.log = x;
intersect.lat = y;
point mid;
mid.lat = (begBound.lat + endBound.lat) / 2;
mid.log = (begBound.log + endBound.log) / 2;
double d1 = distanceFt(mid,intersect);
double d2 = distanceFt(begBound,mid);
if (d1 <= d2)
{
return true;
}
else
{
return false;
}
}
|
9b7d9598966d702de0a90e5fb5d4da9ff60ee687 | e97ffd2b17ffd2353ef3e9eae8c093c65a966ca9 | /06-ExceptionsNamespaceConstexpr/11-UsingNamespaceWhyNot/libMath2.h | 3f2f099dbe51878a1ab7d3c8709cb08a69851b9f | [] | no_license | antselevich/cpp19 | f5fe48ae41763f23f3d2745000d2fcdf751c23cb | ebdab1c71abd98d13b099817ff6564766e1222b2 | refs/heads/master | 2022-11-05T12:00:08.198640 | 2019-06-04T16:35:15 | 2019-06-04T16:35:15 | 175,579,557 | 4 | 4 | null | 2022-10-30T00:05:00 | 2019-03-14T08:27:34 | C++ | UTF-8 | C++ | false | false | 60 | h | libMath2.h | #pragma once
#include "libCube.h"
using namespace LibCube;
|
597cca29af23a0612d22ab147a9eaf8be50647e6 | 5bc8070ac4dc6bdfcdff50079f16c65ebd3dad89 | /86_partition_list.cpp | ee319ed2aba24c1207ec8c58b36d4b9b5538b7a5 | [] | no_license | pi5/leetcode_algos | 6c05c3be926d772a43a461049b4578d8a43e6ec8 | da92d4fd5e47ebdb826155a3aa982fbc5ae8ee8b | refs/heads/master | 2021-01-20T11:13:37.490826 | 2015-04-28T23:40:38 | 2015-04-28T23:40:38 | 33,007,929 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,960 | cpp | 86_partition_list.cpp | /*
* Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
*
* You should preserve the original relative order of the nodes in each of the two partitions.
*
* For example,
* Given 1->4->3->2->5->2 and x = 3,
* return 1->2->2->4->3->5.
*/
/*
**
** Definition for singly-linked list.
** struct ListNode {
** int val;
** ListNode *next;
** ListNode(int x) : val(x), next(NULL) {}
** };
*/
class Solution {
public:
ListNode *partition(ListNode *head, int x) {
if (head == NULL) return NULL;
/* Find the first node with value greater than or equal to x */
struct ListNode *p = head, *before = NULL, *after = NULL;
while(p != NULL && p->val < x) {
before = p;
p = p->next;
}
/* Partitioning is not possible */
if (p == NULL) return head;
after = p;
/* Traverse until the end of the list and reposition the out of place node */
while (after!=NULL && after->next != NULL) {
if (after->next->val >= x) {
after = after->next;
}
else {
struct ListNode* temp = after->next->next;
/* Case when partitioning happens at head; update head */
if (p == head) {
head = after->next;
head->next = p;
after->next = temp;
before = head;
}
else {
before->next = after->next;
before = before->next;
before->next = p;
after->next = temp;
}
}
}
return head;
}
};
|
3587624a73813028339b6b019f0215c3fbecde80 | 94f36df647ee913acbf80bc75605079290da342e | /src/main/cpp/regex_arguments_state.hpp | 2a8d950013eaa1ca080febb4714d94fb1cd3804f | [] | no_license | hapass/regex_parser | 75d8b042b1b6da74cd7192c483d47663e62d2e90 | b122ed552dbd8cb0742066b13d91d50d9e2cb0e7 | refs/heads/master | 2020-03-23T08:55:46.591642 | 2018-08-15T20:32:21 | 2018-08-15T20:32:21 | 141,356,503 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 92 | hpp | regex_arguments_state.hpp | #pragma once
namespace regex_parser {
enum RegexArgumentsState { Help, RegexParams };
} |
4e0c23f3945c4eaa4aec22c19369cd5658c4d120 | 18c02706b60a613c399228b2e3cd5bc1d603b68d | /IsingModelSimulations5_2/Tests/IsingTestRenormGroup1D.h | 0a8c2ee705eb964d0f2545595e6d8ce0109f99f7 | [] | no_license | kmkolasinski/pacp | 16dce510e5770f4053de738981d1092b3e801a43 | 30347ef0c185c063c372b61883c8db521f3159ae | refs/heads/master | 2016-09-06T09:51:51.066201 | 2015-03-14T08:22:08 | 2015-03-14T08:22:08 | 32,202,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,458 | h | IsingTestRenormGroup1D.h | /*
* File: IsingTestRenormGroup1D.h
* Author: mkk
*
* Created on 5 de Maio de 2014, 18:09
*/
#ifndef ISINGTESTRENORMGROUP1D_H
#define ISINGTESTRENORMGROUP1D_H
#include "IsingTest.h"
class IsingTestRenormGroup1D : public IsingTest {
public:
IsingTestRenormGroup1D():IsingTest(){
test_name = "Test of renormalisation group transformation with majority rule.";
test_info = string(" Run test to get dependence of temperature (calculated from \n")+
string(" correlation) on step of renormalisation.\n")+
string(" We start with lattice of length which is power of 3.\n")+
string(" We use majority rule to assign a spin for each block of 3 spins\n")+
string(" and calculate temperature (derived from correlations) for such a shorter chain.\n")+
string(" Then we repeat few times the whole operation.\n")+
string(" We expect that for shorter chains the temperature will wander off the critical point:\n")+
string(" in 1-dimensional case it will go further from T=0 K.\n")+
string(" \n The results are saved in proper files:")+
string(" 'IsingTestRenormGroup1D.txt' and 'IsingTestRenormGroup.png' in 'tests_out' directory. \n")+
string(" See run() function for more details.");
info();
run(); // run all calculations
string cmd =string("cd ")+test_dir_output+string(";gnuplot IsingTestRenormGroup1D.plt");
int info = system(cmd.c_str());
}
/**
* Tests Chi in function of Temperature for 1D model
*/
void run(){
cout << " Running test..." << endl;
int chainLength = 100;
double magneticField = 0.0;
int therm_t = 100; //thermalization time
int measure_f = 1; //measure frequency
int prod_t = 10000; //productiontime
int maxGdist = 20; //domain of correlation function extends from 0 to maxGdist-1
int maxTsep = 2;
double initState = 0.7; //values between 0.5 and 1.0
double temp = 1.0;
string fileout = test_dir_output+"IsingTestRenormGroup1D.txt";
ofstream data_out(fileout.c_str());
string fileout2 = test_dir_output+"IsingTestRenormGroup1D_2.txt";
ofstream data_out2(fileout2.c_str());
int coeff=81;
cout << "\n \n chainLength = " << chainLength*coeff << endl;
Ising chain3(chainLength*coeff,temp,magneticField,initState,maxGdist,maxTsep);
chain3.MC_simulation(therm_t,prod_t,measure_f);
chain3.mean_S_correlation(gettotalFname());
data_out << std::scientific << chainLength*coeff << "\t"
<< chain3.Gs[1] << "\t"
<< (1.0 / atanh(chain3.Gs[1] / chain3.Gs[0])) << endl;
for(coeff=81;coeff>3;){
vector<vector<short> > SS3 = readDATAtoVectors(gettotalFname(), chainLength*coeff);
vector<vector<short> >::iterator t;
vector<short>::iterator pos;
fstream DATA(gettotalFname().c_str(), ios::out);
DATA.setf(ios::showpos);
for (unsigned int i = 0; i < SS3.size() ; i++) {
for (int k = 0; k < SS3[0].size() ; k+=3 ) { //loop over chain sites "pos" at fixed time
DATA << (( SS3[i][k] + SS3[i][k+1] + SS3[i][k+2] ) >0?1:-1) << " ";
//cout << i << ":" << SS3[i][k] << " " << SS3[i][k+1] << " " << SS3[i][k+2] ;
//cout << (( SS3[i][k] + SS3[i][k+1] + SS3[i][k+2] ) >0?1:-1) << endl;
}
// for (unsigned int k = 0; k < SS3[0].size() ; k+=3 ) {
// DATA << SS3[i][k] << " ";
// DATA << SS3[i][k] << " ";
// DATA << SS3[i][k] << " ";
// }
DATA << endl;
}
DATA.close();
coeff/=3;
cout << "\n \n chainLength = " << chainLength*coeff << endl;
Ising chain1(chainLength*coeff,temp,magneticField,initState,maxGdist,maxTsep);
chain1.mean_S_correlation(gettotalFname());
data_out << std::scientific << chainLength*coeff << "\t"
<< chain1.Gs[1] << "\t"
<< (1.0 / atanh(chain1.Gs[1] / chain1.Gs[0])) << endl;
}
data_out.close();
for(temp=0.6; temp<4.01; temp+=0.2){
Ising chain3g(chainLength*9,temp,magneticField,initState,maxGdist,maxTsep);
chain3g.MC_simulation(therm_t,prod_t,measure_f);
chain3g.mean_S_correlation(gettotalFname());
vector<vector<short> > SS3 = readDATAtoVectors(gettotalFname(), chainLength*9);
vector<vector<short> >::iterator t;
vector<short>::iterator pos;
fstream DATA(gettotalFname().c_str(), ios::out);
DATA.setf(ios::showpos);
for (unsigned int i = 0; i < SS3.size() ; i++) {
for (int k = 0; k < SS3[0].size() ; k+=3 ) { //loop over chain sites "pos" at fixed time
DATA << (( SS3[i][k] + SS3[i][k+1] + SS3[i][k+2] ) >0?1:-1) << " ";
}
DATA << endl;
}
DATA.close();
cout << "\n \n chainLength = " << chainLength*3 << endl;
Ising chain1g(chainLength*3,temp,magneticField,initState,maxGdist,maxTsep);
chain1g.mean_S_correlation(gettotalFname());
data_out2 << std::scientific << temp << "\t"
<< chain3g.Gs[1] << "\t"
<< chain1g.Gs[1] << "\t"
<< (1.0 / atanh(chain3g.Gs[1] / chain3g.Gs[0])) << "\t"
<< (1.0 / atanh(chain1g.Gs[1] / chain1g.Gs[0])) << endl;
}
data_out2.close();
}// end of run()
};
#endif /* ISINGTESTRENORMGROUP1D_H */
|
fbe360c41d01d74f7d806f3734fd550b0e653ee2 | 5d10f3e547aa0afc40fe0f1bd7e8d5921db01312 | /server_local.cpp | 65cf064a2e8ed42a240c677e8b7fcef7d2aa2e1c | [] | no_license | erakadjiev/solver-cluster | 53efd2f265a14092632f45a4ac7ea41df621267c | df2946311d804993616daab5d02b54b8a20b2974 | refs/heads/master | 2021-01-10T20:10:08.165947 | 2015-03-29T19:08:14 | 2015-03-29T19:08:14 | 33,175,050 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,924 | cpp | server_local.cpp | /*
* server_local.cpp
*
* Created on: Mar 22, 2015
* Author: rakadjiev
*/
#include "server_local.hpp"
#include <cstring>
#include <algorithm>
#include <iostream>
#include <fstream>
//#include <regex>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <unistd.h>
// this is number of logical CPUs, getting physical cores seems more difficult
const int num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
int num_solvers = std::max(2, num_cpus - 1);
int running_solvers = 0;
zsock_t* solver_service;
solver_proc_info* exec_solver(const std::string query){
fflush(stdout);
fflush(stderr);
int p2cPipe[2];
int c2pPipe[2];
if(
pipe(p2cPipe) ||
pipe(c2pPipe)){
std::cerr << "Failed to pipe\n";
return NULL;
}
pid_t pid = fork();
if (pid > 0) {
// parent
close(p2cPipe[0]);
close(c2pPipe[1]);
int ret = write(p2cPipe[1], query.c_str(), query.length()+1);
close(p2cPipe[1]);
return new solver_proc_info(pid, c2pPipe[0]);
}
else if (pid == 0) {
// child
// Terminate child if parent dies (works only in Linux)
prctl(PR_SET_PDEATHSIG, SIGTERM);
if(dup2(p2cPipe[0], STDIN_FILENO) == -1 ||
dup2(c2pPipe[1], STDOUT_FILENO) == -1 ||
dup2(c2pPipe[1], STDERR_FILENO) == -1){
std::cerr << "Failed to redirect stdin/stdout/stderr\n";
exit(1);
}
close(p2cPipe[0]);
close(p2cPipe[1]);
close(c2pPipe[0]);
close(c2pPipe[1]);
int ret = execl("/home/rakadjiev/workspace/stpwrap2/build/stpwrap2", "/home/rakadjiev/workspace/stpwrap2/build/stpwrap2", (char*)NULL);
exit(ret);
}
else {
std::cerr << "Failed to fork!\n";
return NULL;
}
}
int solver_result_handler(zloop_t* reactor, zmq_pollitem_t* child_pipe, void* arg){
int fd = child_pipe->fd;
int readBytes = 1;
char buf[100];
std::string ans;
while((readBytes = read(fd, buf, sizeof(buf)-1)) > 0){
ans.append(buf, readBytes);
}
zloop_poller_end(reactor, child_pipe);
close(fd);
solver_reply_info* rep = (solver_reply_info*)arg;
unsigned short solver_status = 0;
int status;
pid_t res = 0;
while (res == 0){
res = waitpid(rep->pid, &status, WNOHANG | WUNTRACED);
}
if (res < 0) {
std::cerr << "ERROR: waitpid() for STP failed";
solver_status = 3;
}
// From timed_run.py: It appears that linux at least will on
// "occasion" return a status when the process was terminated by a
// signal, so test signal first.
if (WIFSIGNALED(status) || !WIFEXITED(status)) {
std::cerr << "error: STP did not return successfully. Most likely you forgot to run 'ulimit -s unlimited'\n";
solver_status = 3;
}
int exitcode = WEXITSTATUS(status);
if (exitcode==0) {
// has solution
solver_status = 0;
} else if (exitcode==1) {
// doesn't have solution
solver_status = 1;
} else if (exitcode==52) {
// timeout
std::cerr << "STP timed out";
solver_status = 2;
} else {
// some problem
std::cerr << "error: STP did not return a recognized code";
solver_status = 3;
}
--running_solvers;
if(running_solvers == num_solvers-1){
zloop_reader(reactor, solver_service, solver_handler, NULL);
// std::cout << "Some solvers are ready, continuing to accept queries.\n";
}
zmsg_t* ans_msg = zmsg_new();
zmsg_addstr(ans_msg, rep->message_id.c_str());
zmsg_addstr(ans_msg, std::to_string(solver_status).c_str());
if(solver_status == 0){
zmsg_addstr(ans_msg, ans.c_str());
}
zmsg_prepend(ans_msg, &(rep->identity));
zmsg_send(&ans_msg, rep->solver_service);
std::cout << "Sent solver_service answer\n";
delete rep;
return 0;
}
int solver_handler(zloop_t* reactor, zsock_t* solver_service, void *arg){
zmsg_t* msg = zmsg_recv(solver_service);
zframe_t* identity = zmsg_pop(msg);
char* id = zmsg_popstr(msg);
char* que = zmsg_popstr(msg);
zmsg_destroy(&msg);
std::cout << "Received solver_service query\n";
solver_proc_info* proc = exec_solver(que);
zstr_free(&que);
zmq_pollitem_t child_pipe;
child_pipe.socket = NULL;
child_pipe.fd = proc->fd;
child_pipe.events = ZMQ_POLLIN;
solver_reply_info* rep = new solver_reply_info(identity, proc->pid, solver_service, id);
zstr_free(&id);
delete proc;
zloop_poller(reactor, &child_pipe, solver_result_handler, rep);
++running_solvers;
if(running_solvers >= num_solvers){
zloop_reader_end(reactor, solver_service);
// std::cout << "All solvers busy, not accepting more queries.\n";
}
return 0;
}
int main(int argc, char* argv[]){
// if(argc < 2){
// return 1;
// }
int children = std::stoi(argv[1]);
num_solvers = children;
std::cout << "Starting solver service on port 6790...\n";
std::cout << "Maximum parallel solvers: " << num_solvers << "\n";
solver_service = zsock_new_router("ipc:///tmp/solver_service");
assert(solver_service);
zloop_t* reactor = zloop_new();
zloop_reader(reactor, solver_service, solver_handler, NULL);
zloop_start(reactor);
zloop_destroy(&reactor);
zsock_destroy(&solver_service);
std::cout << "Server exiting...\n";
return 0;
}
|
fa25e897e7305895519cc144f23c97c48936d3d4 | e016bcca4d5ce1e42820b8ccce0b5cbdfedce404 | /c/csp/cspj2021t1_share_candy.cpp | 6bb95e99ecdc439d038f7730ef4255535b270de9 | [] | no_license | outrunJ/algorithm | a27794d000ba06062323fd92072a9d689f173c41 | e572344daffd6d4332c1c3947abfbf01a6474c2b | refs/heads/master | 2023-08-25T05:09:38.106608 | 2023-08-15T11:51:29 | 2023-08-15T11:51:29 | 192,428,780 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 234 | cpp | cspj2021t1_share_candy.cpp | /*
* 7 16 23
*/
#include <bits/stdc++.h>
using namespace std;
int n, L, R;
int main() {
scanf("%d%d%d", &n, &L, &R);
if (L / n == R / n) {
printf("%d\n", R % n);
} else {
printf("%d\n", n - 1);
}
}
|
f9bf84d7f28a95ea9f9b543d5014b74dd2d609d9 | 0dffaaa47468511b9a4af66102b5cb020061a6fa | /Descriptor.cpp | 92719e4ceb239cf5cc0f628aa8cf957ec8fee682 | [
"MIT"
] | permissive | e-kohler/CG | 8e4eb5f508449ca37ce0764c538358c33621b028 | 181e437cea64b47ed6a1408041ccfa14c9c900f8 | refs/heads/master | 2021-04-26T23:43:19.605766 | 2018-06-28T01:18:27 | 2018-06-28T01:18:27 | 123,845,223 | 2 | 0 | MIT | 2018-05-03T00:08:39 | 2018-03-05T01:02:40 | C++ | UTF-8 | C++ | false | false | 2,260 | cpp | Descriptor.cpp | #include "Descriptor.h"
#include <iostream>
#include <cstring>
#include "Vector2z.h"
#include <sstream>
#include <list>
#include "Shape.h"
#include "GUI.h"
std::vector<std::string> Descriptor::lines;
void Descriptor::importObject(char* filename){
std::ifstream infile(filename);
std::cout<< "imported" << filename << std::endl;
for (std::string line; getline(infile, line); ){
lines.push_back(line);
}
GUI::test_merge(translator());
}
std::list<Shape*> Descriptor::translator(){
std::list<Shape*> shapes;
std::vector<Vector2z> vertices;
for(auto it = lines.begin(); it != lines.end(); ++it) {
auto line = *it;
auto inst = line.front();
auto pieces = split(line, ' ');
switch(inst){
case 'v':
{
vertices.push_back(Vector2z(std::stof(pieces[1]), std::stof(pieces[2])));
break;
}
case 'f':
{
Polygon* poly = new Polygon("tetra");
for(auto i = 1; i < pieces.size(); i++){
auto piece_index = std::stof(pieces[i]) - 1;
poly->world_coords.push_back(vertices[piece_index]);
}
shapes.push_back(poly);
if(pieces[0] == "ff") {
poly->filled = true;
}
break;
}
case 'l':
{
Line* linha = new Line("line");
auto ind_fcoord = std::stof(pieces[1]) - 1; // -1 para considerar a linha correta quando dentro do vetor
auto ind_scoord = std::stof(pieces[2]) - 1;
std::cout << ind_fcoord << ind_scoord << std::endl;
// std::cout << vertices[ind_fcoord].getX() << " " << vertices[ind_fcoord].getY() << std::endl;
linha->world_coords.push_back(vertices[ind_fcoord]);
linha->world_coords.push_back(vertices[ind_scoord]);
shapes.push_back(linha);
/*
Deveria pegar o vertice da linha piece[1] e piece[2]
e adcionar em Shape.
E então, retornar para a GUI somar a lista de shapes.
*/
break;
}
}
}
return shapes;
}
void Descriptor::exportObject(){
}
const std::vector<std::string> Descriptor::split(const std::string &s, char c) {
std::string buff {""};
std::vector<std::string> v;
for (auto n:s) {
if (n!= c) buff+=n; else
if (n == c && buff != "") {v.push_back(buff); buff="";}
}
if (buff != "") v.push_back(buff);
return v;
} |
0453b43f78c15d6852e110179e16f04d9fcbaa2e | 378194c1cced295926843d5e64c075b5fc43d0d0 | /misc/codes_lab2/dp/plan_subseq.cpp | 0b0dd27b70c984b17dd32744e7a2a6831f267872 | [] | no_license | ojusvini/DAA-Codes | a5693f5c3693d7943c4dea50f1fd3a23490b775b | 5d202104512fba0a58e46530ee375d4c61370ead | refs/heads/master | 2021-01-20T19:05:22.367614 | 2016-08-16T08:31:09 | 2016-08-16T08:31:09 | 65,802,008 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 467 | cpp | plan_subseq.cpp | #include<stdio.h>
#include<string.h>
int max(int a,int b) {
return a>b?a:b;
}
int main() {
char s[100];
scanf("%[^\n]s",s);
//printf("%s",s);
int cl,n,i;
n=strlen(s);
int l[n][n];
for(i=0;i<n;i++) {
l[i][i]=1;
}
int j;
for(cl=2;cl<=n;cl++) {
for(i=0;i<n-cl+1;i++) {
j=i+cl-1;
if(s[i]==s[j] && cl==2) l[i][j]=2;
else if(s[i]==s[j]) l[i][j]=l[i+1][j-1]+2;
else l[i][j]=max(l[i+1][j],l[i][j-1]);
}
}
printf("%d\n",l[0][n-1]);
return 0;
}
|
e9e1f24411eaed06a51bdc1018754fba8ea9e979 | 5ada15984f0c484e9ecc0ec27d87d5b2902a0890 | /npc_version/ref_trace_osl_src/symm_ref_arr.cpp | 244b5276cab99003cd9a846d9e02a69fba790848 | [] | no_license | dongchen-coder/locapo | a1199d6d5821b9446cdcb0cb39361cdc3f535ffd | bb5ef5a6a8077523b0b95deba8baaded6bad6d70 | refs/heads/master | 2021-06-26T11:25:27.554337 | 2020-11-20T04:35:57 | 2020-11-20T04:35:57 | 176,756,501 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,609 | cpp | symm_ref_arr.cpp |
#include "../utility/reference_lease.h"
#include "../utility/data_size.h"
#ifdef ORG
#define M 1024
#define N 1024
#elif defined(TX)
#elif defined(FX)
#elif defined(EX)
#endif
#define A_OFFSET 0
#define B_OFFSET M * M
#define C_OFFSET M * M + M * N
void symm_trace(double* A, double* B, double* C, double alpha, double beta) {
int i, j, k;
double temp2;
for (i = 0; i < M; i++) {
for (j = 0; j < N; j++ ) {
temp2 = 0;
for (k = 0; k < i; k++) {
C[k * N + j] += alpha*B[i * N + j] * A[i * M + k];
temp2 += B[k * N + j] * A[i * M + k];
rtTmpAccess(B_OFFSET + i * N + j, 0, 1);
rtTmpAccess(A_OFFSET + i * M + k, 1, 2);
rtTmpAccess(C_OFFSET + k * N + j, 2, 0);
rtTmpAccess(C_OFFSET + k * N + j, 3, 0);
rtTmpAccess(B_OFFSET + k * N + j, 4, 1);
rtTmpAccess(A_OFFSET + i * M + k, 5, 2);
}
C[i * N + j] = beta * C[i * N + j] + alpha*B[i * N + j] * A[i * M + i] + alpha * temp2;
rtTmpAccess(C_OFFSET + i * N + j, 6, 0);
rtTmpAccess(B_OFFSET + i * N + j, 7, 1);
rtTmpAccess(A_OFFSET + i * M + i, 8, 2);
rtTmpAccess(C_OFFSET + i * N + j, 9, 0);
}
}
return;
}
int main() {
double* A = (double *)malloc(M * M * sizeof(double));
double* B = (double *)malloc(M * N * sizeof(double));
double* C = (double *)malloc(M * N * sizeof(double));
double alpha = 0.2;
double beta = 0.8;
symm_trace(A, B, C, alpha, beta);
OSL_ref(0);
return 0;
}
|
618770207321686a55850b28d5593be0d271a641 | 0ac7f3ba3ce86b1a4b0086921e5f542017210c00 | /src/Packets/DISC.cpp | 5b13b73b87d3216d33c21b4bbcd3fab60f8aa252 | [] | no_license | alonameir/ass3clion | 18db7ecd8db0ca704b84d51ac495c44b15ab77b4 | 9fd78f0360e93c35f1e805d3297718adbecbfc08 | refs/heads/master | 2021-01-11T22:17:24.854507 | 2017-01-20T15:45:52 | 2017-01-20T15:45:52 | 78,943,856 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 213 | cpp | DISC.cpp | //
// Created by alonam on 1/14/17.
//
//#include <Packets/DISC.h>
#include "Packets/Packet.h"
using namespace std;
short DISC::getOpcode() {
return 10;
}
DISC::DISC() : opcode(10) {}
DISC::~DISC() {
}
|
3d5fbd13e18b4c197182057f6e73d73e862a8442 | a035f5c62e5e80d53b05ebc7d2c2d74cc36aeb1e | /kmymoney/mymoney/mymoneytemplate.cpp | 920c63748feae69471f3fffa8c918f02752a0094 | [] | no_license | KDE/kmymoney | 21446a43780634df84f485fa7dd3346b93c95025 | 21bdb88b4135b89f51f0435e995bd61f93a8e85b | refs/heads/master | 2023-08-30T12:21:44.954663 | 2023-08-30T01:46:42 | 2023-08-30T01:46:42 | 42,720,259 | 111 | 51 | null | 2023-06-15T05:20:53 | 2015-09-18T12:19:55 | C++ | UTF-8 | C++ | false | false | 6,439 | cpp | mymoneytemplate.cpp | /*
SPDX-FileCopyrightText: 2020 Thomas Baumgart <tbaumgart@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "mymoneytemplate.h"
// ----------------------------------------------------------------------------
// QT Includes
#include <QFile>
#include <QUrl>
#include <QMap>
#include <QDomDocument>
#include <QDomNode>
#include <QDebug>
// ----------------------------------------------------------------------------
// KDE Includes
#include <KLocalizedString>
// ----------------------------------------------------------------------------
// Project Includes
#if 0
#include "kmymoneyutils.h"
#include "mymoneyfile.h"
#include "mymoneyaccount.h"
#include "mymoneyexception.h"
#include "mymoneyenums.h"
#endif
#include "mymoneyobject_p.h"
bool MyMoneyTemplateLoadResult::isOK() const
{
return (errorLine == -1) && (errorColumn == -1);
}
void MyMoneyTemplateLoadResult::setErrorMsg(const QString& msg)
{
errorMsg = msg;
// make sure isOK() returns false
if (isOK()) {
errorLine = 0;
errorColumn = 0;
}
}
class MyMoneyTemplatePrivate : public MyMoneyObjectPrivate
{
public:
MyMoneyTemplatePrivate() {}
QDomDocument m_doc;
QDomNode m_accounts;
QString m_title;
QString m_shortDesc;
QString m_longDesc;
QString m_locale;
QUrl m_source;
QMap<QString,QString> m_vatAccountMap;
void collectReferencedObjects() override
{
}
MyMoneyTemplateLoadResult loadDescription()
{
MyMoneyTemplateLoadResult result;
int validMask = 0x00;
const int validAccount = 0x01;
const int validTitle = 0x02;
const int validShort = 0x04;
const int validLong = 0x08;
const int invalid = 0x10;
const int validHeader = 0x0F;
QDomElement rootElement = m_doc.documentElement();
if (!rootElement.isNull()
&& rootElement.tagName() == QLatin1String("kmymoney-account-template")) {
QDomNode child = rootElement.firstChild();
while (!child.isNull() && child.isElement()) {
QDomElement childElement = child.toElement();
// qDebug("MyMoneyTemplate::import: Processing child node %s", childElement.tagName().data());
if (childElement.tagName() == QLatin1String("accounts")) {
m_accounts = childElement.firstChild();
validMask |= validAccount;
} else if (childElement.tagName() == QLatin1String("title")) {
m_title = childElement.text();
validMask |= validTitle;
} else if (childElement.tagName() == QLatin1String("shortdesc")) {
m_shortDesc = childElement.text();
validMask |= validShort;
} else if (childElement.tagName() == QLatin1String("longdesc")) {
m_longDesc = childElement.text();
validMask |= validLong;
} else {
result.setErrorMsg(i18n("<p>Invalid tag <b>%1</b> in template file <b>%2</b></p>", childElement.tagName(), m_source.toDisplayString()));
validMask |= invalid;
}
child = child.nextSibling();
}
if (validMask != validHeader) {
if (!(validMask & validAccount)) {
result.setErrorMsg(i18n("<p>Missing tag <b>%1</b> in template file <b>%2</b></p>", QLatin1String("accounts"), m_source.toDisplayString()));
} else if (!(validMask & validTitle)) {
result.setErrorMsg(i18n("<p>Missing tag <b>%1</b> in template file <b>%2</b></p>", QLatin1String("title"), m_source.toDisplayString()));
} else if (!(validMask & validShort)) {
result.setErrorMsg(i18n("<p>Missing tag <b>%1</b> in template file <b>%2</b></p>", QLatin1String("shortdesc"), m_source.toDisplayString()));
} else if (!(validMask & validLong)) {
result.setErrorMsg(i18n("<p>Missing tag <b>%1</b> in template file <b>%2</b></p>", QLatin1String("longdesc"), m_source.toDisplayString()));
}
}
} else {
result.setErrorMsg(i18n("<p>Invalid root element in template file <b>%1</b></p>", m_source.toDisplayString()));
}
return result;
}
};
MyMoneyTemplate::MyMoneyTemplate()
: MyMoneyObject(*(new MyMoneyTemplatePrivate))
{
}
MyMoneyTemplate::MyMoneyTemplate(const QString& id, const MyMoneyTemplate& other)
: MyMoneyObject(*new MyMoneyTemplatePrivate(*other.d_func()), id)
{
}
MyMoneyTemplate::MyMoneyTemplate(const MyMoneyTemplate& other)
: MyMoneyObject(*new MyMoneyTemplatePrivate(*other.d_func()), other.id())
{
}
MyMoneyTemplate::~MyMoneyTemplate()
{
}
MyMoneyTemplateLoadResult MyMoneyTemplate::setAccountTree(QFile* file)
{
Q_D(MyMoneyTemplate);
MyMoneyTemplateLoadResult result;
d->m_doc.setContent(file, &result.errorMsg, &result.errorLine, &result.errorColumn);
if (result.isOK()) {
result = d->loadDescription();
}
return result;
}
const QDomNode& MyMoneyTemplate::accountTree() const
{
Q_D(const MyMoneyTemplate);
return d->m_accounts;
}
const QString& MyMoneyTemplate::title() const
{
Q_D(const MyMoneyTemplate);
return d->m_title;
}
const QString& MyMoneyTemplate::shortDescription() const
{
Q_D(const MyMoneyTemplate);
return d->m_shortDesc;
}
const QString& MyMoneyTemplate::longDescription() const
{
Q_D(const MyMoneyTemplate);
return d->m_longDesc;
}
const QString& MyMoneyTemplate::locale() const
{
Q_D(const MyMoneyTemplate);
return d->m_locale;
}
const QUrl& MyMoneyTemplate::source() const
{
Q_D(const MyMoneyTemplate);
return d->m_source;
}
void MyMoneyTemplate::setTitle(const QString &s)
{
Q_D(MyMoneyTemplate);
d->m_title = s;
}
void MyMoneyTemplate::setShortDescription(const QString &s)
{
Q_D(MyMoneyTemplate);
d->m_shortDesc = s;
}
void MyMoneyTemplate::setLongDescription(const QString &s)
{
Q_D(MyMoneyTemplate);
d->m_longDesc = s;
}
void MyMoneyTemplate::setLocale(const QString& s)
{
Q_D(MyMoneyTemplate);
d->m_locale = s;
}
void MyMoneyTemplate::setSource(const QUrl& s)
{
Q_D(MyMoneyTemplate);
d->m_source = s;
}
|
dc537e399d35d0888b50cc5bc0db9a5b5cd17b0a | 5be4db8430f2ee01f4d4dff66c87a3b0bbb7e60b | /graph-search/572-oil_deposits.cpp | a1779027c94423a395453454948f7a72369b104f | [
"MIT"
] | permissive | stepan-krivanek/onlinejudge | 979491ad8266d8d794de6123e4107c07f33588c4 | 8483e0f721d75c1f5f8747e8430189340f3de3fb | refs/heads/master | 2023-01-06T18:37:09.298074 | 2020-11-13T17:21:49 | 2020-11-13T17:21:49 | 260,999,556 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,931 | cpp | 572-oil_deposits.cpp | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct Plot{
int x;
int y;
};
struct Land{
int* area;
int rows;
int cols;
};
int neightbors[8][2] = {
{-1, -1}, {-1, 0}, {-1, 1}, {0, -1},
{1, -1}, {1, 0}, {1, 1}, {0, 1}
};
void BFS(Land land, Plot plot){
queue<Plot> q;
q.push(plot);
while (!q.empty()){
Plot p = q.front();
q.pop();
for (int i = 0; i < 8; i++){
int row = p.x + neightbors[i][0];
int col = p.y + neightbors[i][1];
int* index = (land.area + col + (row * land.cols));
if ((row >= 0) && (row < land.rows) && (col >= 0) &&
(col < land.cols) && (*index == 1))
{
*index = 0;
Plot tmp = {row, col};
q.push(tmp);
}
}
}
}
int getPockets(Land land){
int components = 0;
int* ptr;
for (int row = 0; row < land.rows; row++){
for (int col = 0; col < land.cols; col++){
ptr = (land.area + col + (row * land.cols));
if (*ptr == 1){
components += 1;
*ptr = 0;
Plot plot = {row, col};
BFS(land, plot);
}
}
}
return components;
}
int main(){
char c;
bool num;
int ROWS, COLS;
while (1){
cin >> ROWS >> COLS;
if(ROWS == 0){
break;
}
int table[ROWS][COLS];
for (int row = 0; row < ROWS; row++){
for (int col = 0; col < COLS; col++){
cin >> c;
if (c == '*'){
num = 0;
} else {
num = 1;
}
table[row][col] = num;
}
}
Land land = {(int*)table, ROWS, COLS};
cout << getPockets(land) << endl;
}
return 0;
} |
cb8c0b42edd4be562811656e6d256d23114d0552 | bf54e544264632d8fb6418d9ad24cede216722dc | /src/twen/intern/Sample.h | cc414939d4bd84b3b64a929f3ef3e985ee20fbb1 | [] | no_license | DCubix/Twist | 0028da8937c5c4d02e68e12a7c4a05074ce7bd42 | d1d3767716b47578071663693023e1e8ef301a28 | refs/heads/master | 2021-07-11T16:25:36.224936 | 2020-06-12T14:24:16 | 2020-06-12T14:24:16 | 143,633,386 | 139 | 11 | null | 2018-09-13T20:41:43 | 2018-08-05T17:23:47 | C | UTF-8 | C++ | false | false | 938 | h | Sample.h | #ifndef TWEN_SAMPLE_H
#define TWEN_SAMPLE_H
#include "Utils.h"
class Sample {
public:
enum State {
Idle = 0,
Attack,
Decay
};
Sample() : m_frame(0), m_sampleRate(0.0f), m_state(Idle) { }
Sample(const Vec<float> data, float sr)
: m_sampleData(data), m_sampleRate(sr), m_frame(0), m_state(Idle)
{ }
Sample(const Str& fileName);
bool valid() const { return !m_sampleData.empty() && m_sampleRate > 0.0f; }
void invalidate() { m_sampleData.clear(); }
Vec<float> sampleData() const { return m_sampleData; }
float sampleRate() const { return m_sampleRate; }
float frame() const { return m_frame; }
float sampleDirect(float sampleRate);
void gate(bool g);
float sample(float sampleRate, bool repeat = false);
void reset() { m_frame = 0; m_state = Idle; }
State state() const { return m_state; }
protected:
Vec<float> m_sampleData;
float m_frame;
float m_sampleRate;
State m_state;
};
#endif // TWEN_SAMPLE_H
|
bdfd408c399280869bad1474a5c7e618d03f0e25 | f4c4e9a7889324a609b579d634456ca898825b6c | /ConsoleApplication2/myImage.cpp | d151aa1a8ad9444eaec3bb5c58453f954148c52f | [] | no_license | vKokoshko/Chess | 116f581d29fee69088da03ea93ef13c13c69958d | 687fad038f64ab0bdbd23a1aabd49109b0a61728 | refs/heads/master | 2021-05-02T01:02:33.264509 | 2017-02-11T22:21:43 | 2017-02-11T22:21:43 | 78,624,985 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 180 | cpp | myImage.cpp | #include "myImage.h"
myImage::myImage()
{
img.create(80, 55, sf::Color(255, 255, 255, 50));
}
myImage::myImage(char *file)
{
img.loadFromFile(file);
}
myImage::~myImage()
{
}
|
bc73af544ae9ae7b27096cc42bf71ff5a1a04183 | f10c4abe6026245d92b4433f5e138015e9116a7c | /include/parser.hpp | d40a623987929c558a72ac42fc207ae865cbbaf3 | [
"MIT"
] | permissive | kim-hyunsu/mini-c | 0ca36486cfed2b143337d9bf6642ab6e8cdaf35d | 2a11d4647376a4ce0ab88664d007569650e8a0ec | refs/heads/master | 2020-04-06T13:42:43.746677 | 2018-12-17T12:11:07 | 2018-12-17T12:11:07 | 157,511,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 426 | hpp | parser.hpp | #ifndef PARSER_H
#define PARSER_H
#include <vector>
#include "Lexer.hpp"
#include "TypeObject.hpp"
#include "ParseTree.hpp"
class Parser {
public:
Lexer lexer;
std::vector<std::pair<void*, Token>> tokens;
int cursor;
TypeObject *typeObject;
std::string currentName;
public:
Parser(std::string filename);
void tokenize();
bool parseAbstractType();
bool parseDeclaration();
bool firstPass();
};
#endif |
704998d3d561924120c0bdd3ffe02d1db29d7e1e | 5986dd142c8f1152f830c09f8248d5f6fb5d6b88 | /calibracao_jp.ino | dc71bdfcfc8b97e4c61f0d16fd6a382184c6a38f | [] | no_license | joaopschmitz/Arduino | ef91bbe15a7f8698533c7357fee8d24472b406d9 | c61e5c4c1d07ece52fe849ee170ab7781729939a | refs/heads/master | 2020-03-10T01:37:57.705620 | 2018-05-17T18:21:23 | 2018-05-17T18:21:23 | 129,115,031 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,666 | ino | calibracao_jp.ino |
#include "DHT.h"
#define DHTTYPE DHT11
#define PIN_DHT11 A5
#define PIN_MQ135 A0 //define pin sensor MQ-135
#define VRL_VALOR 20000 //resistência de carga RL
#define RO_FATOR_AR_LIMPO 3.7 //resistência do sensor em ar limpo ~3.7 de acordo com o datasheet
#define ITERACOES_CALIBRACAO 50 //numero de leituras para calibracao
#define ITERACOES_LEITURA 5 //numero de leituras para analise
#define GAS_CO 0
#define GAS_NH4 1
#define GAS_C02 2
DHT dht(PIN_DHT11, DHTTYPE);
float COCurve[3] = {1.0,0.46,-0.24}; //curva CO aproximada baseada na sensibilidade descrita no datasheet {x,y,deslocamento} baseada em dois pontos
//p1: (log10, log2.9), p2: (log200, log1.4)
//inclinacao = (Y2-Y1)/(X2-X1)
//vetor={x, y, inclinacao}
float NH4Curve[3] = {1.0,0.41,-0.40}; //curva NH4 aproximada baseada na sensibilidade descrita no datasheet {x,y,deslocamento} baseada em dois pontos
//p1: (log10, log2.6), p2(log200, log0.78)
//inclinacao = (Y2-Y1)/(X2-X1)
//vetor={x, y, inclinacao}
float C02Curve[3] ={1.0,0.38,-0.37}; //curva C02 aproximada baseada na sensibilidade descrita no datasheet {x,y,deslocamento} baseada em dois pontos
//p1: (log10, log2.4), p2: (log200, log0.8)
//inclinacao = (Y2-Y1)/(X2-X1)
//vetor={x, y, inclinacao}
float Ro = 10;
void setup()
{
Serial.begin(9600);
Serial.print("Calibrando o sensor MQ2...\n");
Ro = MQCalibration(PIN_MQ135); //calibra o sensor MQ2
Serial.print("Finalizando a calibracao...\n");
Serial.print("Calibracao concluida...\n");
Serial.print("Valor de Ro=");
Serial.print(Ro);
Serial.print("kohm");
Serial.print("\n");
}
void loop()
{
Serial.print("Temperatura: ");
Serial.print(dht.readTemperature());
Serial.print("ºC");
Serial.println(" ");
Serial.print("Humididade: ");
Serial.print(dht.readHumidity());
Serial.println("%");
Serial.println("");
Serial.print("NH4:");
Serial.print(getQuantidadeGasMQ(leitura_MQ2(PIN_MQ135)/Ro,GAS_NH4) );
Serial.print( "ppm " );
Serial.print("CO:");
Serial.print(getQuantidadeGasMQ(leitura_MQ2(PIN_MQ135)/Ro,GAS_CO) );
Serial.print( "ppm " );
Serial.print("C02:");
Serial.print(getQuantidadeGasMQ(leitura_MQ2(PIN_MQ135)/Ro,GAS_C02) );
Serial.print( "ppm " );
Serial.println("");
delay(200);
}
float calcularResistencia(int tensao) //funcao que recebe o tensao (dado cru) e calcula a resistencia efetuada pelo sensor. O sensor e a resistência de carga forma um divisor de tensão.
{
return (((float)VRL_VALOR*(1023-tensao)/tensao));
}
float MQCalibration(int mq_pin) //funcao que calibra o sensor em um ambiente limpo utilizando a resistencia do sensor em ar limpo 3.7
{
int i;
float valor=0;
for (i=0;i<ITERACOES_CALIBRACAO;i++) { //sao adquiridas diversas amostras e calculada a media para diminuir o efeito de possiveis oscilacoes durante a calibracao
valor += calcularResistencia(analogRead(mq_pin));
delay(500);
}
valor = valor/ITERACOES_CALIBRACAO;
valor = valor/RO_FATOR_AR_LIMPO; //o valor lido dividido pelo R0 do ar limpo resulta no R0 do ambiente
return valor;
}
float leitura_MQ2(int mq_pin)
{
int i;
float rs=0;
for (i=0;i<ITERACOES_LEITURA;i++) {
rs += calcularResistencia(analogRead(mq_pin));
delay(50);
}
rs = rs/ITERACOES_LEITURA;
return rs;
}
int getQuantidadeGasMQ(float rs_ro, int gas_id)
{
if ( gas_id == 0 ) {
return calculaGasPPM(rs_ro,NH4Curve);
} else if ( gas_id == 1 ) {
return calculaGasPPM(rs_ro,COCurve);
} else if ( gas_id == 2 ) {
return calculaGasPPM(rs_ro,C02Curve);
}
return 0;
}
int calculaGasPPM(float rs_ro, float *pcurve) //Rs/R0 é fornecido para calcular a concentracao em PPM do gas em questao. O calculo eh em potencia de 10 para sair da logaritmica
{
return (pow(10,( ((log(rs_ro)-pcurve[1])/pcurve[2]) + pcurve[0])));
}
|
66e175d7172f53d28b76da6fbd9012302cd6329b | 251413d8c6c34086debc828e5a56088c0f3cf4cf | /GgafLib/include/jp/ggaf/lib/actor/CappedGraphBarActor.h | 4a1e6882ae4c1901e57a86e9f99f367f70e21973 | [] | no_license | gecchi/MyMain01 | a7311a3e4659a140dd1127b2ea592e7f1ed1a22b | 31ada3d4a434bea4dcd42fc867a52378493b0853 | refs/heads/master | 2023-09-01T14:30:06.410655 | 2023-08-30T14:39:38 | 2023-08-30T14:39:38 | 13,404,587 | 19 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 974 | h | CappedGraphBarActor.h | #ifndef GGAF_LIB_CAPPEDGRAPHBARACTOR_H_
#define GGAF_LIB_CAPPEDGRAPHBARACTOR_H_
#include "jp/ggaf/lib/actor/GraphBarActor.h"
namespace GgafLib {
/**
* 数量バー(両端テクスチャ有り) .
* テクスチャの番号は、 <=> の "<" の番号に合わせること。
* @version 1.00
* @since 2013/09/17
* @author Masatoshi Tsuge
*/
class CappedGraphBarActor : public GraphBarActor {
public:
/**
* コンストラクタ
* @param prm_name
* @param prm_model
* @param prm_pQty
*/
CappedGraphBarActor(const char* prm_name, const char* prm_model, Quantity<int, pixcoord>* prm_pQty);
/**
* コンストラクタ
* @param prm_name
* @param prm_model
* @param prm_pQty
*/
CappedGraphBarActor(const char* prm_name, const char* prm_model);
void processDraw() override;
virtual ~CappedGraphBarActor();
};
}
#endif /*GGAF_LIB_CAPPEDGRAPHBARACTOR_H_*/
|
69f1885bc4f061d0683c0fc0989aefa1026f9c7a | 64589428b06258be0b9b82a7e7c92c0b3f0778f1 | /Codeforces/Gym/220934 Contest ITA Training #1/D.cpp | 8d1f4376ab272c7ece5a5fe426a8b30469bc6b3b | [] | no_license | splucs/Competitive-Programming | b6def1ec6be720c6fbf93f2618e926e1062fdc48 | 4f41a7fbc71aa6ab8cb943d80e82d9149de7c7d6 | refs/heads/master | 2023-08-31T05:10:09.573198 | 2023-08-31T00:40:32 | 2023-08-31T00:40:32 | 85,239,827 | 141 | 27 | null | 2023-01-08T20:31:49 | 2017-03-16T20:42:37 | C++ | UTF-8 | C++ | false | false | 3,788 | cpp | D.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, int> ii;
//Treap para arvore binária de busca
struct node{
string name;
ii x;
int y, size;
node *l, *r;
node(ii _x, string _name){
name = _name;
x = _x;
y = rand();
size = 1;
l = r = NULL;
}
};
//10 vezes mais lento que Red-Black....
//Tome uma array de pontos (x,y) ordenados por x. u é ancestral de v se e somente se y(u) é maior que todos os elementos de u a v, v incluso!
//Split separa entre k-1 e k.
class Treap{
private:
node* root;
void refresh(node* t){
if (t == NULL) return;
t->size = 1;
if (t->l != NULL)
t->size += t->l->size;
if (t->r != NULL)
t->size += t->r->size;
}
void split(node* &t, ii k, node* &a, node* &b){
node * aux;
if(t == NULL){
a = b = NULL;
return;
}
else if(t->x < k){
split(t->r, k, aux, b);
t->r = aux;
refresh(t);
a = t;
}
else{
split(t->l, k, a, aux);
t->l = aux;
refresh(t);
b = t;
}
}
node* merge(node* &a, node* &b){
node* aux;
if(a == NULL) return b;
else if(b == NULL) return a;
if(a->y < b->y){
aux = merge(a->r, b);
a->r = aux;
refresh(a);
return a;
}
else{
aux = merge(a, b->l);
b->l = aux;
refresh(b);
return b;
}
}
node* count(node* t, ii k){
if(t == NULL) return NULL;
else if(k < t->x) return count(t->l, k);
else if(k == t->x) return t;
else return count(t->r, k);
}
int size(node* t){
if (t == NULL) return 0;
else return t->size;
}
node* nth_element(node* t, int n){
if (t == NULL) return NULL;
if(n <= size(t->l)) return nth_element(t->l, n);
else if(n == size(t->l) + 1) return t;
else return nth_element(t->r, n-size(t->l)-1);
}
void del(node* &t){
if (t == NULL) return;
if (t->l != NULL) del(t->l);
if (t->r != NULL) del(t->r);
delete t;
t = NULL;
}
public:
Treap(){ root = NULL; }
~Treap(){ clear(); }
void clear(){ del(root); }
int size(){ return size(root); }
bool insert(ii k, string name){
if(count(root, k) != NULL) return false;
node *a, *b, *c, *d;
split(root, k, a, b);
c = new node(k, name);
d = merge(a, c);
root = merge(d, b);
return true;
}
bool erase(ii k){
node * f = count(root, k);
if(f == NULL) return false;
node *a, *b, *c, *d;
split(root, k, a, b);
split(b, ii(k.first, k.second+1), c, d);
root = merge(a, d);
delete f;
return true;
}
string nth_element(int n){
node* ans = nth_element(root, n);
if (ans == NULL) return nth_element(size());
else return ans->name;
}
};
map<string, ii> sec;
char op[20], code[50];
int main() {
int N, curid = 0;
scanf("%d", &N);
Treap tr;
while(N --> 0) {
scanf(" %s", op);
if (!strcmp(op, "ISSUE")) {
scanf(" %s", code);
if (sec.count(code)) {
printf("EXISTS %d %d\n", sec[code].second, -sec[code].first);
}
else {
printf("CREATED %d 0\n", curid);
ii x = ii(0, curid++);
tr.insert(x, code);
sec[code] = x;
}
}
if (!strcmp(op, "DELETE")) {
scanf(" %s", code);
if (sec.count(code)) {
printf("OK %d %d\n", sec[code].second, -sec[code].first);
tr.erase(sec[code]);
sec.erase(code);
}
else {
printf("BAD REQUEST\n");
}
}
if (!strcmp(op, "RELIABILITY")) {
int m;
scanf(" %s %d", code, &m);
if (sec.count(code)) {
ii x = sec[code];
tr.erase(x);
x.first -= m;
tr.insert(x, code);
sec[code] = x;
printf("OK %d %d\n", sec[code].second, -sec[code].first);
}
else {
printf("BAD REQUEST\n");
}
}
if (!strcmp(op, "FIND")) {
int n;
scanf("%d", &n);
if (sec.empty()) {
printf("EMPTY\n");
}
else {
string code = tr.nth_element(n+1);
printf("OK %s %d %d\n", code.c_str(), sec[code].second, -sec[code].first);
}
}
}
return 0;
} |
74f86002dc1803c78757852552f0380b8717085b | 78a2545501c4e3f92fd8d0d8fe0f44264f7f4c46 | /DS2X/Services.h | 8dd8c544113c3b6f5d0b252b3b2213553930b477 | [
"MIT"
] | permissive | FreeLikeGNU/DS2DLL | 6616220101e51029e5b3b65a3d3efb647dc7f074 | 7288002def8104cbd4f78edc586e6d988048d1d0 | refs/heads/master | 2021-10-20T21:03:27.350888 | 2019-03-01T21:10:31 | 2019-03-01T21:10:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 332 | h | Services.h | #pragma once
class Services {
public:
DefineSingleton(Services, 0x414306);
DefineStaticMethod(CheckAllSkrits, 0x90f01e, void, NO_PARAMS, NO_ARGS);
DefineStaticMethod(CheckSkrit, 0x90ec8f, void, Params(const gpbstring<char>& unk1), Args(unk1));
DefineMethod(GetOutputConsole, 0x90ea3f, siege::Console&, NO_PARAMS, NO_ARGS);
};
|
52c160a99757d0e5d1974efb7a00b9f05d7fcb6a | 62c8d47803da82bc6b7a276e0c54796601c66276 | /src/config/front-ends/qt/available_geometry.cpp | e0ce909b286bc660cbf7fe5043a0c224b6a2067c | [
"MIT",
"GPL-2.0-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | autc04/executor | a01d1c5081251a331067596141422568159a7596 | ada40683c14d9dfb2a660e52378e9864e0d51357 | refs/heads/master | 2023-07-21T14:33:48.612380 | 2023-05-07T21:33:31 | 2023-05-07T21:33:31 | 106,850,181 | 125 | 9 | MIT | 2023-07-07T14:12:07 | 2017-10-13T16:48:51 | C++ | UTF-8 | C++ | false | false | 2,487 | cpp | available_geometry.cpp | #include <QVector>
#include <QRect>
#include <QGuiApplication>
#include <QScreen>
#include <QWindow>
#include <QEventLoop>
#include <QResizeEvent>
QVector<QRect> getScreenGeometries()
{
QVector<QRect> geometries;
for(QScreen *screen : QGuiApplication::screens())
geometries.push_back(screen->geometry());
return geometries;
}
#ifndef __linux__
/* Actually, this should be the Qt-on-anything-but-X11 case. */
QVector<QRect> getAvailableScreenGeometries()
{
QVector<QRect> geometries;
for(QScreen *screen : QGuiApplication::screens())
geometries.push_back(screen->availableGeometry());
return geometries;
}
#else
/* QScreen::availableGeometry() is documented not to work
on multi-screen X11 systems.
If platformName() != "xcb", we can use availableGeometry();
on X11, we instead figure out available screen geometries by opening
invisible maximized windows on each screen.
*/
template <class F>
struct SizeTestWindow : QWindow
{
F f;
SizeTestWindow(F f)
: f(f)
{
}
void resizeEvent(QResizeEvent *evt) override
{
f(evt->size());
}
};
template <class F>
QWindow* makeSizeTestWindow(F f) { return new SizeTestWindow<F>(f); }
QVector<QRect> getAvailableScreenGeometries()
{
if(qApp->platformName() != QLatin1String("xcb"))
{
QVector<QRect> geometries;
for(QScreen *screen : QGuiApplication::screens())
geometries.push_back(screen->availableGeometry());
return geometries;
}
QVector<QWindow*> windows;
int windowCount = 0;
QEventLoop loop;
for(QScreen *screen : QGuiApplication::screens())
{
++windowCount;
QWindow *window = makeSizeTestWindow(
[&loop, &windowCount](QSize sz) {
if(sz.width() > 100 && sz.height() > 100)
{
if(--windowCount <= 0)
loop.exit();
}
}
);
windows.push_back(window);
window->setFlag(Qt::FramelessWindowHint, true);
window->setFlag(Qt::NoDropShadowWindowHint, true);
window->setOpacity(0);
window->resize(100,100);
window->setPosition(screen->availableGeometry().topLeft());
window->showMaximized();
}
loop.exec();
QVector<QRect> geometries;
for(QWindow *w : windows)
{
geometries.push_back(w->geometry());
delete w;
}
return geometries;
}
#endif
|
12550505ddaa2e3fa491c8942ff95b013a30d42d | 5f85e0b9bb0fe18abb874f498c2e34c3db51a590 | /202011231646 - ruya44 (C - OOP)/03_example-code/University-Course-Object-Oriented-Programming-416f93567861fc33b66a4f1f8d8b7a65ebed1ca8/Laboratory/Lab8/OOP1_Lab8_PreLab_152120141003_SafakAkinci/BugiVideoPlayer.cpp | 1dc38c465da07e084e81a34356285da68e883272 | [] | no_license | serdaraltin/Freelance-Works-2020 | 8370c68603d309f55f67adc41b74931a844a4e1a | 7d890a305e764791bf525a170351386eabd957e3 | refs/heads/master | 2023-05-31T07:10:42.806165 | 2021-06-20T20:25:27 | 2021-06-20T20:25:27 | 292,573,849 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,012 | cpp | BugiVideoPlayer.cpp | /*****************************************
* BugiVideoPlayer.cpp *
*****************************************
* IDE : Xcode *
* Author : Şafak AKINCI *
* Experiment 8: Polymorphism *
*****************************************/
#include "BugiVideoPlayer.h" //To know function prototypes of BugiVideoPlayer Class.
//Constructor Function of BugiVideoPlayer Class.
//BugiVideoPlayer Class is derived from VideoPlayer Class, so this constructor function has to call the constructor of VideoPlayer Class.
BugiVideoPlayer::BugiVideoPlayer(int maxVolumeLevel, string supportedFormats[], int supportedFormatCount):VideoPlayer(maxVolumeLevel,supportedFormats,supportedFormatCount)
{
volumeLevel = 50;
}
//Prints that media player crushed!
void BugiVideoPlayer::EjectMedia()
{
cout<<"BugiVideoPlayer:\tMedia player crushed!"<<endl;
}
//Destructor Function of BugiVideoPlayer Class.
BugiVideoPlayer::~BugiVideoPlayer()
{
}
|
ac05959b6ae476d6186dbbe62ba2946d303cf87d | db84bf6382c21920c3649b184f20ea48f54c3048 | /mjdemonstrator/src/MJDemoThermalShieldCan.cc | c0e0e36b2783ae4cef6ed1de1a11621b258c9e33 | [] | no_license | liebercanis/MaGeLAr | 85c540e3b4c5a48edea9bc0520c9d1a1dcbae73c | aa30b01f3c9c0f5de0f040d05681d358860a31b3 | refs/heads/master | 2020-09-20T12:48:38.106634 | 2020-03-06T18:43:19 | 2020-03-06T18:43:19 | 224,483,424 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,364 | cc | MJDemoThermalShieldCan.cc | //---------------------------------------------------------------------------//
//bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
// //
// //
// MaGe Simulation //
// //
// This code implementation is the intellectual property of the //
// MAJORANA and Gerda Collaborations. It is based on Geant4, an //
// intellectual property of the RD44 GEANT4 collaboration. //
// //
// ********************* //
// //
// Neither the authors of this software system, nor their employing //
// institutes, nor the agencies providing financial support for this //
// work make any representation or warranty, express or implied, //
// regarding this software system or assume any liability for its use. //
// By copying, distributing or modifying the Program (or any work based //
// on on the Program) you indicate your acceptance of this statement, //
// and all its terms. //
// //
//bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
//---------------------------------------------------------------------------//
//
// $Id: MGcodeTemplate.cc,v 1.1 2004-12-09 08:58:35 pandola Exp $
//
// CLASS IMPLEMENTATION: MJDemoThermalShieldCan.cc
//
//---------------------------------------------------------------------------//
/**
* SPECIAL NOTES:
* Part origin:
*
*/
//
//---------------------------------------------------------------------------//
/**
* AUTHOR: Matthew Green
* CONTACT: mpgreen@physics.unc.edu
* FIRST SUBMISSION: Sept 10, 2010
*
* REVISION:
*
* 09-10-2010, Created, M. Green
* 01-13-2012, Changed color attribute from red to copper, K. Nguyen
*/
//---------------------------------------------------------------------------//
//
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Tubs.hh"
#include "G4Sphere.hh"
#include "G4UnionSolid.hh"
#include "G4SubtractionSolid.hh"
#include "G4DisplacedSolid.hh"
#include "G4Torus.hh"
#include "G4Material.hh"
#include "G4VisAttributes.hh"
#include "G4Color.hh"
//---------------------------------------------------------------------------//
#include "io/MGLogger.hh"
#include "mjdemonstrator/MJDemoThermalShieldCan.hh"
#include "mjdemonstrator/MJVDemoPart.hh"
//---------------------------------------------------------------------------//
using namespace CLHEP;
MJDemoThermalShieldCan::MJDemoThermalShieldCan(G4String partName, G4String serialNumber) :
MJVDemoPart(partName, serialNumber, "ShieldCanDwg", "Copper-EF")
{;}
MJDemoThermalShieldCan::MJDemoThermalShieldCan(const MJDemoThermalShieldCan & rhs) :
MJVDemoPart(rhs)
{;}
MJDemoThermalShieldCan::~MJDemoThermalShieldCan()
{;}
G4LogicalVolume* MJDemoThermalShieldCan::ConstructPart()
{
G4LogicalVolumeStore *storePtr = G4LogicalVolumeStore::GetInstance();
G4String logicalName = fDrawingNumber + "_" + fPartMaterial;
G4LogicalVolume* pVol = storePtr->GetVolume(logicalName, false);
if (pVol == NULL){
G4Tubs* body = new G4Tubs("body", 6.1*25.4*mm, 6.14*25.4*mm, 5.47*25.4*mm, 0, 2*pi);
G4DisplacedSolid* body2 = new G4DisplacedSolid("body2", body, 0,
G4ThreeVector(0, 0, -5.47*25.4*mm));
G4Sphere* bottom = new G4Sphere("bottom", 52.66*25.4*mm, 52.70*25.4*mm, 0, 2*pi, 0, 6.165*deg);
G4RotationMatrix* rotation = new G4RotationMatrix();
rotation->rotateX(pi);
G4UnionSolid* body3 = new G4UnionSolid("body3", body2, bottom, rotation,
G4ThreeVector(0, 0, 40.92*25.4*mm));
G4Torus* fillet = new G4Torus("fillet", 0.5*25.4*mm, 0.54*25.4*mm, 5.6*25.4*mm, 0, 2*pi);
G4Tubs* cylCut1 = new G4Tubs("cylCut1", 0, 5.6*25.4*mm, 2*25.4*mm, 0, 2*pi);
G4SubtractionSolid* fillet1 = new G4SubtractionSolid("fillet1", fillet, cylCut1);
G4Tubs* cylCut2 = new G4Tubs("cylCut2", 0, 7*25.4*mm, 1*25.4*mm, 0, 2*pi);
G4SubtractionSolid* fillet2 = new G4SubtractionSolid("fillet2", fillet1, cylCut2, 0,
G4ThreeVector(0, 0, 1*25.4*mm));
G4UnionSolid* body4 = new G4UnionSolid("body4", body3, fillet2, 0,
G4ThreeVector(0, 0, -10.94*25.4*mm));
G4Tubs* thruHole = new G4Tubs("thruHole", 0, 0.09675*25.4*mm, 7*25.4*mm, 0, 2*pi);
G4RotationMatrix* rotation1 = new G4RotationMatrix();
rotation1->rotateY(pi/2);
G4SubtractionSolid* body5 = new G4SubtractionSolid("body5", body4, thruHole, rotation1,
G4ThreeVector(0, 0, -0.188*25.4*mm));
G4RotationMatrix* rotation2 = new G4RotationMatrix();
rotation2->rotateZ(2*pi/3);
rotation2->rotateY(pi/2);
G4SubtractionSolid* body6 = new G4SubtractionSolid("body6", body5, thruHole, rotation2,
G4ThreeVector(0, 0, -0.188*25.4*mm));
G4RotationMatrix* rotation3 = new G4RotationMatrix();
rotation3->rotateZ(4*pi/3);
rotation3->rotateY(pi/2);
G4SubtractionSolid* can = new G4SubtractionSolid("can", body6, thruHole, rotation3,
G4ThreeVector(0, 0, -0.188*25.4*mm));
// G4VisAttributes* redVisAtt = new G4VisAttributes(G4Colour(0.8, 0, 0)); // red
G4VisAttributes* copperVisAtt = new G4VisAttributes(G4Colour(0.839,0.373,0.169,1.0)); // New copper color
// redVisAtt->SetForceWireframe( false );
copperVisAtt->SetForceWireframe( false );
G4Material *material = G4Material::GetMaterial(this->GetMaterial());
pVol = new G4LogicalVolume(can, material, logicalName);
// pVol->SetVisAttributes(redVisAtt);
pVol->SetVisAttributes(copperVisAtt);
MGLog(debugging) << "Created Thermal Shield Can Logical" << endlog;
}
else MGLog(debugging) << "Using pre-existing Thermal Shield Can Logical" << endlog;
return pVol;
}
|
82cb6a84e3fb61bbdddb731b1fe7185fe290761d | fff0e0d3a50e9f16a273d24fa6e2fed3a13dc0b9 | /MultimediaPlayer/videowidget.h | 71b948de284d645fc0600e5bab5cdfb9e4b41206 | [] | no_license | AInsolence/QtEducation | faaf0557e690f9be8d02a1d5e32760ec14302dec | 7c00334dd4ec10ce94da0ec4a301fabf090fe58a | refs/heads/master | 2020-05-25T20:06:56.693836 | 2020-02-06T10:21:50 | 2020-02-06T10:21:50 | 187,966,549 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 416 | h | videowidget.h | #ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H
#include <QVideoWidget>
class VideoWidget : public QVideoWidget
{
Q_OBJECT
public:
explicit VideoWidget(QWidget *parent = nullptr);
protected:
virtual void keyPressEvent(QKeyEvent* event) override;
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
};
#endif // VIDEOWIDGET_H
|
d02ce135adb254b2ef3ad9be780db705eaa50db3 | 6986f1bf3e45fa60f709554ab8b39154d34274db | /GamePlay/ARPGMainCharacter.h | 2fa1c9d0f2df830dfd61d75e735c88b865712e1d | [] | no_license | xindelvcheng/ARPGBasic | 4edb14b5be094c16584a70ffc8c81dc8b1dc5e5c | 87cf82797f6caae27f1180ce5094293808d66bd8 | refs/heads/master | 2023-03-16T14:55:36.112074 | 2021-03-06T13:17:34 | 2021-03-06T13:17:34 | 301,295,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,448 | h | ARPGMainCharacter.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "ARPGCharacter.h"
#include "Components/BoxComponent.h"
#include "ARPGMainCharacter.generated.h"
UCLASS()
class AARPGMainCharacter : public AARPGCharacter
{
GENERATED_BODY()
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;
public:
// Sets default values for this character's properties
AARPGMainCharacter();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UPROPERTY(BlueprintReadWrite,Category="ARPGMainCharacter")
APlayerController* MainPlayerController;
/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};
|
abf967cecbe6edb86d85a80b09db7219adb3ece0 | 19194c2f2c07ab3537f994acfbf6b34ea9b55ae7 | /android-33/java/security/cert/X509CRLEntry.def.hpp | 5e51853ab9bcedc7ddf17c9fa0a835a9e97b20ad | [
"GPL-3.0-only"
] | permissive | YJBeetle/QtAndroidAPI | e372609e9db0f96602da31b8417c9f5972315cae | ace3f0ea2678967393b5eb8e4edba7fa2ca6a50c | refs/heads/Qt6 | 2023-08-05T03:14:11.842336 | 2023-07-24T08:35:31 | 2023-07-24T08:35:31 | 249,539,770 | 19 | 4 | Apache-2.0 | 2022-03-14T12:15:32 | 2020-03-23T20:42:54 | C++ | UTF-8 | C++ | false | false | 1,108 | hpp | X509CRLEntry.def.hpp | #pragma once
#include "../../../JObject.hpp"
class JByteArray;
class JObject;
class JString;
namespace java::math
{
class BigInteger;
}
namespace java::security::cert
{
class CRLReason;
}
namespace java::util
{
class Date;
}
namespace javax::security::auth::x500
{
class X500Principal;
}
namespace java::security::cert
{
class X509CRLEntry : public JObject
{
public:
// Fields
// QJniObject forward
template<typename ...Ts> explicit X509CRLEntry(const char *className, const char *sig, Ts...agv) : JObject(className, sig, std::forward<Ts>(agv)...) {}
X509CRLEntry(QJniObject obj) : JObject(obj) {}
// Constructors
X509CRLEntry();
// Methods
jboolean equals(JObject arg0) const;
javax::security::auth::x500::X500Principal getCertificateIssuer() const;
JByteArray getEncoded() const;
java::util::Date getRevocationDate() const;
java::security::cert::CRLReason getRevocationReason() const;
java::math::BigInteger getSerialNumber() const;
jboolean hasExtensions() const;
jint hashCode() const;
JString toString() const;
};
} // namespace java::security::cert
|
b819740a84dfc26a188d51b871f1f588f681567c | 88ae8695987ada722184307301e221e1ba3cc2fa | /net/third_party/quiche/src/quiche/common/simple_buffer_allocator_test.cc | c23d6b7ba9d496db89e8c3a553a3948328e23d21 | [
"BSD-3-Clause"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 1,774 | cc | simple_buffer_allocator_test.cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "quiche/common/simple_buffer_allocator.h"
#include "quiche/common/platform/api/quiche_test.h"
namespace quiche {
namespace {
TEST(SimpleBufferAllocatorTest, NewDelete) {
SimpleBufferAllocator alloc;
char* buf = alloc.New(4);
EXPECT_NE(nullptr, buf);
alloc.Delete(buf);
}
TEST(SimpleBufferAllocatorTest, DeleteNull) {
SimpleBufferAllocator alloc;
alloc.Delete(nullptr);
}
TEST(SimpleBufferAllocatorTest, MoveBuffersConstructor) {
SimpleBufferAllocator alloc;
QuicheBuffer buffer1(&alloc, 16);
EXPECT_NE(buffer1.data(), nullptr);
EXPECT_EQ(buffer1.size(), 16u);
QuicheBuffer buffer2(std::move(buffer1));
EXPECT_EQ(buffer1.data(), nullptr); // NOLINT(bugprone-use-after-move)
EXPECT_EQ(buffer1.size(), 0u);
EXPECT_NE(buffer2.data(), nullptr);
EXPECT_EQ(buffer2.size(), 16u);
}
TEST(SimpleBufferAllocatorTest, MoveBuffersAssignment) {
SimpleBufferAllocator alloc;
QuicheBuffer buffer1(&alloc, 16);
QuicheBuffer buffer2;
EXPECT_NE(buffer1.data(), nullptr);
EXPECT_EQ(buffer1.size(), 16u);
EXPECT_EQ(buffer2.data(), nullptr);
EXPECT_EQ(buffer2.size(), 0u);
buffer2 = std::move(buffer1);
EXPECT_EQ(buffer1.data(), nullptr); // NOLINT(bugprone-use-after-move)
EXPECT_EQ(buffer1.size(), 0u);
EXPECT_NE(buffer2.data(), nullptr);
EXPECT_EQ(buffer2.size(), 16u);
}
TEST(SimpleBufferAllocatorTest, CopyBuffer) {
SimpleBufferAllocator alloc;
const absl::string_view original = "Test string";
QuicheBuffer copy = QuicheBuffer::Copy(&alloc, original);
EXPECT_EQ(copy.AsStringView(), original);
}
} // namespace
} // namespace quiche
|
d131b17d982f8582177542ce860866ea593d8411 | 3adbdf97c7d0c9287b8f81b5f06e9d33b64f0417 | /Chapter06/GA Lunar Lander - Unmanned/CgaLander.cpp | faef5a57cc8b0f2f743cf129540a8a42f5f257b3 | [] | no_license | KingRight/example_code | 7cf8ef473d57b62ee67cc88fc4014c66009b8d57 | 4a36eba494439562875ec711625b833f270256da | refs/heads/master | 2021-01-10T16:43:59.129486 | 2015-12-06T06:15:07 | 2015-12-06T06:15:07 | 47,485,981 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,047 | cpp | CgaLander.cpp | #include "CgaLander.h"
//----------------------CreateStartPopulation---------------------------
//
//-----------------------------------------------------------------------
void CgaLander::CreateStartPopulation()
{
//clear existing population
m_vecPop.clear();
for (int i=0; i<m_iPopSize; i++)
{
m_vecPop.push_back(SGenome(CHROMO_LENGTH));
}
//reset all variables
m_iGeneration = 0;
m_iFittestGenome = 0;
m_dBestFitness = 0;
m_dTotalFitness = 0;
}
//-------------------------GrabNBest----------------------------------
//
// This works like an advanced form of elitism by inserting NumCopies
// copies of the NBest most fittest genomes into a population vector
//--------------------------------------------------------------------
void CgaLander::GrabNBest(int NBest,
const int NumCopies,
vector<SGenome> &vecPop)
{
//add the required amount of copies of the n most fittest
//to the supplied vector
while(NBest--)
{
for (int i=0; i<NumCopies; ++i)
{
vecPop.push_back(m_vecPop[(m_iPopSize - 1) - NBest]);
}
}
}
//--------------------------RouletteWheelSelection-----------------
//
// selects a member of the population by using roulette wheel
// selection as described in the text.
//------------------------------------------------------------------
SGenome& CgaLander::RouletteWheelSelection()
{
double fSlice = RandFloat() * m_dTotalFitness;
double cfTotal = 0.0;
int SelectedGenome = 0;
for (int i=0; i<m_iPopSize; ++i)
{
cfTotal += m_vecPop[i].dFitness;
if (cfTotal > fSlice)
{
SelectedGenome = i;
break;
}
}
return m_vecPop[SelectedGenome];
}
//----------------------------Mutate---------------------------------
//
//--------------------------------------------------------------------
void CgaLander::Mutate(vector<SGene> &vecActions)
{
for (int gene=0; gene<vecActions.size(); ++gene)
{
//do we mutate the action?
if (RandFloat() < m_dMutationRate)
{
vecActions[gene].action = (action_type)RandInt(0,3);
}
//do we mutate the duration?
if (RandFloat() < m_dMutationRate/2)
{
vecActions[gene].duration += RandomClamped()*MAX_MUTATION_DURATION;
//clamp the duration
Clamp(vecActions[gene].duration, 0, MAX_ACTION_DURATION);
}
}//next gene
}
//--------------------------- CrossoverMulti -----------------------------
//
// This function performs multipoint crossover on the genes. That is to
// say for each chromosome where crossover is to be performed we determine
// a swap rate and iterate through each chromosome swap over individual
// genes where appropriate.
//-------------------------------------------------------------------------
void CgaLander::CrossoverMulti( const vector<SGene> &mum,
const vector<SGene> &dad,
vector<SGene> &baby1,
vector<SGene> &baby2)
{
//just return parents as offspring dependent on the rate
//or if parents are the same
if ( (RandFloat() > m_dCrossoverRate) || (mum == dad))
{
baby1 = mum;
baby2 = dad;
return;
}
//first determine a swapping rate for this chromosome
float SwapRate = RandFloat()*CHROMO_LENGTH;
for (int gene=0; gene<mum.size(); ++gene)
{
if (RandFloat() < SwapRate)
{
//switch the genes at this point
baby1.push_back(dad[gene]);
baby2.push_back(mum[gene]);
}
else
{
//just copy into offspring
baby1.push_back(mum[gene]);
baby2.push_back(dad[gene]);
}
}//next gene
}
//------------------------------ UpdatePop -----------------------------
//
//----------------------------------------------------------------------
void CgaLander::UpdatePop(vector<SGenome> &vOldPop)
{
m_vecPop = vOldPop;
vOldPop = Epoch();
}
//--------------------------------Epoch---------------------------------
//
// This is the workhorse of the GA. It first updates the fitness
// scores of the population then creates a new population of
// genomes using the Selection, Crossover and Mutation operators
// we have discussed
//----------------------------------------------------------------------
vector<SGenome> CgaLander::Epoch()
{
//create some storage for the baby genomes
vector<SGenome> vecBabyGenomes;
//sort the population (for scaling and elitism)
sort(m_vecPop.begin(), m_vecPop.end());
CalculateBestWorstAvTot();
//Now to add a little elitism we shall add in some copies of the
//fittest genomes. Make sure we add an EVEN number or the roulette wheel
//sampling will crash
if (!(NUM_COPIES_ELITE * NUM_ELITE % 2))
{
GrabNBest(NUM_ELITE, NUM_COPIES_ELITE, vecBabyGenomes);
}
while (vecBabyGenomes.size() < m_iPopSize)
{
//select 2 parents
SGenome mum = RouletteWheelSelection();
SGenome dad = RouletteWheelSelection();
//operator - crossover
SGenome baby1, baby2;
CrossoverMulti(mum.vecActions,
dad.vecActions,
baby1.vecActions,
baby2.vecActions);
//operator - mutate
Mutate(baby1.vecActions);
Mutate(baby2.vecActions);
//add to new population
vecBabyGenomes.push_back(baby1);
vecBabyGenomes.push_back(baby2);
}
//copy babies back into starter population
m_vecPop = vecBabyGenomes;
//increment the generation counter
++m_iGeneration;
return m_vecPop;
}
//-----------------------CalculateBestWorstAvTot-----------------------
//
// calculates the fittest and weakest genome and the average/total
// fitness scores. Assumes the genomes have been sorted
//---------------------------------------------------------------------
void CgaLander::CalculateBestWorstAvTot()
{
m_dTotalFitness = 0;
for (int i=0; i<m_iPopSize; ++i)
{
m_dTotalFitness += m_vecPop[i].dFitness;
}//next chromo
m_dAverageFitness = m_dTotalFitness / m_iPopSize;
m_iFittestGenome = 0;
m_dBestFitness = m_vecPop[m_iPopSize - 1].dFitness;
m_dWorstFitness = m_vecPop[0].dFitness;
}
|
f0dcf66000565f8963d06c7cc030d5196f87c96f | 21842e95ac3518a1fc6cab3b0d36741f0b56a02e | /C17_chapter2/C17_chapter2/using_set.cpp | eb4f8da732d50872ef6ea72539aafaa887d745be | [] | no_license | art-lux/C17_stl_features | 6e7e8f5f0b289fed30ec05f5ece57119fe0aaad4 | bb7cd1ce76753003652130e91e0be6f051e1ebd9 | refs/heads/master | 2020-08-02T10:14:52.931711 | 2019-10-08T15:36:54 | 2019-10-08T15:36:54 | 211,314,180 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 317 | cpp | using_set.cpp | #include <set>
#include <iostream>
#include <iterator>
#include <string>
using namespace std;
void using_set()
{
set<string> s;
istream_iterator<string> iter{ cin };
istream_iterator<string> end;
copy(iter, end, inserter(s, s.end()));
for (const auto word : s) {
cout << word << ", ";
}
cout << '\n';
} |
1f0bda2fb6c4d87b9cffe345c8bcb96abb2a2e87 | f950845b2a29a98ca2f96ffaeca8cdf88308adbf | /AN1/LFA - Mitrana Victor/lab/dfa.cpp | f7947bbd5868f539e796d3d15cc319884590c72a | [] | no_license | joahn3/fmi | ba50b35a9ce3aabe837a16e352efe37a3c899041 | e10574973938abc0e27d8f296b015031abb4f43b | refs/heads/master | 2021-10-11T10:16:46.691452 | 2019-01-24T17:24:46 | 2019-01-24T17:24:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,256 | cpp | dfa.cpp | #include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("DFA.in");
ofstream fout("DFA.out");
int md[200][200]; //starile
int Q[100]; //nr stari
char V[200]; //litere/cuvant
int F[100]; //starile finale
int delta(int q, char a)
{
return md[q][a];
// delta[1][a]=2;
}
int delta_tilda(int q, char *s)
{
if(strlen(s)==1)
return delta(q, s[0]);
else
return delta_tilda(delta(q, s[0]), s+1);
}
int main()
{
int n_stari, n_litere, n_st_fin, n_tranz,n_cuv, q0, q, r, q_curent, ok;
char str[100];
char c;
fin>>n_stari;
for(int i=0; i<n_stari; i++)
fin>>Q[i];
fin>>n_litere;
for(int i=0; i<n_litere; i++)
fin>>V[i];
fin>>q0;
fin>>n_st_fin;
for(int i=0; i<n_st_fin; i++)
fin>>F[i];
fin>>n_tranz;
for(int i=0; i<n_tranz; i++)
{
fin>>q>>c>>r;
md[q][c]=r;
}
fin>>n_cuv;
for(int i=0; i<n_cuv; i++)
{
fin>>str;
q_curent=delta_tilda(q0, str);
ok=0;
for(int i=0; i<n_st_fin; i++)
if(q_curent==F[i]) {ok=1;break;}
if(ok==1)fout<<"DA\n";
else fout<<"NU\n";
}
return 0;
}
|
89fe57e206d39ff0234d04c584826fca779d4406 | e32e7b45729c31ce48285121d45a1b053f20cd16 | /cubo.cpp | ec4227cbeb9ab774fc05afe320c902c8d467166f | [] | no_license | ragingdemon/Figuras | 7311ae381e0b4dbd7b75a3f7f9463b5d99e21662 | 5b18809568b62e109e26ed7af05e4b0d18d63376 | refs/heads/master | 2021-01-15T11:49:13.097410 | 2014-03-05T22:12:30 | 2014-03-05T22:12:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 534 | cpp | cubo.cpp | #include "cubo.h"
#include <sstream>
#include <cmath>
Cubo::Cubo(double longitud) : Tridimensional(), longitud(longitud)
{
}
Cubo::Cubo(const Cubo &c) : Tridimensional(c), longitud(c.longitud)
{
}
Cubo::~Cubo()
{
}
double Cubo::getArea() const
{
return 6 * pow(longitud,2);
}
double Cubo::getVolumen() const
{
return pow(longitud,3);
}
std::string Cubo::toString() const
{
std::stringstream ss;
ss<<"Cubo: "<<'['<<longitud<<']'<<" area = "<<getArea()<<','<<" Volumen = "<<getVolumen();
return ss.str();
}
|
eb48f0cfb6872ed41eea05d45b2767196a621bdb | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /third_party/WebKit/Source/modules/vr/VRFieldOfView.h | 03b456dfebe12719ef0e9c4ea8ed388860e684ee | [
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 1,765 | h | VRFieldOfView.h | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef VRFieldOfView_h
#define VRFieldOfView_h
#include "bindings/core/v8/ScriptWrappable.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
namespace blink {
class VRFieldOfView final : public GarbageCollected<VRFieldOfView>,
public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
VRFieldOfView()
: m_upDegrees(0.0),
m_downDegrees(0.0),
m_leftDegrees(0.0),
m_rightDegrees(0.0) {}
VRFieldOfView(double upDegrees,
double rightDegrees,
double downDegrees,
double leftDegrees)
: m_upDegrees(0.0),
m_downDegrees(0.0),
m_leftDegrees(0.0),
m_rightDegrees(0.0) {}
explicit VRFieldOfView(const VRFieldOfView& fov)
: m_upDegrees(fov.m_upDegrees),
m_downDegrees(fov.m_downDegrees),
m_leftDegrees(fov.m_leftDegrees),
m_rightDegrees(fov.m_rightDegrees) {}
double upDegrees() const { return m_upDegrees; }
double downDegrees() const { return m_downDegrees; }
double leftDegrees() const { return m_leftDegrees; }
double rightDegrees() const { return m_rightDegrees; }
void setUpDegrees(double value) { m_upDegrees = value; }
void setDownDegrees(double value) { m_downDegrees = value; }
void setLeftDegrees(double value) { m_leftDegrees = value; }
void setRightDegrees(double value) { m_rightDegrees = value; }
DEFINE_INLINE_TRACE() {}
private:
double m_upDegrees;
double m_downDegrees;
double m_leftDegrees;
double m_rightDegrees;
};
} // namespace blink
#endif // VRFieldOfView_h
|
65c0419d2ff50bfae1191dd505bae209650e2f7d | 81756b89bc5bd169985fe476d45e4c1f791f0cd0 | /Advanced_programmation1/bart-sdl-engine-e17/src/SDLEngine/Rectangle.cpp | 9379df7003c7d2531382c457d08bf4e1f3181d26 | [
"MIT"
] | permissive | Bigbell01/Portfolio | eff20cf34f76443f20b7cac976ca4fb04c1720f4 | ec094a7f96239904ddec9d090bcba2c044eb6119 | refs/heads/master | 2021-08-31T22:36:03.955338 | 2017-12-23T05:27:30 | 2017-12-23T05:27:30 | 115,170,473 | 0 | 0 | MIT | 2017-12-23T05:27:31 | 2017-12-23T04:33:04 | C | UTF-8 | C++ | false | false | 2,626 | cpp | Rectangle.cpp | #include "Rectangle.h"
bool Rectangle::debugMode = true;
Rectangle::Rectangle()
: x(0), y(0), width(0), height(0)
{
}
Rectangle::Rectangle(float x, float y)
:x(x), y(y), width(0), height(0)
{
}
Rectangle::Rectangle(float x, float y, float width, float height)
:x(x), y(y), width(abs(width)), height(abs(height))
{
}
Rectangle::Rectangle(const Vector2D* const topLeft, const Vector2D* const btmRight)
{
if (btmRight->x < topLeft->x && btmRight->y > topLeft->y)
{
this->x = btmRight->x;
this->y = btmRight->y;
this->width = abs(btmRight->x - topLeft->x);
this->height = abs(btmRight->y - topLeft->y);
}
else if (btmRight->x < topLeft->x && btmRight->y < topLeft->y)
{
this->x = btmRight->x;
this->y = topLeft->y;
this->width = abs(topLeft->x - btmRight->x);
this->height = abs(topLeft->y - btmRight->y);
}
else if (btmRight->x > topLeft->x && btmRight->y > topLeft->y)
{
this->x = topLeft->x;
this->y = btmRight->y;
this->width = abs(btmRight->x - topLeft->x);
this->height = abs(btmRight->y - topLeft->y);
}
else if (btmRight->x > topLeft->x && btmRight->y < topLeft->y)
{
this->x = topLeft->x;
this->y = topLeft->y;
this->width = abs(topLeft->x - btmRight->x);
this->height = abs(topLeft->y - btmRight->y);
}
}
void Rectangle::Update()
{
}
void Rectangle::Draw()
{
if (debugMode)
{
SDL_Point points[] =
{
{ int(x), int(y) },
{ int(x + width), int(y) },
{ int(x + width), int(y + height) },
{ int(x), int(y + height) },
{ int(x), int(y) }
};
SDL_SetRenderDrawColor(gRenderer, 0, 255, 0, SDL_ALPHA_OPAQUE);
SDL_RenderDrawLines(gRenderer, points, 5);
gEngine->ResetDrawColor();
}
}
bool Rectangle::Contains(float x, float y) const
{
return (x <= (this->x + this->width) &&
x >= this->x &&
y <= (this->y + this->height) &&
y >= this->y);
}
void Rectangle::SetPosition(const Vector2D * const vect)
{
this->x = vect->x;
this->y = vect->y;
}
void Rectangle::SetPosition(float x, float y)
{
this->x = x;
this->y = y;
}
void Rectangle::MoveBy(const Vector2D * const vect)
{
this->x += vect->x;
this->y += vect->y;
}
void Rectangle::MoveBy(float x, float y)
{
this->x += x;
this->y += y;
}
bool Rectangle::CollidesWith(const Rectangle * const rect) const
{
if (Contains(rect->x, rect->y) ||
Contains(rect->x + rect->width, rect->y) ||
Contains(rect->x, rect->y + rect->height) ||
Contains(rect->x + rect->width, rect->y + rect->height) ||
rect->Contains(x, y) ||
rect->Contains(x + width, y) ||
rect->Contains(x, y + height) ||
rect->Contains(x + width, y + height))
{
return true;
}
return false;
} |
72f459b3a78e577e88d0fe614eee1ece86eea733 | d6720f9cb13c0233b76bc8a81717a83b40ae9830 | /books/c/cguo-e3/ch8/phong_bump/phong.cpp | 98f5ece397c75f9329b46031b4bb3464dc013c1b | [] | no_license | EchoLiao/nalstudy | e4565aadf80ff70388225c4c92eb9bb22d85f384 | 869288a16e540520cadc28c82702e52f1c8396ac | refs/heads/master | 2016-09-05T12:38:06.721690 | 2013-06-05T08:47:01 | 2013-06-05T08:47:01 | 33,391,633 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,282 | cpp | phong.cpp | #include <cstdio>
#include <cstdlib>
#include <GL/glew.h> // GL Extension Wrangling util
#include "GlutWin.h"
#include "Vector3.h"
#include "ShaderObj.h"
#include "Camera.h"
#define GL_GENERATE_MIPMAP 0x8191// i have lame header files
// global variables ///////////////////////////////
// standard demo objects
GlutWin *win = NULL;
ShaderObj *pShaderObj = NULL;
Camera *pCamera;
// texture image data
unsigned char * pBitmapData = NULL;
int width;
int height;
int bpp;
unsigned int color_map_id;
unsigned int normal_map_id;
Vector3 light1;
Vector3 light2;
float theta = 0.0;
// load bitmap file ///////////////////////////////
bool loadBitmapFile( const char * fileName ) {
FILE * fp;
BITMAPFILEHEADER bmpFH;
BITMAPINFOHEADER bmpIH;
unsigned char temp;
fp = fopen( fileName, "rb" ); // rb = read binary
if( fp == NULL )
return( false );
// read in the file header
fread( ( void * )&bmpFH, sizeof( BITMAPFILEHEADER ), 1, fp );
if( bmpFH.bfType != 0x4D42 ) {
fclose( fp );
return( false );
}
// read in the info header
fread( ( void * )&bmpIH, sizeof( BITMAPINFOHEADER ), 1, fp );
// move the file stream to teh start of the image data
fseek( fp, bmpFH.bfOffBits, SEEK_SET );
// set size in bytes
bmpIH.biSizeImage = bmpIH.biHeight * bmpIH.biWidth * ( bmpIH.biBitCount / 8 );
// allocate mem for the image data
pBitmapData = new unsigned char[ bmpIH.biSizeImage ];
if( pBitmapData == NULL ){
// if there was trouble allocating the mem
fclose( fp );
return( false );
}
// read from the stream ( 1 byte at a time, biSizeImage times )
fread( ( void * )pBitmapData, 1, bmpIH.biSizeImage, fp );
if( pBitmapData == NULL ) {
fclose( fp );
return( false );
}
for( int c = 0; c < bmpIH.biSizeImage; c += 3 ) {
// swap the red and blue bytes
temp = pBitmapData[ c ];
pBitmapData[ c ] = pBitmapData[ c + 2 ];
pBitmapData[ c + 2 ] = temp;
}
fclose( fp );
width = bmpIH.biWidth;
height = bmpIH.biHeight;
bpp = bmpIH.biBitCount;
return( true );
}
bool init_shaders() {
if( glewInit() != GLEW_OK ) {
MessageBox( NULL, "GLEW failed to init", "INIT ERROR", MB_OK );
return false;
}
if( ! GLEW_ARB_vertex_shader || ! GLEW_ARB_fragment_shader ) {
MessageBox( NULL, "you don't have ARB_vertex_shader", "INIT ERROR", MB_OK );
return false;
}
if( ! GLEW_ARB_vertex_buffer_object ) {
MessageBox( NULL, "you dont have ARB_vertex_Buffer_object", "INIT_ERROR", MB_OK );
return false;
}
pShaderObj = new ShaderObj();
// compile
pShaderObj->loadVertShader( "phong_bump_vs.glsl" );
pShaderObj->loadFragShader( "phong_bump_fs.glsl" );
// create map of bindings
ShaderObj::stringToIntMap_t s;
s[ "tan" ] = 1;
s[ "tex" ] = 2;
s[ "norm" ] = 3;
return( pShaderObj->link( s ) );
}
bool init_textures() {
glEnable( GL_TEXTURE_2D );
// load data
if( ! loadBitmapFile( "Fieldstone.bmp" ) )
return( false );
// get a texture id
glGenTextures( 1, &color_map_id );
// bind and pass texure data into openGL
glBindTexture( GL_TEXTURE_2D, color_map_id );
// set parameters to make mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
// create the textures
glTexImage2D( GL_TEXTURE_2D, 0,
GL_RGB, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, pBitmapData );
// load data
if( ! loadBitmapFile( "FieldstoneBumpDOT3.bmp" ) )
return( false );
// get a texture id
glGenTextures( 1, &normal_map_id );
// bind and pass texure data into openGL
glBindTexture( GL_TEXTURE_2D, normal_map_id );
// set parameters to make mipmaps
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
// create the textures
glTexImage2D( GL_TEXTURE_2D, 0,
GL_RGB, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, pBitmapData );
return( true );
}
// init demo ////////////////////////////////////////
bool initdemo() {
// initialize GLUT class
win = new GlutWin( 600, 800,
100, 100,
GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH,
"Blinn-Phong Dot3 Demo" );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
// enable depth testing
glEnable( GL_DEPTH_TEST );
init_textures();
if( ! init_shaders() )
return( false );
// clear rendering surface
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // background is white
glViewport(0, 0, 640, 480);
// set the view
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 75.0, 800.0/600.0, 0.01, 1000.0 );
//gluLookAt( 2,2,2, 0,0,0, 0,1,0 );
pCamera = new Camera();
pCamera->Position( 200.0, 200.0, 200.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0 );
ShowCursor( false );
SetCursorPos( 500, 400 );
return( true );
}
void draw_faces() {
glBegin( GL_QUADS );
// front
glVertexAttrib3fARB( 3, 0.0, 0.0, 1.0 );
// tangent passing
glVertexAttrib3fARB( 1, 1, 0, 0 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( -100, -100, 100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( 100, -100, 100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( 100, 100, 100 );
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( -100, 100, 100 );
// back
glVertexAttrib3fARB( 3, 0.0, 0.0, -1.0 );
// tangent passing
glVertexAttrib3fARB( 1, 1, 0, 0 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( -100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( 100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( 100, 100, -100 );
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( -100, 100, -100 );
// top
glVertexAttrib3fARB( 3, 0.0, 1.0, 0.0 );
// tangent passing
glVertexAttrib3fARB( 1, 1, 0, 0 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( -100, 100, -100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( 100, 100, -100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( 100, 100, 100 );
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( -100, 100, 100 );
// base
glVertexAttrib3fARB( 3, 0.0, -1.0, 0.0 );
// tangent passing
glVertexAttrib3fARB( 1, 1, 0, 0 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( -100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( 100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( 100, -100, 100 );
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( -100, -100, 100 );
// left
glVertexAttrib3fARB( 3, -1.0, 0.0, 0.0 );
// tangent passing
glVertexAttrib3fARB( 1, 0, 0, -1 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( -100, -100, 100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( -100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( -100, 100, -100 );
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( -100, 100, 100 );
// right
glVertexAttrib3fARB( 3, 1.0, 0.0, 0.0 );
// tangent passing
glVertexAttrib3fARB( 1, 0, 0, -1 );
// tex coord passing
glVertexAttrib2fARB( 2, 0, 1 );
glVertex3f( 100, -100, 100 );
glVertexAttrib2fARB( 2, 1, 1 );
glVertex3f( 100, -100, -100 );
glVertexAttrib2fARB( 2, 1, 0 );
glVertex3f( 100, 100, -100 );
glVertexAttrib2fARB( 2, 0, 0 );
glVertex3f( 100, 100, 100 );
glEnd();
}
void render() {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_TEXTURE_2D );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt( pCamera->pos.x, pCamera->pos.y, pCamera->pos.z,
pCamera->view.x, pCamera->view.y, pCamera->view.z,
pCamera->up.x, pCamera->up.y, pCamera->up.z );
// use shader object
pShaderObj->bind();
theta += 0.001f;
light1.x = 160.0 * sin( theta );
light1.y = 160.0 * cos( theta );
light1.z = 150.0;
light2.x = 160.0 * sin( theta + ( 3.141592 ) );
light2.y = 160.0 * cos( theta + ( 3.141592 ) );
light2.z = -150.0;
// get positions of uniforms
int color_map_loc = pShaderObj->getUniformLocation( "color_map" );
int normal_map_loc = pShaderObj->getUniformLocation( "normal_map" );
int eye_pos_loc = pShaderObj->getUniformLocation( "eye_pos" );
int light1_dir_loc = pShaderObj->getUniformLocation( "light1_dir" );
int light2_dir_loc = pShaderObj->getUniformLocation( "light2_dir" );
int kd_loc = pShaderObj->getUniformLocation( "kd" );
int ks_loc = pShaderObj->getUniformLocation( "ks" );
int ka_loc = pShaderObj->getUniformLocation( "ka" );
int spec_exp_loc = pShaderObj->getUniformLocation( "spec_exp" );
// set light vars
glUniform1fARB( kd_loc, 0.70 );
glUniform1fARB( ks_loc, 0.50 );
glUniform1fARB( ka_loc, 0.00 );
glUniform1fARB( spec_exp_loc, 150.0 );
// pass eye_pos, light_dir
glUniform3fARB( eye_pos_loc, pCamera->pos.x, pCamera->pos.y, pCamera->pos.z );
glUniform3fARB( light1_dir_loc, light1.x, light1.y, light1.z );
glUniform3fARB( light2_dir_loc, light2.x, light2.y, light2.z );
// set up texture units
glActiveTexture( GL_TEXTURE0 + 1 );
glBindTexture( GL_TEXTURE_2D, color_map_id );
glUniform1iARB( color_map_loc, 1 );
glActiveTexture( GL_TEXTURE0 + 2 );
glBindTexture( GL_TEXTURE_2D, normal_map_id );
glUniform1iARB( normal_map_loc, 2 );
draw_faces();
glUseProgramObjectARB( NULL );
// draw lights as points
glPointSize( 10.0 );
glColor4f( 1.0, 1.0, 1.0, 0.0 ) ;
glDisable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, NULL );
glBegin( GL_POINTS );
glVertex3f( light1.x, light1.y, light1.z );
glVertex3f( light2.x, light2.y, light2.z );
glEnd();
glutSwapBuffers();
glutPostRedisplay();
}
void kb_input( unsigned char key, int x, int y ) {
switch( key ) {
case 'w': pCamera->Move( 10 ); break;
case 's': pCamera->Move( -10 ); break;
case 'a': pCamera->Strafe( -10 ); break;
case 'd': pCamera->Strafe( 10 ); break;
case 'q': exit( 0 );
}
cout << pCamera->pos.x << " " << pCamera->pos.y << " " << pCamera->pos.z << " " << endl;
}
void mouse_motion( int x, int y ) {
static int mx = 500;
static int my = 400;
float dx = x - mx;
float dy = my - y;
my = y;
mx = x;
pCamera->view.y -= dy * 10.0f;
if( ( pCamera->view.y - pCamera->pos.y ) > 700 )
pCamera->view.y = pCamera->pos.y + 700;
if( ( pCamera->view.y - pCamera->pos.y ) < -700 )
pCamera->view.y = pCamera->pos.y - 700;
pCamera->Rotate( 0, dx / 100.0f, 0 );
//SetCursorPos( 500, 400 );
}
int main() {
// init
if( initdemo() ) {
glutDisplayFunc( render );
glutKeyboardFunc( kb_input );
glutPassiveMotionFunc( mouse_motion );
glutMainLoop();
delete win;
delete [] pBitmapData;
}
return( 0 );
}
|
cd32c39bc27b530daa4b08b880e7878e5f44e62f | f02b8065d500df4ca2bcd7869e34123ff2b8db4c | /PTIT121H.cpp | d3e3666f7edc477ff8071d847a2e44d44ff189de | [] | no_license | hoaf13/SPOJ_PTIT_DSA | 5716cf1e8593e80b9c665826f4e8499ae6d392ab | ff145cbc105564e29d72210f6f58bd0ebb0a4550 | refs/heads/master | 2023-05-30T16:49:04.770510 | 2021-06-17T13:29:23 | 2021-06-17T13:29:23 | 290,277,648 | 12 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 996 | cpp | PTIT121H.cpp | #include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define alphaa "abcdefghijklmnopqrstuvwxyz"
#define ALPHAA "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define faster() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> II;
const ld pi=2*acos(0);
const ll inf = LLONG_MAX;
const ll ninf = LLONG_MIN;
const int oo = INT_MAX;
const int noo = INT_MIN;
int m,k;
string s;
int t = 0;
int a[1000006];
void init(){
cin >> m >> k;
cin >> s;
for(int i=0;i<m;i++){
a[i] = i;
}
}
void process(){
for(int i=0;i<s.length()-1;i++){
if(s[i] == 'A'){
t = (t+1)%m;
}
else{
swap(a[t],a[(t+1)%m]);
t = (t+1)%m;
}
}
cout << a[(t+k-1)%m] << " " << a[(t+k)%m] << " " << a[(t+k+1)%m];
}
int main(){
faster();
init();
process();
return 0;
}
|
7ae503315a74135b2f23f2b83627c70aa842677e | c694da160d4365eb2d5aad404334c6ed1d41a75c | /src/include/usr/targeting/common/util.H | edc67b79eef49f9ec9c655dfb424191c1133ff0d | [
"Apache-2.0"
] | permissive | 3mdeb/talos-hostboot | b00e00fa4613731c01338a73dcf39dededae971f | 8d49baa2180fc3cff78c393b19e39816dfa8606f | refs/heads/master | 2022-12-18T01:04:50.303567 | 2018-04-25T02:13:30 | 2018-05-20T06:31:19 | 299,345,985 | 1 | 0 | NOASSERTION | 2020-09-28T15:40:46 | 2020-09-28T15:06:58 | C++ | UTF-8 | C++ | false | false | 6,222 | h | util.H | /* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/targeting/common/util.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* 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. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __TARGETING_COMMON_UTIL_H
#define __TARGETING_COMMON_UTIL_H
/**
* @file targeting/common/util.H
*
* @brief Targeting utility functions
*/
#include <targeting/common/attributes.H>
namespace TARGETING
{
class Target;
/**
* @brief Macro which indicates whether to translate addresses or not
*
* @par Detailed Description:
* If PPC platform (FSP or Hostboot), if 8 byte pointers then it's
* Hostboot, so don't translate. If 4 byte pointers then it's FSP so
* translate. If !PPC (x86 32 or 64 bit), then always translate
*
* @note List of preprocessor macros defined can be determined by calling:
* ppc64-mcp6-gcc -dM -E - < /dev/null
*/
#ifdef __PPC__
#ifndef __HOSTBOOT_RUNTIME
#define TARG_ADDR_TRANSLATION_REQUIRED (sizeof(void*)==4)
#else
#define TARG_ADDR_TRANSLATION_REQUIRED (1)
#endif
#else
#define TARG_ADDR_TRANSLATION_REQUIRED (1)
#endif
namespace PLAT
{
/**
* @brief PLAT::PROPERTIES namespace contains constants that control platform
* specific behaviors
*/
namespace PROPERTIES
{
#if defined(__HOSTBOOT_RUNTIME) //HBRT only
static const bool MULTINODE_AWARE = true;
#elif defined(__HOSTBOOT_MODULE) //HB IPL only
static const bool MULTINODE_AWARE = false;
#else //FSP only
static const bool MULTINODE_AWARE = true;
#endif
}
}
/**
* @brief Checks to see if we are running in a hardware simulation
* environment, i.e. VPO/VBU (not Simics)
*
* @return true if in VPO/VBU
*/
bool is_vpo( void );
/**
* @brief Safely fetch the HUID of a Target
* @param[in] Pointer to a Target
* @return HUID of Target, Zero if NULL, 0xFFFFFFFF if Sentinel
*/
uint32_t get_huid( const Target* i_target );
/**
* @brief Set HWAS Changed Mask to subscription mask
* @param[in] Pointer to a Target
*/
void update_hwas_changed_mask(Target * i_target);
/**
* @brief Set HWAS Changed Mask to specific bits in subscription mask
* @param[in] Pointer to a Target
* @param[in] bit mask of bits to set
*/
void update_hwas_changed_mask(Target * i_target, const uint64_t i_bits);
/**
* @brief Clear bit in HWAS Changed Mask
* @param[in] Pointer to a Target
* @param[in] bit to clear
*/
void clear_hwas_changed_bit(Target * i_target, const HWAS_CHANGED_BIT i_bit);
/**
* @brief Checks if we are loading a PHYP payload
* @description Looks at both ATTR_PAYLOAD_KIND and the MNFG flags
* to determine if we are really loading and starting PHYP
* @param[out] Current value of PAYLOAD_KIND
* @return True if PHYP will be loaded and started
*/
bool is_phyp_load( ATTR_PAYLOAD_KIND_type* o_type = NULL );
/*
* brief Checks if we are loading no payload (PAYLOAD_KIND_NONE)
* @description Looks at both ATTR_PAYLOAD_KIND
* to determine if we are really have no payload
* @return True if No payload will be loaded or started
*/
bool is_no_load( void );
/**
* @brief Utility function to determine if Sapphire is the payload
*
* @description If the payload kind is Sapphire returns true. Does
* not matter if it is Sapphire with FSP or standalone
*
* @return bool True when loadding sapphire
*/
bool is_sapphire_load(void);
/**
* @brief Utility function to determine if an AVP is the payload
* Note the actual payload could be something else -- this
* is based solely on MFG flags
*
* @description If MFG AVP mode flags are set then returns true
* Does not matter what the actual payload is
*
* @return bool True when in AVP mode
*/
bool is_avp_load(void);
/**
* @brief Utility function to obtain the highest known address in the system
*/
uint64_t get_top_mem_addr(void);
/**
* @brief Utility function to obtain the lowest known address in the system
*/
uint64_t get_bottom_mem_addr(void);
/**
* Order two processor targets by NODE_ID then CHIP_ID.
* @param[in] First processor target
* @param[in] Second processor target
* @return true if first target < second target
*/
bool orderByNodeAndPosition( Target* i_firstProc,
Target* i_secondProc);
/**
* @brief Checks if we want to be in FUSED mode or not.
* @description Fused mode is when 2 cores merge to produce
* a core with 8 threads versus 4 threaded cores.
* @return Non-zero if FUSED mode, 0 if non-FUSED mode
*/
uint8_t is_fused_mode( );
}
#endif // __TARGETING_COMMON_UTIL_H
|
5d52bff8b4b55aca5b474475cba29012482cd4d1 | 4081245b8ed21b053664ebd66340db8d38ab8c4f | /Uniquepaths.cpp | 2bcb20f917863d662dcd2fbd7cc2a27995fe8fea | [] | no_license | anandaditya444/LEETCODE | 5240f0adf1df6a87747e00842f87566b0df59f92 | 82e597c21efa965cfe9e75254011ce4f49c2de36 | refs/heads/master | 2020-05-07T15:48:19.081727 | 2019-08-25T16:03:57 | 2019-08-25T16:03:57 | 180,653,012 | 2 | 1 | null | 2019-10-05T13:45:29 | 2019-04-10T19:48:40 | C++ | UTF-8 | C++ | false | false | 425 | cpp | Uniquepaths.cpp | class Solution {
public:
int uniquePaths(int m, int n) {
int mat[m+1][n+1];
for(int i=0;i<m;i++)
{
mat[i][0] = 1;
}
for(int i=0;i<n;i++)
{
mat[0][i] = 1;
}
//DP APPROACH
for(int i=1;i<m;i++)
for(int j=1;j<n;j++)
mat[i][j] = mat[i-1][j] + mat[i][j-1];
return mat[m-1][n-1];
}
};
|
b70d01edaf26f6dd63cb9a5c0dd3ee176f8b0d79 | 642a9d4162c88669d5a2265fbe03db6bf85484ef | /lists/linkedlists/sortedLinkedList.hpp | f940049d6c310b6e8a9e02994954b9710f5fc788 | [] | no_license | MichaelJL3/DataStructures | 492b15e8ef920c8b6c541f38f1adeb9b45240fb2 | 37f059c36297e999e10531aa2f26738760d83434 | refs/heads/master | 2021-01-20T16:59:47.789842 | 2017-03-02T05:46:50 | 2017-03-02T05:46:50 | 82,853,624 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 272 | hpp | sortedLinkedList.hpp |
#ifndef SORTED_LINKED_LIST
#define SORTED_LINKED_LIST
#include "linkedList.hpp"
template<typename T>
class SortedLinkedList : public LinkedList<T>{
public:
using LinkedList<T>::LinkedList;
void insert(T val);
};
#include "sortedLinkedList.cpp"
#endif |
f3944f072a6923221ab902e79dbc87b478d50f52 | 46e6f0d2d450b3bdc71a3477214bba68e0d2139a | /libdqueue/serialisation.h | c847cbe85f7a2dc709ebe801bcf121552ccdd2f8 | [] | no_license | lysevi/dqueue | 3a78bf97390357127c52171287764b6724446725 | 1c3c51f3e2fc93a16e8521c458e0c62d1f6b45e7 | refs/heads/master | 2021-01-23T04:44:32.646985 | 2017-07-07T16:31:59 | 2017-07-07T16:31:59 | 92,938,612 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,615 | h | serialisation.h | #pragma once
#include <libdqueue/exports.h>
#include <cstddef>
#include <cstring>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
namespace dqueue {
namespace serialisation {
template <class T> struct get_size {
static size_t size(const T &) { return sizeof(T); }
};
template <> struct get_size<std::string> {
static size_t size(const std::string &s) { return sizeof(uint32_t) + s.length(); }
};
template <class T> struct get_size<std::vector<T>> {
static size_t size(const std::vector<T> &s) {
static_assert(std::is_pod<T>::value, "T is not a POD object");
return sizeof(uint32_t) + s.size() * sizeof(T);
}
};
template <typename Iterator, typename S> struct writer {
static size_t write_value(Iterator it, const S &s) {
static_assert(std::is_pod<S>::value, "S is not a POD value");
std::memcpy(&(*it), &s, sizeof(s));
return sizeof(s);
}
};
template <typename Iterator> struct writer<Iterator, std::string> {
static size_t write_value(Iterator it, const std::string &s) {
auto len = static_cast<uint32_t>(s.size());
auto ptr = &(*it);
std::memcpy(ptr, &len, sizeof(uint32_t));
std::memcpy(ptr + sizeof(uint32_t), s.data(), s.size());
return sizeof(uint32_t) + s.size();
}
};
template <typename Iterator, class T> struct writer<Iterator, std::vector<T>> {
static size_t write_value(Iterator it, const std::vector<T> &s) {
static_assert(std::is_pod<T>::value, "T is not a POD object");
auto len = static_cast<uint32_t>(s.size());
auto ptr = &(*it);
std::memcpy(ptr, &len, sizeof(uint32_t));
std::memcpy(ptr + sizeof(uint32_t), s.data(), s.size() * sizeof(T));
return sizeof(uint32_t) + s.size() * sizeof(T);
}
};
template <typename Iterator, typename S> struct reader {
static size_t read_value(Iterator it, S &s) {
static_assert(std::is_pod<S>::value, "S is not a POD value");
auto ptr = &(*it);
std::memcpy(&s, ptr, sizeof(s));
return sizeof(s);
}
};
template <typename Iterator> struct reader<Iterator, std::string> {
static size_t read_value(Iterator it, std::string &s) {
uint32_t len = 0;
auto ptr = &(*it);
std::memcpy(&len, ptr, sizeof(uint32_t));
s.resize(len);
std::memcpy(&s[0], ptr + sizeof(uint32_t), size_t(len));
return sizeof(uint32_t) + len;
}
};
template <typename Iterator, class T> struct reader<Iterator, std::vector<T>> {
static size_t read_value(Iterator it, std::vector<T> &s) {
static_assert(std::is_pod<T>::value, "S is not a POD value");
uint32_t len = 0;
auto ptr = &(*it);
std::memcpy(&len, ptr, sizeof(uint32_t));
s.resize(len);
std::memcpy(&s[0], ptr + sizeof(uint32_t), size_t(len) * sizeof(T));
return sizeof(uint32_t) + len * sizeof(T);
}
};
template <class... T> class Scheme {
template <typename Head>
static void calculate_size_rec(size_t &result, const Head &&head) {
result += get_size<Head>::size(head);
}
template <typename Head, typename... Tail>
static void calculate_size_rec(size_t &result, const Head &&head, const Tail &&... t) {
result += get_size<Head>::size(std::forward<const Head>(head));
calculate_size_rec(result, std::forward<const Tail>(t)...);
}
template <class Iterator, typename Head>
static void write_args(Iterator it, const Head &head) {
auto szofcur = writer<Iterator, Head>::write_value(it, head);
it += szofcur;
}
template <class Iterator, typename Head, typename... Tail>
static void write_args(Iterator it, const Head &head, const Tail &... t) {
auto szofcur = writer<Iterator, Head>::write_value(it, head);
it += szofcur;
write_args(it, std::forward<const Tail>(t)...);
}
template <class Iterator, typename Head>
static void read_args(Iterator it, Head &&head) {
auto szofcur = reader<Iterator, Head>::read_value(it, head);
it += szofcur;
}
template <class Iterator, typename Head, typename... Tail>
static void read_args(Iterator it, Head &&head, Tail &&... t) {
auto szofcur = reader<Iterator, Head>::read_value(it, head);
it += szofcur;
read_args(it, std::forward<Tail>(t)...);
}
public:
static size_t capacity(const T &... args) {
size_t result = 0;
calculate_size_rec(result, std::forward<const T>(args)...);
return result;
}
template <class Iterator> static void write(Iterator it, const T &... t) {
write_args(it, std::forward<const T>(t)...);
}
template <class Iterator> static void read(Iterator it, T &... t) {
read_args(it, std::forward<T>(t)...);
}
};
} // namespace serialisation
} // namespace dqueue |
0a8e2cefae741702e00ac14807800e4b94a093b0 | 9c046eeda11be532cc0017e6da316e7ddfd16283 | /Telecomm/SharedLib/ewalletShareLib/include/childrenWidget/recorddetailperwidget.h | 0acf976196428113073409d1f88a716c71fd8778 | [
"BSD-3-Clause"
] | permissive | telecommai/windows | 83cd3ac4dec7742c6e038689689ac7ec9cde842a | 30e34ffe0bc81f39c25be7624d16856bf42e03eb | refs/heads/master | 2023-01-12T02:10:59.904541 | 2019-04-23T11:42:07 | 2019-04-23T11:42:07 | 180,726,308 | 3 | 0 | BSD-3-Clause | 2023-01-03T19:52:20 | 2019-04-11T06:12:20 | C++ | UTF-8 | C++ | false | false | 613 | h | recorddetailperwidget.h | #ifndef RECORDDETAILPERWIDGET_H
#define RECORDDETAILPERWIDGET_H
#include <QWidget>
#include "opcommon.h"
namespace Ui { class RecordDetailPerWidget; };
class RecordDetailPerWidget : public QWidget
{
Q_OBJECT
public:
RecordDetailPerWidget(QWidget *parent = Q_NULLPTR);
~RecordDetailPerWidget();
void setRecord(RecordInfo);
private:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
Ui::RecordDetailPerWidget *ui;
QPoint mouse;
};
#endif//RECORDDETAILPERWIDGET_H |
176a1ae740aa4729bcc69822580c57a0f8b57068 | b4ba3bc2725c8ff84cd80803c8b53afbe5e95e07 | /Medusa/Medusa/Node/Input/IMEHandler.h | 7a649cf5dc30d2368c9def8b3b1eb8e651c2696c | [
"MIT"
] | permissive | xueliuxing28/Medusa | c4be1ed32c2914ff58bf02593f41cf16e42cc293 | 15b0a59d7ecc5ba839d66461f62d10d6dbafef7b | refs/heads/master | 2021-06-06T08:27:41.655517 | 2016-10-08T09:49:54 | 2016-10-08T09:49:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 802 | h | IMEHandler.h | // Copyright (c) 2015 fjz13. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
#pragma once
#include "Node/Input/IInputHandler.h"
#include "Node/Input/EventArg/CharInputEventArg.h"
#include "Node/Input/EventArg/KeyDownEventArg.h"
#include "Node/Input/EventArg/KeyUpEventArg.h"
MEDUSA_BEGIN;
class IMEHandler:public IInputHandler
{
public:
KeyDownEvent OnKeyDown;
KeyUpEvent OnKeyUp;
CharInputEvent OnCharInput;
public:
IMEHandler(INode* node);
virtual ~IMEHandler(void);
virtual InputType GetInputType()const override{ return InputType::IME; }
virtual void KeyDown(KeyDownEventArg& e) override;
virtual void KeyUp(KeyUpEventArg& e) override;
virtual void CharInput(CharInputEventArg& e) override;
};
MEDUSA_END; |
a913064ddf7227fe826347c9a2d3918d75af4708 | d4b508823b87f98534332fc8523ae0708bf5c249 | /DS/Trees/ques15.cpp | 2ede47b29709634afad87783636a38ac1ae72c0a | [] | no_license | vaibsharma/algorithmscpp | 83cad7fbdecc545b4765050fd5e7954f1bec7271 | db4679fff7a89dae6559a8f2c6638350c1348b11 | refs/heads/master | 2021-04-28T13:43:56.651332 | 2018-06-05T13:07:55 | 2018-06-05T13:07:55 | 77,577,276 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,168 | cpp | ques15.cpp | // finding the LCA of the given nodes
#include<iostream>
#include<cstdio>
using namespace std;
struct node{
int key;
node* leftChild;
node* rightChild;
};
node* addChild(int key){
node* p = new node;
if(p){
p->key = key;
p->leftChild = NULL;
p->rightChild = NULL;
}
return p;
}
int main(){
node* root = NULL;
node* findLCA(node*, node*, node*);
root = addChild(7);
root->leftChild = addChild(3);
root->rightChild = addChild(1);
root->rightChild->leftChild = addChild(9);
root->rightChild->rightChild = addChild(12);
root->leftChild->rightChild = addChild(21);
root->leftChild->leftChild = addChild(23);
node *a = root->leftChild->leftChild, *b = root->rightChild;
node* result = findLCA(root,a,b);
if(result){
cout<<result->key<<"\n";
}
else printf("no result is found");
return 0;
}
node* findLCA(node* root,node* a, node* b){
if(!root) return NULL;
else{
if(root == a || root == b) return root;
else{
node* left = findLCA(root->leftChild,a,b);
node* right = findLCA(root->rightChild,a,b);
if(left && right) return root;
else return (left? left:right);
}
}
}
|
7cd2f4b9624287fd9ea4ff7bba694eec8a06899e | 03a39f0b6ddd68c0ca0b6d75a571969c20c63996 | /pinpoint_common/pinpoint_type.h | 9339f63ea6f2b4d82a5d6eca6120fc1e9d5111ea | [
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | yuslf/pinpoint-c-agent | 62233b42c4f377b8d544c0249959468c1805fb04 | 2daf037b5407ec5866517f2539a46e38dfc8d258 | refs/heads/dev | 2020-03-31T11:27:27.708852 | 2019-01-17T03:27:49 | 2019-01-17T03:27:49 | 152,177,410 | 2 | 2 | Apache-2.0 | 2018-10-25T03:12:53 | 2018-10-09T02:45:58 | C++ | UTF-8 | C++ | false | false | 1,316 | h | pinpoint_type.h | /*
* php_type.h
*
* Created on: Mar 15, 2017
* Author: bluse
*/
#ifndef PINPOINT_PHP_PINPOINT_TYPE_H_
#define PINPOINT_PHP_PINPOINT_TYPE_H_
/*******************************************/
/* host proccess info str */
/* take php string as stander*/
/*******************************************/
namespace Pinpoint
{
namespace Naming
{
extern const char* gNameTable[];
enum eName
{
ENAME_MIN,
USER = 0,
HOME,
FCGI_ROLE,
SCRIPT_FILENAME,
QUERY_STRING,
REQUEST_METHOD,
CONTENT_TYPE,
CONTENT_LENGTH,
SCRIPT_NAME,
REQUEST_URI,
DOCUMENT_URI,
DOCUMENT_ROOT,
SERVER_PROTOCOL,
REQUEST_SCHEME,
GATEWAY_INTERFACE,
SERVER_SOFTWARE,
REMOTE_ADDR,
REMOTE_PORT,
SERVER_ADDR,
SERVER_PORT,
SERVER_NAME,
REDIRECT_STATUS,
HTTP_HOST,
HTTP_CONNECTION,
HTTP_XIP,
HTTP_CACHE_CONTROL,
HTTP_DF,
HTTP_USER_AGENT,
HTTP_ASFDAS,
HTTP_ASDFASDF,
HTTP_ASDFSA,
HTTP_POSTMAN_TOKEN,
HTTP_ACCEPT,
HTTP_ACCEPT_ENCODING,
HTTP_ACCEPT_LANGUAGE,
PHP_SELF,
REQUEST_TIME_FLOAT,
REQUEST_TIME,
ENAME_MAX
};
////////////////////////////////////////////////////
#define MAINPROCCESSID "mpid"
}
}
/*******************************************/
#endif /* PINPOINT_PHP_PINPOINT_TYPE_H_ */
|
32b148047739942b015d0f5ea66e14a486bf0800 | dda35829b02d45886f3fa3c193d28087f0c36e69 | /Resource/plateNumberRecognition/plateNumberRecognition/PlateFind.h | 1bf3637c546ec126d5dd0cfbdb9dc5481df70fd4 | [] | no_license | quocdungms/Number-Plate-Recognition | e20f73154dbc77c7764c11da8bd77b913d45ef05 | 906c3bd42948dfaaca53cab77945f78e10ec2099 | refs/heads/master | 2023-03-27T05:21:48.019169 | 2021-03-17T15:23:48 | 2021-03-17T15:23:48 | 113,730,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,143 | h | PlateFind.h | #pragma once
#include <iostream>
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <opencv\cxcore.h>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;
#ifndef _PLATEFIND_H_
#define _PLATEFIND_H_
//
IplImage * grayScale(IplImage*src);
IplImage * ImageRestoration(IplImage *src); // tien xu ly anh goc
IplImage * resizex2(IplImage*src);
IplImage * resize(IplImage*src,int x,int y);
IplImage* FindPlate(IplImage *src); // tim va cat bien so
int CountContour(IplImage*src); // dem so vung co kha nang la ki tu
vector <IplImage*> FindCharacter(IplImage*src);
//void recognictionCharacter(vector<IplImage*>src);
//void grayScale(IplImage* src);
CvMat* convertIplimagetoCvMat(IplImage*src);
vector<IplImage*> resizeVectorImage(vector<IplImage*>src);
void showImgvector(vector<IplImage*>src);
void showCvMatFloat(CvMat*src);
void showIplimagedata(IplImage*src);
void showcharacterFinal(vector<IplImage*>src);
float sumMat(CvMat*src);
IplImage* loadImgData(int x);
void showCvMatFloatAbs(CvMat*src);
int getDataClassifications(int x);
//CvMat* convertMat(CvMat*src);
//
#endif // !_PLATEFIND_H_
|
f6350500b17ea053124c05eb732a563fe2dbc710 | b79a99532fd736fc3d8ffa1cf073056eb1c90381 | /src/g2time.cpp | da687d8c706337da81d4354ab9273e57426767a7 | [
"Unlicense"
] | permissive | spoonless/g3log | 22aac4660e84f3ab52bf396cf213c513d2c1e3ad | b3b30a7eaf1d257c4a458dc5dcd094de455326fd | refs/heads/master | 2020-12-25T08:51:02.929699 | 2015-03-30T18:52:44 | 2015-03-30T18:52:44 | 33,055,118 | 1 | 0 | null | 2015-03-29T00:01:13 | 2015-03-29T00:01:12 | null | UTF-8 | C++ | false | false | 3,224 | cpp | g2time.cpp | /** ==========================================================================
* 2012 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
* with no warranties. This code is yours to share, use and modify with no
* strings attached and no restrictions or obligations.
*
* For more information see g3log/LICENSE or refer refer to http://unlicense.org
* ============================================================================
* Filename:g2time.cpp cross-platform, thread-safe replacement for C++11 non-thread-safe
* localtime (and similar)
* Created: 2012 by Kjell Hedström
*
* PUBLIC DOMAIN and Not under copywrite protection. First published for g2log at KjellKod.cc
* ********************************************* */
#include "g2time.hpp"
#include <sstream>
#include <string>
#include <chrono>
#include <thread>
#include <cassert>
#include <iomanip>
namespace g2 {
namespace internal {
// This mimics the original "std::put_time(const std::tm* tmb, const charT* fmt)"
// This is needed since latest version (at time of writing) of gcc4.7 does not implement this library function yet.
// return value is SIMPLIFIED to only return a std::string
std::string put_time(const struct tm* tmb, const char* c_time_format) {
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(__MINGW32__)
std::ostringstream oss;
oss.fill('0');
// BOGUS hack done for VS2012: C++11 non-conformant since it SHOULD take a "const struct tm* "
oss << std::put_time(const_cast<struct tm*> (tmb), c_time_format);
return oss.str();
#else // LINUX
const size_t size = 1024;
char buffer[size]; // IMPORTANT: check now and then for when gcc will implement std::put_time.
// ... also ... This is way more buffer space then we need
auto success = std::strftime(buffer, size, c_time_format, tmb);
if (0 == success)
{
assert((0 != success) && "strftime fails with illegal formatting");
return c_time_format;
}
return buffer;
#endif
}
} // internal
} // g2
namespace g2 {
std::time_t systemtime_now() {
system_time_point system_now = std::chrono::system_clock::now();
return std::chrono::system_clock::to_time_t(system_now);
}
tm localtime(const std::time_t& time) {
struct tm tm_snapshot;
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) && !defined(__GNUC__))
localtime_s(&tm_snapshot, &time); // windsows
#else
localtime_r(&time, &tm_snapshot); // POSIX
#endif
return tm_snapshot;
}
/// returns a std::string with content of time_t as localtime formatted by input format string
/// * format string must conform to std::put_time
/// This is similar to std::put_time(std::localtime(std::time_t*), time_format.c_str());
std::string localtime_formatted(const std::time_t& time_snapshot, const std::string& time_format) {
std::tm t = localtime(time_snapshot); // could be const, but cannot due to VS2012 is non conformant for C++11's std::put_time (see above)
return g2::internal::put_time(&t, time_format.c_str()); // format example: //"%Y/%m/%d %H:%M:%S");
}
} // g2
|
71406fe109a803050552c7dce3af1e1053bc955c | 47abddd3a85764d5bd052d05534f2af80ce7779e | /JungOl/C1033(회로배치)/lkw_JG_1033_회로배치.cpp | 22eceeae1890b85dd85e35a2bcb471e9a8387eb5 | [] | no_license | kihun123/KWandKids | a7d8b1b1c93e4dba329da282c73cbe40e8c62f88 | 26e231e259a753dd790341f87448954e46c4af3b | refs/heads/master | 2022-04-07T12:22:05.829806 | 2020-03-09T10:16:30 | 2020-03-09T10:16:30 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,132 | cpp | lkw_JG_1033_회로배치.cpp | #include<iostream>
using namespace std;
int map[51][51]={ {0,}, }; // 지나갈 때 비용 ( 1 or k)
int cost[51][51]={ {0,}, }; // 시작점으로 부터 최소 비용
int dy[4] = { 0, 0, -1, 1 }; // 4방향 탐색
int dx[4] = { 1, -1, 0, 0 };
int qy[100000]; // BFS에 사용할 큐
int qx[100000];
int y_b[51][51]; // 이동해온 y좌표 저장
int x_b[51][51]; // 이동해온 x좌표 저장
void search(int N, int k, int y, int x) {
int head = 0, tail = 0;
qy[tail] = y; // 처음은 시작 y 좌표
qx[tail++] = x; // x 좌표
y_b[y][x] = 0;
x_b[y][x] = 0;
cost[y][x] = 1;
while (head < tail) {
int y_f = qy[head]; // 맨 앞에 것을 가져온다
int x_f = qx[head++];
for (int i = 0; i < 4; i++) { // 4 방향
int yt = y_f + dy[i]; // 이동할 4 방향 좌표
int xt = x_f + dx[i];
if (yt >= 1 && yt <= N && xt >= 1 && xt <= N) // 범위를 벗어 나지 않고
if (cost[yt][xt] > map[yt][xt] + cost[y_f][x_f]) {
// 현재까지의 탐색 결과보다 짧은 길을 발견하면
cost[yt][xt] = map[yt][xt] + cost[y_f][x_f]; // 값을 갱신 후
y_b[yt][xt] = y_f; // 건너온 좌표도 저장
x_b[yt][xt] = x_f;
qy[tail] = yt; // 그리고 큐에 삽입
qx[tail++] = xt;
}
}
}
}
int max(int a, int b) {
if (a >= b) return a;
else return b;
}
int min(int a, int b) {
if (a < b) return a;
else return b;
}
int main() {
int N, ans, k, circuit; // 맵 크기, 정답, 회로가중치, 회로 수
int y[2], x[2]; // index] 0 : start, 1 : end
cin >> N; // map size
for (int j = 1; j <= N; j++)
for (int i = 1; i <= N; i++) {
map[j][i] = 1; // 우선 1로 초기화
cost[j][i] = 987654321; // 기본 최대값
}
for (int i = 0; i < 2; i++)
cin >> y[i] >> x[i]; // start, end coordi
cin >> k;
cin >> circuit;
for (int i = 0; i < circuit; i++) {
int corner, ys, xs, ye, xe;
cin >> corner;
cin >> ys >> xs; // 직선의 시작
map[ys][xs] = k;
for (int c = 1; c < corner; c++) {
cin >> ye >> xe; // 직선의 끝
if (xs == xe) {
for (int y0 = min(ys, ye); y0 <= max(ys, ye); y0++)
map[y0][xs] = k;
}
else if (ys == ye) {
for (int x0 = min(xs, xe); x0 <= max(xs, xe); x0++)
map[ys][x0] = k;
}
ys = ye; // 끝이 다음 직선의 시작
xs = xe;
}
}
search(N, k, y[0], x[0]);
/*cout << endl;
for (int j = 1; j <= N; j++) {
for (int i = 1; i <= N; i++) {
printf("%2d ", cost[j][i]);
}cout << endl;
}
cout << endl << "before\n";
for (int j = 1; j <= N; j++) {
for (int i = 1; i <= N; i++) {
printf("(%2d,%2d) ", y_b[j][i], x_b[j][i]);
}cout << endl;
}*/
ans = cost[y[1]][x[1]]; // 최소 거리
cout << ans << endl;
int yy1 = y[1], xx1 = x[1], yy2, xx2; // 끝에서 부터 처음으로 거슬러간다.
// y[1], x[1]은 도착점. yy1,xx1은 이전 점, yy2,xx2는 지금 점
int ylist[2000], xlist[2000]; // 0번부터 끝, 코너들, 시작 순으로 저장
int ldx = 0;
ylist[ldx] = yy1; // 처음엔 끝점
xlist[ldx++] = xx1;
int y_d1 = y_b[yy1][xx1] - yy1; // 이전점 - 지금점 으로 방향을 구한다.
int x_d1 = x_b[yy1][xx1] - xx1;
//cout << "yy1: " << yy1 << ", xx1 : " << xx1 << endl;
while (1) {
yy2 = y_b[yy1][xx1]; // yy2 : [yy1][xx1] 방문 직전 점의 y 좌표
xx2 = x_b[yy1][xx1];
//cout << "yy2: " << yy2 << ", xx2 : " << xx2 << endl;
int y_d2 = yy2 - yy1; // 이전 점으로 돌아가는 방향
int x_d2 = xx2 - xx1;
if (y_d1 != y_d2 || x_d1 != x_d2) { // 직전의 방향과 달라졌다면
ylist[ldx] = yy1; // 코너입니다.
xlist[ldx++] = xx1;
}
if (yy2 == y[0] && xx2 == x[0]) { // 시작점으로 돌아갔다면
ylist[ldx] = yy2;
xlist[ldx++] = xx2;
break;
}
yy1 = yy2; // 현재의 정보가 다음 반복의 이전 정보가 된다.
xx1 = xx2;
y_d1 = y_d2;
x_d1 = x_d2;
}
cout << ldx;
for (int i = ldx - 1; i >= 0; i--)
cout << " " << ylist[i] << " " << xlist[i];
return 0;
} |
e7893bb8445653bd68e648be3afd5995489d659c | 2aad21460b2aa836721bc211ef9b1e7727dcf824 | /libImgEdit/include/IEBrushGroupEventListener.h | c08ec035a9263640c77fba098f3ae338b83bf7c1 | [
"BSD-3-Clause"
] | permissive | chazix/frayer | 4b38c9d378ce8b3b50d66d1e90426792b2196e5b | ec0a671bc6df3c5f0fe3a94d07b6748a14a8ba91 | refs/heads/master | 2020-03-16T20:28:34.440698 | 2018-01-09T15:13:03 | 2018-01-09T15:13:03 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,485 | h | IEBrushGroupEventListener.h | #ifndef _IEBRUSHGROUPEVENTLISTENRE_H_
#define _IEBRUSHGROUPEVENTLISTENRE_H_
class IEBrushGroupEventListener
{
public:
IEBrushGroupEventListener():
m_isLockEvent(false),
m_isCalledIEBrushGroup(false) {};
virtual ~IEBrushGroupEventListener(){};
//! イベント呼び出しを行わないようにする
void LockIEBrushGroupEvent(){ m_isLockEvent = true; };
//! イベント呼び出しを行うようにする
void UnlockIEBrushGroupEvent(){ m_isLockEvent = false; };
//! イベント呼び出しを行うかどうか
bool IsLockIEBrushGroupEvent(){ return m_isLockEvent; };
////////////////////////////////
/*!
選択ブラシが変わったときに呼び出す。
@param[in] pNewBrush 変更後のブラシ
@param[in] pOldBrush 変更前のブラシ
*/
virtual void OnChangeSelectBrush(IEBrush_Ptr pNewBrush, IEBrush_Ptr pOldBrush){};
/////////////////////////////////
/*!
ブラシが追加されたときに呼び出し
@param[in] pBrush 追加されたブラシ
*/
virtual void OnAddBrush(IEBrush_Ptr pBrush){};
//////////////////////////////////
/*!
ブラシが削除されたときに呼び出し
@param[in] pBrish 削除されるブラシ
*/
virtual void OnDeleteBrush(IEBrush_Ptr pBrush){};
bool IsCalledIEBrushGroup(){ return m_isCalledIEBrushGroup; };
void SetCalledIEBrushGroup(bool bl){ m_isCalledIEBrushGroup = bl; };
private:
bool m_isLockEvent;
bool m_isCalledIEBrushGroup;
};
#endif //_IEBRUSHGROUPEVENTLISTENER_H_ |
aa9c26a23a7a868957d19b03e4c8cb082b4b7f74 | eed3f34bc3b2c5bf326a0ed1bf5af7f7782b9f2d | /ex/automobile.cpp | c36d9b0f96a829d6be1febd3aa88a7914509e6f9 | [] | no_license | Kiritow/CarDisplayer | 846343ab89c4b1fec031c08d4e6cb4580caa55af | 5dd10affe7a3d28a77b0578f3d70a55c24837eec | refs/heads/master | 2021-01-12T07:48:11.139036 | 2016-12-29T03:23:46 | 2016-12-29T03:23:46 | 77,021,309 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 992 | cpp | automobile.cpp | #include"automobile.h"
using namespace std;
automobile::automobile(){}
void automobile::show_argument(int p)
{
/*system("\"c:\Program Files\Internet Explorer\iexplor.exe\"网址");*////通过调用ie浏览器实现,直接展示网页
ostringstream os;
os<<"automobile_\\automobile_"<<p<<".txt";
string s=os.str();
ifstream file(s.c_str());
while(file)
{
getline(file,s);
cout<<s<<endl;
}
}
void automobile::show_picture(string p,string q)
{
car *c=this;
c->show_picture(p,q);
}
void automobile::show_history(int p)
{
/*system("\"c:\Program Files\Internet Explorer\iexplor.exe\"网址");*////通过调用ie浏览器实现,直接展示网页
ostringstream os;
os<<"automobile_\\automobile_history_"<<p<<".txt";
string s=os.str();
ifstream file(s.c_str());
while(file)
{
getline(file,s);
cout<<s<<endl;
}
}
|
5ca8811921590533bdeca684c46cded4e20f1545 | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /components/feedback/content/content_tracing_manager.h | c06027f2873a3ffed519df85f84970726978ee4e | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 2,500 | h | content_tracing_manager.h | // Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_FEEDBACK_CONTENT_CONTENT_TRACING_MANAGER_H_
#define COMPONENTS_FEEDBACK_CONTENT_CONTENT_TRACING_MANAGER_H_
#include "components/feedback/tracing_manager.h"
#include <map>
#include <memory>
#include <string>
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
// This class is used to manage performance metrics that can be attached to
// feedback reports. This class is a Singleton that is owned by the preference
// system. It should only be created when it is enabled, and should only be
// accessed elsewhere via Get().
//
// When a performance trace is desired, TracingManager::Get()->RequestTrace()
// should be invoked. The TracingManager will then start preparing a zipped
// version of the performance data. That data can then be requested via
// GetTraceData(). When the data is no longer needed, it should be discarded
// via DiscardTraceData().
class ContentTracingManager : public TracingManager {
public:
~ContentTracingManager() override;
// Create a ContentTracingManager. Can only be called when none exists.
static std::unique_ptr<ContentTracingManager> Create();
// Get the current ContentTracingManager. Returns NULL if one doesn't exist.
static ContentTracingManager* Get();
// Request a trace ending at the current time. If a trace is already being
// collected, the id for that trace is returned.
int RequestTrace() override;
// Get the trace data for |id|. On success, true is returned, and the data is
// returned via |callback|. Returns false on failure.
bool GetTraceData(int id, TraceDataCallback callback) override;
// Discard the data for trace |id|.
void DiscardTraceData(int id) override;
private:
ContentTracingManager();
void StartTracing();
void OnTraceDataCollected(std::unique_ptr<std::string> data);
void OnTraceDataCompressed(scoped_refptr<base::RefCountedString> data);
// ID of the trace that is being collected.
int current_trace_id_ = 0;
// Mapping of trace ID to trace data.
std::map<int, scoped_refptr<base::RefCountedString>> trace_data_;
// Callback for the current trace request.
TraceDataCallback trace_callback_;
base::WeakPtrFactory<ContentTracingManager> weak_ptr_factory_{this};
};
#endif // COMPONENTS_FEEDBACK_CONTENT_CONTENT_TRACING_MANAGER_H_
|
66e93b93b0106f6975c3bf37943c766b70b6b547 | 3ef12e2050a05b0185ddbb69bae20249923e9ed4 | /Carro.h | d09888cfd960ae18ed18b7776800ab987511f80e | [
"MIT"
] | permissive | Pancho98/P3Lab4_FranciscoSantos | 528f27268e10ebd644bae307ba9956c3511f6e76 | c90469fa237c77ef803a1d87548ab129af9c3fce | refs/heads/master | 2021-09-07T03:55:37.051213 | 2018-02-17T00:12:59 | 2018-02-17T00:12:59 | 121,789,176 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 410 | h | Carro.h | #include<string>
using namespace std;
#ifndef CARRO_H
#define CARRO_H
class Carro{
private:
string color;
string marca;
double altura;
public:
//contructores
Carro();
Carro(string, string, double);
//mutadores
string getColor();
void setColor(string);
string getMarca();
void setMarca(string);
double getAltura();
void setAltura(double);
//Destructor
~Carro();
};
#endif
|
7afa9c02ff0b38f0cff86ae13a8fafa8c408be9a | 3edd3da6213c96cf342dc842e8b43fe2358c960d | /abc/abc253/e/main.cpp | df0702a66dee9036729cc74ea2ec3ec69f4b2abf | [] | no_license | tic40/atcoder | 7c5d12cc147741d90a1f5f52ceddd708b103bace | 3c8ff68fe73e101baa2aff955bed077cae893e52 | refs/heads/main | 2023-08-30T20:10:32.191136 | 2023-08-30T00:58:07 | 2023-08-30T00:58:07 | 179,283,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 661 | cpp | main.cpp | #include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
using mint = modint998244353;
int main() {
int n,m,k; cin >> n >> m >> k;
fenwick_tree<mint> dp(m+1);
for(int i = 1; i <= m; i++) dp.add(i,1);
REP(_,n-1) {
fenwick_tree<mint> p(m+1);
swap(dp,p);
for(int j = 1; j <= m; j++) {
if (k == 0) {
dp.add(j, p.sum(1,m+1));
continue;
}
int x1 = j + k;
if (x1 <= m) dp.add(j, p.sum(x1, m+1));
int x2 = j - k;
if (1 <= x2) dp.add(j, p.sum(1, x2+1));
}
}
cout << dp.sum(1,m+1).val() << endl;
return 0;
} |
f7b6bb449f0c0201760fa3334bf8471afb2db80c | 8b9bf13c352ee3727224a7215dcd0e157e3886b5 | /16-2/16-2.cpp | 24549302c3c3d33afc40c23b148e7defed2e4871 | [] | no_license | scnb/Cpp-Learning_Chapter16 | a1b8bebbdeef4a6a810169bb0aa7f78820747d2b | 904b1b8f985a02cc81bc252e4e98a452a27363ce | refs/heads/master | 2021-08-14T15:12:42.595390 | 2017-11-16T02:46:18 | 2017-11-16T02:46:18 | 110,914,127 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,914 | cpp | 16-2.cpp | // 16-2.cpp : 定义控制台应用程序的入口点。
//string类的输入:
/*
1、C-风格字符串的输入 2、string类的输入
char info[100]; string info;
①cin>>info; ①cin>>info;
②getline(info,100); ②getline(cin,info);
③cin.get(info,100);
两者很大的一个区别就是:对于C风格字符串的输入都要指定要读取的字符个数,而string类因为能够智能的裁剪
输入字符串的长短,所以不用指定大小。
两个版本的getline()都有一个可选参数,用于指定使用哪个字符来确定输入的边界。
getline()函数是读取一行,但从输入流中删除行尾的换行符并不保留它,而get()函数是读取一行,然后把行尾的换行符留在输入流中。
string类的getline()函数从输入中读取字符,并将其存到目标对象中,直到出现下列情况:
①到达文件尾,在这种情况下,输入流的eofbit将被设置,这意味着eof()和fail()都将返回true;
②遇到分界字符(默认为\n),在这种情况下,将把分界字符从输入流中删除,但并不保留它。
③读取到的字符数将达到最大允许值,这意味着将设置输入流的failbit,方法fail()将返回true;
*/
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::ifstream;
int main()
{
ifstream fin;
fin.open("tobuy.txt");
if (fin.is_open() == false)
{
std::cerr << "Can't open file.Bye.\n";
exit(EXIT_FAILURE);
}
string item;
int count = 0;
getline(fin, item, ':');//使用 : 作为分解符,即当读取到:时,停止读取
while (fin)
{
++count;
cout << count << ": " << item << endl;
getline(fin, item, ':');
}
cout << "Done\n";
fin.close();
getchar();
getchar();
return 0;
}
|
19d89ee032595f0b7791e584c13e316212b6bd72 | 85d223752d27d041e1f8f9cf3d869ed232628f3b | /algorithms/Alg_BLS.cc | 8ad0273a088a97b4e1a836a5aec62a5877c00838 | [
"MIT"
] | permissive | ADDALemos/MPPTimetables | 2b503a13f0c13dab8e39943daeaf53f6848ef624 | c33d15797686a27c192eabb90948baa54d3ddef5 | refs/heads/master | 2021-06-13T19:37:08.411247 | 2020-07-19T14:38:42 | 2020-07-19T14:38:42 | 156,722,711 | 6 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 13,425 | cc | Alg_BLS.cc | /*!
* \author Vasco Manquinho - vmm@sat.inesc-id.pt
*
* @section LICENSE
*
* Open-WBO, Copyright (c) 2013-2018, Ruben Martins, Vasco Manquinho, Ines Lynce
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include "Alg_BLS.h"
using namespace openwbo;
/************************************************************************************************
//
// Utils for model management
//
************************************************************************************************/
/*_________________________________________________________________________________________________
|
| saveModel : (currentModel : vec<lbool>&) -> [void]
|
| Description:
|
| Saves the current model found by the SAT solver.
|
| Pre-conditions:
| * Assumes that 'nbInitialVariables' has been initialized.
| * Assumes that 'currentModel' is not empty.
|
| Post-conditions:
| * 'model' is updated to the current model.
| * 'nbSatisfiable' is increased by 1.
|
|________________________________________________________________________________________________@*/
bool BLS::saveModel(vec <lbool> ¤tModel) throw() {
//assert (n_initial_vars != 0);
assert (currentModel.size() != 0);
model.clear();
// Only store the value of the variables that belong to the original MaxSAT formula.
for (int i = 0; i < maxsat_formula->nVars(); i++){
model.push(currentModel[i]);
}
nbSatisfiable++;
print();
if (cpuTime() > instance->getTime() && instance->getTime()!=-1)
return false;
return true;
}
void BLS::saveSmallestModel(vec<lbool> ¤tModel){
//assert (n_initial_vars != 0);
assert (currentModel.size() != 0);
_smallestModel.clear();
// Only store the value of the variables that belong to the original MaxSAT formula.
for (int i = 0; i < maxsat_formula->nVars(); i++){
_smallestModel.push(currentModel[i]);
}
}
/************************************************************************************************
//
// BLS search
//
************************************************************************************************/
// Checks if a soft clause is satisfied by saved model
bool BLS::satisfiedSoft(int i) {
for (int j = 0; j < maxsat_formula->getSoftClause(i).clause.size(); j++){
assert (var(maxsat_formula->getSoftClause(i).clause[j]) < model.size());
if ((sign(maxsat_formula->getSoftClause(i).clause[j]) && model[var(maxsat_formula->getSoftClause(i).clause[j])] == l_False) ||
(!sign(maxsat_formula->getSoftClause(i).clause[j]) && model[var(maxsat_formula->getSoftClause(i).clause[j])] == l_True)) {
return true;
}
}
return false;
}
// Call to the SAT solver...
lbool BLS::solve() {
nbSatCalls++;
if (local_limit)
solver->setConfBudget(conflict_limit);
#ifdef SIMP
return ((SimpSolver*)solver)->solveLimited(assumptions);
#else
return solver->solveLimited(assumptions);
#endif
}
void BLS::addMCSClause(vec<int>& unsatClauses) {
vec<Lit> lits;
for (int i = 0; i < unsatClauses.size(); i++) {
lits.push(~maxsat_formula->getSoftClause(unsatClauses[i]).assumption_var);
}
maxsat_formula->addHardClause(lits);
solver->addClause(maxsat_formula->getHardClause(maxsat_formula->nHard()-1).clause);
}
void BLS::initUndefClauses(vec<int>& undefClauses) {
for (int i = 0; i < maxsat_formula->nSoft(); i++)
undefClauses.push(i);
}
bool BLS::LSU() {
printf("c Warn: changing to LSU algorithm.\n");
lbool res = l_True;
uint64_t newCost = UINT64_MAX;
if (model.size() != 0){
newCost = _smallestMCS;
if (!encoder.hasCardEncoding())
encoder.encodeCardinality(solver, objFunction, newCost - 1);
else
encoder.updateCardinality(solver, newCost - 1);
}
while (res == l_True) {
assumptions.clear();
res = solve();
if (res == l_True) {
nbSatisfiable++;
newCost = computeCostModel(solver->model);
if(!saveModel(solver->model))
return false;
printf("o %" PRId64 "\n", newCost + off_set);
if (newCost == 0) {
// If there is a model with value 0 then it is an optimal model
ubCost = newCost;
printAnswer(_OPTIMUM_);
exit(_OPTIMUM_);
} else {
// Unweighted.
if (!encoder.hasCardEncoding())
encoder.encodeCardinality(solver, objFunction, newCost - 1);
else
encoder.updateCardinality(solver, newCost - 1);
ubCost = newCost;
}
} else {
nbCores++;
if (model.size() == 0) {
assert(nbSatisfiable == 0);
// If no model was found then the MaxSAT formula is unsatisfiable
printAnswer(_UNSATISFIABLE_);
exit(_UNSATISFIABLE_);
} else {
printAnswer(_OPTIMUM_);
exit(_OPTIMUM_);
}
}
}
return true;
}
// Always consider all clauses by adding assumption var to each soft clause.
void BLS::basicSearch(int maxMCS = 30) throw(int){
printConfiguration();
// Init Structures
init();
//Build solver
solver = buildSolver();
solver->setConfBudget(conflict_limit);
while (maxMCS) {
if (!findNextMCS()) break;
maxMCS--;
}
if (maxMCS == 0)
printf("c All requested MCSs found\n");
}
// Find next MCS.
// Returns false if the SAT solver was not able to finish. Otherwise, returns true.
bool BLS::findNextMCS() {
vec<int> undefClauses;
vec<int> satClauses;
vec<int> unsatClauses;
uint64_t costModel = _maxWeight;
lbool res = l_True;
//int conflict_limit = 100000;
initUndefClauses(undefClauses);
assumptions.clear();
// make first call.
res = solve();
// Check outcome of first call
if (res == l_False) {
// Hard clause set in unsat!
if (nbMCS == 0) {
printAnswer(_UNSATISFIABLE_);
exit(_UNSATISFIABLE_);
}
else {
// It is not the first MCS. Hence, all MCS were found.
printAnswer(_OPTIMUM_);
exit(_OPTIMUM_);
}
}
else if (res == l_True) {
uint64_t newCost = computeCostModel(solver->model);
if (newCost < _smallestMCS){
if(!
saveModel(solver->model))
return false;
printf("o %" PRId64 "\n", newCost);
_smallestMCS = newCost;
}
}
else {
printf("c Warn: SAT Solver exit due to conflict budget.\n");
if (costModel < _smallestMCS) {
_smallestMCS = costModel;
//Last saved model is smallest MCS...
}
return false;
}
// Iterate to find next MCS
while (undefClauses.size()) {
int i = 0;
if (res == l_True) {
//Remove satisfied soft clauses from undefClauses
while (i < undefClauses.size()) {
if (satisfiedSoft(undefClauses[i])) {
//Add soft clause as Hard!
satClauses.push(undefClauses[i]);
assumptions.push(~(maxsat_formula->getSoftClause(undefClauses[i]).assumption_var));
costModel -= maxsat_formula->getSoftClause(undefClauses[i]).weight;
undefClauses[i] = undefClauses.last();
undefClauses.pop();
}
else i++;
}
if (costModel < _smallestMCS) {
//saveSmallestModel(solver->model);
if(!saveModel(solver->model))
return false;
printf("o %" PRId64 "\n", costModel);
_smallestMCS = costModel;
}
}
if (undefClauses.size() == 0) {
break;
}
i = undefClauses.last();
undefClauses.pop();
satClauses.push(i);
assumptions.push(~(maxsat_formula->getSoftClause(i).assumption_var));
res = solve();
if (res == l_False) {
unsatClauses.push(satClauses.last());
satClauses.pop();
assumptions.pop();
}
else if (res == l_True) {
costModel -= maxsat_formula->getSoftClause(satClauses.last()).weight;
if (undefClauses.size() == 0 && costModel < _smallestMCS){
printf("o %" PRId64 "\n", costModel);
if(!saveModel(solver->model))
return false;
_smallestMCS = costModel;
}
}
else {
printf("c Warn: SAT Solver exit due to conflict budget.\n");
if (costModel < _smallestMCS) {
_smallestMCS = costModel;
//Last saved model is smallest MCS...
}
return false;
}
}
if (costModel < _smallestMCS) {
_smallestMCS = costModel;
//Last saved model is smallest MCS...
}
nbMCS++;
printf("c MCS #%d Weight: %" PRId64 "\n", nbMCS, costModel);
addMCSClause(unsatClauses);
return true;
}
// Public search method
bool BLS::search() throw(int){
basicSearch(_maxMCS);
// Make sure the conflict budget is turned off.
solver->budgetOff();
local_limit = false;
return LSU();
}
/************************************************************************************************
//
// Utils for printing
//
************************************************************************************************/
// Prints the best satisfying model. Assumes that 'model' is not empty.
void BLS::printModel(){
assert (model.size() != 0);
printf("v ");
for (int i = 0; i < model.size(); i++){
if (model[i] == l_True) printf("%d ",i+1);
else printf("%d ",-(i+1));
}
printf("\n");
}
// Prints the corresponding answer.
void BLS::printAnswer(int type){
if (type == _UNKNOWN_ && model.size() > 0)
type = _SATISFIABLE_;
switch(type){
case _SATISFIABLE_:
printf("s SATISFIABLE\n");
printModel();
break;
case _OPTIMUM_:
printf("s OPTIMUM FOUND\n");
printModel();
break;
case _UNSATISFIABLE_:
printf("s UNSATISFIABLE\n");
break;
case _UNKNOWN_:
printf("s UNKNOWN\n");
break;
default:
printf("c Error: Unknown answer type.\n");
}
}
/************************************************************************************************
//
// Other protected methods
//
************************************************************************************************/
Solver *BLS::buildSolver() {
vec<bool> seen;
seen.growTo(maxsat_formula->nVars(), false);
Solver *S = newSATSolver();
for (int i = 0; i < maxsat_formula->nVars(); i++)
newSATVariable(S);
for (int i = 0; i < maxsat_formula->nHard(); i++)
S->addClause(maxsat_formula->getHardClause(i).clause);
vec<Lit> clause;
for (int i = 0; i < maxsat_formula->nSoft(); i++) {
clause.clear();
maxsat_formula->getSoftClause(i).clause.copyTo(clause);
for (int j = 0; j < maxsat_formula->getSoftClause(i).relaxation_vars.size();
j++) {
clause.push(maxsat_formula->getSoftClause(i).relaxation_vars[j]);
}
S->addClause(clause);
}
return S;
}
// Prints search statistics.
void BLS::printConfiguration(){
printf("c ==========================================[ Solver Settings "
"]============================================\n");
printf("c | "
" |\n");
printf("c | Algorithm: %23s "
" |\n",
"MCS");
print_Card_configuration(encoding);
printf("c | Limit number conflicts: %10d "
" |\n", conflict_limit);
printf("c | Limit number iterations: %9d "
" |\n", _maxMCS);
if (local_limit)
printf("c | Global limit number conflicts: F "
" |\n");
else
printf("c | Global limit number conflicts: T "
" |\n");
printf("c | "
" |\n");
}
void BLS::init() {
_maxWeight = 0;
for (int i = 0; i < maxsat_formula->nSoft(); i++) {
Lit l = maxsat_formula->newLiteral();
maxsat_formula->getSoftClause(i).relaxation_vars.push(l);
maxsat_formula->getSoftClause(i).assumption_var = maxsat_formula->getSoftClause(i).relaxation_vars[0]; // Assumption Var is relaxation var
objFunction.push(l);
_maxWeight += maxsat_formula->getSoftClause(i).weight;
}
printf("c Max. Weight: %" PRId64 "\n", _maxWeight);
}
|
68e245bdbc13031fdd40d6e9489572d145e88f01 | a20b95ef719adaac9e9d9a1478428407ecdbdd25 | /src/SpriteNode.cpp | 610448f44e69bd2807405f7bb3ab54a97be87e78 | [] | no_license | ani300/1714game | 4523d8212206153b7279fb0b213573050356cb7c | dcd5b09271692fe40894ff291fb1e8107d52e9aa | refs/heads/master | 2016-09-06T11:27:03.991136 | 2015-01-25T05:11:07 | 2015-01-25T05:11:17 | 17,917,886 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 769 | cpp | SpriteNode.cpp | #include "SpriteNode.hpp"
SpriteNode::SpriteNode(const sf::Texture& texture)
: mSprite(texture) {
}
SpriteNode::SpriteNode(const sf::Texture& texture, const sf::IntRect& textureRect) : mSprite(texture, textureRect) {
}
void SpriteNode::drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const {
target.draw(mSprite, states);
}
void SpriteNode::setSize(sf::Vector2u desiredSize){
float scalex, scaley;
scalex = scaley = 0.0;
scalex = float(desiredSize.x)/mSprite.getTexture()->getSize().x;
scaley = float(desiredSize.y)/mSprite.getTexture()->getSize().y;
setScale(scalex, scaley);
}
void SpriteNode::setColor(sf::Color color){
mSprite.setColor(color);
}
sf::Color SpriteNode::getColor(){
return mSprite.getColor();
}
|
4b11b23c6386be064d8e7dfb86e4d606f8c78603 | 7c405091fa8bce92fbcf5329448e782150d59fcf | /计算几何/计算几何 圆相关 模板.cpp | 8133a18e251659a6eae1a9375c7902554cd3649e | [] | no_license | WhereIsHeroFrom/Code_Templates | 97c6c008ddb6e8d548455c2fbb9bfe90caa947a4 | 28d8e3988bcdd3267b56c5baf721845b4c88fcdc | refs/heads/master | 2022-05-06T18:25:08.218099 | 2022-04-26T00:02:30 | 2022-04-26T00:02:30 | 119,244,828 | 141 | 39 | null | null | null | null | UTF-8 | C++ | false | false | 8,590 | cpp | 计算几何 圆相关 模板.cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXP = 1100;
#define PI acos(-1.0)
#define eps 1e-15
#define LL __int64
typedef double Type;
// 三值函数
int threeValue(Type d) {
if(fabs(d) < 1e-6)
return 0;
return d > 0 ? 1 : -1;
}
// 两线段交点类型
enum SegCrossType {
SCT_NONE = 0,
SCT_CROSS = 1, // 正常相交
SCT_ENDPOINT_ON = 2, // 其中一条线段的端点在另一条上
};
class Point2D {
Type x, y;
public:
Point2D(){
}
Point2D(Type _x, Type _y): x(_x), y(_y) {}
void read() {
scanf("%lf %lf", &x, &y);
}
void print() {
printf("<%lf, %lf>\n", x, y);
}
Point2D turnLeft();
Point2D turnRight();
double angle();
Point2D operator+(const Point2D& other) const;
Point2D operator-(const Point2D& other) const;
Point2D operator*(const double &k) const;
Point2D operator/(const double &k) const;
Type operator*(const Point2D& other) const;
bool operator <(const Point2D &p) const;
Type X(const Point2D& other);
double len();
Point2D normalize();
};
typedef Point2D Vector2D;
double Vector2D::len() {
return sqrt(x*x + y*y);
}
Point2D Vector2D::normalize() {
double l = len();
if(threeValue(l)) {
x /= l;
y /= l;
}
return *this;
}
Point2D Point2D::turnLeft() {
return Point2D(-y, x);
}
Point2D Point2D::turnRight() {
return Point2D(y, -x);
}
double Point2D::angle() {
return atan2(y, x);
}
Point2D Point2D::operator+(const Point2D& other) const {
return Point2D(x + other.x, y + other.y);
}
Point2D Point2D::operator-(const Point2D& other) const {
return Point2D(x - other.x, y - other.y);
}
Point2D Point2D::operator *(const double &k) const {
return Point2D(x * k, y * k);
}
Point2D Point2D::operator /(const double &k) const {
return Point2D(x / k, y / k);
}
bool Point2D::operator <(const Point2D &p) const {
return y + eps < p.y || ( y < p.y + eps && x + eps < p.x );
}
// !!!!注意!!!!
// 如果Type为int,则乘法可能导致int32溢出,小心谨慎
// 点乘
Type Point2D::operator*(const Point2D& other) const {
return x*other.x + y*other.y;
}
// 叉乘
Type Point2D::X(const Point2D& other) {
return x*other.y - y*other.x;
}
class Segment2D {
Point2D s, t;
public:
void read() {
s.read();
t.read();
}
// 定点叉乘
// 外部找一点p,然后计算 (p-s)×(t-s)
Type cross(const Point2D& p) const {
return (p - s).X(t - s);
}
// 跨立测验
// 将当前线段作为一条很长的直线,检测线段other是否跨立在这条直线的两边
bool lineCross(const Segment2D& other) const;
// 点是否在线段上
bool pointOn(const Point2D& p) const;
// 线段判交
// 1.通过跨立测验
// 2.点是否在线段上
SegCrossType segCross(const Segment2D& other);
};
bool Segment2D::lineCross(const Segment2D& other) const {
return threeValue(cross(other.s)) * threeValue(cross(other.t)) == -1;
}
bool Segment2D::pointOn(const Point2D& p) const {
// 满足两个条件:
// 1.叉乘为0, (p-s)×(t-s) == 0
// 2.点乘为-1或0,(p-s)*(p-t) <= 0
return cross(p) == 0 && (p-s)*(p-t) <= 0;
}
SegCrossType Segment2D::segCross(const Segment2D& other) {
if(this->lineCross(other) && other.lineCross(*this)) {
// 两次跨立都成立,则必然相交与一点
return SCT_CROSS;
}
// 任意一条线段的某个端点是否在其中一条线段上,四种情况
if(pointOn(other.s) || pointOn(other.t) ||
other.pointOn(s) || other.pointOn(t) ) {
return SCT_ENDPOINT_ON;
}
return SCT_NONE;
}
class Line2D {
public:
Point2D a, b;
Line2D() {}
Line2D(const Point2D& _a, const Point2D& _b): a(_a), b(_b) {}
Point2D getCrossPoint(const Line2D& );
bool isParallelTo(const Line2D& );
};
// 两条不平行的直线必有交点
// 利用叉乘求面积法的相似三角形比值得出交点
Point2D Line2D::getCrossPoint(const Line2D& other) {
double SA = (other.a - a).X(b - a);
double SB = (b - a).X(other.b - a);
return (other.b * SA + other.a * SB) / (SA + SB);
}
bool Line2D::isParallelTo(const Line2D& other) {
return !threeValue( (b-a).X(other.b - other.a) );
}
struct Polygon {
int n;
Point2D p[MAXP];
void print();
double area();
void getConvex(Polygon &c);
bool isConvex();
bool isPointInConvex(const Point2D &P);
Point2D CalcBary();
void convertToCounterClockwise();
bool
};
void Polygon::print() {
int i;
printf("%d\n", n);
for(i = 0; i < n; ++i) {
p[i].print();
}
}
double Polygon::area() {
double sum = 0;
p[n] = p[0];
for ( int i = 0 ; i < n; i ++ )
sum += p[i].X(p[i + 1]);
return sum / 2;
}
// 求凸包
void Polygon::getConvex(Polygon &c) {
sort(p, p + n);
c.n = n;
for(int i = 0; i < n; ++i) {
c.p[i] = p[i];
}
if(n <= 2) {
return ;
}
int &top = c.n;
top = 1;
for ( int i = 2 ; i < n ; i ++ ) {
while ( top && threeValue(( c.p[top] - p[i] ).X( c.p[top - 1] - p[i] )) >= 0 )
top --;
c.p[++top] = p[i];
}
int temp = top;
c.p[++ top] = p[n - 2];
for ( int i = n - 3 ; i >= 0 ; i -- ) {
while ( top != temp && threeValue(( c.p[top] - p[i] ).X( c.p[top - 1] - p[i] )) >= 0 )
top --;
c.p[++ top] = p[i];
}
}
// 是否凸多边形
bool Polygon::isConvex() {
bool s[3] = { false , false , false };
p[n] = p[0], p[n + 1] = p[1];
for ( int i = 0 ; i < n ; i ++ ) {
s[threeValue(( p[i + 1] - p[i] ) * ( p[i + 2] - p[i] )) + 1] = true;
// 叉乘有左有右,肯定是凹的
if ( s[0] && s[2] ) return false;
}
return true;
}
// 点是否在凸多边形内
bool Polygon::isPointInConvex(const Point2D &P) {
bool s[3] = { false , false , false };
p[n] = p[0];
for ( int i = 0 ; i < n ; i ++ ) {
s[threeValue(( p[i + 1] - P ) * ( p[i] - P )) + 1] = true;
if ( s[0] && s[2] ) return false;
if ( s[1] ) return true;
}
return true;
}
// 转成逆时针顺序
void Polygon::convertToCounterClockwise() {
if(area() >= 0) {
return ;
}
for(int i = 1; i <= n / 2; ++i) {
Point2D tmp = p[i];
p[i] = p[n-i];
p[n-i] = tmp;
}
}
Point2D Polygon::CalcBary() {
Point2D ret(0, 0);
double area = 0;
p[n] = p[0];
for ( int i = 0 ; i < n ; i ++ ) {
double temp = p[i] * p[i + 1];
if ( threeValue(temp) == 0 ) continue;
area += temp;
ret = ret + ( p[i] + p[i + 1] ) * ( temp / 3 );
}
return ret / area;
}
// 点对
struct Point2D_Pair {
Point2D a, b;
Point2D_Pair() {}
Point2D_Pair(Point2D _a, Point2D _b): a(_a), b(_b) {
}
Point2D center();
Vector2D direction();
double len();
void print();
};
Point2D Point2D_Pair::center() {
return (a + b) / 2;
}
Vector2D Point2D_Pair::direction() {
return b - a;
}
double Point2D_Pair::len() {
return direction().len();
}
void Point2D_Pair::print() {
printf("点对如下:\n");
a.print();
b.print();
}
class Circle {
Point2D center;
double radius;
public:
Circle() {}
Circle(Point2D c, double r): center(c), radius(r) {
}
static int getCenterByTwoPoints(Point2D_Pair p, double r, Point2D_Pair& ret);
static int getCenterByAngle(Point2D o, Point2D a, Point2D b, double r, Point2D& ret);
};
// 给定两个点和一个半径r,求经过这两点的圆的圆心。
// 返回值:圆心数量 (0/1/2)
int Circle::getCenterByTwoPoints(Point2D_Pair p, double r, Point2D_Pair& ret) {
double chordal = p.len();
int rc = threeValue(r - chordal/2);
if(rc == -1) {
// 1.半径小于弦长一半,无解
return 0;
}else if(rc == 0) {
// 2.半径等于弦长一半,圆心唯一,为弦中点
ret.a = ret.b = p.center();
return 1;
}else {
// 3.半径大于弦长一半,则半径为斜边,弦长一半为直角边,可获得两个圆心
double verLen = sqrt(r*r - chordal*chordal/4);
Point2D ip = p.direction();
ip.normalize();
ret.a = p.center() + ip.turnLeft()*verLen;
ret.b = p.center() + ip.turnRight()*verLen;
return 2;
}
}
// 给定oa-ob这段角度,求卡在这个角内的圆的圆心
// 注意:请保证ob在oa的逆时针方向,且|oa| != |ob|
// 返回值:圆心数量 (0/1)
int Circle::getCenterByAngle(Point2D o, Point2D a, Point2D b, double r, Point2D& ret) {
Vector2D OA = a - o;
Vector2D OB = b - o;
double ad = OA.angle();
double bd = OB.angle();
if(bd < ad) {
bd += 2*PI;
}
// 两射线构成的角 >= 180度,则无法放入圆
if( threeValue(bd - ad - PI) >= 0 ) {
return 0;
}
OA.normalize(), OB.normalize();
ret = o + (OA - OB).normalize().turnLeft() * r;
return 1;
}
|
bb22bae41c4eac420d6fad701b79d67448e6d2bd | e45ef0115d58ab472f156f4dfdcb2c89c6d3d728 | /043.cpp | 4fe2a8feaac6030bffda1d190ae30c1477ddc5e5 | [] | no_license | plenilune3/cpp_for_beginners_200 | e0267c3dcda93ff2eba8ed0752eecb77ec038c46 | ba1a480d8f8d7a965195e18decdd278a93a6916a | refs/heads/master | 2020-06-14T03:07:20.944080 | 2019-12-19T14:18:30 | 2019-12-19T14:18:30 | 194,876,853 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | 043.cpp | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << "== 소수점 버리기 ==" << endl;
cout << "floor(1.1) : " << floor(1.1) << endl;
cout << "floor(2.3) : " << floor(2.3) << endl;
cout << "floor(40.5) : " << floor(40.5) << endl;
cout << "floor(55.7) : " << floor(55.7) << endl;
cout << "floor(100.9) : " << floor(100.9) << endl;
cout << "== 소수점 올리기 ==" << endl;
cout << "ceil(1.1) : " << ceil(1.1) << endl;
cout << "ceil(2.3) : " << ceil(2.3) << endl;
cout << "ceil(40.5) : " << ceil(40.5) << endl;
cout << "ceil(55.7) : " << ceil(55.7) << endl;
cout << "ceil(100.9) : " << ceil(100.9) << endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.