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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6115b79027475f0484b74c45e737b610f1ae3216
|
27c917a12edbfd2dba4f6ce3b09aa2e3664d3bb1
|
/Graph/flood_fill.cpp
|
2315cf2991835bbffc4f6d9efba0b8a05575b09b
|
[] |
no_license
|
Spetsnaz-Dev/CPP
|
681ba9be0968400e00b5b2cb9b52713f947c66f8
|
88991e3b7164dd943c4c92784d6d98a3c9689653
|
refs/heads/master
| 2023-06-24T05:32:30.087866
| 2021-07-15T19:33:02
| 2021-07-15T19:33:02
| 193,662,717
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,052
|
cpp
|
flood_fill.cpp
|
#include<bits/stdc++.h>
using namespace std;
int arr[100][100];
void printPixels(int n, int m)
{
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<arr[i][j]<<" ";
}
}
}
void floodFill(int n, int m, int x, int y, int newColor, int curr)
{
if(x < 0 or x >= n or y < 0 or y >= m or arr[x][y] != curr)
return;
arr[x][y] = newColor;
floodFill(n, m, x+1, y, newColor, curr); //Down
floodFill(n, m, x-1, y, newColor, curr); //Up
floodFill(n, m, x, y-1, newColor, curr); //Left
floodFill(n, m, x, y+1, newColor, curr); //Right
}
int main()
{
int t;
cin>>t;
while(t--) {
int n, m;
cin>>n>>m;
// int arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
int x,y,k;
cin>>x>>y>>k;
if(arr[x][y] != k)
floodFill(n, m, x, y, k, arr[x][y]);
printPixels(n, m);
}
return 0;
}
|
09f2ca0ca5c988116f945fef4f540667037bb275
|
d9c455e5069ada17fc4b5c04d1956126d3990a8e
|
/OpenMEEG/include/sensors.h
|
1d13b73d33b56940b9db68ed9e7307d73c667a5e
|
[] |
no_license
|
massich/findmkl_openmeeg
|
74f08f4d822067c2488843ec690299d3109ac2c1
|
85c280a8fa20333e26efd473761d270d0e75583d
|
refs/heads/master
| 2021-05-05T14:20:03.643384
| 2018-03-15T09:26:01
| 2018-03-15T15:21:27
| 118,476,151
| 1
| 0
| null | 2018-03-15T10:14:58
| 2018-01-22T15:32:16
|
C++
|
UTF-8
|
C++
| false
| false
| 8,700
|
h
|
sensors.h
|
/*
Project Name : OpenMEEG
© INRIA and ENPC (contributors: Geoffray ADDE, Maureen CLERC, Alexandre
GRAMFORT, Renaud KERIVEN, Jan KYBIC, Perrine LANDREAU, Théodore PAPADOPOULO,
Emmanuel OLIVI
Maureen.Clerc.AT.inria.fr, keriven.AT.certis.enpc.fr,
kybic.AT.fel.cvut.cz, papadop.AT.inria.fr)
The OpenMEEG software is a C++ package for solving the forward/inverse
problems of electroencephalography and magnetoencephalography.
This software is governed by the CeCILL-B license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-B
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's authors, the holders of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-B license and that you accept its terms.
*/
#pragma once
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <IOUtils.H>
#include <vector.h>
#include <matrix.h>
#include <geometry.h>
#include <om_common.h>
#include <OpenMEEG_Export.h>
namespace OpenMEEG {
/*!
* Sensors class for EEG and MEG sensors.
* This class is made for reading sensors description file. This description file is a file text. Sensors may have names (labels)
* in the first column of the file (it has to contains at least one character to be considered as label)
* the file can have the shape of (neglecting if present the first, label column):
* <ul>
*
* <li> 1 line per sensor and 3 columns (EEG sensors OR MEG sensors without orientation OR EIT punctual patches)
* <ul TYPE="circle">
* <li> the 1st, 2nd and 3rd columns are respectively position coordinates x, y, z of sensor </li>
* </ul>
* </li>
* <li> 1 line per sensor and 4 columns (EEG EIT patches (circular patches)) :
* <ul TYPE="circle">
* <li> the 1st, 2nd and 3rd are respectively position coordinates x, y, z of sensor </li>
* <li> the 4th is the patche radius (unit relative to the mesh) </li>
* </ul>
* </li>
* <li> 1 line per sensor and 6 columns (MEG sensors) :
* <ul TYPE="circle">
* <li> the 1st, 2nd and 3rd are respectively position coordinates x, y, z of sensor </li>
* <li> the 4th, 5th and 6th are coordinates of vector orientation </li>
* </ul>
* </li>
* <li> 1 line per integration point for each sensor and 7 columns (MEG sensors) :
* <ul TYPE="circle">
* <li> the 1st, 2nd and 3rd are respectively position coordinates x, y, z of sensor </li>
* <li> the 4th, 5th and 6th are coordinates of vector orientation </li>
* <li> the 7th is the weight to apply for numerical integration (uses sensor name) </li>
* </ul>
* </li>
* </ul>
*/
class OPENMEEG_EXPORT Sensors {
public:
Sensors(): m_nb(0), m_geo(NULL) {} /*!< Default constructor. Number of sensors = 0. */
Sensors(const Geometry& g): m_nb(0), m_geo(&g) {} /*!< Default constructor with a geometry. Number of sensors = 0. */
Sensors(const char* filename): m_geo(NULL) { this->load(filename,'t'); } /*!< Construct from file. Option 't' is for text file.*/
Sensors(const char* filename, const Geometry& g): m_geo(&g) { this->load(filename,'t'); }; /*!< Construct from file and geometry (for EIT). */
void load(const char* filename, char filetype = 't' ); /*!< Load sensors from file. Filetype is 't' for text file or 'b' for binary file. */
void load(std::istream &in); /*!< Load description file of sensors from stream. */
void save(const char* filename);
size_t getNumberOfSensors() const { return m_nb; } /*!< Return the number of sensors. */
size_t getNumberOfPositions() const { return m_positions.nlin(); } /*!< Return the number of integration points. */
Matrix& getPositions() { return m_positions ; } /*!< Return a reference on sensors positions. */
Matrix getPositions() const { return m_positions ; } /*!< Return a copy of sensors positions */
Matrix& getOrientations() {return m_orientations ; } /*!< Return a reference on sensors orientations. */
Matrix getOrientations() const {return m_orientations ; } /*!< Return a copy of sensors orientations. */
Strings& getNames() {return m_names ; } /*!< Return a reference on sensors names. */
Strings getNames() const {return m_names ; } /*!< Return a copy of sensors names. */
bool hasRadii() const { return m_radii.nlin() > 0 ;} /*!< Return true if contains radii */
bool hasOrientations() const { return m_orientations.nlin() > 0 ;} /*!< Return true if contains orientations */
bool hasNames() const { return m_names.size() == m_nb ;} /*!< Return true if contains all sensors names */
Vector getPosition(size_t idx) const; /*!< Return the position (3D point) of the integration point i. */
Vector getOrientation(size_t idx) const; /*!< Return the orientations (3D point) of the integration point i. */
std::string getName(size_t idx) const{ om_assert(idx < m_names.size()); return m_names[idx]; } /*!< Return the name of the idx_th sensor */
void setPosition(size_t idx, Vector& pos); /*!< Set the position (3D point) of the integration point i. */
void setOrientation(size_t idx, Vector& orient); /*!< Set the orientation (3D point) of the integration point i. */
bool hasSensor(std::string name);
size_t getSensorIdx(std::string name);
Triangles getInjectionTriangles(size_t idx) const { om_assert(idx < m_triangles.size()); return m_triangles[idx]; } /*!< For EIT, get triangles under the current injection electrode. */
Vector getRadii() const { return m_radii; }
Vector getWeights() const { return m_weights; }
SparseMatrix getWeightsMatrix() const;
bool isEmpty() { if(m_nb == 0) return true; else return false; } /*!< Return if the sensors object is empty. The sensors object is empty if its number of sensors is null. */
void info() const; /*!< \brief get info about sensors. */
private:
size_t m_nb; /*!< Number of sensors. */
Strings m_names; /*!< List of sensors names. */
Matrix m_positions; /*!< Matrix of sensors positions. ex: positions(i,j) with j in {0,1,2} for sensor i */
Matrix m_orientations; /*!< Matrix of sensors orientations. ex: orientation(i,j) with j in {0,1,2} for sensor i */
Vector m_weights; /*!< Weights of integration points */
Vector m_radii; /*!< Areas of the EIT sensors */
std::vector<Triangles> m_triangles; /*!< Triangles under each EIT sensors */
const Geometry * m_geo; /*!< Geometry on which are applied EIT sensors */
std::vector<size_t> m_pointSensorIdx; /*!< Correspondance between point id and sensor id */
void findInjectionTriangles(); /*!< Get the triangles under each EIT sensors */
};
inline Vector Sensors::getPosition(size_t idx) const {
return m_positions.getlin(idx);
}
inline Vector Sensors::getOrientation(size_t idx) const {
return m_orientations.getlin(idx);
}
inline void Sensors::setPosition(size_t idx, Vector& pos) {
return m_positions.setlin(idx,pos);
}
inline void Sensors::setOrientation(size_t idx, Vector& orient) {
return m_orientations.setlin(idx,orient);
}
}
|
f30d9172da413950dd1eb31115383920861f68d3
|
b40f33f7af6858c1d87ce0fb19cdf917c38a36aa
|
/ConnectionHandler.cpp
|
737aff6e91b293b415728cbfd8fd158d44c44b33
|
[] |
no_license
|
Fantomas4/EzRemote_Project_Computer_Server
|
92b056532424b725cf4ca50892a5155b309a3610
|
4df1f1a258d6bcbb0bd3cedfe50f7e8c130e8e53
|
refs/heads/master
| 2020-03-21T20:13:14.733715
| 2019-10-12T21:06:58
| 2019-10-12T21:06:58
| 138,994,228
| 0
| 0
| null | 2019-10-12T21:06:59
| 2018-06-28T09:07:49
|
C++
|
UTF-8
|
C++
| false
| false
| 2,669
|
cpp
|
ConnectionHandler.cpp
|
//
// Created by Sierra Kilo on 31-Aug-19.
//
#include "ConnectionHandler.h"
#include <string>
#include <iostream>
#include <cstring>
int ConnectionHandler::recvMsg(SOCKET recvSocket, char *recv_buf) {
// empty the recv_buf buffer by filling it with 0 (null)
*recv_buf = {0};
// For the client - server communication, "\0" (null) is used as delimiter. Since strlen("\0") is 0,
// the message part that contains the delimiter (last message part) will cause the recv() function to
// return an integer representing the actual number of chars received (example: "ty\0" returns 4), while
// strlen() that ignores the null character will return an amount smaller than the chars actually received (for our example,
// it would return 2).
// temp_buf temporarily holds the last string message the recv() function has received from the client
int temp_buf_size = 1000;
char temp_buf[temp_buf_size];
std::string s_recv_buf;
int n = 0, total_size = 0;
do {
n = recv(recvSocket, temp_buf, temp_buf_size, 0);
total_size += n;
// *** new addition
if (n == 0) {
break;
}
// create a temporary string to store the recv_buf char array as a string.
s_recv_buf = recv_buf;
// add the new message part received to the string of the whole message
s_recv_buf += temp_buf;
// convert string to char array and copy it to the original recv_buf
strcpy(recv_buf, s_recv_buf.c_str());
} while(strlen(temp_buf) == n);
printf("------------------------------ I return from Recv... -----------------------------------------\n");
return total_size;
}
void ConnectionHandler::sendMsg(SOCKET sendSocket, const char* outboundMsg) {
std::cout << "ConnectionHandler outbound_msg is: " << std::endl;
for (int i=0; i<strlen(outboundMsg); i++) {
std::cout << outboundMsg[i];
}
send(sendSocket , outboundMsg, strlen(outboundMsg) , 0);
}
int ConnectionHandler::sockInit() {
#ifdef _WIN32
WSADATA wsa_data;
return WSAStartup(MAKEWORD(1,1), &wsa_data);
#else
return 0;
#endif
}
/* Note: For POSIX, typedef SOCKET as an int. */
int ConnectionHandler::sockClose(SOCKET sock) {
int status = 0;
#ifdef _WIN32
status = shutdown(sock, SD_BOTH);
if (status == 0) {
status = closesocket(sock);
}
#else
status = shutdown(sock, SHUT_RDWR);
if (status == 0) {
status = close(sock);
}
#endif
return status;
}
int ConnectionHandler::serverQuit() {
#ifdef _WIN32
return WSACleanup();
#else
return 0;
#endif
}
|
b6eadb1dde7703b4b31f40a2cc5b26d97a85fe7c
|
439d28f761c1774f759fdf720c14ab2108bb93b8
|
/FbCup/2016/qround/fb01.cpp
|
efadca914e3e3d45ea866738279e7b6710fbefa5
|
[] |
no_license
|
Chomtana/cptraining
|
19fec94cd489c6117f49bd6d80642d60079276f1
|
df380badd952dceb335525f03373738c35aa0b3a
|
refs/heads/master
| 2021-01-09T20:53:24.758998
| 2020-04-11T04:10:48
| 2020-04-11T04:10:48
| 56,289,132
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,355
|
cpp
|
fb01.cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> star;
long long dist(long long x1,long long y1,long long x2,long long y2) {
return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}
long long dist(star a,star b) {
return dist(a.first,a.second,b.first,b.second);
}
int main() {
ifstream fs("fb01.txt");
ofstream ofs("fb01out.txt");
int t;fs>>t;
for (int _t=1;_t<=t;_t++) {
int n;fs>>n;
vector< star > data(n);
for (int i = 0;i<n;i++) {
//data[i].first = 0;
//data[i].second = i;
fs>>data[i].first>>data[i].second;
}
//sort(data.begin(),data.end(),sortstar);
long long result = 0;
for (int i = 0;i<n;i++) {
map<long long,long long> dcount;
set<long long> dcountkey;
for (int j = 0;j<n;j++) {
if (i==j) continue;
long long d = dist(data[i],data[j]);
dcount[d]++;
dcountkey.insert(d);
}
for (set<long long>::iterator j = dcountkey.begin();j!=dcountkey.end();j++) {
//cout << i << " " << *j << " " << dcount[*j] << "\n";
result += dcount[*j]*(dcount[*j]-1);
}
}
ofs << "Case #" << _t << ": " << result/2 << "\n";
}
return 0;
}
|
210542adddea6571dd97e49d375f392cb09c7366
|
6b68a9353da47027d8d57abed70d77a36e5422ea
|
/filemanager.h
|
fad6fe135c898ff2958abac31322517280b5e4ae
|
[] |
no_license
|
eustaceb/conversational-audio-browser
|
642b28382d61c0f733c1ce2bebfa3bb2b2f29068
|
3f1c7972151e3e29f142db842ac66d25d847bdfc
|
refs/heads/master
| 2022-02-13T08:19:28.687680
| 2022-01-30T15:23:09
| 2022-01-30T15:23:09
| 74,995,270
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 658
|
h
|
filemanager.h
|
#ifndef PARTICIPANTMANAGER_H
#define PARTICIPANTMANAGER_H
#include <QDialog>
namespace Ui {
class FileManager;
}
class FileManager : public QDialog
{
Q_OBJECT
public:
explicit FileManager(QWidget *parent = 0);
~FileManager();
private slots:
void on_annotationFileLookupButton_clicked();
void on_cancelOkButtonBox_accepted();
void on_cancelOkButtonBox_rejected();
void on_loadFilesButton_clicked();
void on_audioFileLookupButton_clicked();
signals:
void notify_mainWindow_filesLoaded(const QString &annotationsFile, const QString &audioFile);
private:
Ui::FileManager *ui;
};
#endif // PARTICIPANTMANAGER_H
|
44d0c20979f2f7ef1d98df15ebcdd18ffe82815b
|
350167ad671cea6e40222db4b15d632db06a51b2
|
/ObjectOrientedProgramming/Person.cpp
|
89e4902ce3483bca5260b751310fdcd856af1a9b
|
[] |
no_license
|
michaelfordbrown/AcceleratedIntroductionToCPP
|
35d15c8631ab28ded6143ac10a73fe7c2f99a482
|
2617e86c36c6dc9ed59fdefb9dc1523d08f6edf3
|
refs/heads/master
| 2021-08-30T00:38:48.079928
| 2017-12-15T11:43:18
| 2017-12-15T11:43:18
| 112,620,119
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,792
|
cpp
|
Person.cpp
|
#include "stdafx.h"
#include "Address.h"
#include "Person.h"
// Initial constructor
Person::Person(int age, string name, int sex)
// Set base member variables
: age(age), name(name), sex(sex)
{
// Assume that address (new additional member field) field not set
address = nullptr;
}
// Second constructor that includes new address field by appending from initial constructor
Person::Person(int age, string name, int sex,
int house_number, string street_name, string city)
: Person(age, name, sex)
{
// Check if address variable already defined
if (address != nullptr)
delete address;
try
{
// NEW used to allocate heap memory by returned address
address = new Address(house_number, street_name, city);
}
// std::bad_alloc is the type of the object thrown as exceptions by the allocation functions to report failure to allocate storage.
catch (const bad_alloc& e)
{
cout << "Bad Memory Allocation for Address member variable (" << e.what()<< "\n";
}
}
Person::~Person()
{
// Check if address member variable present before return memory to the heap
if (address != nullptr)
{
// DELETE - Deallocates a block of memory.
delete address;
// Clear address pointer to signify no address present
address = nullptr;
}
}
void Person::greet()
{
//Reference to current instance (this)
cout << "Greetings my name is " << this->name
<< " and I am " << this->age << " years old."
<< endl;
// Check if address member variable present before streaming out details
if (address)
{
cout << "I live at " << this->address->house_number << " "
<< this->address->street_name << ", "
<< this->address->city << endl;
}
}
// PUBLIC function that gets member variable
int Person::getLifeExpectancy()
{
return lifeExpectancy;
}
int Person::lifeExpectancy = 80;
|
aed16b4f77e3d3314f603783fdafb3eb6e231f16
|
7a1b2614987dbc456d793a19f0e85eac6ddd027a
|
/augustChallange/ks2.cpp
|
993ae76c4046326c7857fb9cbb9b9c57af349acb
|
[] |
no_license
|
javasucks69/sharedrepo
|
7f7dce8ef36c8156685571447b1739d21e0c08d3
|
2eefe287b8bd539bf0b41c0eb818f9b05e84002b
|
refs/heads/master
| 2020-07-01T19:17:05.886022
| 2019-08-08T17:54:43
| 2019-08-08T17:54:43
| 201,270,222
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,126
|
cpp
|
ks2.cpp
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
cin>>t;
while(t--){
long n;
cin>>n;
vector<vector<long>> temp;
vector<unordered_set<long>> arr2;
vector<long> arr;
long count = 0;
vector<long> t;
for(int i =0 ; i < n;i++)
t.push_back(0);
for(int i =0 ; i < n;i++){
vector<long> t;
temp.push_back(t);
}
for(int i =0 ; i < n;i++){
long tmp;
cin>>tmp;
arr.push_back(tmp);
}
vector<long> allXOR;
long XORofall = 0;
for(long i:arr)
XORofall^=i;
long tempXORofall = 0;
for(long i:arr){
tempXORofall^=i;
allXOR.push_back(XORofall^tempXORofall);
}
sort(arr.begin(),arr.end());
for(long i : allXOR){
if(binary_search(arr.begin(),arr.end(),i))
count++;
}
cout<<count<<endl;
}
}
|
709b4baee164885206472d745d30de9bbd1de9d0
|
c3fae616f99e8ee21397d730583d15b9545ee566
|
/problem/001-050/27.cpp
|
9cccffc70e60623ca0a878ea1dd49c93d62b64c1
|
[] |
no_license
|
kavin23923/Leetcode
|
1de5a664b591d7dc0ccb6484466d9a4ff87e30bd
|
b4b5e08259073f99d02f43736708adaf4e65e021
|
refs/heads/master
| 2020-08-22T03:07:01.228602
| 2020-07-29T14:20:51
| 2020-07-29T14:20:51
| 216,304,311
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 253
|
cpp
|
27.cpp
|
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int now = 0;
int i, size = nums.size();
for (i = 0; i < size; i++) {
if (nums[i] != val) {
nums[now++] = nums[i];
}
}
return now;
}
};
|
21ea54e0fb36f326dc4e91c3ae9e096d3365c473
|
f5397c3b7ed27ca58988fc9d431f6ea28691388e
|
/Maze_v6/main.cpp
|
5d2ebfaaaac2dc51ad1580943b4c2afb340d9369
|
[] |
no_license
|
choooooow/Meadow-maze
|
f3642c0710340f7063a5c0b5de36087c98a30eeb
|
a5429d6842ef9b1794aa816b897a0dbaf1825467
|
refs/heads/master
| 2021-10-27T07:07:05.454297
| 2021-10-21T07:07:38
| 2021-10-21T07:07:38
| 138,808,913
| 0
| 0
| null | 2018-06-27T00:32:04
| 2018-06-27T00:32:04
| null |
UTF-8
|
C++
| false
| false
| 26,625
|
cpp
|
main.cpp
|
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <vector>
#include "stb/stb_image.h"
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw_gl3.h"
#include "maze/camera.h"
#include "maze/shader.h"
#include "maze/model.h"
#include "maze/maze.h"
#include "maze/cloth.h"
using namespace std;
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void cursor_callback(GLFWwindow* window, double xpos, double ypos);
void mouse_callback(GLFWwindow* window, int button, int action, int mods);
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
void processInput(GLFWwindow* window, Maze* ourMaze);
unsigned int loadTexture(const char* path);
unsigned int loadCubemap(vector<std::string> faces);
void RenderScene(Shader& shader, unsigned int& planeVAO, unsigned int& cubeVAO, Maze* ourMaze);
// settings
int SCR_WIDTH = 1280;
int SCR_HEIGHT = 720;
// camera
Camera camera(glm::vec3(0.0f, 3.0f, 3.0f));
float lastX = (float)SCR_WIDTH / 2.0;
float lastY = (float)SCR_HEIGHT / 2.0;
float objectSize = 0.04f;
bool firstMouse = true;
// light source
glm::vec3 lightPos(-21.0f, 35.0f, -35.0f);
// glm::vec3 lightPos(0.0f, 0.3f, 1.0f);
// timing
float deltaTime = 0.0f;
float lastFrame = 0.0f;
// map
int mazeMap = 1;
// set up vertex data (and buffer(s)) and configure vertex attributes
// ------------------------------------------------------------------
float cubeVertices[] = {
// positions // normals // texCoords // tangent // bitangent
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f,
};
float skyboxVertices[] = {
// positions
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};
float planeVertices[] = {
25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 0.0f,
-25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 25.0f,
-25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 0.0f,
25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 25.0f,
-25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 25.0f
};
float quadVertices[] = { // vertex attributes for a quad that fills the entire screen in Normalized Device Coordinates.
// positions // texCoords
-1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
// Cloth
Cloth cloth;
int main()
{
// glfw: initialize and configure
// ------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Maze", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetCursorPosCallback(window, cursor_callback);
glfwSetScrollCallback(window, scroll_callback);
// glfwSetMouseButtonCallback(window, mouse_callback);
// tell GLFW to capture our mouse
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
// configure global opengl state
// -----------------------------
glEnable(GL_DEPTH_TEST);
// build and compile shaders
// -------------------------
Shader cubeShader("shader/cube_shader.vs", "shader/cube_shader.fs");
Shader depthShader("shader/depth_shader.vs", "shader/depth_shader.fs");
Shader skyboxShader("shader/skybox_shader.vs", "shader/skybox_shader.fs");
Shader screenShader("shader/screen_shader.vs", "shader/screen_shader.fs");
Shader clothShader("shader/cloth_shader.vs", "shader/cloth_shader.fs");
Shader postShader("shader/post_shader.vs", "shader/post_shader.fs");
// shader configuration
// --------------------
cubeShader.use();
cubeShader.setInt("diffuseTexture", 0);
cubeShader.setInt("shadowMap", 1);
cubeShader.setInt("normalMap", 2);
skyboxShader.use();
skyboxShader.setInt("skybox", 0);
screenShader.use();
screenShader.setInt("screenTexture", 0);
clothShader.use();
clothShader.setInt("shadowMap", 0);
postShader.use();
postShader.setInt("shadowMap", 2);
// cube VAO
unsigned int cubeVAO, cubeVBO;
glGenVertexArrays(1, &cubeVAO);
glGenBuffers(1, &cubeVBO);
glBindVertexArray(cubeVAO);
glBindBuffer(GL_ARRAY_BUFFER, cubeVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), &cubeVertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 14 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 14 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 14 * sizeof(float), (void*)(6 * sizeof(float)));
glEnableVertexAttribArray(2);
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 14 * sizeof(float), (void*)(8 * sizeof(float)));
glEnableVertexAttribArray(3);
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, 14 * sizeof(float), (void*)(11 * sizeof(float)));
glEnableVertexAttribArray(4);
glBindVertexArray(0);
// skybox VAO
unsigned int skyboxVAO, skyboxVBO;
glGenVertexArrays(1, &skyboxVAO);
glGenBuffers(1, &skyboxVBO);
glBindVertexArray(skyboxVAO);
glBindBuffer(GL_ARRAY_BUFFER, skyboxVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), &skyboxVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
// plane VAO
unsigned int planeVAO, planeVBO;
glGenVertexArrays(1, &planeVAO);
glGenBuffers(1, &planeVBO);
glBindVertexArray(planeVAO);
glBindBuffer(GL_ARRAY_BUFFER, planeVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(planeVertices), planeVertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
glEnableVertexAttribArray(2);
glBindVertexArray(0);
// setup screen VAO
unsigned int quadVAO, quadVBO;
glGenVertexArrays(1, &quadVAO);
glGenBuffers(1, &quadVBO);
glBindVertexArray(quadVAO);
glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
// Load textures
unsigned int planeTexture = loadTexture("./img/plane4.jpg");
unsigned int cubeTexture = loadTexture("./img/wall_test.jpg");
unsigned int normalMap = loadTexture("./img/wall_normal.jpg");
vector<std::string> faces
{
"skybox/waterMountain/right.jpg",
"skybox/waterMountain/left.jpg",
"skybox/waterMountain/top.jpg",
"skybox/waterMountain/bottom.jpg",
"skybox/waterMountain/back.jpg",
"skybox/waterMountain/front.jpg"
};
unsigned int cubemapTexture = loadCubemap(faces);
// configure MSAA framebuffer
// --------------------------
unsigned int framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
// create a multisampled color attachment texture
unsigned int textureColorBufferMultiSampled;
glGenTextures(1, &textureColorBufferMultiSampled);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureColorBufferMultiSampled);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGB, SCR_WIDTH, SCR_HEIGHT, GL_TRUE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, textureColorBufferMultiSampled, 0);
// create a (also multisampled) renderbuffer object for depth and stencil attachments
unsigned int rbo;
glGenRenderbuffers(1, &rbo);
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, SCR_WIDTH, SCR_HEIGHT);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
cout << "ERROR::FRAMEBUFFER:: Framebuffer is not complete!" << endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// configure second post-processing framebuffer
unsigned int intermediateFBO;
glGenFramebuffers(1, &intermediateFBO);
glBindFramebuffer(GL_FRAMEBUFFER, intermediateFBO);
// create a color attachment texture
unsigned int screenTexture;
glGenTextures(1, &screenTexture);
glBindTexture(GL_TEXTURE_2D, screenTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, SCR_WIDTH, SCR_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0); // we only need a color buffer
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
cout << "ERROR::FRAMEBUFFER:: Intermediate framebuffer is not complete!" << endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Configure depth map FBO
const GLuint SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
GLuint depthMapFBO;
glGenFramebuffers(1, &depthMapFBO);
// Create depth texture
GLuint depthMap;
glGenTextures(1, &depthMap);
glBindTexture(GL_TEXTURE_2D, depthMap);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLfloat borderColor[] = { 1.0, 1.0, 1.0, 1.0 };
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// maze: initialize and configure
// ------------------------------
Maze* ourMaze = new Maze();
ourMaze->Init(8, 8);
ourMaze->autoGenerateMaze();
glm::vec3 exitPos = ourMaze->getExit();
// load models
// -----------
Model post("./model/post/rv_lamp_post_2.obj");
// Render loop
while (!glfwWindowShouldClose(window))
{
// Set frame time
float currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
// Check and call events
processInput(window, ourMaze);
// Render
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render depth of scene to texture (from light's perspective)
// get light projection/view matrix.
glm::mat4 lightProjection;
GLfloat near_plane = 40.0f, far_plane = 80.0f;
lightProjection = glm::perspective(glm::radians(50.0f), (float)SHADOW_WIDTH / (float)SHADOW_HEIGHT, near_plane, far_plane);
// lightProjection = glm::ortho(-25.0f, 25.0f, -25.0f, 25.0f, near_plane, far_plane);
glm::mat4 lightView = glm::lookAt(lightPos, glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0));
glm::mat4 lightSpaceMatrix = lightProjection * lightView;
glm::mat4 model;
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
// - now render scene from light's point of view
depthShader.use();
depthShader.setMat4("lightSpaceMatrix", lightSpaceMatrix);
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
glClear(GL_DEPTH_BUFFER_BIT);
RenderScene(depthShader, planeVAO, cubeVAO, ourMaze);
model = glm::translate(glm::mat4(), glm::vec3(0.1f, 0.4f, 0.0f)+exitPos);
model = glm::scale(model, glm::vec3(0.02f, 0.016f, 0.016f));
depthShader.setMat4("model", model);
cloth.update(deltaTime);
cloth.draw();
model = glm::translate(glm::mat4(), glm::vec3(0.0f, -0.5f, 0.0f)+exitPos);
model = glm::scale(model, glm::vec3(0.06f, 0.06f, 0.06f));
depthShader.setMat4("model", model);
post.Draw(depthShader);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Render scene as normal
glfwGetFramebufferSize(window, &SCR_WIDTH, &SCR_HEIGHT);
glViewport(0, 0, SCR_WIDTH, SCR_HEIGHT);
// draw scene as normal in multisampled buffers
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
cubeShader.use();
cubeShader.setMat4("view", view);
cubeShader.setMat4("projection", projection);
cubeShader.setVec3("lightPos", lightPos);
cubeShader.setVec3("viewPos", camera.Position);
cubeShader.setMat4("lightSpaceMatrix", lightSpaceMatrix);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, planeTexture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, depthMap);
model = glm::mat4();
cubeShader.setMat4("model", model);
cubeShader.setInt("object", 1);
glBindVertexArray(planeVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
// Render maze
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, cubeTexture);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, normalMap);
cubeShader.setInt("object", 2);
ourMaze->DrawMaze(cubeShader, cubeVAO);
if (mazeMap == 0) {
ourMaze->DrawMap(camera.Position.x, camera.Position.z);
}
// Render flag
clothShader.use();
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthMap);
model = glm::translate(glm::mat4(), glm::vec3(0.1f, 0.4f, 0.0f)+exitPos);
model = glm::scale(model, glm::vec3(0.02f, 0.016f, 0.016f));
clothShader.setMat4("view", view);
clothShader.setMat4("projection", projection);
clothShader.setMat4("model", model);
clothShader.setMat4("lightSpaceMatrix", lightSpaceMatrix);
clothShader.setVec3("lightPos", lightPos);
clothShader.setVec3("viewPos", camera.Position);
cloth.draw();
postShader.use();
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthMap);
model = glm::translate(glm::mat4(), glm::vec3(0.0f, -0.5f, 0.0f)+exitPos);
model = glm::scale(model, glm::vec3(0.06f, 0.06f, 0.06f));
postShader.setMat4("projection", projection);
postShader.setMat4("view", view);
postShader.setMat4("model", model);
postShader.setVec3("lightPos", lightPos);
postShader.setVec3("viewPos", camera.Position);
postShader.setMat4("lightSpaceMatrix", lightSpaceMatrix);
post.Draw(postShader);
// Render skybox
// change depth function so depth test passes when values are equal to depth buffer's content
glDepthFunc(GL_LEQUAL);
skyboxShader.use();
// remove translation from the view matrix
view = glm::mat4(glm::mat3(camera.GetViewMatrix()));
skyboxShader.setMat4("view", view);
skyboxShader.setMat4("projection", projection);
// skybox cube
glBindVertexArray(skyboxVAO);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
glDrawArrays(GL_TRIANGLES, 0, 36);
glBindVertexArray(0);
// set depth function back to default
glDepthFunc(GL_LESS);
// now blit multisampled buffer(s) to normal colorbuffer of intermediate FBO. Image is stored in screenTexture
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, intermediateFBO);
glBlitFramebuffer(0, 0, SCR_WIDTH, SCR_HEIGHT, 0, 0, SCR_WIDTH, SCR_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// now render quad with scene's visuals as its texture image
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// draw Screen quad
screenShader.use();
glBindVertexArray(quadVAO);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, screenTexture); // use the now resolved color attachment as the quad's texture
glDrawArrays(GL_TRIANGLES, 0, 6);
// Swap the buffers
glfwSwapBuffers(window);
glfwPollEvents();
}
glDeleteVertexArrays(1, &cubeVAO);
glDeleteVertexArrays(1, &skyboxVAO);
glDeleteVertexArrays(1, &planeVAO);
glDeleteBuffers(1, &cubeVBO);
glDeleteBuffers(1, &skyboxVBO);
glDeleteBuffers(1, &planeVBO);
glfwTerminate();
delete ourMaze;
return 0;
}
void RenderScene(Shader& shader, unsigned int& planeVAO, unsigned int& cubeVAO, Maze* ourMaze)
{
// skybox
glm::mat4 model;
shader.setMat4("model", model);
glBindVertexArray(planeVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
ourMaze->DrawMaze(shader, cubeVAO);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
void processInput(GLFWwindow* window, Maze* ourMaze)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) {
camera.ProcessKeyboard(FORWARD, deltaTime);
ourMaze->doCollisions(camera, objectSize, FORWARD, deltaTime);
}
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) {
camera.ProcessKeyboard(BACKWARD, deltaTime);
ourMaze->doCollisions(camera, objectSize, BACKWARD, deltaTime);
}
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) {
camera.ProcessKeyboard(LEFT, deltaTime);
ourMaze->doCollisions(camera, objectSize, LEFT, deltaTime);
}
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
camera.ProcessKeyboard(RIGHT, deltaTime);
ourMaze->doCollisions(camera, objectSize, RIGHT, deltaTime);
}
// jump
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) {
camera.ProcessKeyboard(JUMP, deltaTime);
}
// map
if (glfwGetKey(window, GLFW_KEY_M) == GLFW_PRESS) {
mazeMap ^= 1;
}
}
// glfw: whenever the mouse moves, this callback is called
// -------------------------------------------------------
void cursor_callback(GLFWwindow* window, double xpos, double ypos)
{
if (firstMouse)
{
lastX = xpos;
lastY = ypos;
firstMouse = false;
}
float xoffset = xpos - lastX;
float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
lastX = xpos;
lastY = ypos;
camera.ProcessMouseMovement(xoffset, yoffset);
}
void mouse_callback(GLFWwindow* window, int button, int action, int mods)
{
/**
*
*
*/
}
// glfw: whenever the mouse scroll wheel scrolls, this callback is called
// ----------------------------------------------------------------------
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
camera.ProcessMouseScroll(yoffset);
}
unsigned int loadTexture(char const * path)
{
unsigned int textureID;
glGenTextures(1, &textureID);
int width, height, nrComponents;
unsigned char *data = stbi_load(path, &width, &height, &nrComponents, 0);
if (data)
{
GLenum format;
if (nrComponents == 1)
format = GL_RED;
else if (nrComponents == 3)
format = GL_RGB;
else if (nrComponents == 4)
format = GL_RGBA;
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
stbi_image_free(data);
}
else
{
std::cout << "Texture failed to load at path: " << path << std::endl;
stbi_image_free(data);
}
return textureID;
}
/**
* order:
* +X (right)
* -X (left)
* +Y (top)
* -Y (bottom)
* +Z (front)
* -Z (back)
*/
// ------------------------------------------------
unsigned int loadCubemap(vector<std::string> faces)
{
unsigned int textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
int width, height, nrChannels;
for (unsigned int i = 0; i < faces.size(); i++)
{
unsigned char *data = stbi_load(faces[i].c_str(), &width, &height, &nrChannels, 0);
if (data)
{
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
stbi_image_free(data);
}
else
{
std::cout << "Cubemap texture failed to load at path: " << faces[i] << std::endl;
stbi_image_free(data);
}
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
return textureID;
}
|
7628501eaac1833d509fcae7745d1bd326866086
|
27af56a543eb6d596cf6823529b9889c6646856d
|
/common/log/log.cpp
|
e3f387c9e7507d3ed3bd28f732896bec73e9b472
|
[] |
no_license
|
LaffRM/client_server
|
30045a779cbf0dedf850e10607e48d651855fd7b
|
de72e02b0d9b76892ddc33fade0a7404006ef67d
|
refs/heads/master
| 2020-04-19T05:29:59.972809
| 2019-01-28T15:54:14
| 2019-01-28T15:54:14
| 167,989,444
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,902
|
cpp
|
log.cpp
|
#include "log.h"
using namespace std;
log::log(unsigned int n_, bool c_, char const *f_, char const *fp_)
{
file__ = f_;
file_prefix__ = fp_;
max_size__ = n_;
close__ = c_;
name_create();
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
if (file_length() + 149 >= max_size__)
{
fclose(file_ptr__);
file_clear();
if(close__)
{
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
}
}
if(close__)
{
fclose(file_ptr__);
}
}
log::~log()
{
if(!close__)
{
fclose(file_ptr__);
}
}
void log::write(const char *msg_)
{
char buffer_log[256]={0};
char buffer_msg[128]={0};
size_t msg_len = 0;
if (close__)
{
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
}
msg_len = strlen(msg_);
if (msg_len > 128)
{
cut_msg(msg_, buffer_msg);
}
else
{
memcpy(buffer_msg, msg_, msg_len);
}
log_create(buffer_log, buffer_msg);
msg_len = strlen(buffer_log);
if (msg_len+file_length() > max_size__)
{
fclose(file_ptr__);
file_rename();
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
fseek(file_ptr__, 0, SEEK_END);
fprintf(file_ptr__, "%s", buffer_log);
}
else
{
fseek(file_ptr__, 0, SEEK_END);
fprintf(file_ptr__, "%s", buffer_log);
}
if (close__)
{
fclose(file_ptr__);
}
}
size_t log::file_length()
{
int f_l = 0;
fseek(file_ptr__, 0, SEEK_END);
f_l = ftell(file_ptr__);
return f_l;
}
char* log::get_time(char* buf)
{
struct tm *ptr;
time_t tm;
tm = time(NULL);
ptr = localtime(&tm);
strftime(buf, 80, "%g%m%d %H%M%S", ptr);
return buf;
}
char* log::get_usec(char *buf)
{
unsigned int usec;
struct timeval tv;
gettimeofday(&tv, NULL);
usec = tv.tv_usec;
snprintf (buf, 80, "%d", usec);
return buf;
}
void log::name_create()
{
if(file_prefix__ != NULL)
{
strcpy(file_name__, file_prefix__);
}
strcat(file_name__, file__);
}
void log::log_create(char* buf_log, char const *buf_msg)
{
char buffer_time[80];
char buffer_usec[80];
char buf_rn[2] = {'\r', '\n'};
char buf_cpy[2] = {'\0'};
unsigned int i = 0;
i = strlen(buf_msg);
if ( i >= 2)
{
buf_cpy[0] = buf_msg[i - 2];
buf_cpy[1] = buf_msg[i - 1];
if (memcmp(buf_cpy, buf_rn, 2) == 0)
sprintf(buf_log, "%s %s %s", get_time(buffer_time), get_usec(buffer_usec), buf_msg);
else
sprintf(buf_log, "%s %s %s\r\n", get_time(buffer_time), get_usec(buffer_usec), buf_msg);
}
else
sprintf(buf_log, "%s %s %s\r\n", get_time(buffer_time), get_usec(buffer_usec), buf_msg);
}
void log::file_clear()
{
file_ptr__ = fopen(file_name__, "w");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
fclose(file_ptr__);
}
void log::file_rename()
{
if (file_name__[strlen(file_name__)-1] == '~')
{
file_name__[strlen(file_name__)-1] = '\0';
}
else
{
strncat(file_name__, "~", 1);
}
file_clear();
}
void log::cut_msg(const char *buf, char *buf_msg)
{
strncpy(buf_msg, buf, 124);
strcat(buf_msg, "...");
}
void log::writeb(void const* buf_, size_t len_, char const *info_)
{
char buf_msg[256]={0};
char buffer_log[256]={0};;
size_t msg_len = 0;
if (close__)
{
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
}
if(file_ptr__)
{
fclose(file_ptr__);
}
file_ptr__ = fopen(file_name__, "ab+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
logb_msg(buf_, len_, info_, buf_msg);
blog_create(buffer_log, buf_msg);
msg_len = strlen(buffer_log);
if (msg_len+file_length() > max_size__)
{
fclose(file_ptr__);
file_rename();
file_ptr__ = fopen(file_name__, "a+");
if(!file_ptr__)
{
printf("ERROR! File wasn't opened!");
return;
}
fseek(file_ptr__, 0, SEEK_END);
fprintf(file_ptr__, "%s", buffer_log);
}
else
{
fseek(file_ptr__, 0, SEEK_END);
fprintf(file_ptr__, "%s", buffer_log);
}
if (close__)
{
fclose(file_ptr__);
}
}
void log::logb_msg(void const* buf_, size_t len_, char const *info_, char *buf_msg_)
{
unsigned char const *p = (unsigned char const *)buf_;
if(strlen(info_) <= 128)
{
strcpy(buf_msg_, info_);
}
else
{
char tmp_buf[128];
cut_msg(info_, tmp_buf);
strcpy(buf_msg_, tmp_buf);
return;
}
for(unsigned int i = 0; (i < len_) && (strlen(buf_msg_)) <= 126; i++)
{
char tmp_c[4];
sprintf(tmp_c, " %02x", p[i]);
strcat(buf_msg_, tmp_c);
}
if (strlen(buf_msg_) > 128)
{
char tmp_buf[256];
memcpy(tmp_buf, buf_msg_, 256);
cut_msg(buf_msg_, tmp_buf);
memcpy(buf_msg_, tmp_buf, 256);
}
}
void log::blog_create(char* buf_log, char const *buf_msg)
{
char buffer_time[80];
char buffer_usec[80];
sprintf(buf_log, "%s %s %s\r\n", get_time(buffer_time), get_usec(buffer_usec), buf_msg);
}
|
2572875caef674a332a43a407e01e2f6754b7392
|
35003442901ecf5dcfbc65a6cbe2b978c3bfb367
|
/Homework5/vector.cpp
|
ec8201c908ef66b4f0d1d96741ed4ffac3b4b705
|
[] |
no_license
|
Lebron-WEI/OpenGL
|
71b227b1097770c0d94f5e8ac7a78ae9e6229c61
|
99cb80cbe84f3ca44c24c3e2c026d0fd0b5ea1c4
|
refs/heads/master
| 2022-03-05T22:55:00.949069
| 2019-11-17T12:38:32
| 2019-11-17T12:38:32
| 217,489,872
| 0
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 1,510
|
cpp
|
vector.cpp
|
#include "vector.h"
Vector::Vector()
{
}
Vector::~Vector()
{
}
Vector::Vector(float posX, float posY, float posZ)
{
x = posX;
y = posY;
z = posZ;
}
Vector Vector::operator+(Vector v)
{
return Vector(x + v.x, v.y + y, v.z + z);
}
Vector Vector::operator-(Vector v)
{
return Vector(x - v.x, y - v.y, z - v.z);
}
Vector Vector::operator*(float n)
{
return Vector(x * n, y * n, z * n);
}
Vector Vector::operator/(float n)
{
return Vector(x / n, y / n, z / n);
}
void Vector::getInfo()
{
cout << "x:" << x << " y:" << y << " z:" << z << endl;
}
Vector Vector::abs()
{
if (x < 0) x *= -1;
if (y < 0) y *= -1;
if (z < 0) z *= -1;
return Vector(x, y, z);
}
float Vector::dotMul(Vector v2)
{
return (x * v2.x + y * v2.y + z * v2.z);
}
Vector Vector::crossMul(Vector v2)
{
Vector vNormal;
vNormal.x = ((y * v2.z) - (z * v2.y));
vNormal.y = ((z * v2.x) - (x * v2.z));
vNormal.z = ((x * v2.y) - (y * v2.x));
return vNormal;
}
float Vector::getLength()
{
return (float)sqrt(x * x + y * y + z * z);
}
Vector Vector::normalize()
{
float length = getLength();
x = x / length;
y = y / length;
z = z / length;
return Vector(x, y, z);
}
void Vector::show()
{
cout << "£¨ x:" << x << " y:" << y << " z £©" << z << endl;
}
float Vector::max()
{
float tmp = MAX(y, z);
return MAX(x, tmp);
}
float Vector::min()
{
float tmp = MIN(y, z);
return MIN(x, tmp);
}
float Vector::getDist(Vector v)
{
float tmp = (x - v.x) * (x - v.x) + (y - v.y) * (y - v.y) + (z - v.z) * (z - v.z);
return sqrt(tmp);
}
|
84531d294b99a5c62930b1f32894b26454211418
|
6930cbc7f72d4086352b17b2895c1c7c0effc8c0
|
/Hmwk/Assignment_5/Savitch_9thEd_Chap5_Prob04_FtMConvChoice/main.cpp
|
dd1ce821babae271506d66c5c580d53b5df684d0
|
[] |
no_license
|
javierborja95/JB_CSC5
|
863a6366d7a2b67fd892f631dc282fab802ca862
|
29d5e8a6a5e750cb8b923b010b3ebccec3f189fb
|
refs/heads/master
| 2021-04-12T12:03:05.969346
| 2016-07-29T17:43:40
| 2016-07-29T17:43:40
| 61,830,852
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,543
|
cpp
|
main.cpp
|
/*
* File: main.cpp
* Author: Javier Borja
* Created on July 19, 2016, 4:40 PM
* Purpose: Converts ft to m or vice versa, depending on choice.
*/
//System Libraries
#include <iostream> //Input/ Output Stream Library
#include <iomanip> //Format Output
using namespace std; //Namespace of the System Libraries
//User Libraries
//Global Constants
const float FTMCNV=.3048; //0.3048 m in a foot
//Function Prototypes
void input1(float&,float&);
void convert1(int,int,float&,int&);
void display1(float,int);
void input2(float&,int&);
void convert2(float,int,float&,float&);
void display2(float,float);
//Execution
int main(int argc, char** argv) {
//Variables
int cm;
float m,ft,in;
char ans;
char choice;
do{
//Input Data
cout<<"Type in 1 to convert feet to meters.\n"
"Type in 2 to convert meters to feet."<<endl;
cin>>ans;
if(ans=='1')
input1(ft,in);
else input2(m,cm);
//Process Data
if(ans=='1')
convert1(ft,in,m,cm);
else
convert2(m,cm,ft,in);
//Output Data
if(ans=='1')
display1(m,cm);
else display2(ft,in);
cout<<endl<<"Type 1 to run this program again. Anything else to exit. ";
cin>>choice;
}while(choice=='1');
return 0;
}
void input1(float& ft,float& in){
//Input Data
cout<<"Input whole feet and inches to convert into metric.\n"
"Feet: ";
cin>>ft;
cout<<"Inches: ";
cin>>in;
}
void convert1(int ft,int in,float& m,int& cm){
//Convert Data
float totFtIn; //total feet & inches
totFtIn=ft+(in/12.0f);
m=totFtIn*FTMCNV;
cm=((m-static_cast<int>(m))*1000)+.5;
}
void display1(float m,int cm){
//Display Data
cout<<"Meters = "<<setw(4)<<static_cast<int>(m)<<" m"<<endl;
cout<<"Centimeters = "<<setw(4)<<cm<<"cm"<<endl;
}
void input2(float& ft,int& in){
//Input Data
cout<<"Input whole meters and centimeters to convert to imperial\n"
"Meters: ";
cin>>ft;
cout<<"Centimeters: ";
cin>>in;
}
void convert2(float m,int cm,float& ft,float& in){
//Convert Data
float totMCm; //total feet & inches
totMCm=m+(cm/1000.0f);
ft=totMCm/FTMCNV;
in=((ft-static_cast<int>(ft))/1.0f)*12;
}
void display2(float ft,float in){
//Display Data
cout<<"Feet = "<<setw(5)<<fixed<<static_cast<int>(ft)<<" ft"<<endl;
cout<<"Inches = "<<setw(8)<<setprecision(2)<<fixed<<showpoint<<in<<"in"<<endl;
}
|
2873c55ef2396f50bc3ad5443f09683cd8413ed9
|
711b05c35211a6f733b825c413bf05ede7581821
|
/ZF/ZFCore/zfsrc/ZFCore/ZFFileDescriptor.cpp
|
17ede5acb1f6b5a43aae4ec9b30323c411f94bc0
|
[
"MIT"
] |
permissive
|
chmodawk/ZFFramework
|
67a5232f8853febe72eae5f314a8f78a51f0c637
|
cfac6ca5e71662ad2ebfc5d681f3877fe56742cd
|
refs/heads/master
| 2021-07-18T13:10:24.849114
| 2017-10-20T09:27:20
| 2017-10-20T09:27:20
| 108,427,246
| 1
| 0
| null | 2017-10-26T15:05:18
| 2017-10-26T15:05:18
| null |
UTF-8
|
C++
| false
| false
| 12,907
|
cpp
|
ZFFileDescriptor.cpp
|
/* ====================================================================== *
* Copyright (c) 2010-2016 ZFFramework
* home page: http://ZFFramework.com
* blog: http://zsaber.com
* contact: master@zsaber.com (Chinese and English only)
* Distributed under MIT license:
* https://github.com/ZFFramework/ZFFramework/blob/master/license/license.txt
* ====================================================================== */
#include "ZFFileDescriptor.h"
ZF_NAMESPACE_GLOBAL_BEGIN
// ============================================================
zfclassPOD _ZFP_ZFFileDescriptorCallbackData
{
public:
ZFFileDescriptorInputCallbackGetter inputCallbackGetter;
ZFFileDescriptorOutputCallbackGetter outputCallbackGetter;
};
ZF_GLOBAL_INITIALIZER_INIT_WITH_LEVEL(ZFFileDescriptorTypeHolder, ZFLevelZFFrameworkStatic)
{
}
public:
ZFCoreMap fileDescriptorTypeMap; // _ZFP_ZFFileDescriptorCallbackData *
ZF_GLOBAL_INITIALIZER_END(ZFFileDescriptorTypeHolder)
#define _ZFP_ZFFileDescriptorTypeMap (ZF_GLOBAL_INITIALIZER_INSTANCE(ZFFileDescriptorTypeHolder)->fileDescriptorTypeMap)
static _ZFP_ZFFileDescriptorCallbackData *_ZFP_ZFFileDescriptorTypeFind(ZF_IN const zfchar *fileDescriptorType)
{
return _ZFP_ZFFileDescriptorTypeMap.get<_ZFP_ZFFileDescriptorCallbackData *>(fileDescriptorType);
}
// ============================================================
ZFInputCallback _ZFP_ZFInputCallbackForFileDescriptor(ZF_IN const ZFCallerInfo &callerInfo,
ZF_IN const zfchar *fileDescriptor,
ZF_IN_OPT zfindex fileDescriptorLen /* = zfindexMax() */,
ZF_IN_OPT ZFFileOpenOptionFlags flags /* = ZFFileOpenOption::e_Read */,
ZF_IN_OPT const ZFFileBOMList &autoSkipBOMTable /* = ZFFileBOMListDefault() */)
{
ZFInputCallback ret = ZFCallbackNullDetail(callerInfo);
if(fileDescriptor == zfnull)
{
return ret;
}
const zfchar *typeStart = zfnull;
zfindex typeLength = 0;
const zfchar *dataStart = zfnull;
zfindex dataLength = 0;
{
const zfchar *p = fileDescriptor;
const zfchar *pEnd = ((fileDescriptorLen == zfindexMax()) ? p + zfslen(fileDescriptor) : p + fileDescriptorLen);
for( ; p != pEnd; ++p)
{
if(*p == ':')
{
typeStart = fileDescriptor;
typeLength = p - typeStart;
dataStart = p + 1;
dataLength = pEnd - dataStart;
break;
}
}
if(typeStart == zfnull)
{
return ret;
}
}
const _ZFP_ZFFileDescriptorCallbackData *callbackData = _ZFP_ZFFileDescriptorTypeFind(zfstring(typeStart, typeLength).cString());
if(callbackData == zfnull)
{
return ret;
}
ret = callbackData->inputCallbackGetter(
dataStart, dataLength,
flags,
autoSkipBOMTable);
ret.callbackCallerInfoSet(callerInfo);
{
zfstring callbackId;
callbackId += zfText("ZFInputCallbackForFileDescriptor");
ZFFileBOMListToString(callbackId, autoSkipBOMTable);
callbackId += zfText(":");
callbackId.append(fileDescriptor, fileDescriptorLen);
ret.callbackIdSet(callbackId);
}
{
zfbool success = zffalse;
ZFSerializableData customData;
customData.itemClassSet(ZFSerializableKeyword_node);
do
{
ZFSerializableData fileDescriptorData;
if(!zfstringToData(fileDescriptorData, fileDescriptor))
{
break;
}
fileDescriptorData.categorySet(ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_fileDescriptor);
customData.elementAdd(fileDescriptorData);
if(flags != ZFFileOpenOption::e_Read)
{
ZFSerializableData flagsData;
if(!ZFFileOpenOptionFlagsToData(flagsData, flags))
{
break;
}
flagsData.categorySet(ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_flags);
customData.elementAdd(flagsData);
}
if(autoSkipBOMTable.objectCompare(ZFFileBOMListDefault()) != ZFCompareTheSame)
{
ZFSerializableData autoSkipBOMTableData;
if(!zfstringToData(autoSkipBOMTableData, ZFFileBOMListToString(autoSkipBOMTable)))
{
break;
}
autoSkipBOMTableData.categorySet(ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_autoSkipBOMTable);
customData.elementAdd(autoSkipBOMTableData);
}
success = zftrue;
} while(zffalse);
if(success)
{
ret.callbackSerializeCustomTypeSet(ZFCallbackSerializeCustomType_ZFInputCallbackForFileDescriptor);
ret.callbackSerializeCustomDataSet(customData);
}
}
return ret;
}
ZFMETHOD_FUNC_DEFINE_4(ZFInputCallback, ZFInputCallbackForFileDescriptor,
ZFMP_IN(const zfchar *, fileDescriptor),
ZFMP_IN_OPT(zfindex, fileDescriptorLen, zfindexMax()),
ZFMP_IN_OPT(ZFFileOpenOptionFlags, flags, ZFFileOpenOption::e_Read),
ZFMP_IN_OPT(const ZFFileBOMList &, autoSkipBOMTable, ZFFileBOMListDefault()))
{
return ZFInputCallbackForFileDescriptor(fileDescriptor, fileDescriptorLen, flags, autoSkipBOMTable);
}
ZFCALLBACK_SERIALIZE_CUSTOM_TYPE_DEFINE(ZFCallbackSerializeCustomTypeId_ZFInputCallbackForFileDescriptor)
{
const ZFSerializableData *fileDescriptorData = ZFSerializableUtil::requireElementByCategory(
serializableData, ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_fileDescriptor, outErrorHint, outErrorPos);
if(fileDescriptorData == zfnull)
{
return zffalse;
}
const zfchar *fileDescriptor = zfnull;
if(!zfstringFromData(fileDescriptor, *fileDescriptorData, outErrorHint, outErrorPos))
{
return zffalse;
}
ZFFileOpenOptionFlags flags = ZFFileOpenOption::e_Read;
{
const ZFSerializableData *flagsData = ZFSerializableUtil::checkElementByCategory(serializableData, ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_flags);
if(flagsData != zfnull && !ZFFileOpenOptionFlagsFromData(flags, *flagsData, outErrorHint, outErrorPos))
{
return zffalse;
}
}
ZFFileBOMList BOMList;
{
const ZFSerializableData *autoSkipBOMTableData = ZFSerializableUtil::checkElementByCategory(serializableData, ZFSerializableKeyword_ZFInputCallbackForFileDescriptor_autoSkipBOMTable);
zfstring BOMStringList;
if(autoSkipBOMTableData != zfnull)
{
if(!zfstringFromData(BOMStringList, *autoSkipBOMTableData, outErrorHint, outErrorPos))
{
return zffalse;
}
BOMList.removeAll();
if(!ZFFileBOMListFromString(BOMList, BOMStringList))
{
ZFSerializableUtil::errorOccurred(outErrorHint, outErrorPos, *autoSkipBOMTableData, zfText("format BOM list error"));
return zffalse;
}
}
else
{
BOMList.addFrom(ZFFileBOMListDefault());
}
}
serializableData.resolveMark();
result = ZFInputCallbackForFileDescriptor(fileDescriptor, zfindexMax(), flags, BOMList);
return zftrue;
}
// ============================================================
ZFOutputCallback _ZFP_ZFOutputCallbackForFileDescriptor(ZF_IN const ZFCallerInfo &callerInfo,
ZF_IN const zfchar *fileDescriptor,
ZF_IN_OPT zfindex fileDescriptorLen /* = zfindexMax() */,
ZF_IN_OPT ZFFileOpenOptionFlags flags /* = ZFFileOpenOption::e_Create */)
{
ZFOutputCallback ret = ZFCallbackNullDetail(callerInfo);
if(fileDescriptor == zfnull)
{
return ret;
}
const zfchar *typeStart = zfnull;
zfindex typeLength = 0;
const zfchar *dataStart = zfnull;
zfindex dataLength = 0;
{
const zfchar *p = fileDescriptor;
const zfchar *pEnd = ((fileDescriptorLen == zfindexMax()) ? p + zfslen(fileDescriptor) : p + fileDescriptorLen);
for( ; p != pEnd; ++p)
{
if(*p == ':')
{
typeStart = fileDescriptor;
typeLength = p - typeStart;
dataStart = p + 1;
dataLength = pEnd - dataStart;
break;
}
}
if(typeStart == zfnull)
{
return ret;
}
}
const _ZFP_ZFFileDescriptorCallbackData *callbackData = _ZFP_ZFFileDescriptorTypeFind(zfstring(typeStart, typeLength).cString());
if(callbackData == zfnull)
{
return ret;
}
ret = callbackData->outputCallbackGetter(
dataStart, dataLength,
flags);
ret.callbackCallerInfoSet(callerInfo);
{
zfbool success = zffalse;
ZFSerializableData customData;
customData.itemClassSet(ZFSerializableKeyword_node);
do
{
ZFSerializableData fileDescriptorData;
if(!zfstringToData(fileDescriptorData, fileDescriptor))
{
break;
}
fileDescriptorData.categorySet(ZFSerializableKeyword_ZFOutputCallbackForFileDescriptor_fileDescriptor);
customData.elementAdd(fileDescriptorData);
if(flags != ZFFileOpenOption::e_Create)
{
ZFSerializableData flagsData;
if(!ZFFileOpenOptionFlagsToData(flagsData, flags))
{
break;
}
flagsData.categorySet(ZFSerializableKeyword_ZFOutputCallbackForFileDescriptor_flags);
customData.elementAdd(flagsData);
}
success = zftrue;
} while(zffalse);
if(success)
{
ret.callbackSerializeCustomTypeSet(ZFCallbackSerializeCustomType_ZFOutputCallbackForFileDescriptor);
ret.callbackSerializeCustomDataSet(customData);
}
}
return ret;
}
ZFMETHOD_FUNC_DEFINE_3(ZFOutputCallback, ZFOutputCallbackForFileDescriptor,
ZFMP_IN(const zfchar *, fileDescriptor),
ZFMP_IN_OPT(zfindex, fileDescriptorLen, zfindexMax()),
ZFMP_IN_OPT(ZFFileOpenOptionFlags, flags, ZFFileOpenOption::e_Create))
{
return ZFOutputCallbackForFileDescriptor(fileDescriptor, fileDescriptorLen, flags);
}
ZFCALLBACK_SERIALIZE_CUSTOM_TYPE_DEFINE(ZFCallbackSerializeCustomTypeId_ZFOutputCallbackForFileDescriptor)
{
const ZFSerializableData *fileDescriptorData = ZFSerializableUtil::requireElementByCategory(
serializableData, ZFSerializableKeyword_ZFOutputCallbackForFileDescriptor_fileDescriptor, outErrorHint, outErrorPos);
if(fileDescriptorData == zfnull)
{
return zffalse;
}
const zfchar *fileDescriptor = zfnull;
if(!zfstringFromData(fileDescriptor, *fileDescriptorData, outErrorHint, outErrorPos))
{
return zffalse;
}
ZFFileOpenOptionFlags flags = ZFFileOpenOption::e_Create;
{
const ZFSerializableData *flagsData = ZFSerializableUtil::checkElementByCategory(serializableData, ZFSerializableKeyword_ZFOutputCallbackForFileDescriptor_flags);
if(flagsData != zfnull && !ZFFileOpenOptionFlagsFromData(flags, *flagsData, outErrorHint, outErrorPos))
{
return zffalse;
}
}
serializableData.resolveMark();
result = ZFOutputCallbackForFileDescriptor(fileDescriptor, zfindexMax(), flags);
return zftrue;
}
void ZFFileDescriptorTypeRegister(ZF_IN const zfchar *descriptorType,
ZF_IN ZFFileDescriptorInputCallbackGetter inputCallbackGetter,
ZF_IN ZFFileDescriptorOutputCallbackGetter outputCallbackGetter)
{
_ZFP_ZFFileDescriptorCallbackData *callbackData = zfnew(_ZFP_ZFFileDescriptorCallbackData);
callbackData->inputCallbackGetter = inputCallbackGetter;
callbackData->outputCallbackGetter = outputCallbackGetter;
_ZFP_ZFFileDescriptorTypeMap.set(descriptorType, ZFCorePointerForObject<_ZFP_ZFFileDescriptorCallbackData *>(callbackData));
}
void ZFFileDescriptorTypeUnregister(ZF_IN const zfchar *descriptorType)
{
_ZFP_ZFFileDescriptorTypeMap.remove(descriptorType);
}
void ZFFileDescriptorTypeGetAllT(ZF_OUT ZFCoreArray<const zfchar *> &ret)
{
_ZFP_ZFFileDescriptorTypeMap.allKeyT(ret);
}
ZF_NAMESPACE_GLOBAL_END
|
2c3456446efdde3ab261111689ea83aca81f454b
|
5162cca172a82e746f19132d860dd60a56d307d6
|
/AccIIIDriver/tests/AccIIIDriverMock.h
|
90decee337ae25a6d107b2f9fb56a78c84ce8210
|
[] |
no_license
|
maxwellre/AccIII
|
45448bdac8b44b29efbdf945e470af6f1f5834df
|
3f7b9f111d97d03adda3e4a65bbcd96c0d12823d
|
refs/heads/master
| 2021-03-27T10:04:58.160766
| 2020-09-03T16:58:38
| 2020-09-03T16:58:38
| 116,180,437
| 1
| 4
| null | 2020-09-03T16:58:40
| 2018-01-03T20:45:51
|
VHDL
|
UTF-8
|
C++
| false
| false
| 1,569
|
h
|
AccIIIDriverMock.h
|
/*
* AccIIIDriverMock.h
*
* Inherits from AccIIIDriver.
* Mock class to access protected content during Unit Tests.
*
* Created on: Aug 25, 2020
* Author: Basil Duvernoy
*/
#ifndef ACCIIIDRIVERMOCK_H_
#define ACCIIIDRIVERMOCK_H_
#include "AccIIIDriver/AccIIIDriver.h"
class AccIIIDriverMock : public AccIIIDriver {
private:
protected:
public:
void setreadTime(int _readTime_ms);
int getreadTime();
void seterrorCommunication(bool b);
/**------ byteStack Modifiers/Getters/Setters --------**/
bool initbyteStack();
void addtobyteStack(Byte* bp, long length = -1);
void addtobyteStack(Byte b);
bool removeFrombyteStack(long nbByte);
std::deque< Byte > getFrombyteStack(long nbByte);
int getbyteStack_length();
/**------ Threads State Modifiers --------------------**/
void setmasterState(StateThread value);
void setlistenerState(StateThread value);
void setdecoderState(StateThread value);
void setState(StateThread* state_var, StateThread value);
/**------ Threads State Getters ----------------------**/
StateThread getmasterState();
StateThread getlistenerState();
StateThread getdecoderState();
StateThread getState(StateThread* state_var);
/**------ Threads State Checkers ---------------------**/
bool is_master(StateThread st);
bool is_listener(StateThread st);
bool is_decoder(StateThread st);
bool are_slaves(StateThread st);
bool areAfter_slaves(StateThread st);
bool is_listenerDone();
};
#endif /* ACCIIIDRIVERMOCK_H_ */
|
a3bc86b9db3c9392c4f9aa91cf43696d023fdc66
|
060bf587ae7b4d9188d5b14e6e46de442100f9ff
|
/encoderdecoder.h
|
53e7016444165267667a9d1c146c3ed17746248f
|
[] |
no_license
|
guysarusi2/spl3client
|
f32b939cb3e6c77c166f308fa597a002e34d177a
|
f6e395cd403393588975eb98fc6bd02b23f4adbb
|
refs/heads/master
| 2023-02-09T16:22:47.827636
| 2021-01-06T17:15:59
| 2021-01-06T17:15:59
| 326,487,371
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 511
|
h
|
encoderdecoder.h
|
//
// Created by guy on 29/12/2020.
//
#ifndef ASSIGNMENT4_ENCODERDECODER_H
#define ASSIGNMENT4_ENCODERDECODER_H
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
class encoderdecoder {
private:
//const int size;
char bytes[1024];
int len;
unordered_map<string, short> opCode;
public:
encoderdecoder();
std::string decodeNextByte(char nextByte);
void encode(std::vector<string> message, char& buf);
};
#endif //ASSIGNMENT4_ENCODERDECODER_H
|
9e270f114bba55bb0c71d5dcd9140692032e1db7
|
b9f6b0998ee5d26e4d7ec7a67b247ad9e51b163f
|
/tags/5.0/thread/idleapp.cc
|
736d886ce11b9ab29d5469ff003c657fcaa27d67
|
[] |
no_license
|
rbsn/FAU-BST
|
a7ab5255e2586d27a5979fed80e9d4726b84dfb3
|
0750fdddc8163c0fbf1a60de44dd503cf309f50f
|
refs/heads/master
| 2021-01-25T03:48:09.815420
| 2011-07-27T10:54:20
| 2011-07-27T10:54:20
| 1,701,311
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 351
|
cc
|
idleapp.cc
|
#include "idleapp.h"
// Konstruktor
void IdleApp::action () {
O_Stream idlestream;
int counter = 0;
while(1) {
idlestream << /*gotoxy(cid * 2, 100) << color(color::FG_BLACK + cid, color::BG_WHITE - cid, color::OFF) <<*/ "Idle " << cid << " on CPU " << cpu << ": "<< counter++ << endl;
for(volatile int i = 0; i < 40000000; i++) {
}
}
}
|
8f2ef2689725eb544d4edd1c77331c8c6aec43e4
|
305b9d7e4bc8ba731164fb10e53fb1e0a8d53775
|
/libspindle/io/TextDataFile.h
|
742153fc72e8f855073b46d15171b550351ee044
|
[
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-mit-old-style"
] |
permissive
|
skn123/Spindle
|
33b2bed84de866bb87e69bbfb2eca06e780b3dcb
|
d5f2cab92c86c547efbf09fb30be9d478da04332
|
refs/heads/master
| 2021-05-26T12:50:00.410427
| 2012-11-14T01:23:01
| 2012-11-14T01:23:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,290
|
h
|
TextDataFile.h
|
//
// TextDataFile.h
//
// $Id: TextDataFile.h,v 1.2 2000/02/18 01:31:52 kumfert Exp $
//
// Gary Kumfert, Old Dominion University
// Copyright(c) 1998, Old Dominion University. All rights reserved.
//
// Permission to use, copy, modify, distribute and sell this software and
// its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. Old Dominion University makes no
// representations about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
//
// =========================================================================
//
//
#ifndef SPINDLE_TEXT_DATA_FILE_H_
#define SPINDLE_TEXT_DATA_FILE_H_
#ifdef REQUIRE_OLD_CXX_HEADER_SUFFIX
#include <stdio.h>
#include <string.h>
#else
#include <cstdio>
#include <cstring>
#endif
#ifndef SPINDLE_H_
#include "spindle/spindle.h"
#endif
SPINDLE_BEGIN_NAMESPACE
/**
* @memo Handles compressed or uncompressed files.
* @type class
*
* This class hides details about where the #FILE# pointer
* came from. It could be that the user just specified
* a file name, or the user could have specified a
* command with a pipe #|# symbol. Or the user could
* have specified a compressed (gzipped, etc) file that
* this class uncompresses and opens a pipe to.
*
* @author Gary Kumfert
* @version #$Id: TextDataFile.h,v 1.2 2000/02/18 01:31:52 kumfert Exp $#
*/
class TextDataFile {
private:
enum {pipe, file} filetype;
bool openRead( const char* string, const char* mode );
bool openWrite( const char* string, const char* mode );
void checkERRNO();
protected:
FILE * fp;
bool m_isBinary;
bool m_isFormatted;
/// protected default constructor
TextDataFile() : fp(0), m_isBinary(false), m_isFormatted(false) {}
public:
/// destructor
~TextDataFile();
/// returns the FILE*
FILE* getFilePointer();
/// opens a file, pipe, or compressed file depending on string
bool open( const char* string, const char* mode );
/// closes the file.
bool close();
};
inline FILE*
TextDataFile::getFilePointer() {
return fp;
}
SPINDLE_END_NAMESPACE
#endif
|
dd2d86c4fe9a24f45e7c05f8048b39a6ae130cc1
|
a97ea4a3dd636ae1beceba387228919e609ffb5c
|
/Clase_prietene_si_imbricate/Clase_prietene_si_imbricate/main.cpp
|
5fa2f1f3c880d9e880505ba71554dd32b1c51612
|
[] |
no_license
|
RobuRaluca/Clase-prietene-si-imbricate
|
90f425daa368c9571578b3976e7d9131dc0f1bbc
|
47e77dd24b669eb29e96dfcc6dbf9be05a2e625e
|
refs/heads/master
| 2023-08-27T23:33:44.178776
| 2021-10-13T19:40:58
| 2021-10-13T19:40:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,657
|
cpp
|
main.cpp
|
#include"Clista.h"
#include<iostream>
using namespace std;
int optiune, numar;
int main() {
Clista list;
cout << "Meniu" << endl << endl;
cout << "Introduce 1 pentru a adauga un element in lista" << endl;
cout << "Introduce 2 pentru a sterge un element din lista" << endl;
cout << "Introduce 3 pentru a elimina din lista elementele mai mici decat o valoare data" << endl;
cout << "Introduce 4 pentru calculul mediei aritmetice a elementelor din lista" << endl;
cout << "Introduce 5 pentru a afisa elementele din lista" << endl;
cout << "Introduce 0 pentru a iesi" << endl;
cout << endl << endl << "Optiunea este : ";
cin >> optiune;
int index = 0;
while (optiune != 0) {
if (index != 0) {
cout << endl << endl << "Introduce-ti urmatoarea optiune, sau 0 pentru a iesi din meniu" << endl << "Optiunea este :";
cin >> optiune;
}
index++;
if (optiune == 1) {
cout << endl << endl << "Introduce-ti numarul pe care vreti sa-l introduceti in lista : ";
cin >> numar;
list.Adaugare_in_lista(numar);
}
if (optiune == 2) {
cout << endl << endl << "Introduce-ti elementul pe care vreti sa-l stergeti : ";
cin >> numar;
list.Stergere_element_din_lista(numar);
}
if (optiune == 3) {
cout << endl << endl << "Eliminarea elementelor mai mici decat o valoare data. Valoare = ";
cin >> numar;
list.Eliminarea_elementelor_mai_mici_de(numar);
}
if (optiune == 4) {
cout << endl << endl << "Media aritmetica a elementelor listei este : ";
list.Medie();
}
if (optiune == 5) {
cout << endl << endl << "Afisarea elementelor din lista :";
list.Afisare_lista();
}
}
int a;
cin >> a;
}
|
0af92b148aa404fce73e3da2a1b4b2fec00ee397
|
819843deb59ed8eb94738e5946a6649cc9f9e59a
|
/Duilib/Layout/DuiTabLayout.cpp
|
0659be24dcef82d014500bae37d0a454535b4b22
|
[] |
no_license
|
guifumo/DuiLib_White
|
dc7fa1c96723e2056171b8adf62a688117772a17
|
62f00cfde1e8a72fd32ea712a44447006cda1297
|
refs/heads/master
| 2022-01-10T06:07:12.523155
| 2018-12-27T09:24:54
| 2018-12-27T09:24:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,986
|
cpp
|
DuiTabLayout.cpp
|
#include "StdAfx.h"
#include "DuiTabLayout.h"
namespace DuiLib
{
IMPLEMENT_DUICONTROL(CDuiTabLayout)
CDuiTabLayout::CDuiTabLayout(void)
: m_iCurSel(-1)
{
}
CDuiTabLayout::~CDuiTabLayout(void)
{
}
CDuiString CDuiTabLayout::GetClass() const
{
return DUI_CTR_TABLAYOUT;
}
LPVOID CDuiTabLayout::GetInterface(CDuiString strName)
{
if(strName == DUI_CTR_TABLAYOUT)
{
return static_cast<CDuiTabLayout*>(this);
}
return CDuiContainer::GetInterface(strName);
}
BOOL CDuiTabLayout::Add(CDuiControl* pControl)
{
BOOL ret = CDuiContainer::Add(pControl);
if(!ret)
{
return ret;
}
if(m_iCurSel == -1 && pControl->IsVisible())
{
m_iCurSel = GetItemIndex(pControl);
}
else
{
pControl->SetVisible(FALSE);
}
return ret;
}
BOOL CDuiTabLayout::AddAt(CDuiControl* pControl, int iIndex)
{
BOOL ret = CDuiContainer::AddAt(pControl, iIndex);
if(!ret)
{
return ret;
}
if(m_iCurSel == -1 && pControl->IsVisible())
{
m_iCurSel = GetItemIndex(pControl);
}
else if(m_iCurSel != -1 && iIndex <= m_iCurSel)
{
m_iCurSel += 1;
}
else
{
pControl->SetVisible(FALSE);
}
return ret;
}
BOOL CDuiTabLayout::Remove(CDuiControl* pControl)
{
if(pControl == NULL)
{
return FALSE;
}
int index = GetItemIndex(pControl);
BOOL ret = CDuiContainer::Remove(pControl);
if(!ret)
{
return FALSE;
}
if(m_iCurSel == index)
{
if(GetCount() > 0)
{
m_iCurSel = 0;
GetItemAt(m_iCurSel)->SetVisible(TRUE);
}
else
{
m_iCurSel = -1;
}
NeedParentUpdate();
}
else if(m_iCurSel > index)
{
m_iCurSel -= 1;
}
return ret;
}
void CDuiTabLayout::RemoveAll()
{
m_iCurSel = -1;
CDuiContainer::RemoveAll();
NeedParentUpdate();
}
BOOL CDuiTabLayout::SelectItem(int iIndex)
{
if(iIndex < 0 || iIndex >= GetItems()->GetSize())
{
return FALSE;
}
if(iIndex == m_iCurSel)
{
return TRUE;
}
int iOldSel = m_iCurSel;
m_iCurSel = iIndex;
for(int it = 0; it < GetItems()->GetSize(); it++)
{
if(it == iIndex)
{
GetItemAt(it)->SetVisible(TRUE);
GetItemAt(it)->SetFocus();
SetPos(GetPos());
}
else
{
GetItemAt(it)->SetVisible(FALSE);
}
}
NeedParentUpdate();
if(GetManager() != NULL)
{
GetManager()->SetNextTabControl();
GetManager()->SendNotify(this, DUI_MSGTYPE_TABSELECT, m_iCurSel, iOldSel);
}
return TRUE;
}
BOOL CDuiTabLayout::SelectItem(CDuiControl* pControl)
{
int iIndex = GetItemIndex(pControl);
if(iIndex == -1)
{
return FALSE;
}
else
{
return SelectItem(iIndex);
}
}
int CDuiTabLayout::GetCurSel() const
{
return m_iCurSel;
}
void CDuiTabLayout::SetCurSel(int iCurSel)
{
m_iCurSel = iCurSel;
}
void CDuiTabLayout::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
if(_tcsicmp(pstrName, _T("selectedid")) == 0)
{
SelectItem(_ttoi(pstrValue));
}
else
{
return CDuiContainer::SetAttribute(pstrName, pstrValue);
}
}
void CDuiTabLayout::SetPos(RECT rc, BOOL bNeedInvalidate /*= TRUE*/)
{
CDuiControl::SetPos(rc, bNeedInvalidate);
// Adjust for inset
rc = GetPos();
RECT rcInset = GetInset();
rc.left += rcInset.left;
rc.top += rcInset.top;
rc.right -= rcInset.right;
rc.bottom -= rcInset.bottom;
for(int it = 0; it < CDuiContainer::GetCount(); it++)
{
CDuiControl* pControl = static_cast<CDuiControl*>(CDuiContainer::GetItemAt(it));
if(!pControl->IsVisible())
{
continue;
}
if(pControl->IsFloat())
{
SetFloatPos(it);
continue;
}
if(it != m_iCurSel)
{
continue;
}
RECT rcPadding = pControl->GetPadding();
rc.left += rcPadding.left;
rc.top += rcPadding.top;
rc.right -= rcPadding.right;
rc.bottom -= rcPadding.bottom;
SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
SIZE sz = pControl->EstimateSize(szAvailable);
if(sz.cx == 0)
{
sz.cx = MAX(0, szAvailable.cx);
}
if(sz.cx < pControl->GetMinWidth())
{
sz.cx = pControl->GetMinWidth();
}
if(sz.cx > pControl->GetMaxWidth())
{
sz.cx = pControl->GetMaxWidth();
}
if(sz.cy == 0)
{
sz.cy = MAX(0, szAvailable.cy);
}
if(sz.cy < pControl->GetMinHeight())
{
sz.cy = pControl->GetMinHeight();
}
if(sz.cy > pControl->GetMaxHeight())
{
sz.cy = pControl->GetMaxHeight();
}
RECT rcCtrl = { rc.left, rc.top, rc.left + sz.cx, rc.top + sz.cy};
pControl->SetPos(rcCtrl, FALSE);
}
}
}
|
877cfa48bc16d90b79d1ef90d0b6f69dbf8c7a04
|
bc7d06038df1275710de064999c5e0a2aa4f81a7
|
/July/29 July/twoNonRepeatingNumbersInAnArray.cpp
|
dd7cbcb17f363235762e35c7e8bc030f444464ab
|
[] |
no_license
|
almas-ashruff/DSASolutions
|
0da67313658239e2355a13bc14d6f3c7aad4478e
|
649c536826c67fc0a0b658603b92463eb51e8d89
|
refs/heads/main
| 2023-07-20T00:54:00.888617
| 2021-08-12T14:26:55
| 2021-08-12T14:26:55
| 376,128,025
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,378
|
cpp
|
twoNonRepeatingNumbersInAnArray.cpp
|
// Given an array A containing 2*N+2 positive numbers, out of which
// 2*N numbers exist in pairs whereas the other two number occur exactly once
// and are distinct. Find the other two numbers.
// https://practice.geeksforgeeks.org/problems/finding-the-numbers0215/1#
// https://www.youtube.com/watch?v=pnx5JA9LNM4
vector<int> singleNumber(vector<int> nums) {
int XxorY = 0;
// Find the XOR of all numbers.
// All repeating number are cancelled out.
// The XOR of the two non repeating values, x and y is the answer
for(int num : nums) {
XxorY = XxorY ^ num;
}
// find the right most set bit mask of the xor ans -> something like 0000010
int rsbm = XxorY & (-XxorY); // rightmost set bit mask
// declare the two answer values
int x = 0, y = 0;
// now, the numbers can be divided into two sets.
// values in one set will have 1 at the RSBM,
// values in the other set will have 0.
// The two non repeating values will always end up in different sets.
// Now, XOR the two sets among themselves.
// The reamining value in each set will be the answers
for(int num : nums) {
if((num & rsbm) == 0) {
x = x ^ num;
} else {
y = y ^ num;
}
}
if( x < y) {
return {x, y};
}
return {y, x};
}
|
1eb50d99c6715fa490895698de959b85828e1abe
|
2528bec40987c7643bee32a78b1f2d2b11fb4888
|
/src/morphogens/Maxwell.cpp
|
712b853aef7f4cb1e0fbc9d8244ba8a85cec038a
|
[] |
no_license
|
portegys/Maxwell
|
7aaf9497cda49ecf8451d867918fb7dec2cd9ed1
|
254ef12f95225a76209661fcd53a0e66d10bf57d
|
refs/heads/master
| 2020-07-15T15:06:50.169482
| 2019-08-31T20:02:03
| 2019-08-31T20:02:03
| 205,590,214
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 25,128
|
cpp
|
Maxwell.cpp
|
/*
* This software is provided under the terms of the GNU General
* Public License as published by the Free Software Foundation.
*
* Copyright (c) 2003 Tom Portegys, All Rights Reserved.
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.
*/
#include "Maxwell.hpp"
#include "../base/Mechanics.hpp"
#include "../util/Random.hpp"
#include "../util/Log.hpp"
// Set genome
void Maxwell::setGenome(Genome *genome)
{
if (this->genome != NULL)
{
delete this->genome;
}
this->genome = genome;
}
// Create genome.
Genome *Maxwell::createGenome()
{
Genome *genome = new Genome();
assert(genome != NULL);
return(genome);
}
// Constructor.
Maxwell::Maxwell()
{
// Create associated morphogens.
bondMorph = new BondMorph();
assert(bondMorph != NULL);
createMorph = new CreateMorph();
assert(createMorph != NULL);
grappleMorph = new GrappleMorph();
assert(grappleMorph != NULL);
propelMorph = new PropelMorph();
assert(propelMorph != NULL);
orientMorph = new OrientMorph();
assert(orientMorph != NULL);
typeMorph = new TypeMorph();
assert(typeMorph != NULL);
// Create genome.
genome = new Genome();
assert(genome != NULL);
#if (FORAGING_MOVEMENT_SCREEN == 1)
// Create movement test neighborhood.
int x, y;
Particle *particle;
for (x = 0; x < 3; x++)
{
for (y = 0; y < 3; y++)
{
testNeighbors.cells[x][y] = new Cell();
assert(testNeighbors.cells[x][y] != NULL);
}
}
particle = new Particle(BODY_SIDE_TYPE);
assert(particle != NULL);
testNeighbors.cells[0][1]->particles.push_front(particle);
particle = new Particle(BODY_CORNER_TYPE);
assert(particle != NULL);
particle->orientation.direction = NORTHEAST;
testNeighbors.cells[1][1]->particles.push_front(particle);
particle = new Particle(BODY_SIDE_TYPE);
assert(particle != NULL);
particle->orientation.direction = EAST;
testNeighbors.cells[1][0]->particles.push_front(particle);
#endif
}
// Destructor.
Maxwell::~Maxwell()
{
delete bondMorph;
delete createMorph;
delete grappleMorph;
delete propelMorph;
delete orientMorph;
delete typeMorph;
delete genome;
#if (FORAGING_MOVEMENT_SCREEN == 1)
// Delete movement test neighborhood.
int x, y;
Particle *particle;
std::list<Particle *>::const_iterator listItr;
for (x = 0; x < 3; x++)
{
for (y = 0; y < 3; y++)
{
for (listItr = testNeighbors.cells[x][y]->particles.begin();
listItr != testNeighbors.cells[x][y]->particles.end(); listItr++)
{
particle = *listItr;
delete particle;
}
delete testNeighbors.cells[x][y];
}
}
#endif
}
// Initialize.
void Maxwell::init(Mechanics *mechanics)
{
// Base init.
((Morphogen *)this)->init(mechanics);
// Initialize components.
bondMorph->init(mechanics);
createMorph->init(mechanics);
grappleMorph->init(mechanics);
propelMorph->init(mechanics);
orientMorph->init(mechanics);
typeMorph->init(mechanics);
}
// Load body configuration.
bool Maxwell::load(Body **bodies, int numBodies)
{
int i, n, r, l, x, y;
n = r = l = 0;
Body *body, *maxwell, *food, *poison, *obstacle;
Particle *particle;
// Identify bodies.
maxwell = food = poison = obstacle = NULL;
for (i = 0; i < numBodies; i++)
{
body = bodies[i];
if ((particle = body->particles) == NULL)
{
continue;
}
switch (particle->type)
{
case FOOD_TYPE:
food = body;
break;
case POISON_TYPE:
poison = body;
break;
case OBSTACLE_TYPE:
obstacle = body;
break;
case BODY_SIDE_TYPE:
case BODY_CORNER_TYPE:
maxwell = body;
break;
}
}
if (maxwell == NULL)
{
Log::logError("Cannot load Maxwell");
return(false);
}
// Clear placement map.
for (x = 0; x < WIDTH; x++)
{
for (y = 0; y < HEIGHT; y++)
{
map[x][y] = -1;
}
}
// Place Maxwell.
body = maxwell->duplicate(mechanics);
if (!placeBody(body, 0.0f))
{
Log::logError("Cannot place Maxwell");
return(false);
}
// Add body to automaton.
mechanics->addBody(body);
#if (FORAGE_ENV == 1)
// Add food to forage.
if (food == NULL)
{
Log::logError("Cannot load food");
return(false);
}
// Determine number of patches.
n = Random::nextInt(MAX_FOOD_PATCHES - MIN_FOOD_PATCHES + 1);
n += MIN_FOOD_PATCHES;
for (i = 0; i < n; i++)
{
// Determine radius.
r = Random::nextInt(MAX_PATCH_RADIUS - MIN_PATCH_RADIUS + 1);
r += MIN_PATCH_RADIUS;
// Map food patch.
#if (SNAPSHOT == 1)
x = WIDTH / 2;
y = HEIGHT / 2;
#else
x = Random::nextInt(WIDTH);
y = Random::nextInt(HEIGHT);
#endif
mapPatch(FOOD_TYPE, x, y, r);
}
// Create food particles.
for (x = 0; x < WIDTH; x++)
{
for (y = 0; y < HEIGHT; y++)
{
if (map[x][y] == FOOD_TYPE)
{
body = food->duplicate(mechanics);
particle = body->particles;
particle->vPosition.x = POSITION(x);
particle->vPosition.y = POSITION(y);
particle->coefficientOfRestitution = 0.1f;
mechanics->addBody(body);
}
}
}
#endif
#if (POISON_ENV == 1)
// Add poison to avoid and repair damage from.
if (poison == NULL)
{
Log::logError("Cannot load poison");
return(false);
}
// Determine number of poison particles.
n = Random::nextInt(MAX_POISON_PARTICLES - MIN_POISON_PARTICLES + 1);
n += MIN_POISON_PARTICLES;
for (i = 0; i < n; i++)
{
body = poison->duplicate(mechanics);
if (!placeBody(body, MAX_VELOCITY))
{
Log::logError("Cannot place poison");
return(false);
}
mechanics->addBody(body);
}
#endif
#if (OBSTACLE_ENV == 1)
// Add obstacles to avoid.
if (obstacle == NULL)
{
Log::logError("Cannot load obstacle");
return(false);
}
// Determine number of walls.
n = Random::nextInt(MAX_OBSTACLE_WALLS - MIN_OBSTACLE_WALLS + 1);
n += MIN_OBSTACLE_WALLS;
for (i = 0; i < n; i++)
{
// Determine wall length.
l = Random::nextInt(MAX_WALL_LENGTH - MIN_WALL_LENGTH + 1);
l += MIN_WALL_LENGTH;
// Map wall.
x = Random::nextInt(WIDTH);
y = Random::nextInt(HEIGHT);
switch (Random::nextInt(4))
{
case 0:
for (int j = 0; j < l; j++)
{
if (y >= HEIGHT)
{
break;
}
if ((map[x][y] != -1) && (map[x][y] != OBSTACLE_TYPE))
{
break;
}
map[x][y] = OBSTACLE_TYPE;
y++;
}
break;
case 1:
for (int j = 0; j < l; j++)
{
if (y < 0)
{
break;
}
if ((map[x][y] != -1) && (map[x][y] != OBSTACLE_TYPE))
{
break;
}
map[x][y] = OBSTACLE_TYPE;
y--;
}
break;
case 2:
for (int j = 0; j < l; j++)
{
if (x >= WIDTH)
{
break;
}
if ((map[x][y] != -1) && (map[x][y] != OBSTACLE_TYPE))
{
break;
}
map[x][y] = OBSTACLE_TYPE;
x++;
}
break;
case 3:
for (int j = 0; j < l; j++)
{
if (x < 0)
{
break;
}
if ((map[x][y] != -1) && (map[x][y] != OBSTACLE_TYPE))
{
break;
}
map[x][y] = OBSTACLE_TYPE;
x--;
}
break;
}
}
// Create wall particles.
for (x = 0; x < WIDTH; x++)
{
for (y = 0; y < HEIGHT; y++)
{
if (map[x][y] == OBSTACLE_TYPE)
{
body = obstacle->duplicate(mechanics);
particle = body->particles;
particle->vPosition.x = POSITION(x);
particle->vPosition.y = POSITION(y);
particle->setFixed(true);
mechanics->addBody(body);
}
}
}
#endif
return(true);
}
// Place body.
bool Maxwell::placeBody(Body *body, float maxVelocity)
{
int i;
Particle *particle;
double dx, dy, x, y;
dx = dy = 0.0;
for (i = 0; i < MAX_PLACEMENT_TRIES; i++)
{
dx = WIDTH * Random::nextDouble();
dy = HEIGHT * Random::nextDouble();
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
x = particle->vPosition.x + dx;
y = particle->vPosition.y + dy;
if ((x < 0.0) || (x >= WIDTH) || (y < 0.0) || (y >= HEIGHT))
{
break;
}
}
if (particle == NULL)
{
break;
}
}
if (i == MAX_PLACEMENT_TRIES)
{
return(false);
}
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
particle->vPosition.x = POSITION(particle->vPosition.x + dx);
particle->vPosition.y = POSITION(particle->vPosition.y + dy);
}
// Randomize body velocity.
if (maxVelocity > 0.0f)
{
body->vVelocity.x = Random::nextDouble() * maxVelocity;
if (Random::nextBoolean())
{
body->vVelocity.x = -body->vVelocity.x;
}
body->vVelocity.y = Random::nextDouble() * -maxVelocity;
if (Random::nextBoolean())
{
body->vVelocity.y = -body->vVelocity.y;
}
}
// Map particle placements.
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
map[(int)particle->vPosition.x][(int)particle->vPosition.y] = particle->type;
}
return(true);
}
// Map patch.
void Maxwell::mapPatch(int type, int x, int y, int radius)
{
if (radius == 0)
{
return;
}
if (map[x][y] == -1)
{
map[x][y] = type;
}
if (x > 0)
{
mapPatch(type, x - 1, y, radius - 1);
}
if (x < WIDTH - 1)
{
mapPatch(type, x + 1, y, radius - 1);
}
if (y > 0)
{
mapPatch(type, x, y - 1, radius - 1);
}
if (y < HEIGHT - 1)
{
mapPatch(type, x, y + 1, radius - 1);
}
}
// Pre-morph processing.
void Maxwell::preMorph()
{
}
// Emit signals.
Emission *Maxwell::signal(Neighborhood *neighbors)
{
Cell *cell;
int i, x, y, dx, dy, action, type;
Particle *particle;
Gene *gene;
Signal *signal;
Emission *emissionList, *emission;
std::list<Particle *>::const_iterator listItr;
Orientation orientation;
// Process particles in neighborhood origin.
emissionList = NULL;
cell = neighbors->cells[1][1];
for (listItr = cell->particles.begin();
listItr != cell->particles.end(); listItr++)
{
particle = *listItr;
// Transform neighborhood to particle orientation.
neighbors->transform(particle->orientation);
// Perform actions determined by genes.
for (i = 0; i < NUM_GENES; i++)
{
gene = genome->genes[i];
// Get action.
if (!gene->matchNeighborhood(neighbors))
{
continue;
}
if (gene->types[1][1] != particle->type)
{
continue;
}
if ((action = gene->action) == -1)
{
continue;
}
x = gene->dx;
y = gene->dy;
neighbors->getCellLocation(x, y);
// Execute action.
signal = NULL;
switch (action)
{
case CREATE_ACTION:
// Cannot create food.
if (gene->type == FOOD_TYPE)
{
continue;
}
orientation.direction =
particle->orientation.aim(gene->orientation.direction);
orientation.mirrored =
particle->orientation.getMirrorX2(gene->orientation.mirrored);
signal = createMorph->createCreateSignal(particle,
orientation, gene->type);
break;
case BOND_ACTION:
signal = bondMorph->createBondSignal(particle, gene->type);
break;
case SET_TYPE_ACTION:
// Cannot change to food.
if (gene->type == FOOD_TYPE)
{
continue;
}
// Target must be in neighborhood.
if ((x < -1) || (x > 1) || (y < -1) || (y > 1))
{
continue;
}
type = gene->types[x + 1][y + 1];
if (type < 0)
{
continue;
}
signal = typeMorph->createTypeSignal(gene->type, type);
break;
case ORIENT_ACTION:
orientation.direction =
particle->orientation.aim(gene->orientation.direction);
orientation.mirrored =
particle->orientation.getMirrorX2(gene->orientation.mirrored);
signal = orientMorph->createOrientSignal(orientation, gene->type);
break;
case UNBOND_ACTION:
signal = bondMorph->createUnbondSignal(particle, gene->type);
break;
case DESTROY_ACTION:
// Cannot destroy obstacle.
if (gene->type == OBSTACLE_TYPE)
{
continue;
}
signal = createMorph->createDestroySignal(gene->type);
break;
case GRAPPLE_ACTION:
if ((x < -1) || (x > 1) || (y < -1) || (y > 1))
{
continue;
}
orientation.direction = gene->orientation.direction;
orientation.mirrored = particle->orientation.mirrored;
Neighborhood::getDxy(x, y, orientation, dx, dy);
signal = grappleMorph->createGrappleSignal(particle, dx, dy, gene->type);
break;
case PROPEL_ACTION:
signal = propelMorph->createPropelSignal(particle,
particle->orientation.aim(gene->orientation.direction),
gene->strength, gene->tendency, gene->type);
break;
}
// Queue signal emission to target cell.
if (signal != NULL)
{
emission = new Emission(signal, x, y, gene->delay, gene->duration);
assert(emission != NULL);
emission->next = emissionList;
emissionList = emission;
}
}
}
// Return signal emissions.
return(emissionList);
}
// Morph.
void Maxwell::morph(Cell *cell)
{
// Associated signal processing.
bondMorph->morph(cell);
createMorph->morph(cell);
grappleMorph->morph(cell);
propelMorph->morph(cell);
orientMorph->morph(cell);
typeMorph->morph(cell);
}
// Post-morph processing.
void Maxwell::postMorph()
{
Body *body;
Particle *particle, *removeParticle;
bool done;
// Propel bodies.
propelMorph->postMorph();
// Kill particles hit by poison particles.
done = false;
while (!done)
{
done = true;
for (body = mechanics->bodies; body != NULL; body = body->next)
{
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
if ((particle->type == BODY_SIDE_TYPE) ||
(particle->type == BODY_CORNER_TYPE))
{
if ((particle->collide != NULL) &&
mechanics->isValidParticle(particle->collide) &&
(particle->collide->type == POISON_TYPE))
{
removeParticle = particle;
done = false;
break;
}
}
}
if (!done)
{
break;
}
}
if (!done)
{
mechanics->removeParticle(body, removeParticle);
}
}
}
// Get morphogen fitness.
double Maxwell::getFitness()
{
Body *body;
int variance;
double fitness;
// Maxwell is "alive"?
body = findMaxwell(variance);
if ((body == NULL) || (variance > MIN_VARIANCE))
{
return(0.0);
}
fitness = (double)(body->energy - variance);
if (fitness < 0.0)
{
fitness = 0.0;
}
return(fitness);
}
// Find "best" Maxwell: if found, return body (NULL if not found)
// and measure of its "variance" from ideal.
// Note: Maxwell's sides can be temporarily removed to admit food.
Body *Maxwell::findMaxwell(int& bestVariance)
{
int corners, sides, i, j;
int variance;
Body *body, *bestBody;
Particle *particle;
Particle *p[4], *px, *py;
Particle *ne, *se, *sw, *nw; // corners
Particle *n, *s, *e, *w; // sides
bestBody = NULL;
bestVariance = -1;
for (body = mechanics->bodies; body != NULL; body = body->next)
{
variance = 0;
// Count "foreign" particles.
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
if ((particle->type != BODY_CORNER_TYPE) &&
(particle->type != BODY_SIDE_TYPE))
{
variance++;
}
}
// Get corners.
p[0] = p[1] = p[2] = p[3] = NULL;
corners = 0;
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
if (particle->type == BODY_CORNER_TYPE)
{
corners++;
if (p[0] == NULL)
{
p[0] = particle;
}
else if (p[1] == NULL)
{
p[1] = particle;
}
else if (p[2] == NULL)
{
p[2] = particle;
}
else if (p[3] == NULL)
{
p[3] = particle;
}
}
}
if (corners < 4)
{
variance += (4 - corners);
}
if (corners > 4)
{
variance += (corners - 4);
}
// Got corners: determine ordering.
ne = se = sw = nw = NULL;
for (i = 0; i < 4; i++)
{
if (p[i] == NULL)
{
continue;
}
px = py = NULL;
for (j = 0; j < 4; j++)
{
if (i == j)
{
continue;
}
if (p[j] == NULL)
{
continue;
}
if (p[i]->vPosition.x == p[j]->vPosition.x)
{
px = p[j];
}
if (p[i]->vPosition.y == p[j]->vPosition.y)
{
py = p[j];
}
}
if ((px == NULL) || (py == NULL))
{
break;
}
if (px->vPosition.y > p[i]->vPosition.y)
{
if (py->vPosition.x > p[i]->vPosition.x)
{
sw = p[i];
}
else
{
se = p[i];
}
}
else
{
if (py->vPosition.x > p[i]->vPosition.x)
{
nw = p[i];
}
else
{
ne = p[i];
}
}
}
// Get sides.
p[0] = p[1] = p[2] = p[3] = NULL;
sides = 0;
for (particle = body->particles; particle != NULL;
particle = particle->next)
{
if (particle->type == BODY_SIDE_TYPE)
{
sides++;
if (p[0] == NULL)
{
p[0] = particle;
}
else if (p[1] == NULL)
{
p[1] = particle;
}
else if (p[2] == NULL)
{
p[2] = particle;
}
else if (p[3] == NULL)
{
p[3] = particle;
}
}
}
if (sides < 4)
{
variance += (4 - sides);
}
if (sides > 4)
{
variance += (sides - 4);
}
// Got sides: determine ordering.
n = s = e = w = NULL;
for (i = 0; i < 4; i++)
{
if (p[i] == NULL)
{
continue;
}
for (j = 0; j < 4; j++)
{
if (i == j)
{
continue;
}
if (p[j] == NULL)
{
continue;
}
if (p[i]->vPosition.x == p[j]->vPosition.x)
{
if (p[i]->vPosition.y > p[j]->vPosition.y)
{
n = p[i];
}
else
{
s = p[i];
}
}
if (p[i]->vPosition.y == p[j]->vPosition.y)
{
if (p[i]->vPosition.x > p[j]->vPosition.x)
{
e = p[i];
}
else
{
w = p[i];
}
}
}
}
// Check connectivity.
if (n != NULL)
{
if ((ne != NULL) && (n->getBond(ne) == NULL))
{
variance++;
}
if ((nw != NULL) && (n->getBond(nw) == NULL))
{
variance++;
}
}
if (s != NULL)
{
if ((se != NULL) && (s->getBond(se) == NULL))
{
variance++;
}
if ((sw != NULL) && (s->getBond(sw) == NULL))
{
variance++;
}
}
if (e != NULL)
{
if ((se != NULL) && (e->getBond(se) == NULL))
{
variance++;
}
if ((ne != NULL) && (e->getBond(ne) == NULL))
{
variance++;
}
}
if (w != NULL)
{
if ((sw != NULL) && (w->getBond(sw) == NULL))
{
variance++;
}
if ((nw != NULL) && (w->getBond(nw) == NULL))
{
variance++;
}
}
if ((bestVariance == -1) || (variance < bestVariance))
{
bestVariance = variance;
bestBody = body;
}
}
return(bestBody);
}
// Create a viable gene.
void Maxwell::createViableGene(Gene *gene, int action)
{
int x, y;
// Clear gene.
gene->clear();
// Choose a target cell/particle.
x = Random::nextInt(3);
y = Random::nextInt(3);
gene->types[x][y] = Random::nextInt(NUM_PARTICLE_TYPES);
gene->strength = Gene::STRENGTH_QUANTUM;
gene->dx = x - 1;
gene->dy = y - 1;
// Choose default parameters.
gene->type = gene->types[x][y];
gene->orientation.direction = Random::nextInt(8);
gene->tendency = Gene::TENDENCY_QUANTUM;
switch (gene->action = action)
{
case CREATE_ACTION:
gene->types[x][y] = Gene::EMPTY_CELL;
gene->type = Random::nextInt(NUM_PARTICLE_TYPES);
break;
case BOND_ACTION:
break;
case SET_TYPE_ACTION:
// Prevent illegal/ineffective type change.
if (NUM_PARTICLE_TYPES > 2)
{
while (true)
{
gene->type = Random::nextInt(NUM_PARTICLE_TYPES);
if ((gene->type != FOOD_TYPE) && (gene->type !=
gene->types[x][y]))
{
break;
}
}
}
break;
case ORIENT_ACTION:
gene->orientation.mirrored = Random::nextBoolean();
break;
case UNBOND_ACTION:
break;
case DESTROY_ACTION:
break;
case GRAPPLE_ACTION:
gene->orientation.mirrored = Random::nextBoolean();
break;
case PROPEL_ACTION:
break;
}
}
#if (FORAGING_MOVEMENT_SCREEN == 1)
// Gene produces mobility (self-propulsion)?
bool Maxwell::isMobile(int geneNum)
{
Particle *particle;
Gene *gene;
// Check center particle for propulsion.
particle = *testNeighbors.cells[1][1]->particles.begin();
assert(particle != NULL);
// Transform neighborhood to particle orientation.
testNeighbors.transform(particle->orientation);
// Test gene for propulsion.
gene = genome->genes[geneNum];
if ((gene->action == PROPEL_ACTION) &&
(gene->types[1][1] == particle->type) &&
(gene->dx == 0) && (gene->dy == 0) &&
(gene->orientation.direction != CENTER) &&
gene->matchNeighborhood(&testNeighbors))
{
return(true);
}
else
{
return(false);
}
}
#endif
|
ed3b5fd5c7f545e128578ce19378f6d26c518b76
|
f5dc059a4311bc542af480aa8e8784965d78c6e7
|
/lattices/Lattices/TiledCollapser.h
|
fe1e7035352401b821d95d72c5b83f77dad197fb
|
[] |
no_license
|
astro-informatics/casacore-1.7.0_patched
|
ec166dc4a13a34ed433dd799393e407d077a8599
|
8a7cbf4aa79937fba132cf36fea98f448cc230ea
|
refs/heads/master
| 2021-01-17T05:26:35.733411
| 2015-03-24T11:08:55
| 2015-03-24T11:08:55
| 32,793,738
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,348
|
h
|
TiledCollapser.h
|
//# TiledCollapser.h: Abstract base class to collapse chunks for LatticeApply
//# Copyright (C) 1996,1997,1998
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id: TiledCollapser.h 20229 2008-01-29 15:19:06Z gervandiepen $
#ifndef LATTICES_TILEDCOLLAPSER_H
#define LATTICES_TILEDCOLLAPSER_H
//# Includes
#include <casa/aips.h>
#include <scimath/Mathematics/NumericTraits.h>
namespace casa { //# NAMESPACE CASA - BEGIN
//# Forward Declarations
template <class T> class Array;
class IPosition;
// <summary>
// Abstract base class to collapse chunks for LatticeApply
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class=LatticeApply>LatticeApply</linkto>
// </prerequisite>
// <etymology>
// </etymology>
// <synopsis>
// This is an abstract base class for the collapsing of chunks to
// be used in function <src>tiledApply</src>
// in class <linkto class=LatticeApply>LatticeApply</linkto>.
// It is meant for cases where an entire line or plane is not needed
// (e.g. calculation of maximum). If that is needed (e.g. to calculate moment),
// it is better to use function <src>LatticeApply::lineApply</src>
// with class <linkto class=LineCollapser>LineCollapser</linkto>.
// <p>
// The user has to derive a concrete class from this base class
// and implement the (pure) virtual functions.
// <br> The main function is <src>process</src>, which needs to do the
// calculation.
// <br> Other functions make it possible to perform an initial check.
// <p>
// The class is Doubly templated. Ths first template type
// is for the data type you are processing. The second type is
// for what type you want the results of the processing assigned to.
// For example, if you are computing sums of squares for statistical
// purposes, you might use higher precision (FLoat->Double) for this.
// No check is made that the template types are self-consistent.
// </synopsis>
// <example>
// <srcblock>
// </srcblock>
// </example>
// <motivation>
// </motivation>
// <todo asof="1997/08/01">
// <li>
// </todo>
template <class T, class U=T> class TiledCollapser
{
public:
// Destructor
virtual ~TiledCollapser();
// The init function for a derived class.
// It can be used to check if <src>nOutPixelsPerCollapse</src>
// corresponds with the number of pixels produced per collapsed chunk.
// <br><src>processAxis</src> is the axis of the line being passed
// to the <src>process</src> function.
virtual void init (uInt nOutPixelsPerCollapse) = 0;
// Can the process function in the derived class handle a null mask pointer?
// If not, LatticeApply ensures that it'll always pass a mask block,
// even if the lattice does not have a mask (in that case that mask block
// contains all True values).
// <br>The default implementation returns False.
// <br>The function is there to make optimization possible when no masks
// are involved. On the other side, it allows the casual user to ignore
// optimization.
virtual Bool canHandleNullMask() const;
// Create and initialize the accumulator.
// The accumulator can be a cube with shape [n1,n2,n3],
// where <src>n2</src> is equal to <src>nOutPixelsPerCollapse</src>.
// However, one can also use several matrices as accumulator.
// <br> The data type of the accumulator can be any. E.g. when
// accumulating Float lattices, the accumulator could be of
// type Double to have enough precision.
// <br>In the <src>endAccumulator</src> function the accumulator
// data has to be copied into an Array object with the correct
// shape and data type.
virtual void initAccumulator (uInt n1, uInt n3) = 0;
// Collapse the given input data containing (<src>nrval</src> values
// with an increment of <src>inIncr</src> elements).
// <src>inMask</src> is a Bool block representing a mask with the
// same nr of values and increment as the input data. If a mask
// value is False, the corresponding input value is masked off.
// <br>When function <src>canHandleNullMask</src> returned True,
// it is possible that <src>inMask</src> is a null pointer indicating
// that the input has no mask, thus all values are valid.
// <br>
// The result(s) have to be stored in the accumulator at the given indices.
// <br><src>startPos</src> gives the lattice position of the first value.
// The position of other values can be calculated from index and shape
// using function <src>toPositionInArray</src> in class
// <linkto class=IPosition>IPosition</linkto>.
virtual void process (uInt accumIndex1, uInt accumIndex3,
const T* inData, const Bool* inMask,
uInt inIncr, uInt nrval,
const IPosition& startPos,
const IPosition& shape) = 0;
// End the accumulator. It should return the accumulator as an
// Array of datatype U (e.g. double the precision of type T)
// with the given shape. The accumulator should thereafter be deleted when needed.
virtual void endAccumulator (Array<U>& result,
Array<Bool>& resultMask,
const IPosition& shape) = 0;
};
} //# NAMESPACE CASA - END
#ifndef CASACORE_NO_AUTO_TEMPLATES
#include <lattices/Lattices/TiledCollapser.tcc>
#endif //# CASACORE_NO_AUTO_TEMPLATES
#endif
|
074012a4c4d3c48402cabff33dfa7ab121b4aa25
|
c469979c93eed823ee544fb62e3928ea2ac2f686
|
/project/Unit1.cpp
|
042efef380e652efdccd26669de5044a0d45aaeb
|
[] |
no_license
|
lnik801l/lab6
|
e241b5dde6f6573a5948872c07cdba5a86680280
|
c5f5818202cdb8923ccb05cba1c13c9212d836b8
|
refs/heads/master
| 2023-01-29T23:35:41.319298
| 2020-12-15T19:28:29
| 2020-12-15T19:28:29
| 321,768,899
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,635
|
cpp
|
Unit1.cpp
|
//---------------------------------------------------------------------------
#include <vcl.h>
#include <iostream>
#include <string>
#include <cmath>
#include "Unit1.h"
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
using namespace std;
TForm1 *Form1;
void sort_asc(int arr[], const int size)
{
for (auto i = 0; i < size - 1; i++) {
for (auto j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
swap(arr[j], arr[j + 1]);
}
}
}
}
void sort_desc(int arr[], const int size)
{
for (auto i = 0; i < size - 1; ++i)
{
auto smallest_index = i;
for (auto j = i; j < size + 1; ++j)
{
if (arr[j] > arr[smallest_index])
smallest_index = j;
}
swap(arr[i], arr[smallest_index]);
}
}
short calculate(double a, double b, double c, double &x1, double &x2)
{
try
{
short status = -1;
const auto disc = b * b - 4 * a * c;
if (disc == 0) status = 1;
if (disc > 0) status = 2;
if (disc < 0) status = 0;
x1 = (-b + sqrt(disc)) / 2 * a;
x2 = (-b - sqrt(disc)) / 2 * a;
if (x1 != x1 || x2 != x2) {
return -1;
}
return status;
} catch (exception ignored)
{
return -1;
}
}
wchar_t* reverse_str(wchar_t str[], const unsigned int size)
{
for (auto i = 0u; i < size / 2; i++)
swap(str[i], str[size - i - 1]);
return str;
}
System::String process_string(const wchar_t str[], unsigned int length, bool asc)
{
int arr[100];
for (auto& i : arr)
{
i = 0;
}
auto j = 0;
auto flag = false;
for (auto i = 0u; i < length; i++) {
if (str[i] == ',')
continue;
if (str[i] == ' ') {
j++;
flag = false;
}
else {
if (str[i] == '-') {
flag = true;
continue;
}
wchar_t s[2];
s[0] = str[i];
s[1] = 0;
if (flag)
arr[j] = arr[j] * 10 - _wtoi(s);
else
arr[j] = arr[j] * 10 + _wtoi(s);
}
}
if (asc)
sort_asc(arr, j + 1);
else
sort_desc(arr, j + 1);
System::String result = "";
for (auto i = 0u; i < j + 1; i++) {
result += arr[i];
result += " ";
}
return result;
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::exec_pow(TObject *Sender)
{
auto number = Form1->Edit1->Text.ToIntDef(1);
auto rank = Form1->Edit2->Text.ToIntDef(1);
auto res = pow(number, rank);
Form1->Label5->Caption = res;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::revert_handler(TObject *Sender)
{
auto str = Form1->Edit3->Text;
Form1->Label9->Caption = reverse_str(str.c_str(), str.Length());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::sort_array(TObject *Sender)
{
auto str = Form1->Edit4->Text;
Form1->Label13->Caption = process_string(str.c_str(), str.Length(), Form1->CheckBox1->Checked).c_str();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::exec_function(TObject *Sender)
{
double x1;
double x2;
Form1->Label19->Caption = calculate(Form1->Edit5->Text.ToIntDef(1),
Form1->Edit6->Text.ToIntDef(1),
Form1->Edit7->Text.ToIntDef(1),
x1,x2);
Form1->Label21->Caption = x1;
Form1->Label23->Caption = x2;
}
//---------------------------------------------------------------------------
|
94465e3b80e896a86e0d14fe7be2b012c910f362
|
9b5acc90f8d4bad27bf618bf8605ed68d8e907f9
|
/win/task_dialog.h
|
51501b08cf55594747a884e5321cd628d08c46dc
|
[
"MIT"
] |
permissive
|
BluTree/windows
|
2847495ac58ed4fd1b703ada50d400045d8cad52
|
01dbb9cd5098f036771d79c2ed1ea5921f69f759
|
refs/heads/master
| 2023-03-10T07:41:42.467743
| 2021-02-17T16:09:06
| 2021-02-17T16:09:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,546
|
h
|
task_dialog.h
|
/*
MIT License
Copyright (c) 2010-2016 Eren Okka
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.
*/
#pragma once
#include <vector>
#include <windows.h>
#include <commctrl.h>
#define TD_ICON_NONE static_cast<PCWSTR>(0)
#define TD_ICON_INFORMATION TD_INFORMATION_ICON
#define TD_ICON_WARNING TD_WARNING_ICON
#define TD_ICON_ERROR TD_ERROR_ICON
#define TD_ICON_SHIELD TD_SHIELD_ICON
#define TD_ICON_SHIELD_GREEN MAKEINTRESOURCE(-8)
#define TD_ICON_SHIELD_RED MAKEINTRESOURCE(-7)
#define TDF_SIZE_TO_CONTENT 0x1000000
namespace win {
class TaskDialog {
public:
TaskDialog();
TaskDialog(LPCWSTR title, LPWSTR icon);
virtual ~TaskDialog() {}
void AddButton(LPCWSTR text, int id);
int GetSelectedButtonID() const;
bool GetVerificationCheck() const;
void SetCollapsedControlText(LPCWSTR text);
void SetContent(LPCWSTR text);
void SetExpandedControlText(LPCWSTR text);
void SetExpandedInformation(LPCWSTR text);
void SetFooter(LPCWSTR LPCWSTR);
void SetFooterIcon(LPWSTR icon);
void SetMainIcon(LPWSTR icon);
void SetMainInstruction(LPCWSTR text);
void SetVerificationText(LPCWSTR text);
void SetWindowTitle(LPCWSTR text);
HRESULT Show(HWND parent);
void UseCommandLinks(bool use);
protected:
static HRESULT CALLBACK Callback(
HWND hwnd, UINT uNotification,
WPARAM wParam, LPARAM lParam,
LONG_PTR dwRefData);
void Initialize();
std::vector<TASKDIALOG_BUTTON> buttons_;
TASKDIALOGCONFIG config_;
int selected_button_id_;
bool verification_checked_;
};
} // namespace win
|
eacdb24ea25cdda40df288d886d3b6f56fa59348
|
8fe04c79865999441e65d22fe57a02383d222a00
|
/PCLModeling/QResampling.cpp
|
06875228292f632e901866865a6b1c9a2f567578
|
[] |
no_license
|
eglrp/oldpct
|
b32c8e447b8e2c131dfc67fee86f246b7d53d179
|
79e40f8fd4f355b4dfce7a87b1894371d7b1515a
|
refs/heads/master
| 2020-04-17T13:37:33.541545
| 2018-11-01T06:22:42
| 2018-11-01T06:22:42
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 2,753
|
cpp
|
QResampling.cpp
|
#include "QResampling.h"
#include <pcl/surface/mls.h> //最小二乘法平滑处理类定义头文件
//点的类型的头文件
#include <pcl/point_types.h>
//点云文件IO(pcd文件和ply文件)
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
//kd树
#include <pcl/kdtree/kdtree_flann.h>
//特征提取
#include <pcl/features/normal_3d_omp.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/marching_cubes_hoppe.h>
#include <pcl/surface/marching_cubes_rbf.h>
//重构
#include <pcl/surface/gp3.h>
#include <pcl/surface/poisson.h>
//可视化
#include <pcl/visualization/pcl_visualizer.h>
//多线程
#include <boost/thread/thread.hpp>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <QDoubleValidator>
#include <QRendView.h>
#include <PCManage.h>
QResampling::QResampling(QWidget *parent)
: QSubDialogBase(parent)
{
ui.setupUi(this);
ui.lineEdit->setValidator(new QDoubleValidator(this));
}
QResampling::~QResampling()
{
}
void QResampling::PclMlsReconstruct(double k/* = 5*/, PointCloudT::Ptr color_cloud /*= nullptr*/)
{
QRendView* ins = QRendView::MainRendView();
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
if (!color_cloud)
{
color_cloud = PCManage::ins().cloud_;
}
cloud->resize(color_cloud->size());
for (int i = 0; i < cloud->size(); ++i)
{
cloud->at(i).x = color_cloud->at(i).x;
cloud->at(i).y = color_cloud->at(i).y;
cloud->at(i).z = color_cloud->at(i).z;
}
// 创建 KD-Tree
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
// Output has the PointNormal type in order to store the normals calculated by MLS
pcl::PointCloud<pcl::PointNormal> mls_points;
// 定义最小二乘实现的对象mls
pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;
mls.setComputeNormals(true); //设置在最小二乘计算中需要进行法线估计
// Set parameters
mls.setInputCloud(cloud);
mls.setPolynomialFit(true);
mls.setSearchMethod(tree);
mls.setSearchRadius(k);
mls.setUpsamplingRadius(2);
// Reconstruct
mls.process(mls_points);
color_cloud->clear();
color_cloud->resize(mls_points.size());
for (int i = 0; i < color_cloud->size(); ++i)
{
color_cloud->at(i).x = mls_points.at(i).x;
color_cloud->at(i).y = mls_points.at(i).y;
color_cloud->at(i).z = mls_points.at(i).z;
}
// Save output
//pcl::io::savePCDFile("bun0-mls.pcd", mls_points);
ins->UpdateView();
}
void QResampling::on_click()
{
PclMlsReconstruct(ui.lineEdit->text().toDouble());
accept();
}
|
dab891ee94ea6956af8af08396ffee7e12928704
|
3df39118dcdbdb479720ccefc1e0ad84999fa544
|
/src/client/include/BigInteger.h
|
765a9184bf2bf3ad10d4ddd3ca850faeb3695933
|
[] |
no_license
|
ajcj151/ecdl
|
1b9d2aca171e44222509bbf40b373e7b02aa8b33
|
974f0674acd71d81685c2aa5dbf1b62e31b81e79
|
refs/heads/master
| 2020-03-28T15:22:04.766104
| 2017-07-08T20:34:13
| 2017-07-08T20:34:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,436
|
h
|
BigInteger.h
|
#ifndef _BIG_INTEGER_H
#define _BIG_INTEGER_H
#include <string>
#ifdef _WIN32
#include "mpirxx.h"
#else
#include "gmpxx.h"
#endif
#define GMP_BYTE_ORDER_MSB 1
#define GMP_BYTE_ORDER_LSB -1
#define GMP_ENDIAN_BIG 1
#define GMP_ENDIAN_LITTLE -1
#define GMP_ENDIAN_NATIVE 0
class BigInteger {
private:
mpz_class e;
public:
BigInteger();
BigInteger( int i );
BigInteger( const BigInteger &i );
BigInteger( std::string s, int base = 0);
BigInteger( const unsigned char *bytes, size_t len );
BigInteger( const unsigned long *words, size_t len );
BigInteger( const unsigned int *words, size_t len);
~BigInteger();
std::string toString(int base = 10) const;
BigInteger pow( unsigned int exponent ) const;
BigInteger pow( const BigInteger &exponent, const BigInteger &modulus ) const;
BigInteger pow( unsigned int exponent, const BigInteger &modulus ) const;
BigInteger invm( const BigInteger &modulus ) const;
int lsb() const;
BigInteger rshift( int n ) const;
bool isZero() const;
bool operator==(const BigInteger &i) const;
bool operator==(const int &i) const;
bool operator<(const BigInteger &i) const;
bool operator!=( const BigInteger &i ) const;
size_t getBitLength() const;
size_t getByteLength() const;
size_t getWordLength() const;
size_t getLength32() const;
size_t getLength64() const;
size_t getLengthNative() const;
void getWords(unsigned long *words, size_t size) const;
void getWords(unsigned int *words, size_t size) const;
void getWords(unsigned int *words) const;
void getBytes(unsigned char *bytes, size_t size) const;
bool equals( BigInteger &i ) const;
BigInteger operator-(const BigInteger &i) const;
BigInteger operator+(const BigInteger &i) const;
BigInteger operator%(const BigInteger &i) const;
BigInteger operator*(const BigInteger &i) const;
BigInteger operator*(int &i) const;
BigInteger operator/(const BigInteger &i) const;
BigInteger operator+=(const BigInteger &a) const;
BigInteger operator& (const int &i) const;
BigInteger operator<< (const int &i) const;
BigInteger operator>> (const int &i) const;
//BigInteger operator=(const BigInteger &i) const;
};
BigInteger randomBigInteger( const BigInteger &min, const BigInteger &max );
#endif
|
a046a367bcec923f3dd26b88842d38a5baf7b6e9
|
4352b5c9e6719d762e6a80e7a7799630d819bca3
|
/tutorials/eulerVortex.twitch.alternative.numerics/eulerVortex.cyclic.twitch.moving/1.86/T
|
03ddb00e0d52ec25ee9f365d1a0961e80be0e010
|
[] |
no_license
|
dashqua/epicProject
|
d6214b57c545110d08ad053e68bc095f1d4dc725
|
54afca50a61c20c541ef43e3d96408ef72f0bcbc
|
refs/heads/master
| 2022-02-28T17:20:20.291864
| 2019-10-28T13:33:16
| 2019-10-28T13:33:16
| 184,294,390
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 75,631
|
T
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "1.86";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField nonuniform List<scalar>
22500
(
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
0.999998
0.999998
0.999997
0.999996
0.999996
0.999996
0.999996
0.999996
0.999997
0.999998
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999997
0.999996
0.999995
0.999993
0.999991
0.99999
0.999989
0.999988
0.999988
0.999989
0.99999
0.999991
0.999993
0.999995
0.999997
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999996
0.999994
0.999992
0.999989
0.999986
0.999983
0.999979
0.999976
0.999974
0.999973
0.999972
0.999973
0.999975
0.999978
0.999981
0.999985
0.999989
0.999993
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999997
0.999994
0.999991
0.999987
0.999982
0.999977
0.99997
0.999963
0.999956
0.99995
0.999945
0.999941
0.99994
0.999942
0.999946
0.999952
0.999959
0.999966
0.999974
0.999981
0.999987
0.999992
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999995
0.999992
0.999987
0.999981
0.999973
0.999963
0.999952
0.999938
0.999924
0.999911
0.999899
0.999889
0.999882
0.99988
0.999883
0.999891
0.999901
0.999914
0.99993
0.999945
0.999959
0.999971
0.99998
0.999988
0.999993
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999994
0.999989
0.999983
0.999974
0.999961
0.999946
0.999927
0.999905
0.99988
0.999853
0.999828
0.999805
0.999786
0.999774
0.999771
0.999776
0.999788
0.999808
0.999833
0.999863
0.999892
0.999919
0.999941
0.999961
0.999974
0.999985
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999993
0.999986
0.999978
0.999966
0.999948
0.999925
0.999896
0.999862
0.99982
0.999775
0.999729
0.999683
0.999642
0.999608
0.999587
0.999582
0.99959
0.999612
0.999646
0.999693
0.999745
0.999798
0.999846
0.999889
0.999924
0.99995
0.99997
0.999983
0.99999
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999992
0.999985
0.999973
0.999957
0.999934
0.999902
0.999861
0.999809
0.999747
0.999675
0.999597
0.999516
0.999437
0.999366
0.99931
0.999276
0.999266
0.999281
0.999321
0.999383
0.999462
0.999549
0.999638
0.999722
0.999798
0.999859
0.999907
0.999943
0.999964
0.999982
0.99999
0.999996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999992
0.999983
0.99997
0.999949
0.999919
0.999878
0.999823
0.999751
0.999662
0.999555
0.999433
0.999301
0.999166
0.999034
0.998915
0.998824
0.99877
0.998756
0.998785
0.998856
0.998965
0.999096
0.999242
0.999385
0.999526
0.99965
0.999753
0.999836
0.999893
0.999936
0.999964
0.99998
0.999991
0.999996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
0.999999
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
0.999992
0.999982
0.999967
0.999943
0.999907
0.999855
0.999785
0.99969
0.999569
0.99942
0.999243
0.999041
0.998824
0.998602
0.998389
0.998203
0.998058
0.997972
0.997955
0.998011
0.998134
0.998314
0.998529
0.998767
0.999004
0.99923
0.999428
0.999592
0.999725
0.999818
0.999892
0.999933
0.999966
0.99998
0.999993
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999997
0.999992
0.999983
0.999966
0.999938
0.999898
0.999837
0.99975
0.999631
0.999475
0.999276
0.999032
0.998746
0.998423
0.998076
0.997725
0.997394
0.997109
0.996894
0.996768
0.996749
0.996844
0.997049
0.997336
0.997683
0.998057
0.99844
0.998794
0.999103
0.999365
0.999559
0.999719
0.999818
0.999898
0.999938
0.99997
0.999985
0.999993
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
0.999998
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999993
0.999984
0.999967
0.999937
0.999891
0.999822
0.999722
0.999579
0.999386
0.999134
0.998816
0.998429
0.997979
0.997477
0.996943
0.99641
0.995913
0.99549
0.995181
0.995014
0.99501
0.995171
0.99549
0.995934
0.996471
0.997051
0.997632
0.998171
0.99864
0.999035
0.999336
0.99957
0.999728
0.999839
0.999906
0.999955
0.999972
0.99999
0.999996
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
0.999998
0.999995
0.999986
0.999968
0.999938
0.99989
0.999814
0.9997
0.999537
0.99931
0.999004
0.998609
0.998113
0.997517
0.996833
0.996077
0.995283
0.994497
0.993775
0.993175
0.992747
0.992536
0.992567
0.992844
0.993338
0.994015
0.994812
0.995678
0.996529
0.997312
0.998017
0.998569
0.999041
0.999353
0.99961
0.999749
0.999872
0.999919
0.999963
0.999983
0.999992
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
0.999999
1
0.999999
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
0.999999
1
0.999999
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
0.999995
0.999988
0.999971
0.999942
0.999892
0.999813
0.999691
0.999509
0.999252
0.998896
0.998424
0.99782
0.997071
0.99618
0.995167
0.994063
0.99292
0.991801
0.990785
0.989959
0.989394
0.989149
0.98925
0.989698
0.990452
0.991457
0.992627
0.993863
0.995082
0.996203
0.997186
0.997994
0.998623
0.999103
0.999421
0.999661
0.999797
0.999886
0.999945
0.99997
0.999987
0.999995
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
0.999998
1
1
0.999999
1
0.999999
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
0.999998
0.99999
0.999975
0.999947
0.9999
0.999819
0.999692
0.9995
0.999217
0.99882
0.998279
0.997568
0.996667
0.995568
0.994275
0.992816
0.99125
0.989653
0.988116
0.986746
0.985654
0.984939
0.984678
0.984906
0.985607
0.98673
0.988174
0.989833
0.991564
0.993242
0.994825
0.996135
0.997287
0.99811
0.998782
0.999207
0.99954
0.999708
0.999852
0.999911
0.999958
0.999978
0.999992
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
1
0.999998
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999997
1
0.999998
1
1
0.999999
1
0.999999
0.999999
1
0.999999
1
1
0.999999
1
1
1
1
0.999999
1
1
1
0.999999
0.999993
0.99998
0.999954
0.999909
0.999831
0.999704
0.999505
0.999208
0.99878
0.998182
0.99738
0.996337
0.99503
0.993458
0.991632
0.989598
0.987441
0.985272
0.983226
0.981446
0.98007
0.979226
0.979002
0.979437
0.980496
0.982108
0.98414
0.986412
0.988768
0.991047
0.993115
0.994929
0.996368
0.99755
0.998352
0.998999
0.999356
0.999646
0.99979
0.999889
0.999941
0.999971
0.999987
0.999993
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
0.999998
1
1
0.999998
1
0.999998
1
1
0.999996
1
1
0.999999
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
0.999995
0.999984
0.999963
0.99992
0.999847
0.999723
0.999527
0.999224
0.998777
0.998141
0.997265
0.996102
0.99461
0.992767
0.990574
0.988067
0.985319
0.982441
0.979587
0.976941
0.974695
0.973027
0.972095
0.971999
0.972763
0.974336
0.976592
0.979353
0.982398
0.985488
0.98851
0.991151
0.99352
0.995355
0.996848
0.997921
0.998691
0.9992
0.999542
0.999735
0.999864
0.999924
0.999966
0.999982
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
0.999999
1
0.999999
1
1
1
0.999998
1
1
1
1
0.999999
1
1
0.999997
1
1
0.999996
1
0.999997
1
1
1
1
1
0.999998
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
0.999997
0.99999
0.99997
0.999933
0.999867
0.999751
0.999562
0.999264
0.998813
0.998155
0.997232
0.995978
0.994333
0.992255
0.98972
0.986745
0.983396
0.979782
0.976055
0.972424
0.969122
0.966391
0.964459
0.963506
0.963645
0.964878
0.967134
0.970227
0.973884
0.977846
0.981855
0.985598
0.989059
0.99188
0.994315
0.996059
0.99747
0.99835
0.999039
0.99941
0.999687
0.99982
0.999914
0.999956
0.999979
0.999992
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999998
1
1
0.999999
1
0.999999
1
1
0.999998
0.999999
1
0.999995
1
1
0.999994
1
1
0.999995
1
1
0.999997
1
1
0.999998
0.999998
1
1
1
1
1
1
1
1
0.999999
0.999992
0.999978
0.999946
0.999887
0.999783
0.999606
0.999322
0.99888
0.998222
0.997278
0.995967
0.994215
0.991947
0.989122
0.985727
0.9818
0.977444
0.972815
0.968127
0.963643
0.959659
0.956474
0.954364
0.953519
0.954051
0.95594
0.959059
0.963139
0.967875
0.972882
0.977915
0.982552
0.986751
0.990257
0.993106
0.995335
0.996916
0.998087
0.998816
0.99932
0.99961
0.999788
0.999893
0.999944
0.999976
0.999989
0.999995
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999999
0.999999
1
0.999998
1
0.999999
0.999998
1
0.999997
0.999998
1.00001
0.999995
1
1.00001
0.999992
1
1
0.999995
1
1
0.999995
1
1
1
0.999998
1
1
1
1
1
1
1
1
1
0.999996
0.999984
0.999959
0.999909
0.999818
0.999658
0.999394
0.998974
0.998334
0.997396
0.996069
0.994254
0.991858
0.988807
0.98506
0.980627
0.975581
0.970066
0.964299
0.958566
0.953196
0.948542
0.944969
0.942779
0.942209
0.94332
0.946089
0.950276
0.955543
0.961485
0.967737
0.973744
0.979491
0.984347
0.988645
0.991918
0.994561
0.99641
0.997773
0.998632
0.999219
0.999543
0.999764
0.999869
0.999936
0.99997
0.999986
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999999
0.999999
1
0.999999
1
1
0.999996
1.00001
0.999997
0.999996
1.00001
0.999997
0.999994
1.00001
0.999989
1
1.00001
0.999992
0.999998
1.00001
0.999999
0.999997
1
0.999999
0.999996
1
1
1
1
1
1
1
1
1
0.999999
0.999991
0.99997
0.99993
0.999852
0.999713
0.999474
0.999087
0.998484
0.997579
0.996269
0.994445
0.991988
0.98879
0.98478
0.979929
0.974281
0.967959
0.961163
0.954177
0.947358
0.94111
0.935859
0.932014
0.929916
0.929788
0.931699
0.935535
0.940969
0.947608
0.954924
0.962433
0.969696
0.976297
0.982156
0.986936
0.990885
0.993767
0.995987
0.997436
0.998484
0.999095
0.999505
0.999729
0.999857
0.999931
0.999965
0.999984
0.999994
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
0.999999
1
1
0.999998
1
0.999996
1
1
0.99999
1.00001
0.999997
0.999991
1.00001
0.999993
0.999994
1.00001
0.999993
0.999996
1.00001
0.999996
0.999993
1.00001
1.00001
0.999997
0.999996
1
1
1
1
1
1
1
1
0.999999
0.999995
0.99998
0.999949
0.999884
0.999767
0.99956
0.999213
0.998658
0.997809
0.996554
0.994769
0.992316
0.989063
0.984893
0.979743
0.973614
0.96659
0.958861
0.950698
0.942455
0.934565
0.927503
0.921765
0.917799
0.915999
0.916537
0.919491
0.92459
0.931485
0.939601
0.948426
0.957214
0.965751
0.973312
0.980021
0.985461
0.989837
0.993147
0.995546
0.99722
0.99832
0.999019
0.99946
0.9997
0.999849
0.999925
0.999964
0.999984
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
0.999999
1
1
0.999997
1
0.999998
0.999999
1.00001
0.999987
1.00001
1
0.999982
1.00002
0.999999
0.999983
1.00002
0.999996
0.99999
1.00001
1
0.999995
1
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
0.999997
0.999988
0.999964
0.999915
0.999819
0.999644
0.999342
0.99885
0.998072
0.996902
0.9952
0.992819
0.989594
0.985379
0.98006
0.973593
0.96603
0.957507
0.948284
0.938714
0.929226
0.920331
0.912579
0.906503
0.902634
0.901314
0.902787
0.906961
0.913558
0.922063
0.931841
0.942116
0.952439
0.96196
0.970725
0.978023
0.984215
0.988938
0.992616
0.99519
0.997038
0.998205
0.99898
0.999422
0.999691
0.999841
0.999918
0.999962
0.999983
0.999993
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999996
1.00001
0.999991
1
1.00002
0.999973
1.00002
1.00001
0.999976
1.00002
1
0.999983
1.00001
1.00001
0.999986
1
1.00001
0.999998
0.999992
1
1.00001
1
1
1
1
1
1
1
1
0.999994
0.999976
0.99994
0.999866
0.999726
0.999472
0.999046
0.998355
0.997292
0.995713
0.993458
0.990345
0.986197
0.98085
0.974216
0.966276
0.957149
0.94704
0.93629
0.925333
0.914673
0.904891
0.896596
0.890401
0.886836
0.886284
0.888923
0.894566
0.902846
0.913073
0.924521
0.936385
0.947996
0.958791
0.968338
0.976492
0.983079
0.988303
0.992156
0.994975
0.996868
0.998143
0.998936
0.999407
0.999687
0.999837
0.999918
0.999961
0.999982
0.999992
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999997
1
0.999998
0.999991
1.00002
0.999979
1
1.00003
0.999963
1.00002
1.00002
0.999972
1.00001
1.00001
0.999989
1
1.00001
0.999998
0.999998
1
1
0.999998
1
1
1
1
1
1
1
0.999999
0.999989
0.999963
0.999906
0.999797
0.999594
0.999238
0.998645
0.997705
0.996279
0.994196
0.99127
0.987288
0.982058
0.975421
0.967315
0.957781
0.946998
0.935274
0.923019
0.910741
0.899033
0.888524
0.879898
0.873822
0.87082
0.871331
0.875356
0.88272
0.8928
0.904869
0.917965
0.931415
0.944222
0.956151
0.96646
0.975269
0.982304
0.987811
0.991888
0.994822
0.996803
0.99811
0.99891
0.999402
0.999681
0.999835
0.999919
0.999962
0.999982
0.999992
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
1
1
0.99999
1.00001
0.999995
0.99998
1.00004
0.999962
1.00001
1.00003
0.999966
1.00001
1.00002
0.999981
0.999998
1.00001
0.999997
0.999995
1
1
1
0.999998
1
1
1
1
1
1
1
0.999996
0.999979
0.99994
0.99986
0.999702
0.999417
0.998926
0.998122
0.996869
0.994997
0.992313
0.988588
0.9836
0.977137
0.96907
0.959365
0.948155
0.935683
0.922366
0.908672
0.895203
0.882605
0.871578
0.862875
0.857167
0.855075
0.856878
0.862586
0.871791
0.883775
0.897618
0.912444
0.927187
0.941348
0.954025
0.965192
0.974389
0.981859
0.987541
0.991789
0.994761
0.996807
0.998118
0.998931
0.999412
0.999686
0.999839
0.99992
0.999963
0.999984
0.999994
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999994
1
1.00001
0.999976
1.00003
0.99999
0.999973
1.00005
0.999972
0.999989
1.00003
0.999984
0.999995
1.00001
0.999998
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
0.99999
0.999965
0.999909
0.999796
0.999578
0.999187
0.998524
0.997459
0.995825
0.993424
0.990028
0.985388
0.979259
0.971434
0.961814
0.950432
0.9375
0.923371
0.908518
0.893521
0.879028
0.865743
0.854455
0.845937
0.840938
0.84002
0.843402
0.85097
0.862109
0.876005
0.891628
0.907947
0.924049
0.939141
0.952695
0.964352
0.974007
0.981662
0.987527
0.991818
0.994832
0.996857
0.998159
0.998967
0.99944
0.999706
0.999852
0.999928
0.999966
0.999986
0.999995
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
0.999999
1.00001
0.999985
1.00001
1.00002
0.999953
1.00005
0.999988
0.999971
1.00004
0.999992
0.999984
1.00001
0.999999
0.999997
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999998
0.999983
0.999947
0.999869
0.999712
0.999417
0.998895
0.998023
0.996641
0.994557
0.991539
0.987333
0.981665
0.974277
0.964984
0.953728
0.940635
0.925998
0.910275
0.89401
0.877874
0.862547
0.848832
0.837544
0.829529
0.825551
0.826071
0.831266
0.840754
0.853872
0.869608
0.886905
0.904609
0.921894
0.937815
0.952035
0.964081
0.974
0.981786
0.987705
0.991993
0.99499
0.996977
0.998243
0.999015
0.999468
0.999725
0.999864
0.999936
0.999971
0.999988
0.999995
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999995
0.999997
1.00002
0.999969
1.00002
1.00002
0.999957
1.00003
1.00001
0.999974
1.00001
1
0.999994
1
1
1
1
0.999998
1
1
1
1
1
1
1
1
0.999996
0.999973
0.999924
0.999818
0.999608
0.999217
0.998536
0.997415
0.995664
0.99306
0.989346
0.984237
0.977444
0.968706
0.957868
0.944945
0.930146
0.913874
0.896664
0.879166
0.862063
0.846154
0.832262
0.821279
0.814091
0.811381
0.813592
0.820669
0.832136
0.847171
0.864679
0.883462
0.902495
0.920653
0.937372
0.951984
0.964358
0.974363
0.982196
0.988064
0.992296
0.995215
0.997143
0.99836
0.999091
0.999512
0.999746
0.999873
0.999939
0.999972
0.999988
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999996
1.00001
0.999993
0.999989
1.00004
0.999961
1.00001
1.00002
0.999975
1
1.00001
0.999994
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
0.99999
0.999962
0.999895
0.999755
0.999482
0.998979
0.998111
0.996701
0.994531
0.991346
0.986865
0.980778
0.972784
0.962636
0.950222
0.935637
0.919197
0.901394
0.882858
0.864297
0.84647
0.830228
0.816443
0.806081
0.799974
0.79878
0.802782
0.811768
0.825193
0.842049
0.86119
0.88141
0.901477
0.920487
0.937669
0.952599
0.965067
0.97509
0.982841
0.988598
0.992706
0.995508
0.997339
0.998485
0.999172
0.999564
0.999778
0.999889
0.999946
0.999974
0.999988
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
1
1
0.999988
1.00002
0.999984
0.999992
1.00003
0.999979
0.999995
1.00002
0.999993
0.999996
1
0.999999
0.999998
1
1
1
1
1
1
1
1
1
1
1
0.999985
0.999947
0.999861
0.999683
0.999336
0.998704
0.997625
0.995892
0.993258
0.989442
0.984139
0.977021
0.967782
0.956199
0.94222
0.926032
0.908048
0.888864
0.869184
0.849771
0.83147
0.815144
0.801776
0.792286
0.787493
0.78795
0.793755
0.804667
0.81993
0.83852
0.859198
0.880631
0.90162
0.921233
0.938737
0.953788
0.966215
0.976114
0.983689
0.989264
0.993199
0.995857
0.997572
0.998628
0.999252
0.999608
0.999804
0.999906
0.999957
0.999981
0.999992
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999997
1
1
0.999984
1.00002
0.999992
0.999991
1.00001
0.999998
0.999996
1
0.999998
0.999999
1
1
0.999998
1
1
1
1
1
1
1.00001
1
0.999998
0.999978
0.999929
0.999823
0.999602
0.999174
0.9984
0.997091
0.995008
0.991877
0.987396
0.981234
0.973059
0.962564
0.949563
0.934074
0.91638
0.896995
0.876603
0.855981
0.835958
0.817416
0.801303
0.788594
0.780201
0.776882
0.779011
0.786645
0.799383
0.816404
0.836634
0.858671
0.881138
0.902864
0.922839
0.940496
0.95548
0.967741
0.977395
0.984708
0.99003
0.993745
0.996231
0.99782
0.998786
0.999346
0.999657
0.999826
0.999917
0.999964
0.999986
0.999996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.99999
1.00001
1
0.999988
1.00001
1
0.999992
1
1
0.999999
1
1
0.999998
1
1
1
1
1
1
1.00001
1.00001
1
0.999995
0.999969
0.999911
0.999782
0.999515
0.999002
0.998079
0.996527
0.994078
0.990433
0.985269
0.978241
0.969011
0.957288
0.942927
0.926025
0.906959
0.886343
0.864941
0.843596
0.823196
0.804675
0.789022
0.777191
0.770076
0.768278
0.772109
0.781514
0.795971
0.81469
0.836377
0.859583
0.882916
0.905098
0.925264
0.94285
0.957615
0.969561
0.97887
0.98585
0.990872
0.994334
0.996618
0.998061
0.998933
0.999435
0.99971
0.999856
0.999931
0.999969
0.999987
0.999996
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
0.999993
1.00001
1
0.999994
1
1
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999992
0.999963
0.999892
0.99974
0.999429
0.998831
0.997758
0.995961
0.993145
0.988986
0.983142
0.975265
0.965016
0.952127
0.936504
0.918324
0.898054
0.876397
0.854195
0.832356
0.811817
0.793558
0.77857
0.767814
0.762053
0.761818
0.767331
0.778395
0.794542
0.814771
0.83773
0.861924
0.885834
0.908266
0.928384
0.94572
0.960109
0.971616
0.980485
0.987064
0.991748
0.994939
0.997016
0.998305
0.999073
0.999512
0.999754
0.999881
0.999945
0.999976
0.99999
0.999996
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999997
1
1
0.999994
1
1
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999988
0.999954
0.999874
0.9997
0.999348
0.998671
0.997456
0.995424
0.992254
0.987599
0.981106
0.972425
0.961226
0.94727
0.93052
0.911225
0.889942
0.867456
0.844674
0.822565
0.802115
0.784329
0.770197
0.760609
0.756263
0.757601
0.764707
0.777403
0.795071
0.816621
0.840671
0.865562
0.889805
0.912236
0.932094
0.949
0.962869
0.973838
0.982197
0.988322
0.992631
0.995532
0.997398
0.998543
0.999213
0.99959
0.999795
0.999901
0.999955
0.999981
0.999992
0.999997
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999997
1
1
0.999998
0.999997
1
1
1
1
0.999999
1
1
1
1
1
1
1.00001
1.00001
1
0.999985
0.999946
0.999858
0.999667
0.99928
0.998536
0.997194
0.994951
0.991456
0.986345
0.979257
0.969845
0.957794
0.942903
0.925186
0.904967
0.882882
0.859782
0.836646
0.814486
0.794329
0.777195
0.764047
0.755708
0.752803
0.755653
0.764319
0.778518
0.797514
0.820224
0.845069
0.870387
0.894699
0.916885
0.936277
0.952583
0.965808
0.976153
0.983947
0.98959
0.993507
0.996109
0.99776
0.99876
0.99934
0.999662
0.999833
0.999921
0.999964
0.999985
0.999994
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999983
0.999941
0.999845
0.999641
0.999229
0.998434
0.996995
0.994578
0.990805
0.985297
0.97769
0.967642
0.954866
0.939195
0.9207
0.899768
0.8771
0.853613
0.830335
0.808331
0.788647
0.772307
0.760228
0.753182
0.751687
0.756017
0.766138
0.781655
0.80184
0.825423
0.850787
0.876261
0.900367
0.922076
0.940809
0.956375
0.968853
0.978501
0.985685
0.990823
0.994344
0.996652
0.998096
0.998959
0.999452
0.999722
0.999865
0.999938
0.999973
0.99999
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
0.999999
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.99998
0.999937
0.999837
0.999625
0.9992
0.998376
0.996874
0.994332
0.990347
0.984523
0.976491
0.965928
0.952572
0.936298
0.917228
0.895805
0.872781
0.84913
0.82592
0.804255
0.785198
0.769753
0.758802
0.753038
0.752923
0.75864
0.77006
0.786761
0.807867
0.832051
0.857673
0.883006
0.906649
0.92766
0.94557
0.960279
0.971929
0.98083
0.987378
0.992002
0.99513
0.997152
0.998399
0.999135
0.99955
0.999775
0.999892
0.999951
0.999979
0.999992
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999997
0.999979
0.999934
0.999833
0.999621
0.999195
0.998367
0.996844
0.994237
0.990119
0.984074
0.975734
0.964792
0.951018
0.93433
0.914898
0.893208
0.870059
0.846459
0.823516
0.802352
0.784041
0.769568
0.75976
0.755253
0.756438
0.763416
0.775996
0.793646
0.815424
0.839963
0.86553
0.890445
0.913382
0.933506
0.950451
0.964198
0.974961
0.983087
0.988991
0.993108
0.995855
0.997606
0.998671
0.99929
0.999635
0.99982
0.999915
0.999961
0.999983
0.999993
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1.00001
1
0.999998
0.999979
0.999935
0.999835
0.999626
0.999211
0.998405
0.996905
0.994303
0.990143
0.983989
0.975472
0.964302
0.950282
0.933376
0.913794
0.892064
0.86901
0.845668
0.82317
0.802648
0.785181
0.771716
0.763042
0.759736
0.76212
0.77022
0.783756
0.80213
0.824349
0.848934
0.874162
0.898403
0.920419
0.939485
0.955342
0.968056
0.977897
0.985237
0.990503
0.994125
0.996509
0.998008
0.998907
0.999424
0.999707
0.999857
0.999933
0.99997
0.999988
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999997
0.99998
0.999938
0.999842
0.999642
0.999247
0.998484
0.997051
0.994527
0.990424
0.984286
0.975733
0.964494
0.950408
0.933478
0.913957
0.892401
0.869654
0.846763
0.824869
0.805112
0.788552
0.776113
0.768538
0.766352
0.769812
0.778859
0.793146
0.812021
0.834392
0.858752
0.883381
0.906702
0.927595
0.945463
0.960149
0.971789
0.980691
0.987248
0.991892
0.995044
0.99709
0.99836
0.999111
0.999536
0.999767
0.999888
0.999949
0.999979
0.999993
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999983
0.999943
0.999854
0.999666
0.999299
0.998594
0.997267
0.994888
0.990946
0.984953
0.976518
0.965377
0.951404
0.934643
0.915383
0.894204
0.871955
0.849689
0.828541
0.809644
0.794039
0.782618
0.776087
0.774924
0.779316
0.789128
0.803954
0.823071
0.84534
0.86921
0.892971
0.915151
0.934764
0.951337
0.964797
0.975337
0.9833
0.989096
0.993149
0.995863
0.997601
0.998663
0.999283
0.999631
0.999817
0.999914
0.999962
0.999984
0.999994
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999985
0.999951
0.99987
0.999698
0.999361
0.998724
0.997528
0.995353
0.99167
0.985956
0.977795
0.966927
0.953247
0.936839
0.918028
0.897407
0.875833
0.854341
0.834057
0.816094
0.801472
0.791047
0.785493
0.78524
0.79041
0.800794
0.81593
0.835054
0.856961
0.88007
0.902732
0.923597
0.94181
0.957009
0.969207
0.97865
0.985702
0.990772
0.994271
0.996582
0.99804
0.99892
0.999428
0.999709
0.999859
0.999935
0.999972
0.999989
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999989
0.999959
0.999889
0.999736
0.999432
0.998864
0.99781
0.995881
0.992539
0.98723
0.979501
0.969077
0.955871
0.939999
0.921811
0.901915
0.881163
0.860575
0.841251
0.82428
0.810649
0.801185
0.796532
0.797072
0.802848
0.813599
0.828827
0.847714
0.869003
0.891117
0.912487
0.931888
0.948605
0.962391
0.973333
0.981708
0.987886
0.992271
0.995255
0.9972
0.998413
0.999136
0.999549
0.999774
0.999891
0.99995
0.999978
0.999992
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999993
0.999968
0.999909
0.999778
0.999508
0.999006
0.998093
0.996425
0.993484
0.988687
0.981537
0.971732
0.959179
0.944015
0.926613
0.907593
0.887794
0.868215
0.849925
0.833985
0.821342
0.812796
0.808961
0.810158
0.816366
0.827283
0.842383
0.860801
0.881242
0.902148
0.922054
0.939886
0.955064
0.967437
0.977142
0.984483
0.989833
0.993585
0.996109
0.997733
0.99873
0.999315
0.999645
0.999824
0.999917
0.999964
0.999986
0.999995
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999996
0.999977
0.999929
0.999821
0.999591
0.999151
0.998363
0.996948
0.994431
0.990223
0.983783
0.974755
0.963029
0.948745
0.932287
0.914277
0.895544
0.87706
0.859864
0.844975
0.833305
0.825625
0.822516
0.82423
0.83069
0.841573
0.856336
0.87407
0.89345
0.912971
0.931294
0.947492
0.961111
0.972085
0.980599
0.986969
0.991559
0.994734
0.99684
0.998177
0.998989
0.999462
0.999726
0.999866
0.999938
0.999973
0.999989
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999985
0.999947
0.999861
0.999673
0.999296
0.998619
0.997428
0.995321
0.991734
0.986094
0.977983
0.967248
0.954006
0.93864
0.921767
0.904203
0.886889
0.870828
0.856999
0.846277
0.839407
0.836915
0.838996
0.845528
0.856194
0.87043
0.887282
0.905422
0.92342
0.940074
0.954608
0.966688
0.976318
0.983707
0.989169
0.993056
0.995715
0.997457
0.99855
0.999205
0.999582
0.999789
0.999899
0.999954
0.99998
0.999993
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999993
0.999964
0.999897
0.999748
0.999438
0.998863
0.997861
0.996119
0.993134
0.988329
0.981234
0.971627
0.959579
0.945447
0.929835
0.91353
0.897448
0.882555
0.869786
0.85998
0.853847
0.851861
0.854153
0.860596
0.870879
0.884417
0.900218
0.91697
0.933346
0.948294
0.96118
0.971769
0.980115
0.986451
0.991086
0.994347
0.996549
0.997974
0.998857
0.999381
0.999678
0.999839
0.999924
0.999966
0.999987
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999999
0.999978
0.999928
0.999815
0.999569
0.999094
0.998254
0.996817
0.994372
0.990379
0.984335
0.975947
0.965216
0.952448
0.938206
0.923249
0.908458
0.894757
0.883039
0.874106
0.868636
0.867033
0.869394
0.875606
0.88537
0.898067
0.912678
0.927936
0.942635
0.955875
0.967154
0.976324
0.98348
0.988854
0.99274
0.995443
0.997247
0.998401
0.999107
0.999521
0.999754
0.999879
0.999944
0.999975
0.99999
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.99999
0.999953
0.999868
0.999683
0.999304
0.998613
0.99743
0.995439
0.992177
0.98715
0.980006
0.970665
0.959355
0.946581
0.933049
0.919599
0.90711
0.89643
0.888331
0.883439
0.882109
0.884423
0.890297
0.899434
0.911175
0.92449
0.938186
0.951196
0.962769
0.972518
0.980362
0.986421
0.990925
0.994148
0.996363
0.997825
0.99875
0.99931
0.999634
0.999814
0.99991
0.999959
0.999983
0.999994
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999999
0.999974
0.999912
0.999775
0.999486
0.998934
0.997971
0.996356
0.993716
0.989608
0.983658
0.975709
0.965903
0.954655
0.942606
0.930536
0.919271
0.909617
0.902312
0.897929
0.896778
0.898968
0.904437
0.912865
0.92356
0.935509
0.947619
0.958969
0.968946
0.977263
0.983889
0.988958
0.992689
0.995331
0.997127
0.998299
0.999031
0.99947
0.999722
0.999861
0.999934
0.99997
0.999988
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
1
0.999989
0.999946
0.999847
0.999634
0.99921
0.998445
0.997144
0.995024
0.991705
0.986835
0.980209
0.971878
0.962164
0.951619
0.940946
0.930909
0.922272
0.915727
0.911794
0.910775
0.912802
0.917823
0.925487
0.935076
0.945626
0.956167
0.965922
0.974403
0.981405
0.986932
0.991121
0.994173
0.996314
0.997754
0.998683
0.999258
0.999599
0.999792
0.999897
0.999952
0.999979
0.999992
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999997
0.999971
0.999903
0.999749
0.999434
0.998844
0.997819
0.996129
0.993475
0.989541
0.984109
0.977162
0.968927
0.959857
0.950568
0.941751
0.934117
0.928305
0.924795
0.923891
0.925748
0.930301
0.937159
0.94561
0.954766
0.963791
0.972048
0.979157
0.984972
0.989522
0.99294
0.995409
0.997122
0.998264
0.998992
0.999438
0.999699
0.999846
0.999925
0.999966
0.999986
0.999995
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
1
0.999988
0.999943
0.999835
0.999608
0.999169
0.998381
0.997058
0.99496
0.99182
0.98743
0.981729
0.974867
0.967199
0.959241
0.951614
0.944959
0.939859
0.936763
0.935982
0.937676
0.941745
0.947774
0.95508
0.962883
0.970483
0.977364
0.983236
0.988
0.991698
0.994452
0.996423
0.997778
0.998672
0.999236
0.999579
0.999777
0.999888
0.999947
0.999976
0.999991
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999997
0.99997
0.999898
0.99974
0.999422
0.998834
0.997822
0.996192
0.993722
0.990223
0.985615
0.979985
0.973604
0.966901
0.960407
0.954695
0.950286
0.947605
0.946963
0.948493
0.952064
0.957253
0.963444
0.969972
0.976262
0.981908
0.986688
0.990538
0.993502
0.995692
0.997246
0.998305
0.998996
0.999428
0.999688
0.999837
0.99992
0.999963
0.999984
0.999994
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999987
0.999942
0.999834
0.999611
0.999185
0.998432
0.997193
0.995284
0.992541
0.988875
0.984331
0.979108
0.973554
0.968117
0.963293
0.95955
0.957283
0.956781
0.958138
0.961198
0.965563
0.970699
0.976056
0.981174
0.985735
0.989569
0.992635
0.994979
0.996697
0.997906
0.998722
0.999249
0.999577
0.999772
0.999883
0.999944
0.999975
0.99999
0.999996
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999997
0.999969
0.9999
0.999748
0.999448
0.998903
0.997986
0.996542
0.994433
0.991569
0.987965
0.983765
0.979242
0.974771
0.97077
0.967654
0.965785
0.965407
0.966574
0.969124
0.972705
0.976874
0.981188
0.985281
0.988907
0.991937
0.994344
0.996172
0.997502
0.998429
0.999049
0.999447
0.999693
0.999838
0.999919
0.999962
0.999982
0.999992
0.999997
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
0.999999
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999987
0.999944
0.999844
0.999639
0.999257
0.998594
0.99753
0.995945
0.993753
0.990951
0.987638
0.984026
0.980417
0.977165
0.974628
0.973119
0.972831
0.973794
0.975854
0.97872
0.982033
0.985443
0.98866
0.991498
0.993855
0.995718
0.997122
0.998136
0.998837
0.999302
0.999599
0.999782
0.999887
0.999942
0.999971
0.999986
0.999994
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999997
0.999972
0.999908
0.999773
0.999512
0.999047
0.998283
0.99712
0.995483
0.993353
0.990796
0.987971
0.985119
0.982531
0.980508
0.979307
0.979077
0.979833
0.981447
0.983685
0.986263
0.98891
0.991398
0.993581
0.995388
0.996805
0.997869
0.998629
0.999152
0.999498
0.999716
0.999844
0.999916
0.999957
0.99998
0.999993
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
0.999999
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999998
1
1
0.999999
1
1
0.999999
1
0.999999
0.999999
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999988
0.999951
0.999864
0.999691
0.999374
0.998839
0.998009
0.996817
0.995236
0.993309
0.991148
0.988946
0.986931
0.985347
0.984399
0.984202
0.984768
0.985994
0.987701
0.98967
0.991686
0.993577
0.995229
0.996591
0.997656
0.998447
0.999009
0.999394
0.999645
0.999797
0.999888
0.999943
0.999975
0.999992
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
0.999998
1
0.999999
1
1
0.999999
1
0.999999
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999976
0.999923
0.999812
0.999603
0.99924
0.998662
0.997816
0.996673
0.995255
0.993644
0.99198
0.990443
0.989222
0.988478
0.988303
0.988706
0.989613
0.990887
0.992363
0.993872
0.995284
0.996513
0.997525
0.998309
0.998886
0.999295
0.999574
0.999752
0.999859
0.999926
0.999967
0.999988
0.999996
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
0.999998
1
0.999996
1
0.999996
1
0.999996
1
0.999998
1
0.999999
0.999999
1
0.999997
1
1
0.999998
1
1
0.999999
1
1
0.999999
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
0.999991
0.999961
0.999892
0.999758
0.999518
0.999128
0.998543
0.997737
0.99672
0.995546
0.994317
0.993167
0.99224
0.991661
0.991505
0.99178
0.992436
0.99337
0.994453
0.995562
0.9966
0.997502
0.998234
0.998798
0.999216
0.999512
0.999704
0.999828
0.999911
0.999959
0.999981
0.999988
0.999992
0.999995
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999997
1
0.999998
1
1
0.999994
1.00001
0.999996
1
0.999999
1
1
0.999999
1
1
0.999998
1
1
1
1
1
1
0.999999
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
0.999982
0.999942
0.999859
0.999706
0.999449
0.999054
0.998502
0.997789
0.996953
0.996064
0.99522
0.994528
0.994085
0.993948
0.99413
0.994595
0.995264
0.996046
0.996847
0.997596
0.998241
0.998762
0.999166
0.999463
0.999667
0.999801
0.99989
0.999943
0.999969
0.999981
0.99999
0.999996
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
1
0.999996
1.00001
0.999994
1.00001
0.999992
1.00001
0.99999
1.00001
0.999994
1
1
0.999993
1.00001
0.999998
0.999997
1
0.999999
0.999997
1
1
0.999999
1
0.999999
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999995
0.999972
0.999922
0.999828
0.999663
0.999405
0.999034
0.998547
0.997965
0.997334
0.996728
0.996221
0.995887
0.995772
0.99589
0.996213
0.996685
0.997239
0.997806
0.998332
0.998784
0.999153
0.999439
0.999642
0.999779
0.99987
0.999926
0.999958
0.999975
0.999989
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
1
0.999999
1
1
0.999997
1
0.999998
0.999998
1.00001
0.999988
1.00001
0.999991
1
1
0.999997
1
0.999998
0.999998
1
0.999999
0.999999
1
1
1
1
1
1
1
0.999998
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999989
0.999961
0.999904
0.999802
0.999637
0.999393
0.999068
0.998671
0.998234
0.997807
0.997443
0.997199
0.997108
0.99718
0.997402
0.997728
0.998113
0.998506
0.998867
0.999184
0.99944
0.999629
0.999762
0.999852
0.999914
0.999955
0.99998
0.999994
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
0.999995
1.00001
0.999992
1.00001
0.99999
1.00001
0.999985
1.00002
0.99999
0.999999
1.00001
0.999986
1.00001
1
0.999992
1.00001
1
0.999997
1
1
1
1
0.999998
0.999999
1
1
0.999998
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
0.999983
0.99995
0.999889
0.999786
0.999631
0.999418
0.999153
0.998856
0.99856
0.998307
0.998132
0.998064
0.998107
0.998255
0.998479
0.998739
0.999005
0.999255
0.999471
0.999633
0.999754
0.999845
0.99991
0.999959
0.999985
0.999993
0.999997
0.999999
0.999998
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
1
0.999996
1
0.999995
1
0.999999
1
1
1
0.999995
1.00001
0.999985
1.00002
0.999983
1.00001
1
0.999991
1.00001
1
0.999994
1
1
0.999997
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999995
0.999977
0.999941
0.999879
0.999783
0.999646
0.999473
0.999277
0.999076
0.998904
0.998783
0.998733
0.998761
0.998857
0.999006
0.99918
0.999358
0.999522
0.999658
0.999765
0.999845
0.999912
0.999959
0.999976
0.999981
0.999986
0.99999
0.999994
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
1
0.999999
0.999999
1
0.999993
1.00001
0.999991
1.00001
0.99999
1.00001
0.99998
1.00002
0.999988
0.999996
1.00002
0.999983
1.00001
1.00001
0.999991
1
1
0.999998
1
1
0.999999
1
1
0.999998
0.999999
1
1
0.999998
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
0.999992
0.999972
0.999935
0.999876
0.999791
0.999681
0.999553
0.999423
0.999307
0.999225
0.999191
0.999209
0.999272
0.999369
0.99948
0.999597
0.999703
0.999784
0.99986
0.999921
0.999952
0.999968
0.999974
0.999978
0.999991
1
1.00001
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
1
0.999997
1
0.999993
1.00001
0.999993
1
0.999997
1
0.999996
1.00001
0.999994
1.00001
0.999986
1.00002
0.999975
1.00001
1.00001
0.999984
1.00001
1.00001
0.999993
0.999998
1.00001
0.999999
0.999998
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999989
0.999969
0.999933
0.999882
0.999813
0.999732
0.999649
0.999573
0.99952
0.999499
0.999509
0.999551
0.999611
0.999682
0.999755
0.99982
0.999878
0.999927
0.999955
0.999963
0.99997
0.999991
1.00001
1.00002
1.00001
1.00001
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
1
0.999996
1
0.999999
0.999997
1.00001
0.999991
1.00001
0.999992
1.00001
0.999987
1.00002
0.999978
1.00002
0.999987
0.999998
1.00002
0.999983
1.00001
1.00001
0.999989
1
1
0.999997
0.999999
1
0.999999
0.999998
1
1
0.999997
1
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999998
0.999986
0.999967
0.999936
0.999893
0.999845
0.999793
0.999746
0.999713
0.9997
0.999706
0.999731
0.999769
0.999813
0.999859
0.999896
0.999934
0.999958
0.999962
0.999978
1
1.00001
1.00001
1.00001
0.999996
0.999994
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
1
0.999996
1.00001
0.999992
1.00001
0.999997
1
0.999999
1
0.999995
1
1
0.999999
0.999989
1.00003
0.999973
1.00001
1.00001
0.999986
1
1.00001
0.999999
0.999995
1
1
0.999999
0.999998
1
1
0.999998
1
1
1
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999996
0.999985
0.999967
0.999944
0.999914
0.999882
0.999853
0.999834
0.999826
0.99983
0.999845
0.999869
0.999895
0.999924
0.999948
0.999958
0.99997
0.99999
1.00001
1.00001
1
0.999981
0.999977
0.999989
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999997
1
0.999996
1
1
0.999993
1.00001
0.999993
1
0.999995
1.00001
0.999985
1.00002
0.999985
1.00002
0.99998
1.00001
1.00001
0.999983
1
1.00001
0.999988
1
1.00001
0.999999
0.999996
1
1
0.999997
1
1
0.999997
0.999999
1
1
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999995
0.999986
0.999972
0.999954
0.999935
0.999921
0.999907
0.999903
0.999908
0.999916
0.99993
0.999948
0.99996
0.999974
0.999981
0.999991
1.00001
1.00001
0.999987
0.999988
0.999995
0.999999
1.00001
1.00001
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
0.999999
1
0.999994
1.00001
0.999997
0.999998
1
0.999998
0.999998
1
1
0.999993
1.00001
0.999996
0.999993
1.00002
0.999984
1
1.00001
0.999992
1
1
1
0.999999
0.999998
1
1
0.999999
0.999997
1
1
0.999998
0.999999
1
1
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999995
0.999987
0.999978
0.999967
0.999959
0.999952
0.999949
0.999953
0.999959
0.999967
0.999974
0.999979
0.99999
1
1
0.999999
1
0.999996
1
1.00002
1.00002
1
0.999997
0.999997
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
0.999997
1
1
0.999994
1.00001
0.999993
1
1
1
0.999993
1.00001
0.999992
1
0.999993
1.00002
0.999974
1.00001
1.00001
0.999985
0.999997
1.00001
0.999998
0.999991
1
1.00001
0.999995
0.999997
1
1
0.999996
0.999999
1
1
1
1
0.999998
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
0.999996
0.999991
0.999985
0.99998
0.99998
0.999976
0.999977
0.999983
0.999984
0.999987
0.999998
1
0.999998
0.999997
0.999994
1.00001
1.00002
1.00001
0.999996
0.999996
0.999992
0.99999
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
1
1
0.999996
1.00001
0.999997
0.999997
1.00001
0.999994
0.999999
1.00001
0.999998
0.999994
1.00001
0.999994
1
0.999992
1.00001
0.999997
0.99999
1.00001
1
0.99999
1
1
0.999998
0.999998
1
0.999999
0.999998
1
1
1
1
0.999999
1
1
1
0.999999
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
0.999997
0.999995
0.999992
0.99999
0.999992
0.999991
0.999992
0.999997
1
1
1
0.999996
1
1.00001
0.999999
0.999996
0.999994
0.999987
0.999994
1.00001
1.00001
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
1
1
0.999996
1.00001
0.999993
1
1.00001
0.999994
0.999999
1.00001
0.999994
1
1
1
0.999989
1.00001
0.999993
1
1
1
0.999997
0.999998
1.00001
1
0.999993
1
1
0.999999
0.999998
1
1
1
1
0.999998
0.999999
1
1
0.999999
0.999999
1
1
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999998
0.999998
0.999999
0.999998
1
1.00001
0.999999
0.999998
1.00001
1.00002
1.00001
0.999995
0.999993
1.00001
1.00002
1.00001
1.00001
1.00001
0.999999
0.999995
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999997
1
0.999997
0.999998
1.00001
0.999992
1
1.00001
0.999991
1
1.00001
0.999993
1
0.999995
1.00002
0.999975
1.00002
1
0.999991
0.999997
1.00001
1
0.99999
1
1.00001
0.999996
0.999998
1
1
1
0.999999
0.999998
1
1
0.999998
0.999999
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
0.999997
1
1.00001
1.00001
1.00001
0.999999
0.99999
0.99999
0.999995
0.999998
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
0.999997
1.00001
0.999994
1
1.00001
0.999991
1
1.00001
0.999989
1
1
1
0.999995
1
1.00001
0.999989
0.999998
1.00001
0.999999
0.999993
1
1
0.999999
1
0.999998
1
1
0.999999
0.999998
1
1
0.999997
1
1
0.999998
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1.00001
1.00001
0.999998
0.999985
0.999991
1
1
0.999994
0.999984
0.999987
0.999993
0.999997
1
1.00001
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999997
0.999998
1.00001
0.999992
1
1.00001
0.999986
1.00001
1
0.999992
1
0.999997
1.00001
0.999982
1.00001
0.999994
1
0.999993
1.00001
0.999999
0.999997
1
1
0.999995
1
0.999999
0.999998
1
0.999998
0.999998
1
1
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
1.00001
1
0.99999
0.999998
1
0.999998
0.999994
0.999996
1
1.00001
1.00001
1
1
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
1.00001
0.999995
1
1.00001
0.99999
1
1.00001
0.999983
1.00001
0.999998
1
0.999997
0.999998
1.00001
0.999982
1.00001
0.999997
1
0.999996
1
1
0.999995
1
1
1
0.999999
0.999999
0.999998
1
1
0.999997
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1
0.999993
1
1.00001
1.00001
1.00001
1
1.00001
1.00001
1.00001
1
1
0.999997
0.999996
0.999998
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
0.999999
1.00001
0.999992
1
1.00001
0.999985
1.00001
1
0.999989
1.00001
0.999993
1.00001
0.999988
1.00001
1
0.999998
0.999994
1.00001
0.999996
1
0.999996
1
1
1
0.999994
1
1.00001
0.999997
0.999998
1
1
0.999998
1
1
0.999999
1
1
1
1
1
0.999999
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999994
1
1.00001
1.00001
1
1
1
1
0.999997
0.999994
0.999995
0.999997
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
1
0.999995
1
1.00001
0.99999
1
1.00001
0.999984
1.00001
0.999997
0.999998
1
0.999994
1.00001
0.999987
1.00001
0.999992
1.00001
0.99999
1
0.999998
1
1
0.999997
0.999999
1
1
0.999995
1
1
0.999998
1
1
0.999999
1
0.999999
1
1
0.999999
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999997
1
1.00001
1
1
0.999999
0.999994
0.999995
0.999998
0.999995
0.999994
0.999998
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999998
1
1
0.999993
1
1.00001
0.999987
1.00001
1
0.99999
1.00001
0.999993
1.00001
0.999994
1
1
0.999995
1.00001
0.999996
1
1
0.999996
1
0.999997
1.00001
0.999996
1
1
1
0.999998
1
1
0.999998
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1.00001
1.00001
1
0.999993
0.999994
0.999998
0.999999
0.999999
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
1
0.999996
1
1
0.999992
1
1.00001
0.999988
1.00001
0.999998
0.999997
1.00001
0.999993
1.00001
0.999988
1.00001
0.999995
1
0.999997
1.00001
0.999989
1.00001
0.999998
1
0.999998
1
0.999998
0.999997
1
0.999999
0.999998
1
1
0.999999
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999998
0.999997
0.999999
1
1
1
1
1
1
1
0.999999
0.999998
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999998
1
1
0.999996
1
1
0.999992
1.00001
1
0.999992
1.00001
0.999995
1
0.999999
0.999997
1.00001
0.99999
1.00001
0.999995
1
0.999997
1.00001
0.999996
0.999998
1.00001
0.999996
0.999999
1
1
0.999996
1
1
0.999999
1
1
0.999999
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
0.999999
0.999997
0.999999
1
1
1
1
1
1
0.999999
0.999999
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999997
1
1
0.999996
1
1
0.999993
1.00001
0.999999
0.999997
1
0.999995
1.00001
0.999995
1
1
0.999995
1
1
0.999995
1
0.999998
1
0.999993
1.00001
0.999999
0.999998
1
1
1
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
1
0.999999
0.999999
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999996
1
1
0.999996
1
0.999998
1
1
0.999996
1.00001
0.999993
1
1
0.999998
0.999998
1.00001
0.999992
1
0.999999
1
0.999998
1
1
0.999998
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
0.999999
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999997
1
1
0.999998
1
0.999997
1
0.999999
0.999997
1.00001
0.999993
1
1
0.999999
0.999996
1.00001
0.999999
0.999996
1
0.999998
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999998
1
1
0.999998
1
0.999999
1
1
0.999996
1
0.999998
0.999997
1
0.999997
0.999999
1
0.999999
0.999999
0.999999
1
0.999995
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
1
0.999999
1
0.999998
1
1
0.999996
1
1
0.999998
1
1
0.999997
1
1
1
0.999998
1
0.999999
0.999999
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
0.999998
1
1
0.999997
1
1
0.999999
1
1
0.999999
0.999999
1
0.999999
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999999
1
1
1
0.999999
1
1
0.999998
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
0.999999
1
0.999999
1
1
1
1
1
1
0.999999
1
1
0.999998
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0.999999
1
1
0.999999
1
1
1
1
1
1
0.999999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
)
;
boundaryField
{
emptyPatches_empt
{
type empty;
}
top_cyc
{
type cyclic;
}
bottom_cyc
{
type cyclic;
}
inlet_cyc
{
type cyclic;
}
outlet_cyc
{
type cyclic;
}
}
// ************************************************************************* //
|
|
a31256056405370c0fc6e6e231faf1dea964d9ed
|
1956af138784d983b812ef71b683a0c54c7f4a63
|
/集合运算/集合运算.cpp
|
118d79032de97d748b315a8749aca1331aefa251
|
[] |
no_license
|
wangzilong2019/lan-qiao
|
e46e6668ba1e7ef3a0b8ef69cb1bda41ac704642
|
d742a5cac56413ce46b0206edfb4422f35b33276
|
refs/heads/master
| 2020-09-09T15:26:39.297956
| 2020-01-13T13:30:22
| 2020-01-13T13:30:22
| 221,482,997
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 838
|
cpp
|
集合运算.cpp
|
#include<stdio.h>
#define MAX 1000
int main(){
int a[MAX],b[MAX],n_temp[MAX],c_temp[MAX];
int n,m,i,j,k,temp;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
scanf("%d",&m);
for(i=0;i<m;i++){
scanf("%d",&b[i]);
}
int p=0;
int q=0;
int flag;
for(i=0;i<n;i++){
flag=0;
for(j=0;j<m;j++){
if(a[i]==b[j]){
flag=1;
n_temp[q]=a[i];
q++;
}
}
if(flag==0){
c_temp[p]=a[i];
p++;
}
}
int la,lb,new_n,new_c;
new_n=q;
new_c=p;
for(i=m,k=0;i<p+m,k<p;k++,i++){
b[i]=c_temp[k];
}
for(i=0;i<q;i++){
printf("%d ",n_temp[i]);
}
printf("\n");
for(i=0;i<p+m-1;i++){
for(j=i+1;j<p+m;j++){
if(b[i]>b[j]){
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
}
for(i=0;i<p+m;i++){
printf("%d ",b[i]);
}
printf("\n");
for(i=0;i<p;i++){
printf("%d ",c_temp[i]);
}
return 0;
}
|
f52270444ac702d9c92fbbe6c0cdda2b89584d99
|
2e6487397358d85e6f317ef320cd37a075bea06d
|
/unittest/main.cpp
|
a80e6ffe292a42f8af4904c42cf7b32fb9d99376
|
[
"Apache-2.0"
] |
permissive
|
ericyeungcode/huobi_swap_Cpp
|
26aa617707d9d3415bfb30bcbac9366aade1e561
|
f316cc1cfa349752f95e9289950a9d3c804d57b2
|
refs/heads/master
| 2022-12-08T17:45:10.556775
| 2020-08-27T10:45:44
| 2020-08-27T10:45:44
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 448
|
cpp
|
main.cpp
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include <gtest/gtest.h>
#include "TestGetAccount.h"
#include "TestErrorResponse.h"
#include "TestDecimal.h"
#include "TestSubscribeOrderUpdateEvent.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
a23cc1e072a821a712e8729362d3b54c2d8dc0a1
|
44289ecb892b6f3df043bab40142cf8530ac2ba4
|
/Sources/Elastos/Frameworks/Droid/Base/Core/src/elastos/droid/inputmethodservice/CExtractButton.cpp
|
43a8deb3efb4d3d3b10ac1f67bcdf6ad8cdd27b4
|
[
"Apache-2.0"
] |
permissive
|
warrenween/Elastos
|
a6ef68d8fb699fd67234f376b171c1b57235ed02
|
5618eede26d464bdf739f9244344e3e87118d7fe
|
refs/heads/master
| 2021-01-01T04:07:12.833674
| 2017-06-17T15:34:33
| 2017-06-17T15:34:33
| 97,120,576
| 2
| 1
| null | 2017-07-13T12:33:20
| 2017-07-13T12:33:20
| null |
UTF-8
|
C++
| false
| false
| 2,041
|
cpp
|
CExtractButton.cpp
|
//=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// 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.
//=========================================================================
#include "elastos/droid/inputmethodservice/CExtractButton.h"
#include "elastos/droid/R.h"
using Elastos::Droid::R;
namespace Elastos {
namespace Droid {
namespace InputMethodService {
CAR_OBJECT_IMPL(CExtractButton);
ECode CExtractButton::constructor(
/* [in] */ IContext* context)
{
return Button::constructor(context, NULL);
}
ECode CExtractButton::constructor(
/* [in] */ IContext* context,
/* [in] */ IAttributeSet* attrs)
{
return Button::constructor(context, attrs, R::attr::buttonStyle);
}
ECode CExtractButton::constructor(
/* [in] */ IContext* context,
/* [in] */ IAttributeSet* attrs,
/* [in] */ Int32 defStyleAttr)
{
return constructor(context, attrs, defStyleAttr, 0);
}
ECode CExtractButton::constructor(
/* [in] */ IContext* context,
/* [in] */ IAttributeSet* attrs,
/* [in] */ Int32 defStyleAttr,
/* [in] */ Int32 defStyleRes)
{
return Button::constructor(context, attrs, defStyleAttr, defStyleRes);
}
ECode CExtractButton::HasWindowFocus(
/* [out] */ Boolean* res)
{
VALIDATE_NOT_NULL(res);
Int32 v = 0;
*res = (IsEnabled(res), *res) && (GetVisibility(&v), v) == IView::VISIBLE;
return NOERROR;
}
} // namespace InputMethodService
} // namespace Droid
} // namespace Elastos
|
6abd2b0ba9e5bee002d87ec9bfc37382ec464cea
|
8a632e4647c7b882f1aa795791d35d1ae4a29714
|
/Textbook/Chapter7/二维指针.cpp
|
2f201a643bff305d2a67544ba375b13e13be94b1
|
[] |
no_license
|
david990917/CPP-PROGRAMMING
|
f392fdd18d67559a99fb2265531dd66871a3597b
|
ec6a0a645cd22f8cbcbec1a8329f0da663d141ef
|
refs/heads/main
| 2023-01-04T06:43:47.351981
| 2020-10-30T22:45:45
| 2020-10-30T22:45:45
| 308,758,402
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 280
|
cpp
|
二维指针.cpp
|
#include <iostream>
using namespace std;
int main() {
int x = 15;
int* p = &x;
int** q = &p;
const char* city[] = { "aaa","bbb","ccc" };
const char** pointer;
for (pointer = city; pointer < city + 3; ++pointer) { cout << *pointer << endl; }
return 0;
}
|
efd7acc3c45f5095b7a64a1e02ba400b8043f900
|
2d483bdb041c3e0f9ebecbf826bdf195274d8b1c
|
/smash.cpp
|
93c566518256c2c0bdc4b2194fe0d288c8fbfd8a
|
[] |
no_license
|
Ofir-Shechtman/234123-Operating_Systems-Smash_Project
|
677f13b617c814df689b5e51f9620cd7725bccde
|
2416e577eefd0711c055dcc63a2042df96747562
|
refs/heads/master
| 2023-05-26T00:51:49.744762
| 2020-05-05T17:15:08
| 2020-05-05T17:15:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,503
|
cpp
|
smash.cpp
|
#include <iostream>
#include <csignal>
#include "Commands.h"
#include "signals.h"
#include "system_functions.h"
int main(int argc, char *argv[]) {
setbuf(stdout, nullptr); //TODO remove
struct sigaction alarm = {{alarmHandler}};
alarm.sa_flags = SA_RESTART;
alarm.sa_handler = alarmHandler;
if (sigaction(SIGALRM, &alarm,nullptr) == -1) {
perror("smash error: failed to set alarm handler");
}
if (signal(SIGTSTP, ctrlZHandler) == SIG_ERR) {
perror("smash error: failed to set ctrl-Z handler");
}
if (signal(SIGINT, ctrlCHandler) == SIG_ERR) {
perror("smash error: failed to set ctrl-C handler");
}
if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
perror("smash error: failed to set ctrl-C handler");
}
SmallShell &smash = SmallShell::getInstance();
while (true) {
//std::cout<<"\x1B[1;36m"<<smash.get_prompt()<< "> " << "\x1B[0m";
std::cout << smash.get_prompt() << "> ";
std::string cmd_line;
std::getline(std::cin, cmd_line);
try {
smash.executeCommand(cmd_line.c_str());
}
catch (Continue &) {
if(smash.is_smash())
continue;
break;
}
catch (Quit &) {
return 0;
}
catch(std::bad_alloc& e) {
if (smash.is_smash()){
do_perror("allocation");
continue;
}
break;
}
catch(...){}
}
}
|
8af8c4e33371b67aa262bd32e6610f09592314b5
|
64ba6948ef57f16a511a6ec1bea21a3f24aea2df
|
/include/app_utils/type_name.hpp
|
6a10d4517bdcd3a60848820efcd4b23c2e612d88
|
[] |
no_license
|
Guillaume227/app_utils
|
aad0b1494f2d49ca73c84fff3e9dcbca60d7e6cc
|
51fc252632894fde188b58ac2c9bbb8a77f61165
|
refs/heads/master
| 2023-08-23T14:46:52.427902
| 2023-07-24T10:12:16
| 2023-07-24T10:12:16
| 168,242,234
| 0
| 2
| null | 2022-06-23T14:29:51
| 2019-01-29T22:51:01
|
C++
|
UTF-8
|
C++
| false
| false
| 1,895
|
hpp
|
type_name.hpp
|
#pragma once
#include <string_view>
#include <string>
#include <typeinfo>
#include <array>
namespace app_utils {
std::string_view parseTypeName(std::string_view paramName, bool minimal = false);
template<typename T>
std::string_view typeName(bool minimal = false) {
return parseTypeName(typeid(T).name(), minimal);
}
template<typename T>
std::string_view typeName(T const& t, bool minimal = false) {
return parseTypeName(typeid(t).name(), minimal);
}
template<typename T, size_t N>
std::string_view typeName(std::array<T, N> const& t, bool minimal = false) {
static std::string const type_name =
"std::array<" + std::string{typeName<T>(t[0], minimal)} + ", " + std::to_string(N) + ">";
return type_name;
}
template<>
constexpr std::string_view typeName<uint8_t>(bool) {
return "uint8_t";
}
template<>
constexpr std::string_view typeName<int8_t>(bool) {
return "int8_t";
}
template<>
constexpr std::string_view typeName<uint16_t>(bool) {
return "uint16_t";
}
template<>
constexpr std::string_view typeName<int16_t>(bool) {
return "int16_t";
}
template<>
constexpr std::string_view typeName<uint32_t>(bool) {
return "uint32_t";
}
template<>
constexpr std::string_view typeName<int32_t>(bool) {
return "int32_t";
}
template<>
constexpr std::string_view typeName(uint8_t const&, bool) {
return typeName<uint8_t>();
}
template<>
constexpr std::string_view typeName(int8_t const&, bool) {
return typeName<int8_t>();
}
template<>
constexpr std::string_view typeName(uint16_t const&, bool) {
return typeName<uint16_t>();
}
template<>
constexpr std::string_view typeName(int16_t const&, bool) {
return typeName<int16_t>();
}
template<>
constexpr std::string_view typeName(uint32_t const&, bool) {
return typeName<uint32_t>();
}
template<>
constexpr std::string_view typeName(int32_t const&, bool) {
return typeName<int32_t>();
}
}// namespace app_utils
|
74b4671379dd197b2f055b6a25a8b1669741bedb
|
530b659f67a287b5fd47d8f862df9479f204630a
|
/2.12/2.12/2.12.cpp
|
fd58100291106eb81cb293aca4fdca4be326c334
|
[] |
no_license
|
senpao51/promising
|
8e1d3f7f82c4c6910acc4fddae480074219ee020
|
9f1e41e36193da8f0e59af39f15c32b55a4835d6
|
refs/heads/master
| 2021-07-10T09:28:32.631575
| 2020-09-29T13:26:25
| 2020-09-29T13:26:25
| 201,902,814
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,055
|
cpp
|
2.12.cpp
|
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stdlib.h>
using namespace std;
//int main()
//{
// int i = 0, a = 0;
// while (i < 20)
// {
// for (;;)
// {
// if ((i % 10) == 0)
// break;
// else
// i--;
// }
// i += 11; a += i;
// }
// cout << a << endl;
// return 0;
//}
typedef struct s
{
char ch;
int mark;
}s;
typedef struct Stack
{
struct s*tmp;
int capacity;
int top;
}Stack;
void StackInit(Stack*st)
{
st->capacity = 10000;
st->tmp = (s*)malloc(sizeof(s)*st->capacity);
st->tmp->ch = '\0';
st->tmp->mark = 0;
st->top = 0;
}
void StackInsert(Stack*st,char s)
{
st->tmp->ch = s;
st->top++;
}
bool canConstruct(char * ransomNote, char * magazine)
{
if (ransomNote == magazine)
return true;
Stack st;
StackInit(&st);
while (*magazine != '\0')
{
StackInsert(&st, *magazine);
magazine++;
}
while (*ransomNote != '\0')
{
for (int i = 0; <st.top; i++)
{
}
}
}
//"fffbfg"
//"effjfggbffjdgbjjhhdegh"
int main()
{
cout << canConstruct("fffbfg", "effjfggbffjdgbjjhhdegh") << endl;
return 0;
}
|
8f0cfd75e09c4e8186ec1fab1b3e9cfc3f3dca99
|
9e99fd66b5b7bff602b30ca937e929627dcc366e
|
/uWater_MBED/mbedConnectorInterface/api/TickerResourceObserver.h
|
3d548476a55daf549f317538ddde6246effe8d31
|
[] |
no_license
|
jiwu14/uWater
|
acdd9a2eb5e7476028efa3c8a6f4372777867404
|
e8c33d8cb4acd6dc397afab031dee9bc4f08fc82
|
refs/heads/master
| 2021-01-22T17:57:43.597980
| 2015-06-10T18:23:42
| 2015-06-10T18:23:42
| 37,214,530
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,303
|
h
|
TickerResourceObserver.h
|
/**
* @file TickerResourceObserver.h
* @brief mbed CoAP DynamicResource Ticker-based observer (header)
* @author Doug Anson/Chris Paola
* @version 1.0
* @see
*
* Copyright (c) 2014
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TICKER_RESOURCE_OBSERVER_H__
#define __TICKER_RESOURCE_OBSERVER_H__
// mbed support
#include "mbed.h"
// switch for proper resource observer selection (from mbedEndpointNetwork)
#include "configuration.h"
// mbedConnectorInterface configuration
#include "mbedConnectorInterface.h"
// Base class support
#include "ResourceObserver.h"
class TickerResourceObserver : public ResourceObserver {
public:
/**
Default Constructor
@param resource input the resource to observe
@param timer_id input the id for our timer (can be index value of each resource that is observed...)
@param sleep_time input the time for the observation tasklet to sleep (in whole seconds...)
*/
TickerResourceObserver(DynamicResource *resource,int sleep_time = NSP_DEFAULT_OBS_PERIOD);
/**
Copy Constructor
*/
TickerResourceObserver(const TickerResourceObserver &observer);
/**
Destructor
*/
virtual ~TickerResourceObserver();
/**
begin the observation
*/
virtual void beginObservation();
/**
stop the observation
*/
virtual void stopObservation();
/**
tasklet invoke function (static)
*/
void observationNotifier(void);
private:
Ticker m_ticker;
};
#endif // __TICKER_RESOURCE_OBSERVER_H__
|
5833a3452671db8194b4db45d32cb904b4b62b67
|
ea7a0fdea3872e70412b971ef12b5b58dc093302
|
/TitleProject_Cpp/0520_检测大写字母.cpp
|
972cbf42bbeea37f6601bf87b2468b46b99b4214
|
[] |
no_license
|
Xnco/Data-Structures-and-Algorithms
|
3328e364c3edf71b62a8fc52bff9d34807059a71
|
e2c370c4d94ee0231ae9af1172b06ada7543452c
|
refs/heads/master
| 2021-06-28T02:21:52.443892
| 2020-10-01T06:23:41
| 2020-10-01T06:23:41
| 155,956,604
| 12
| 2
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,325
|
cpp
|
0520_检测大写字母.cpp
|
#include "pch.h"
#include "DataStructure.h"
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#pragma region 520_检测大写字母
/*
给定一个单词,你需要判断单词的大写使用是否正确。
我们定义,在以下情况时,单词的大写用法是正确的:
全部字母都是大写,比如"USA"。
单词中所有字母都不是大写,比如"leetcode"。
如果单词不只含有一个字母,只有首字母大写, 比如 "Google"。
否则,我们定义这个单词没有正确使用大写字母。
示例 1:
输入: "USA"
输出: True
示例 2:
输入: "FlaG"
输出: False
注意: 输入是由大写和小写拉丁字母组成的非空单词。
*/
class Solution {
public:
// 巧妙的做法 4ms(100%), 8.4MB(98.75%)
bool detectCapitalUse(string word) {
int num = 0;
for (size_t i = 0; i < word.size(); i++)
{
if (isUpper(word[i]))
{
if (num < i) // 只要有一个大写字母出现在小写字母后面就是false
{
return false;
}
num++;
}
}
// 要不大写字符数量 == 字符串长度
// 要不大写字母没有或只有一个
return num == word.size() || num <= 1;
}
bool isUpper(char c)
{
return c >= 'A' && c <= 'Z';
}
};
#pragma endregion
|
a043ce58c71143028d1496288d0476767aa63f50
|
47247c8cf74b5c833dc55e3e62b11da7b6cc9a8d
|
/EnemyClass.cpp
|
df03041626f9583ddf7f342883ca6177fbaacecc
|
[] |
no_license
|
BenAbdul/tripping-octo-dangerzone
|
5eaa5b8a465eaab00f594d79d2f3ee5c612cb0ee
|
e3c3165a836d3e21dcf74fc3fffddc930d69ad80
|
refs/heads/master
| 2016-09-06T12:21:40.691379
| 2014-04-13T13:47:48
| 2014-04-13T13:47:48
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,370
|
cpp
|
EnemyClass.cpp
|
#include"EnemyClass.h"
#include"Declarations.h"
int CurrentID = 0;
Enemy::Enemy()
{
xPos = rand () % 5500 + 500;
yPos = rand () % 5500 + 500;
CurrentID++;
ID = CurrentID;
Random = (rand () % 80 + 20) / 10;
if ( PlayerXVel > 19 && PlayerX < 4400 && LazyFlag2 == false)
{
xPos = PlayerX + 900;
yPos = PlayerY;
LazyFlag2 = true;
}
else if ( PlayerXVel < -19 && PlayerX > 1000 && LazyFlag2 == false)
{
xPos = PlayerX - 900;
yPos = PlayerY;
LazyFlag2 = true;
}
else if (PlayerYVel > 19 && PlayerY < 4600 && LazyFlag2 == false)
{
yPos = PlayerY + 700;
xPos = PlayerX;
LazyFlag2 = true;
}
else if (PlayerYVel < -19 && PlayerY > 1200 && LazyFlag2 == false)
{
yPos = PlayerY - 700;
xPos = PlayerX;
LazyFlag2 = true;
}
else
{
if (xPos > CameraX && xPos && xPos < CameraX + 800 && yPos > CameraY && yPos < CameraY + 600)
{
bool XIsDone = false;
bool YIsDone = false;
while (1)
{
if (XIsDone == false)
{
xPos = rand () % 5500 + 500;
if (xPos < CameraX || xPos > CameraX + 800) XIsDone = true;
}
if(YIsDone == false)
{
yPos = rand () % 5500 + 500;
if (yPos < CameraY || yPos > CameraY + 600) YIsDone = true;
}
else if (XIsDone == true) break; //My programming skillz know no bounds
}
}
}
Frame = 0;
FrameTime = 0;
xVel = 0;
yVel = 0;
Active = 1;
Facing = 0;
}
|
f8a08c5efe7e607b12ea6a2b25755e85776e4af8
|
1ff891783726d340433cbcfe2a3139ae935de6bf
|
/NAudio/Source/NAudio/ControlChangeNotifier.cpp
|
72ee2931dc1a9009980aad9c677077299846e0f6
|
[] |
no_license
|
ctmartinez1992/NAudio
|
133336236b5a71345274d5414b5073b0b2855d21
|
cb4f446d66c5c606331c05a2fa090b74c1a8caba
|
refs/heads/master
| 2021-01-20T04:02:04.640469
| 2017-04-27T17:47:32
| 2017-04-27T17:47:32
| 89,624,822
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,293
|
cpp
|
ControlChangeNotifier.cpp
|
#include "ControlChangeNotifier.h"
namespace NAudio {
namespace NAudio_DSP {
ControlChangeNotifier_::ControlChangeNotifier_() :
outputReadyToBeSentToUI(false)
{
}
ControlChangeNotifier_::~ControlChangeNotifier_() {
}
void
ControlChangeNotifier_::computeOutput(const SynthesisContext_& context) {
output_ = input_.tick(context);
if(output_.triggered) {
//Crude atomic control.
outputReadyToBeSentToUI = false;
outputToSendToUI = output_;
outputReadyToBeSentToUI = true;
}
}
void
ControlChangeNotifier_::sendControlChangesToSubscribers() {
if(outputReadyToBeSentToUI) {
for(std::vector<ControlChangeSubscriber*>::iterator it = subscribers.begin(); it != subscribers.end(); ++it) {
(*it)->valueChanged(name, outputToSendToUI.value);
}
outputReadyToBeSentToUI = false;
}
}
void
ControlChangeNotifier_::addValueChangedSubscriber(ControlChangeSubscriber* sub) {
subscribers.push_back(sub);
}
void
ControlChangeNotifier_::removeValueChangedSubscriber(ControlChangeSubscriber* sub) {
subscribers.erase(std::remove(subscribers.begin(), subscribers.end(), sub), subscribers.end());
}
}
void
ControlChangeNotifier::sendControlChangesToSubscribers() {
gen()->sendControlChangesToSubscribers();
}
}
|
0d8e37f0e57f7c0fdb7e436b9eb9af0925cef190
|
2ecd4792f9a76ed3b0aa8bbbe568a881d6f675e1
|
/01 - naveGL/src/inimigo.cpp
|
5c63720ae9db5a3fa46cf1c96e00bfe39e5fe67d
|
[] |
no_license
|
andersori/Computacao-Grafica
|
1daa33811f6bbe0ce91c18598ae166df8fea454c
|
4c6c3c22c60445e0d7d8466cdffc9c865d2c82ac
|
refs/heads/master
| 2020-03-14T04:12:52.398424
| 2018-04-28T23:06:40
| 2018-04-28T23:06:40
| 131,437,216
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,109
|
cpp
|
inimigo.cpp
|
#include "inimigo.h"
#include <QtOpenGL>
Inimigo::Inimigo()
{
this->vertices = new float*[4];
for(int i=0; i < 4;i++)
this->vertices[i] = new float[3];
set_vertice_1(-0.08, 0.0, 0.0);
set_vertice_2(0.08, 0.0, 0.0);
set_vertice_3(0.08, 0.1, 0.0);
set_vertice_4(-0.08, 0.1, 0.0);
set_raio();
}
Inimigo::~Inimigo()
{
for(int i = 0; i < 6; i++)
{
delete vertices[i];
}
delete vertices;
}
void Inimigo::paint()
{
float temp[4][3] = {{vertices[0][0] + pos[0] ,
vertices[0][1] + pos[1] ,
vertices[0][2] + pos[2] },
{vertices[1][0] + pos[0] ,
vertices[1][1] + pos[1] ,
vertices[1][2] + pos[2] },
{vertices[2][0] + pos[0] ,
vertices[2][1] + pos[1] ,
vertices[2][2] + pos[2] },
{vertices[3][0] + pos[0] ,
vertices[3][1] + pos[1] ,
vertices[3][2] + pos[2] },
};
set_centro(temp);
glBegin(GL_QUADS);
glColor3fv(cor);
glVertex3fv(temp[0]);
glVertex3fv(temp[1]);
glVertex3fv(temp[2]);
glVertex3fv(temp[3]);
glEnd();
glPointSize(5);
glBegin(GL_POINTS);
glColor3f(1.0, 1.0, 1.0);
glVertex3fv(centro);
glEnd();
glFlush();
mover(Desenho::BAIXO);
}
void Inimigo::mover(Desenho::Direcao dir)
{
Desenho::mover(dir);
if(this->centro[1] < -1.0)
{
this->pos[1] = 1.0;
}
if(this->pos[1] > 1.0 && this->centro[1] > 1.0)
{
this->pos[1] = -1.0;
}
if(this->centro[0] < -1.0)
{
this->pos[0] = 1.0;
}
if(this->centro[0] > 1.0)
{
this->pos[0] = -1.0;
}
}
void Inimigo::set_vertice_1(float x, float y, float z)
{
this->vertices[0][0] = x;
this->vertices[0][1] = y;
this->vertices[0][2] = z;
}
void Inimigo::set_vertice_2(float x, float y, float z)
{
this->vertices[1][0] = x;
this->vertices[1][1] = y;
this->vertices[1][2] = z;
}
void Inimigo::set_vertice_3(float x, float y, float z)
{
this->vertices[2][0] = x;
this->vertices[2][1] = y;
this->vertices[2][2] = z;
}
void Inimigo::set_vertice_4(float x, float y, float z)
{
this->vertices[3][0] = x;
this->vertices[3][1] = y;
this->vertices[3][2] = z;
}
void Inimigo::set_centro(float temp[4][3])
{
float x_max = temp[0][0];
float y_max = temp[0][1];
float x_min = temp[0][0];
float y_min = temp[0][1];
//procurando maiores
for(int i=0;i<4;i++)
{
if (x_max < temp[i][0])
x_max = temp[i][0];
if (y_max < temp[i][1])
y_max = temp[i][1];
}
//procurando menores
for(int i=0;i<4;i++)
{
if (x_min > temp[i][0])
x_min = temp[i][0];
if (y_min > temp[i][1])
y_min = temp[i][1];
}
this->centro[0] = (x_max + x_min) / 2.0;
this->centro[1] = (y_max + y_min) / 2.0;
}
|
4f8c99ccaec7a8c6cc2cf6f8ee6054d020bc1acd
|
5c925f3600b26707cf653c4add72e6cc80082be2
|
/filezillaclient/clien/src/interface/verifycertdialog.h
|
732de4ed76d1cf5a00b123fb1893e3b13435158a
|
[] |
no_license
|
ljx0305/fileZilla
|
52100ad9b41882d78372232de3801ed449db9408
|
d88d83c8b8bd39c0636166ba9a2911435c8fab63
|
refs/heads/main
| 2023-06-18T01:16:35.811661
| 2021-07-12T17:15:03
| 2021-07-12T17:15:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,730
|
h
|
verifycertdialog.h
|
#ifndef __VERIFYCERTDIALOG_H__
#define __VERIFYCERTDIALOG_H__
#include "xmlfunctions.h"
class wxDialogEx;
class CVerifyCertDialog : protected wxEvtHandler
{
public:
CVerifyCertDialog();
virtual ~CVerifyCertDialog();
bool IsTrusted(CCertificateNotification const& notification);
void ShowVerificationDialog(CCertificateNotification& notification, bool displayOnly = false);
protected:
struct t_certData {
wxString host;
int port{};
unsigned char* data{};
unsigned int len{};
};
bool IsTrusted(const wxString& host, int port, const unsigned char* data, unsigned int len, bool permanentOnly);
bool DoIsTrusted(const wxString& host, int port, const unsigned char* data, unsigned int len, std::list<t_certData> const& trustedCerts);
bool DisplayCert(wxDialogEx* pDlg, const CCertificate& cert);
void ParseDN(wxWindow* parent, const wxString& dn, wxSizer* pSizer);
void ParseDN_by_prefix(wxWindow* parent, std::list<wxString>& tokens, wxString prefix, const wxString& name, wxSizer* pSizer, bool decode = false);
wxString DecodeValue(const wxString& value);
wxString ConvertHexToString(const unsigned char* data, unsigned int len);
unsigned char* ConvertStringToHex(const wxString& str, unsigned int &len);
void SetPermanentlyTrusted(CCertificateNotification const& notification);
void LoadTrustedCerts();
std::list<t_certData> m_trustedCerts;
std::list<t_certData> m_sessionTrustedCerts;
CXmlFile m_xmlFile;
std::vector<CCertificate> m_certificates;
wxDialogEx* m_pDlg{};
wxSizer* m_pSubjectSizer{};
wxSizer* m_pIssuerSizer{};
int line_height_{};
void OnCertificateChoice(wxCommandEvent& event);
};
#endif //__VERIFYCERTDIALOG_H__
|
67b24a30c4caa2120ae9db9eab1d92270c780c9b
|
80cacc31954b7d44f1485913fbcf8259460bd01b
|
/Codeforces/CF 781C.cpp
|
106bd46e69e70a55f34e4eb314fe0adecc07719f
|
[] |
no_license
|
ConnorZhong/ACM
|
67918b881bafb13fe1b733b0b157365f23d40f1e
|
d3588b3a5241465e9ac132f9efab655424e06ad1
|
refs/heads/master
| 2021-04-28T23:33:07.400120
| 2020-02-24T16:57:50
| 2020-02-24T16:57:50
| 77,731,351
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,387
|
cpp
|
CF 781C.cpp
|
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <bitset>
#define fi first
#define se second
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define per(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,a,b) for (int i=(a);i<=(b);i++)
#define PER(i,a,b) for (int i=(b);b>=(a);i--)
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 200005; // 2e5;
int n,m,k,t;
vector<int> G[MAXN];
vector<int> Path[MAXN];
bool visited[MAXN];
int cnt = 1;
void upd(int x)
{
if (Path[cnt].size() >= t) cnt++;
Path[cnt].push_back(x);
// cout<<1<<endl;
}
void dfs(int i)
{
visited[i] = true;
// cout<<i<<endl;
for (int j = 0; j < G[i].size(); j++)
{
int v = G[i][j];
// cout<<v<<endl;
if (visited[v]) continue;
upd(v);
dfs(v);
upd(i);
}
}
int main()
{
// freopen("in.txt","r",stdin);
scanf("%d%d%d",&n,&m,&k);
rep(i,0,m)
{
int s,t;
scanf("%d%d",&s,&t);
G[s].push_back(t);
G[t].push_back(s);
}
t = (n*2+(k-1))/k;
// cout<<t<<endl;
upd(1);
dfs(1);
// cout<<cnt<<endl;
rep(i,1,k+1)
{
if (Path[i].size()!=0)
{
printf("%d ",Path[i].size());
for(auto &x: Path[i]) printf("%d ",x);
}
else
printf("1 1");
printf("\n");
}
}
|
32f307117d9523d326db5fa3fa91c2def691ea8f
|
64a53394a163316e429d41fe4590fba24fbd1817
|
/Silence.cc
|
0363506f4364e25502414b5298f61007fe179f16
|
[] |
no_license
|
stephaniewhoo/Sorcery-game
|
623ea3015eacfc967f1108301c009aa1dc770906
|
dca235bddfdca416dc0c78a341e00a03e8b26430
|
refs/heads/master
| 2021-05-12T17:10:34.971974
| 2018-01-11T02:25:00
| 2018-01-11T02:25:00
| 117,038,250
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 365
|
cc
|
Silence.cc
|
#include "Silence.h"
#include <iostream>
using namespace std;
Silence::Silence(Player *owner): Enchantment{ "Silence", "Enchantment", "Enchanted minion cannot use abilities", 1, owner, 0, 0 } {}
Silence::~Silence() {}
void Silence::activate(shared_ptr<Card> c) {
cout<<"using silence"<<endl;
c->silence();
}
void Silence::deactivate(shared_ptr<Card> c) {
}
|
b6bd3a723c65c7fca7dfc0dd1a4ccd20baaa3797
|
d5b3aae4177c1dcb58a18eebe56dd3fe59bda0ff
|
/BridgePattern/BridgePattern.h
|
4720231eb5c8b56eb1b2cbac058df6eefa2eddc3
|
[] |
no_license
|
xfc1939/DesignPatterns
|
3c2058e485b74faa513793e20bd30e81015dbf4a
|
e7b872b9a0f1c9ee762a0e6032cf9faa0338c5e2
|
refs/heads/master
| 2020-03-20T13:58:59.093903
| 2018-08-26T04:15:13
| 2018-08-26T04:15:13
| 137,472,136
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,322
|
h
|
BridgePattern.h
|
//
// Created by xfc on 2018/8/3.
//
#ifndef DESIGNPATTERNS_BRIDGEPATTERN_H
#define DESIGNPATTERNS_BRIDGEPATTERN_H
/*
* 桥接模式
*/
#include <iostream>
class Implementor {
public:
Implementor() = default;
virtual ~Implementor() = default;
virtual void oper() = 0;
};
class ImplementorA :public Implementor {
public:
ImplementorA() = default;
~ImplementorA() override = default;
public:
void oper() override {
std::cout << __FUNCTION__ << " implementorA" << std::endl;
}
};
class ImplementorB :public Implementor {
public:
ImplementorB() = default;
~ImplementorB() override = default;
public:
void oper() override {
std::cout << __FUNCTION__ << " implementorB" << std::endl;
}
};
class Abstraction {
public:
explicit Abstraction():impl_(nullptr){}
void setImpl(Implementor *impl) {
impl_ = impl;
}
virtual ~Abstraction() = default;
virtual void oper() {
if (impl_) {
impl_->oper();
}
}
protected:
Implementor *impl_;
};
class RefindAbstraction: public Abstraction
{
public:
explicit RefindAbstraction() : Abstraction(){}
~RefindAbstraction() override = default;
public:
void oper() override {
impl_->oper();
}
};
#endif //DESIGNPATTERNS_BRIDGEPATTERN_H
|
5151e08e6ab2d263f67d341553eeca925f452099
|
f7f5564041e9a7e700ccfd53ffbc3f5fa7d2e35c
|
/src/scanner/src/ModelPlaque.cpp
|
02e60b3a9fa6f6e68804a9658a256ac5a3275894
|
[] |
no_license
|
rishihahs/3d_scanner
|
34e0a51cd4fca616825c67a40cbbfdff189ee9af
|
ec20e2f474298f6bc3746c4d27ed95dff9a03491
|
refs/heads/master
| 2020-03-22T16:46:25.923916
| 2018-05-19T06:56:31
| 2018-05-19T06:56:31
| 140,350,281
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 925
|
cpp
|
ModelPlaque.cpp
|
#include "ModelPlaque.h"
#include "mapping_calibration/HomCartShortcuts.h"
using namespace Eigen;
ModelPlaque::ModelPlaque(double width, double height)
: _modelPC2D(createModelPlaque(width, height)),
_modelPH2D(addARowOfConst(_modelPC2D, 1.0)),
_modelPC3D(addARowOfConst(_modelPC2D, 0.0)),
_modelPH3D(addARowOfConst(_modelPC3D, 1.0)) {}
ModelPlaque::~ModelPlaque() {}
MatrixXd ModelPlaque::getModelPC2D() const { return _modelPC2D; }
MatrixXd ModelPlaque::getModelPH2D() const { return _modelPH2D; }
MatrixXd ModelPlaque::getModelPC3D() const { return _modelPC3D; }
MatrixXd ModelPlaque::getModelPH3D() const { return _modelPH3D; }
MatrixXd ModelPlaque::createModelPlaque(double width, double height) {
MatrixXd m(2, 4); // 4 corners
m(0, 0) = 0.;
m(1, 0) = 0.;
m(0, 1) = width;
m(1, 1) = 0.;
m(0, 2) = width;
m(1, 2) = height;
m(0, 3) = 0.;
m(1, 3) = height;
return m;
}
|
2b73037f1ff0bd4a73102fb6bea4e409dafa90ff
|
2e6bb5ab6f8ad09f30785c386ce5ac66258df252
|
/project/HappyHunter/Core/SceneNode.cpp
|
e454bdc6bcc2d93d48a1782b4fe49916b00910f7
|
[] |
no_license
|
linfuqing/happyhunter
|
961061f84947a91256980708357b583c6ad2c492
|
df38d8a0872b3fd2ea0e1545de3ed98434c12c5e
|
refs/heads/master
| 2016-09-06T04:00:30.779303
| 2010-08-26T15:41:09
| 2010-08-26T15:41:09
| 34,051,578
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,148
|
cpp
|
SceneNode.cpp
|
#include "StdAfx.h"
#include "SceneNode.h"
using namespace zerO;
CSceneNode::CSceneNode(void) :
m_pParent(NULL),
m_bIsTransformDirty(false)
{
D3DXMatrixIdentity(&m_LocalMatrix);
D3DXMatrixIdentity(&m_WorldMatrix);
if( GAMEHOST.GetScene() )
GAMEHOST.GetScene()->AddChild(this);
}
CSceneNode::~CSceneNode(void)
{
Destroy();
}
bool CSceneNode::Destroy()
{
m_Children.clear();
return true;
}
void CSceneNode::AddChild(CSceneNode* pChild)
{
if(pChild == this)
return;
if(pChild->m_pParent)
pChild->m_pParent->RemoveChild(pChild);
m_Children.push_back(pChild);
pChild->m_pParent = this;
pChild->_SetTransformDirty();
}
void CSceneNode::RemoveChild(CSceneNode* pChild)
{
m_Children.remove(pChild);
pChild->m_pParent = NULL;
pChild->_SetTransformDirty();
}
void CSceneNode::UpdateChildren()
{
for(std::list<CSceneNode*>::const_iterator i = m_Children.begin(); i != m_Children.end(); i ++)
{
(*i)->Update();
(*i)->UpdateChildren();
}
}
void CSceneNode::_SetTransformDirty()
{
m_bIsTransformDirty = true;
for(std::list<CSceneNode*>::const_iterator i = m_Children.begin(); i != m_Children.end(); i ++)
(*i)->_SetTransformDirty();
}
void CSceneNode::UpdateTransform()
{
m_bIsTransformDirty = false;
if(m_pParent)
D3DXMatrixMultiply(&m_WorldMatrix, &m_LocalMatrix, &m_pParent->m_WorldMatrix);
else
m_WorldMatrix = m_LocalMatrix;
m_WorldRect = m_LocalRect;
m_WorldRect.Transform(m_WorldMatrix);
}
void CSceneNode::Update()
{
if(m_bIsTransformDirty)
UpdateTransform();
}
void CSceneNode::Clone(CSceneNode& Node)const
{
for(std::list<CSceneNode*>::const_iterator i = m_Children.begin(); i != m_Children.end(); i ++)
Node.m_Children.push_back(*i);
Node.m_LocalMatrix = m_LocalMatrix;
Node.m_WorldMatrix = m_WorldMatrix;
Node.m_LocalRect = m_LocalRect;
Node.m_WorldRect = m_WorldRect;
Node.m_bIsTransformDirty = m_bIsTransformDirty;
}
bool CSceneNode::ApplyForRender()
{
return true;
}
void CSceneNode::Render(CRenderQueue::LPRENDERENTRY pEntry, zerO::UINT32 uFlag)
{
}
|
163d6204e675d0042938a0038686585173de892f
|
9a1e18c88790eb05dfcf4a8f6ef50ade8ff4f731
|
/objcLib/test/testMany/tmp/byYear2.cpp
|
be6705884a2a06456ae771fb4de8d2ee6e8f880b
|
[] |
no_license
|
CodeFarmsInc/QSP
|
25d6af4d5bfc064f115ade014a39290f7cc02149
|
031c9fe2ee4008fce3837ed08bff1f6511c26b15
|
refs/heads/master
| 2021-01-25T14:58:32.496669
| 2018-03-04T01:13:45
| 2018-03-04T01:13:45
| 123,725,986
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,970
|
cpp
|
byYear2.cpp
|
class Student;
class Took;
void byYear_Aggregate2::addHead(Student *p, Took *c){
if(c->ZZds.ZZbyYear.parent){
printf("byYear.addHead() error: Child=%d already in byYear_Aggregate2\n",c);
return;
}
c->ZZds.ZZbyYear.parent=p;
byYear_LinkedList2::addHead(p,c);
}
void byYear_Aggregate2::addTail(Student *p, Took *c){
if(c->ZZds.ZZbyYear.parent){
printf("byYear.addTail() error: Child=%d already in byYear_Aggregate2\n",c);
return;
}
c->ZZds.ZZbyYear.parent=p;
byYear_LinkedList2::addTail(p,c);
}
// append Child c2 after Child c1
void byYear_Aggregate2::append(Took *c1, Took *c2){
Student* p=c1->ZZds.ZZbyYear.parent;
if(!p){
printf("byYear.append() error: c1=%d not in byYear_Aggregate2\n",c1);
return;
}
if(c2->ZZds.ZZbyYear.parent){
printf("byYear.addTail() error: c2=%d already in byYear_Aggregate2\n",c2);
return;
}
c2->ZZds.ZZbyYear.parent=p;
byYear_LinkedList2::append(p,c1,c2);
}
// insert Child c1 before Child c1
void byYear_Aggregate2::insert(Took *c1, Took *c2){
Student* p=c2->ZZds.ZZbyYear.parent;
if(!p){
printf("byYear.append() error: c2=%d not in byYear_Aggregate2\n",c2);
return;
}
if(c1->ZZds.ZZbyYear.parent){
printf("byYear.addTail() error: c1=%d already in byYear_Aggregate2\n",c1);
return;
}
c1->ZZds.ZZbyYear.parent=p;
byYear_LinkedList2::insert(c1,c2);
}
void byYear_Aggregate2::remove(Took *c){
Student* p=c->ZZds.ZZbyYear.parent;
if(p){byYear_LinkedList2::remove(p,c); c->ZZds.ZZbyYear.parent=NULL;}
else printf("WARNING: byYear.remove() with c=%d already disconnected\n",c);
}
Student* const byYear_Aggregate2::parent(Took *c){
return c->ZZds.ZZbyYear.parent; }
|
f2898dccb76162d786cf6abaafab5e2f7f0e454b
|
235e80327fdc5b25b6474c2e6a4427e83751a4a6
|
/bomb.cpp
|
fe9857c1b5bdd3df9ff3a7c50f148cf380c9341f
|
[] |
no_license
|
NeeXxx/noUI
|
4026ede9f2ccff3e4c100f21f25c241fc4c33279
|
b94813e229497d26e0eeed424e40b864032c1103
|
refs/heads/master
| 2020-12-02T17:39:11.771676
| 2017-07-10T07:31:48
| 2017-07-10T07:31:48
| 96,405,063
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 521
|
cpp
|
bomb.cpp
|
#include "bomb.h"
bomb::bomb(QFrame* parent,int tx,int ty,int tp,player* str):
QFrame(parent),x(tx),y(ty),power(tp),setter(str)
{
timer.start(1500,this);
}
void bomb::timerEvent(QTimerEvent* event)
{
if(event->timerId()==timer.timerId())
{
tryExplode();
}
}
//<<<<<<< HEAD
void bomb::setExploded()
{
exploded=true;
}
void bomb::tryExplode()
{
if(!exploded)
{
emit explode(*this);
}
setExploded();
}
//=======
//>>>>>>> b983aedae3197ff03680f7cf948d84e1d4a2fcfc
|
33eb69fd914fd992bb3eb67938d8a26459aaa46e
|
654d82abbe33802ed5ef65990ac05d22b4e1aab3
|
/tests/benchmark.cc
|
d76b145e2611d2b041e73bb6d2de3ec5433702f1
|
[] |
no_license
|
walac/split-rectangle-cpp
|
41de705f2fa5388a7e64da25161a29991c859468
|
6052d013de0f767736259ccbc81b3230bf8ed157
|
refs/heads/master
| 2023-02-21T20:47:55.586448
| 2021-01-17T14:50:10
| 2021-01-18T15:46:06
| 328,672,118
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 924
|
cc
|
benchmark.cc
|
#include <random>
#include <vector>
#include <algorithm>
#define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#include <catch2/catch.hpp>
#include "split_rect.h"
constexpr auto SEED = 13607;
constexpr auto N = 500;
template<typename T>
std::vector<Rect<T>> gen_data() {
using rect_t = Rect<T>;
std::default_random_engine g(SEED);
std::uniform_int_distribution<T> d(1, 100);
std::vector<rect_t> recs;
std::generate_n(std::back_inserter(recs), N, [&] {
return rect_t(d(g), d(g), d(g), d(g));
});
return recs;
}
TEST_CASE("split_rectangles") {
BENCHMARK_ADVANCED("default")(Catch::Benchmark::Chronometer meter) {
auto recs = gen_data<int>();
std::vector<Rect<int>> result;
auto inserter = std::back_inserter(recs);
meter.measure([&] {
return split_rectangles(recs.cbegin(), recs.cend(), inserter);
});
};
}
|
d0b8cda68e40a3155996f791195aafa7f2cf5156
|
c696a3030c9ed5d2c62909d0b83f34758f1d2b44
|
/game/screen_audiodevices.cc
|
0f6abf202e0893ab5bff4c2e9b4cec4c2e6b719b
|
[] |
no_license
|
ycaihua/performous
|
26209baea1e3e52241212fcd86674d3bd0f6961e
|
3d5f01392b15ae5c9686ea357c7ad6fa81c1faed
|
refs/heads/master
| 2020-12-29T00:01:10.133960
| 2015-06-25T13:47:37
| 2015-06-25T13:47:37
| 39,230,284
| 1
| 0
| null | 2015-07-17T02:12:22
| 2015-07-17T02:12:21
| null |
UTF-8
|
C++
| false
| false
| 9,074
|
cc
|
screen_audiodevices.cc
|
#include "screen_audiodevices.hh"
#include "configuration.hh"
#include "controllers.hh"
#include "theme.hh"
#include "audio.hh"
#include "i18n.hh"
#include <boost/thread.hpp>
#include <boost/bind.hpp>
namespace {
static const int unassigned_id = -1; // mic.dev value for unassigned
static const float yoff = 0.18; // Offset from center where to place top row
static const float xoff = 0.45; // Offset from middle where to place first column
bool countRow(std::string needle, std::string const& haystack, int& count) {
if (haystack.find(needle) != std::string::npos) ++count;
if (count > 1) return false;
return true;
}
}
ScreenAudioDevices::ScreenAudioDevices(std::string const& name, Audio& audio): Screen(name), m_audio(audio) {
m_selector.reset(new Surface(findFile("device_selector.svg")));
m_mic_icon.reset(new Surface(findFile("sing_pbox.svg")));
m_pdev_icon.reset(new Surface(findFile("icon_pdev.svg")));
}
void ScreenAudioDevices::enter() {
m_theme.reset(new ThemeAudioDevices());
portaudio::AudioDevices ads;
m_devs = ads.devices;
// FIXME: Something more elegant, like a warning box
if (m_devs.empty()) throw std::runtime_error("No audio devices found!");
m_selected_column = 0;
// Detect if there is existing advanced configuration and warn that this will override
if (!config["audio/devices"].isDefault()) {
ConfigItem::StringList devconf = config["audio/devices"].sl();
std::map<std::string, int> countmap;
bool ok = true;
for (ConfigItem::StringList::const_iterator it = devconf.begin(); it != devconf.end(); ++it) {
if (!countRow("blue", *it, countmap["blue"])) { ok = false; break; }
if (!countRow("red", *it, countmap["red"])) { ok = false; break; }
if (!countRow("green", *it, countmap["green"])) { ok = false; break; }
if (!countRow("yellow", *it, countmap["yellow"])) { ok = false; break; }
if(!countRow("fuchsia", *it, countmap["fuchsia"])) { ok = false; break; }
if(!countRow("lightgreen", *it, countmap["lightgreen"])) { ok = false; break; }
if(!countRow("purple", *it, countmap["purple"])) { ok = false; break; }
if(!countRow("aqua", *it, countmap["aqua"])) { ok = false; break; }
if (!countRow("out=", *it, countmap["out="])) { ok = false; break; }
}
if (!ok)
Game::getSingletonPtr()->dialog(
_("It seems you have some manual configurations\nincompatible with this user interface.\nSaving these settings will override\nall existing audio device configuration.\nYour other options changes will be saved too."));
}
// Populate the mics vector and check open devices
load();
// TODO: Scrolling would be nicer than just zooming out infinitely
float s = std::min(xoff / m_channels.size() / 1.2, yoff*2 / m_devs.size() / 1.1);
m_mic_icon->dimensions.fixedWidth(s);
m_pdev_icon->dimensions.fixedWidth(s);
}
void ScreenAudioDevices::exit() { m_theme.reset(); }
void ScreenAudioDevices::manageEvent(input::NavEvent const& event) {
Game* gm = Game::getSingletonPtr();
input::NavButton nav = event.button;
auto& chpos = m_channels[m_selected_column].pos;
const unsigned posN = m_devs.size() + 1;
if (nav == input::NAV_CANCEL) gm->activateScreen("Intro");
else if (nav == input::NAV_PAUSE) m_audio.togglePause();
else if (m_devs.empty()) return; // The rest work if there are any devices
else if (nav == input::NAV_START) { if (save()) gm->activateScreen("Intro"); }
else if (nav == input::NAV_LEFT && m_selected_column > 0) --m_selected_column;
else if (nav == input::NAV_RIGHT && m_selected_column < m_channels.size()-1) ++m_selected_column;
else if (nav == input::NAV_UP) chpos = (chpos + posN) % posN - 1;
else if (nav == input::NAV_DOWN) chpos = (chpos + posN + 2) % posN - 1;
}
void ScreenAudioDevices::manageEvent(SDL_Event event) {
if (event.type == SDL_KEYDOWN) {
int key = event.key.keysym.scancode;
uint16_t modifier = event.key.keysym.mod;
if (m_devs.empty()) return; // The rest work if there are any config options
// Reset to defaults
else if (key == SDL_SCANCODE_R && modifier & KMOD_CTRL) {
config["audio/devices"].reset(modifier & KMOD_ALT);
save(true); // Save to disk, reload audio & reload UI to keep stuff consistent
}
}
}
void ScreenAudioDevices::draw() {
m_theme->bg.draw();
if (m_devs.empty()) return;
// Calculate spacing between columns/rows
const float xstep = (xoff - 0.5 + xoff) / m_channels.size();
const float ystep = yoff*2 / m_devs.size();
// Device text & bg
m_theme->device_bg.dimensions.stretch(std::abs(xoff*2), m_mic_icon->dimensions.h()*0.9).middle();
m_selector->dimensions.stretch(m_mic_icon->dimensions.w() * 1.75, m_mic_icon->dimensions.h() * 1.75);
for (size_t i = 0; i <= m_devs.size(); ++i) {
const float y = -yoff + i*ystep;
float alpha = 1.0f;
// "Grey out" devices that doesn't fit the selection
if (m_channels[m_selected_column].name == "OUT" && !m_devs[i].out) alpha = 0.5f;
else if (m_channels[m_selected_column].name != "OUT" && !m_devs[i].in) alpha = 0.5f;
m_theme->device_bg.dimensions.center(y);
m_theme->device_bg.draw();
ColorTrans c(Color::alpha(alpha));
m_theme->device.dimensions.middle(-xstep*0.5).center(y);
m_theme->device.draw(i < m_devs.size() ? m_devs[i].desc() : _("- Unassigned -"));
}
// Icons
for (size_t i = 0; i < m_channels.size(); ++i) {
Surface& srf = (i < m_channels.size()-1) ? *m_mic_icon : *m_pdev_icon;
{
ColorTrans c(MicrophoneColor::get(m_channels[i].name));
int pos = m_channels[i].pos;
if (pos == unassigned_id) pos = m_devs.size(); // Transform -1 to the bottom of the list
srf.dimensions.middle(-xoff + xstep*0.5 + i*xstep).center(-yoff+pos*ystep);
srf.draw();
}
// Selection indicator
if (m_selected_column == i)
m_selector->dimensions.middle(srf.dimensions.xc()).center(srf.dimensions.yc());
}
m_selector->draw(); // Position already set in the loop
// Key help
m_theme->comment_bg.dimensions.stretch(1.0, 0.025).middle().screenBottom(-0.054);
m_theme->comment_bg.draw();
m_theme->comment.dimensions.left(-0.48).screenBottom(-0.067);
m_theme->comment.draw(_("Use arrow keys to configure. Hit Enter/Start to save and test or Esc/Select to cancel. Ctrl + R to reset defaults"));
// Additional info
m_theme->comment_bg.dimensions.middle().screenBottom(-0.01);
m_theme->comment_bg.draw();
m_theme->comment.dimensions.left(-0.48).screenBottom(-0.023);
m_theme->comment.draw(_("For advanced device configuration, use command line parameter --audio (use --audiohelp for details)."));
}
void ScreenAudioDevices::load() {
std::string names[] = { "blue", "red", "green", "yellow", "fuchsia", "lightgreen", "purple", "aqua", "OUT" }; //there were 4 colors here
m_channels.assign(std::begin(names), std::end(names));
// Get the currently assigned devices for each channel (FIXME: this is a really stupid algorithm)
for (auto const& d: m_audio.devices()) {
for (auto& c: m_channels) {
if (!d.isChannel(c.name)) continue;
for (size_t i = 0; i < m_devs.size(); ++i) {
if (unsigned(m_devs[i].idx) == d.dev) c.pos = i;
}
}
}
}
bool ScreenAudioDevices::save(bool skip_ui_config) {
if (!skip_ui_config) {
ConfigItem::StringList devconf;
// Loop through the devices and if there is mics/pdev assigned, form a config line
for (auto const& d: m_devs) { // PortAudio devices
std::string mics = "", pdev = "";
for (auto const& c: m_channels) { // blue, red, ..., OUT
if (c.pos == unassigned_id || m_devs[c.pos].idx != d.idx) continue;
if (c.name == "OUT") pdev = "out=2"; // Pdev, only stereo supported
else { // Mic
if (!mics.empty()) mics += ","; // Add separator if needed
mics += c.name; // Append mic color
}
}
if (mics.empty() && pdev.empty()) continue; // Continue looping if device is not used
std::string dev = "dev=\"" + d.flex + "\""; // Use flexible name for more robustness
// Use half duplex I/O even if the same device is used for capture and playback (works better)
if (!mics.empty()) devconf.push_back(dev + " mics=" + mics);
if (!pdev.empty()) devconf.push_back(dev + " " + pdev);
}
config["audio/devices"].sl() = devconf;
}
writeConfig(); // Save the new config
// Give audio a little time to shutdown but then just quit
boost::thread audiokiller(boost::bind(&Audio::close, boost::ref(m_audio)));
if (!audiokiller.timed_join(boost::posix_time::milliseconds(2500)))
Game::getSingletonPtr()->fatalError("Audio hung for some reason.\nPlease restart Performous.");
m_audio.restart(); // Reload audio to take the new settings into use
m_audio.playMusic(findFile("menu.ogg"), true); // Start music again
// Check that all went well
bool ret = verify();
if (!ret) Game::getSingletonPtr()->dialog(_("Some devices failed to open!"));
// Load the new config back for UI
load();
return ret;
}
bool ScreenAudioDevices::verify() {
for (auto const& c: m_channels) {
if (c.pos == unassigned_id) continue; // No checking needed of unassigned channels
// Find the device
for (auto const& d: m_audio.devices()) if (d.isChannel(c.name)) goto found;
return false;
found:;
}
return true;
}
|
8070f32b84e3286be690d1c5da4c3b75cc6eb3a9
|
c27d0b92516043a57fe53f79ef64505541c3b54c
|
/Project1/Project1/Craft.cpp
|
cc6675a3bdee675fcc3206131af03324edebde2e
|
[] |
no_license
|
hhhJG/metallurgy
|
11843f8682465d25c48b4f3c203ee368fa209669
|
d8a188555735248dd86076c03720033000a6f96c
|
refs/heads/master
| 2021-01-10T10:40:59.328301
| 2015-12-19T06:18:56
| 2015-12-19T06:18:56
| 46,651,017
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 7,320
|
cpp
|
Craft.cpp
|
#include "Craft.h"
#include "DataOperation.h"
#include "Solution.h"
#include "PriOperationData.h"
#include "MySqlDeal.h"
#include <string>
#include <list>
#include <vector>
#include <iostream>
#include <math.h>
#include <fstream>
Craft::Craft()
{
gCraftInfor.gGrayStand = 10;
gCraftInfor.gKeepWarm = 1;
gCraftInfor.gMultiMrFileSear = true;
}
Craft::~Craft()
{
}
void Craft::SetCraftDetailMsg()
{
string s;
ifstream mCraftMsgFile(gCraftInfor.gDetailMsgFilePath);
while (getline(mCraftMsgFile, s))
{
if (s.find("工件名称=") != string::npos)
{
gCraftInfor.gCraftName = s.substr(s.find("=") + 1);
}
gCraftDetailMsgLt.push_back(s);
}
mCraftMsgFile.close();
}
list<string>* Craft::GetCraftDetailMsg()
{
return &(this->gCraftDetailMsgLt);
}
void Craft::SetCraftInfor(CraftInfor* tCraftInfor)
{
gCraftInfor.gKey = tCraftInfor->gKey;
gCraftInfor.gProCheckState = tCraftInfor->gProCheckState;
gCraftInfor.gManuCheckState = tCraftInfor->gManuCheckState;
gCraftInfor.gCraftName = tCraftInfor->gCraftName;
gCraftInfor.gBasePath = tCraftInfor->gBasePath;
gCraftInfor.gDetailMsgFilePath = tCraftInfor->gBasePath + "detailMsg.txt";
gCraftInfor.g3DFilePath = tCraftInfor->gBasePath + "3D.txt";
gCraftInfor.gAllPointFilePath = tCraftInfor->gBasePath + "idandpoint.inp";
gCraftInfor.gBadSolidFilePath = tCraftInfor->gBasePath + "quexian.txt";
gCraftInfor.gGrayFilePath = tCraftInfor->gBasePath + "huidu.ntl";
gCraftInfor.gSolutionFilePath = tCraftInfor->gBasePath + "solution.txt";
gCraftInfor.gSTLFilePath = tCraftInfor->gBasePath + "stl.stl";
gCraftInfor.gIDandTimeFilePath = tCraftInfor->gBasePath + "idandtime.txt";
gCraftInfor.gGrayStand = tCraftInfor->gGrayStand;
gCraftInfor.gKeepWarm = tCraftInfor->gKeepWarm;
gCraftInfor.gMrFileIndex = tCraftInfor->gMrFileIndex;
gCraftInfor.gMultiMrFileSear = tCraftInfor->gMultiMrFileSear;
}
bool Craft::UpdateCheckState()
{
try
{
MySqlDeal mMySqlDealObj;
mMySqlDealObj.UpdateState(&this->gCraftInfor);
return true;
}
catch (exception e)
{
cout << e.what() << endl;
return false;
}
}
CraftInfor* Craft::GetCraftInfor()
{
return &gCraftInfor;
}
void Craft::SetAllPossAnswers()
{
gAllPossAnswers.clear();
string s;
ifstream mSoulutionFile(gCraftInfor.gSolutionFilePath.c_str());
double x, y, z;
double mMr;
int mAnswerIndex = 0;
vector<Riser> mRiserVec;
gAllPossAnswers.push_back(mRiserVec);
while (getline(mSoulutionFile, s))
{
if(s.find("#") == string::npos)
{
Riser mRiser;
x = atof(s.substr(0, s.find_first_of(",")).c_str());
y = atof(s.substr(s.find_first_of(",") + 1, s.find_last_of(",")).c_str());
z = atof(s.substr(s.find_last_of(",") + 1).c_str());
Point mCenter(x, y, z);
mRiser.gCenter = mCenter;
getline(mSoulutionFile, s);
mRiser.gIDRemark = s;
getline(mSoulutionFile, s);
mMr = atof(s.c_str());
mRiser.gRadius = mMr;
gAllPossAnswers.at(mAnswerIndex).push_back(mRiser);
}
else
{
mAnswerIndex++;
vector<Riser> mOneRiserVec;
gAllPossAnswers.push_back(mOneRiserVec);
}
}
gAllPossAnswers.erase(gAllPossAnswers.begin() + mAnswerIndex);
mSoulutionFile.close();
}
vector<vector<Riser>>* Craft::GetAllPossAnswers()
{
return &gAllPossAnswers;
}
bool Craft::Execute()
{
try
{
string mFilePointsStr = gCraftInfor.gAllPointFilePath;
string mThreeDFileStr = gCraftInfor.g3DFilePath;
string mFileHuiStr = gCraftInfor.gGrayFilePath;
string mFileIDTimeStr = gCraftInfor.gIDandTimeFilePath;
string mFileSolidsStr = gCraftInfor.gBadSolidFilePath;
string mFileSolutionStr = gCraftInfor.gSolutionFilePath;
int mStandGray = gCraftInfor.gGrayStand;
int mKeepWarm = gCraftInfor.gKeepWarm;
int mMrFileIndex = gCraftInfor.gMrFileIndex;
bool mMultiMrSearch = gCraftInfor.gMultiMrFileSear;
//对数据进行预处理,以便达到生成期望文件
PriOperationData mPriOperationData(mKeepWarm, mStandGray);
vector<Point> mAllPointsOfSolids;
mPriOperationData.AllPointsOfSolids(mFileHuiStr, mFilePointsStr, mFileIDTimeStr);
list<list<Point>> mSplitPointsLtLt;
mPriOperationData.DetachSolids();
mPriOperationData.WriteToFile(mFileSolidsStr);
Point mTopSidePoint;//主要为了获取z值,确定打冒口的平面。z值的单位是mm
mPriOperationData.GetTopSidePoint(&mTopSidePoint);
//输出3D文件,供神经网络使用
mPriOperationData.ThreeDDeal(mFilePointsStr);
mPriOperationData.ThreeDWriteToFile(mThreeDFileStr);
//提供缺陷文件
DataOperation mDataObj;
mDataObj.LoadFile(mFileSolidsStr.c_str());
Solution mSolution(mDataObj.GetAllSolidVecP());
mSolution.SetTopSidePoint(&mTopSidePoint);
mSolution.SetSerchCoindition(mMrFileIndex, mMultiMrSearch);
//聚类半径R
mSolution.Method();
mSolution.WriteSolutionToFile(mFileSolutionStr);
MySqlDeal mMySqlDealObj;
gCraftInfor.gBasePath.replace(gCraftInfor.gBasePath.find_first_of("\\"), 1, "\\\\");
gCraftInfor.gBasePath.replace(gCraftInfor.gBasePath.find_last_of("\\"), 1, "\\\\");
cout << gCraftInfor.gBasePath << endl;
mMySqlDealObj.InsertCraft(&gCraftInfor);
SetAllPossAnswers();
return true;
}
catch (exception e)
{
cout << e.what() << endl;
return false;
}
}
void Craft::DisplayInfor()
{
cout << "3D文件路径:" << gCraftInfor.g3DFilePath << endl;
cout << "坐标文件路径:" << gCraftInfor.gAllPointFilePath << endl;
cout << "标准缺陷文件路径:" << gCraftInfor.gBadSolidFilePath << endl;
cout << "工艺详细信息文件路径:" << gCraftInfor.gDetailMsgFilePath << endl;
cout << "灰度文件路径:" << gCraftInfor.gGrayFilePath << endl;
cout << "凝固时间文件路径:" << gCraftInfor.gIDandTimeFilePath << endl;
cout << "STL文件路径:" << gCraftInfor.gSTLFilePath << endl;
cout << "解决方案文件路径:" << gCraftInfor.gSolutionFilePath << endl;
cout << "程序检验状态:" << gCraftInfor.gProCheckState << endl;
cout << "生产检验状态:" << gCraftInfor.gManuCheckState << endl;
cout << "Key:" << gCraftInfor.gKey << endl;
cout << "Mr文件编号:" << gCraftInfor.gMrFileIndex << endl;
cout << "是否保温冒口(1-是,0-否):" << gCraftInfor.gKeepWarm << endl;
cout << "灰度标准:" << gCraftInfor.gGrayStand << endl;
cout << "工艺名称:" << gCraftInfor.gCraftName << endl;
list<string>::iterator mCraftDetailMsgLtIter = gCraftDetailMsgLt.begin();
cout << "工艺详细信息:" << endl;
while (mCraftDetailMsgLtIter != gCraftDetailMsgLt.end())
{
cout << *mCraftDetailMsgLtIter << endl;
mCraftDetailMsgLtIter++;
}
int m = 1;
vector<vector<Riser>>::iterator mAllPossAnswersIter = gAllPossAnswers.begin();
while (mAllPossAnswersIter != gAllPossAnswers.end())
{
vector<Riser>& mOneSolutionVec = *mAllPossAnswersIter;
vector<Riser>::iterator mOneSolutionVecIter = mOneSolutionVec.begin();
cout << "第" << m++ << "个结果:格式为 中心-漏洞集合-模数(mm)" << endl;
while (mOneSolutionVecIter != mOneSolutionVec.end())
{
Riser& mOneRiser = *mOneSolutionVecIter;
cout << "(" << mOneRiser.gCenter.GetX() << " , " << mOneRiser.gCenter.GetY() << " , " << mOneRiser.gCenter.GetZ() <<")" << endl;
cout << mOneRiser.gIDRemark << endl;
cout << mOneRiser.gRadius << endl;
mOneSolutionVecIter++;
}
mAllPossAnswersIter++;
cout << endl << endl;
}
}
|
99e35dee6553a8ea000f02f93924a844da0da9dc
|
1bef9dbb11d31415d5e86c440f7dcbd79bbca363
|
/IR_Switch_4_Relays_on_PCB_001a.ino
|
7842481b3c9d052b73d13a68dc37b3b4666ce955
|
[] |
no_license
|
ErneyBob/4-relays-IR-control
|
6c6dbc48a63ab9a4938625a3a89c5ac4a693bb50
|
ff1c44f914b2211b685de6f9601512c92b1233d0
|
refs/heads/master
| 2020-06-15T23:11:10.443354
| 2019-07-05T13:54:25
| 2019-07-05T13:54:25
| 195,417,115
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,836
|
ino
|
IR_Switch_4_Relays_on_PCB_001a.ino
|
// P02 Infrared remote control 4 relays on PCB board
#include <IRremote.h>
IRrecv irrecv(9);
decode_results results;
uint32_t val, irkey[17] =
{
16580863, 16613503, 16597183, 16589023, 16621663, 16605343, 16584943, 16617583, 16601263,
16593103, 16625743, 16609423, 16615543, 16591063, 16623703, 16607383, 16619623
};
int16_t TimeStored4Relay[6], PresetPot, CountDownTimer;
const uint16_t LengthOnPeriod[5] = {100, 1200, 6000, 24000, 60000};
uint8_t SelectOnPeriod, DeviceSelect, relay[6];
void setup()
{
for (int8_t f = 10; f < 14; f++)
{
pinMode(f, OUTPUT); digitalWrite(f, 0);
}
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
PresetPot = analogRead(A0);
PresetPot = map(PresetPot, 0, 1023, 1, 9);
for (int8_t f = 0; f < PresetPot; f++)
{
flash();
delay (200);
}
}
void loop()
{
if (irrecv.decode(&results))
{
val = (results.value);
if (val == irkey[PresetPot - 1] && DeviceSelect == 1)
{
Serial.print ("==select==");
val = 0;
DeviceSelect = 2;
CountDownTimer = 1000;
flash(); flash(); flash();
}
if (DeviceSelect == 1) DeviceSelect = 0;
if (val == irkey[9] && DeviceSelect == 0)
{
Serial.print ("==*==");
DeviceSelect = 1;
flash();
}
if (DeviceSelect == 2 && CountDownTimer > 1)
{
for (int8_t g = 0; g < 4; g++)
{
if (val == irkey[g])
{
relay[g] = 1 - relay[g];
digitalWrite(g + 10, relay[g]);
flash();
}
if (val == irkey[g + 4])
{
TimeStored4Relay[g] = LengthOnPeriod[SelectOnPeriod];
relay[g] = 1;
digitalWrite(g + 10, 1);
flash();
}
}
if (val == irkey[8])
{
for (int8_t f = 10; f < 14; f++)
{
TimeStored4Relay[f - 10] = 0;
relay[f - 10] = 1;
digitalWrite(f, 1);
delay (100);
};
flash();
}
if (val == irkey[10])
{
for (int8_t f = 10; f < 14; f++)
{
TimeStored4Relay[f - 10] = 0;
relay[f - 10] = 0;
digitalWrite(f, 0);
delay (100);
};
flash();
}
if (val == irkey[11])
{
DeviceSelect = 0;
flash();
}
if (val == irkey[14]) DisplayOnPeriod();
if (val == irkey[12])
{
SelectOnPeriod++;
if (SelectOnPeriod == 5) SelectOnPeriod = 0;
DisplayOnPeriod();
}
if (val == irkey[16])
{
SelectOnPeriod--;
if (SelectOnPeriod == -1) SelectOnPeriod = 4;
DisplayOnPeriod();
}
}
Serial.print(val); Serial.print(" SelectOnPeriod= "); Serial.println(SelectOnPeriod);
irrecv.resume(); // Receive the next value
}
for (int8_t g = 0; g < 4; g++)
{
TimeStored4Relay[g] = TimeStored4Relay[g] - (TimeStored4Relay[g] > 1);
if (TimeStored4Relay[g] == 2)
{
digitalWrite(g + 10, 0);
relay[g] = 0;
}
}
if (CountDownTimer > 0) CountDownTimer--;
if (CountDownTimer == 2) DeviceSelect = 0;
delay(100);
}
void flash()
{
delay (125);
digitalWrite(8, 0);
delay (125);
digitalWrite(8, 1);
Serial.print("flash===");
}
void DisplayOnPeriod()
{
digitalWrite(8, LOW);
delay (1000);
for (int8_t f = 1; f < SelectOnPeriod + 2; f++)
{
delay(250);
digitalWrite(8, HIGH);
delay (125);
digitalWrite(8, LOW);
}
delay(1000);
digitalWrite(8, HIGH);
}
//unsigned long irkey[17] = {16738455,16750695,16756815,16724175,16718055,16743045,16716015,16726215,16734885,16728765,16730805,16732845,16736925,16720605,16712445,16761405,16754775};
|
041e5ebc0cbb7736a714a015c4712cafda24c2c3
|
b457e46523b344a1d3863bd28c1b742729765510
|
/finddup.cpp
|
7a85a958973afb93e6d0bea021989db5f04700a1
|
[] |
no_license
|
Novicei/pfa
|
a31068becb1299309198d51b863d2bbd91d10a7b
|
5505a0c92c163b3a561544a169809f3bf20b332a
|
refs/heads/master
| 2023-08-14T23:51:24.730004
| 2021-09-24T07:54:13
| 2021-09-24T07:54:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,507
|
cpp
|
finddup.cpp
|
// cl /EHsc /O2 /openmp matcher.cpp Landmark.cpp Database.cpp lib/WavReader.cpp lib/Timing.cpp lib/ReadAudio.cpp lib/BmpReader.cpp lib/Signal.cpp lib/utils.cpp lib/Sound.cpp .\PeakFinder.cpp .\PeakFinderDejavu.cpp Analyzer.cpp
#include <stdio.h>
#include <cstdint>
#include <algorithm>
#include <string>
#include <stdexcept>
#include <fstream>
#include <sstream>
#include <omp.h>
#include <mpi.h>
#include "lib/Timing.hpp"
#include "Landmark.hpp"
#include "lib/utils.hpp"
#include "Database.hpp"
#include "PeakFinderDejavu.hpp"
int processQuery(
std::string name,
LandmarkBuilder &builder,
const Database &db,
int songid,
int blacklist,
std::ostream &fout
) {
Timing tm;
int oneread = 10000;
std::vector<Peak> peaks(oneread);
FILE *fin = fopen(name.c_str(), "rb");
if (fin == NULL) {
return -1;
}
int nread;
int total = 0;
while ((nread = fread(&peaks[total], sizeof(Peak), oneread, fin)) > 0) {
total += nread;
peaks.resize(total + oneread);
}
peaks.resize(total);
int max_t = 0;
for (Peak peak : peaks) {
if (peak.time > max_t) max_t = peak.time;
}
int nsongs = db.songList.size();
int ptr = 0;
std::vector<match_t> scores(nsongs);
for (int t = 0; t < max_t; t += 8000 * 10 / 512) {
std::vector<Peak> sub_peaks;
while (ptr < peaks.size() && peaks[ptr].time < t + 8000 * 10 / 512) {
sub_peaks.push_back(peaks[ptr]);
ptr++;
}
std::vector<Landmark> lms = builder.peaks_to_landmarks(sub_peaks);
db.query_landmarks(lms, scores.data());
std::vector<int> song_rank;
for (int i = 0; i < nsongs; i++) {
if (i != blacklist) song_rank.push_back(i);
}
std::sort(song_rank.begin(), song_rank.end(), [&](int a, int b){
return scores[a].score > scores[b].score;
});
fout << songid << ',' << t;
for (int rank = 0; rank < 10 && rank < song_rank.size(); rank++) {
int which = song_rank[rank];
fout << ',' << which << ',' << scores[which].score << ',' << scores[which].offset;
}
fout << '\n';
}
fout.flush();
return 0;
}
int main(int argc, char *argv[]) {
int nprocs, pid;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &pid);
if (argc < 4) {
if (pid == 0)
printf("Usage: ./finddup <peak file list> <database dir> <result file>\n");
return 1;
}
Timing timing;
std::ifstream flist(argv[1]);
if (!flist) {
printf("cannot read peak list!\n");
return 1;
}
char namebuf[100];
sprintf(namebuf, "finddup-pid-%d", pid);
init_logger(namebuf);
std::string line;
std::vector<std::string> queryList;
while (std::getline(flist, line)) {
queryList.push_back(line);
}
flist.close();
LOG_DEBUG("read peak list %.3fs", timing.getRunTime() * 0.001);
Database db;
if (db.load(argv[2])) {
LOG_FATAL("cannot load database");
return 1;
}
int nSongs = db.songList.size();
std::stringstream ss;
ss << argv[3] << "-pid-" << pid;
std::ofstream fout(ss.str());
if (!fout) {
LOG_FATAL("cannot write result!");
return 1;
}
LOG_DEBUG("load database %.3fs", timing.getRunTime() * 0.001);
LandmarkBuilder builder;
for (int i = pid; i < queryList.size(); i += nprocs) {
std::string name = queryList[i];
LOG_INFO("File: %s", name.c_str());
processQuery(name, builder, db, i, i, fout);
}
fout.close();
LOG_INFO("Total time: %.3fs", timing.getRunTime() * 0.001);
MPI_Finalize();
return 0;
}
|
96862f070e09ab56c53e977a770b33af83ea0f63
|
c301b797d4d8e3dcc967648da460ab07bcbb66ab
|
/Source/Bomb.h
|
1051b338239a9b173826eb9784d9831afaf0b466
|
[] |
no_license
|
guillaumep-nvizzio/DiceInvaders
|
feb179868c34b409470495af9d59fb61f094cc56
|
ad99dfcfab4459e7ca899d9e9b0b8db673eccaa5
|
refs/heads/master
| 2020-12-02T18:06:47.747126
| 2018-11-19T14:26:02
| 2018-11-19T14:27:21
| 96,476,415
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 540
|
h
|
Bomb.h
|
#ifndef __BOMB_H__
#define __BOMB_H__
#include "resource.h"
#include "DiceInvaders.h"
#include "GameObject.h"
/**
* Bomb: The projectile from aliens
*
**/
class Bomb : public GameObject
{
public:
Bomb(class Game* the_game);
~Bomb();
virtual bool Create(int pos_x, int pos_y);
virtual void Destroy();
virtual bool Update(float delta_time);
void Move();
void SetExploded() { exploded = true; }
bool IsExploded() { return exploded; }
private:
bool exploded;
static constexpr unsigned kSpeedY = 6;
};
#endif //__BOMB_H__
|
dcc82f08fe4b90852bc34fd1b7a9d344774dc9a3
|
d3390faaf4a661412b6d173b8964566d97fc81a8
|
/addons/taser/configs/CfgAmmo.hpp
|
10c2fafdae5a9880f2f00e611314881d53c0dacb
|
[
"MIT"
] |
permissive
|
TacticalBaconDevs/TBMod
|
ce6b6dcdbc887fa642db93ce63433ba14e94f88c
|
acc54a6014758f2fcff7d305a816b3cb95c4180b
|
refs/heads/master
| 2022-11-03T10:14:12.769187
| 2022-10-28T14:01:56
| 2022-10-28T14:01:56
| 142,904,755
| 11
| 2
|
MIT
| 2022-10-28T14:01:58
| 2018-07-30T17:05:47
|
C++
|
UTF-8
|
C++
| false
| false
| 254
|
hpp
|
CfgAmmo.hpp
|
/*
Part of the TBMod ( https://github.com/TacticalBaconDevs/TBMod )
Developed by http://tacticalbacon.de
Author: Eric Ruhland
*/
class CfgAmmo
{
class B_45ACP_Ball;
class TB_ammo_taser : B_45ACP_Ball
{
hit = 0;
};
};
|
090e161d3f80207fbe11e72700d8789de3b4e22c
|
e3322a1a988228884de6893c5806bf32f5ae921b
|
/Threading/Threading/Threading.cpp
|
0c7578a77b6e9c51117f9ff02cbfffac64faa1ab
|
[] |
no_license
|
Cornelius27584046/ITRW316-Projects
|
9720db3baa753a3dc09478a9ba2a1bdb5c807be0
|
67b0c30cd2e1737461361629cdc517438f85d634
|
refs/heads/master
| 2020-05-28T00:41:42.851958
| 2019-05-27T12:09:59
| 2019-05-27T12:09:59
| 188,834,528
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 618
|
cpp
|
Threading.cpp
|
// Threading.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <thread>
#include <iostream>
#include <chrono>
using namespace std;
void t1()
{
for (int i = 1; i <= 10; i++)
{
cout << "A" << i << endl;
}
}
void t2()
{
for (int i = 1; i <= 10; i++)
{
cout << "B" << i << endl;
}
}
void threadless()
{
for (int i = 1; i <= 10; i++)
{
cout << i << endl;
}
}
int main()
{
std::thread thread1(t1);
std::thread thread2(t2);
threadless();
thread2.join();
thread1.join();
int j = 0;
cin >> j;
return 0;
}
|
4108cba6e18880a70db9f49be757c80cd3474f84
|
a81c4b073e27e54041e9e86485b415fdf45d7960
|
/src/loader/functionloader.h
|
a721b5bf18e1c717625c3b88b28159cf7943a0a6
|
[
"MIT"
] |
permissive
|
svenslaggare/StackJIT
|
eaf2905ee8dad95b70769b64353a0069c8be6ee9
|
7702bd016e4daa9f6999d0e26120e1e7555cc45c
|
refs/heads/master
| 2020-04-06T06:20:02.888369
| 2017-10-15T19:48:50
| 2017-10-15T19:48:50
| 21,389,165
| 21
| 5
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,366
|
h
|
functionloader.h
|
#pragma once
#include <string>
#include <vector>
#include "loader.h"
namespace stackjit {
class VMState;
class FunctionDefinition;
class ManagedFunction;
class ImageContainer;
////Represents a function loader
//namespace FunctionLoader {
// //Generates a definition for the given function
// void generateDefinition(VMState& vmState,
// const Loader::Function& function,
// FunctionDefinition& definition);
// //Loads the given external function
// void loadExternal(VMState& vmState,
// const Loader::Function& function,
// FunctionDefinition& loadedFunction);
// //Loads the given managed function
// ManagedFunction* loadManaged(VMState& vmState,
// const Loader::Function& function,
// const FunctionDefinition& functionDefinition);
//}
//Represents a function loader
class FunctionLoader {
private:
VMState& mVMState;
public:
FunctionLoader(VMState& vmState);
//Generates a definition for the given function
void generateDefinition(const Loader::Function& function, FunctionDefinition& definition);
//Loads the given external function
void loadExternal(const Loader::Function& function, FunctionDefinition& loadedFunction);
//Loads the given managed function
ManagedFunction* loadManaged(const Loader::Function& function,const FunctionDefinition& functionDefinition);
};
}
|
4d984499df619055e9c602b5ed818398585fe926
|
01c2c11843b6adc0e54c6403ac8de41013bfdacc
|
/include/block-maker/Physic/FixtureFactory/IBlock.hpp
|
545d25f6788ccf767e48ffe8a930fca687e0f95a
|
[] |
no_license
|
adrian19lb/block-maker
|
b7271cef3e1bc919e9b788c2d275bb60b505d2fd
|
97a7990fc8f02c8c3a8f3a869892b01dc697da60
|
refs/heads/master
| 2020-08-31T07:53:48.864229
| 2019-10-31T12:55:25
| 2019-10-31T12:55:25
| 218,640,943
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 458
|
hpp
|
IBlock.hpp
|
#ifndef IBLOCK_HPP_INCLUDED
#define IBLOCK_HPP_INCLUDED
#include <block-maker/Physic/FixtureFactory/FileFixtureFactory.hpp>
#include <block-maker/Loader/Xml/Xml.hpp>
#include <block-maker/Resource/Binder/XmlResource.hpp>
namespace bm::physic {
class IBlock : public FileFixtureFactory<std::vector, float> {
public:
IBlock(ShapeFactoryPtr shapeFactory, Fixture fixture);
~IBlock() = default;
};
}
#endif // IBLOCK_HPP_INCLUDED
|
a3079ef89eff6418a5277aae61e8f85d697d6b17
|
e5b98edd817712e1dbcabd927cc1fee62c664fd7
|
/Classes/message/Decoding/task/RequestTaskList.cpp
|
ef675f55dc4236891ec701f21700874a16e2a908
|
[] |
no_license
|
yuangu/project
|
1a49092221e502bd5f070d7de634e4415c6a2314
|
cc0b354aaa994c0ee2d20d1e3d74da492063945f
|
refs/heads/master
| 2020-05-02T20:09:06.234554
| 2018-12-18T01:56:36
| 2018-12-18T01:56:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 350
|
cpp
|
RequestTaskList.cpp
|
//
// RequestTaskList.cpp
// FightPass
//
// Created by zhangxiaobin on 15/9/28.
//
//
#include "RequestTaskList.h"
RequestTaskList::RequestTaskList()
{
}
RequestTaskList::~RequestTaskList()
{
}
ByteStream* RequestTaskList::encodingData()
{
MessageSendI::encodingData(SCENSE_CLIENT_TASK_TaskCommonPageReq);
SetMessageLength();
}
|
4b9a713f9c2f65f18c5e098b2451719fa9d9ffe5
|
065852abb89ebd78660b784030ea2fa175ba00d7
|
/Functions/RoundingTest.cpp
|
4045ee6419a61d9a15a869d7c84d65a3067f9714
|
[] |
no_license
|
Raj6713/BasicCpp
|
ed2c7858c0af31807cef0937f9ff3a964ad08264
|
47ada849826faf08b4e8668deb6cafbfa0e9c643
|
refs/heads/master
| 2021-07-05T13:09:52.729329
| 2017-09-29T21:48:11
| 2017-09-29T21:48:11
| 103,849,456
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 910
|
cpp
|
RoundingTest.cpp
|
//This class will show the working of the rounding class
#include<iostream>
using namespace std;
#include "Rounding.h"
int main()
{
Rounding rp;
float num;
int choice;
char ch;
do
{
cout<<"Enter number: ";
cin>>num;
rp.setNumber(num);
cout<<"1>To Integer"<<endl;
cout<<"2>To tenth"<<endl;
cout<<"3>To hundredth"<<endl;
cout<<"4>To thousandth"<<endl;
cin>>choice;
switch(choice)
{
case 1:
rp.RoundToInteger();
rp.displayMessage();
break;
case 2:
rp.RoundToTen();
rp.displayMessage();
break;
case 3:
rp.RoundToHundred();
rp.displayMessage();
break;
case 4:
rp.RoundToThousand();
rp.displayMessage();
break;
default:
cerr<<"Wrong choice entered"<<endl;
}
cout<<"Enter Y or y for repeat: ";
cin>>ch;
}while(ch=='Y' || ch=='y');
}
|
dda3427b20f508d3351789451f718fee1e3d8729
|
c43b0d1e041d004d1fa8e1469f57b62d4d4bea88
|
/garnet/lib/vulkan/tests/vkprimer/common/vulkan_shader.cc
|
dbd5f7054b01c7b5968786772d4449da0ab57b56
|
[
"BSD-3-Clause"
] |
permissive
|
ZVNexus/fuchsia
|
75122894e09c79f26af828d6132202796febf3f3
|
c5610ad15208208c98693618a79c705af935270c
|
refs/heads/master
| 2023-01-12T10:48:06.597690
| 2019-07-04T05:09:11
| 2019-07-04T05:09:11
| 195,169,207
| 0
| 0
|
BSD-3-Clause
| 2023-01-05T20:35:36
| 2019-07-04T04:34:33
|
C++
|
UTF-8
|
C++
| false
| false
| 1,305
|
cc
|
vulkan_shader.cc
|
// Copyright 2018 The Fuchsia 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 "vulkan_shader.h"
#include <fstream>
#include "utils.h"
bool VulkanShader::ReadFile(const std::string& file_name,
std::vector<char>* buffer) {
std::ifstream file(file_name, std::ios::ate | std::ios::binary);
if (!file.is_open()) {
RTN_MSG(false, "Failed to open file \"%s\"\n", file_name.c_str());
}
size_t file_size = (size_t)file.tellg();
buffer->resize(file_size);
file.seekg(0);
file.read(buffer->data(), file_size);
file.close();
return true;
}
bool VulkanShader::CreateShaderModule(VkDevice device,
const std::vector<char>& code,
VkShaderModule* shader_module) {
VkShaderModuleCreateInfo create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
create_info.codeSize = code.size();
create_info.pCode = reinterpret_cast<const uint32_t*>(code.data());
auto err = vkCreateShaderModule(device, &create_info, nullptr, shader_module);
if (VK_SUCCESS != err) {
RTN_MSG(false, "VK Error: 0x%x - Failed to create shader module.\n", err);
}
return true;
}
|
203dfacc12953d30c63f712bf1c427ddaf36bc4f
|
2056302cc35c8d73eaa1518d49715ef1695b9162
|
/interfaces.h
|
f2d518b3d04b0a8d9a202384b32e9fd5c8448a54
|
[] |
no_license
|
adamb924/AcousticWorkspace
|
e3624b5703eba5ee66327f70d6d8fc8e1464a36f
|
99dc981e9a34162a9795f8ae9434dc668ea35403
|
refs/heads/master
| 2020-03-25T06:32:44.263138
| 2014-07-24T21:09:42
| 2014-07-24T21:09:42
| 13,478,639
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,647
|
h
|
interfaces.h
|
#ifndef INTERFACES_H
#define INTERFACES_H
#include <QtPlugin>
#include <QList>
#include <QStringList>
#include <QVariant>
#include <qwt_series_data.h>
class WaveformData;
class SpectrogramData;
/*! \class AbstractMeasurement
\ingroup Plugin
\brief Base class for other abstract measurement classes
This class provides the pure virtual function \a fn settings, which is used by all measurement plugins.
*/
class AbstractMeasurement: public QObject
{
Q_OBJECT
public:
//! \brief Display the settings dialog box for measurement \a i
virtual void settings(int i) = 0;
};
/*! \class AbstractWaveform2WaveformMeasure
\ingroup Plugin
\brief Base class for other plugins that create new waveforms from old waveforms
*/
class AbstractWaveform2WaveformMeasure : public AbstractMeasurement
{
Q_OBJECT
public:
AbstractWaveform2WaveformMeasure() {}
virtual ~AbstractWaveform2WaveformMeasure() {}
virtual AbstractWaveform2WaveformMeasure* copy () const = 0;
//! \brief Return the name of the plugin library
virtual QString name() const = 0;
//! \brief Return the name the plugin should have for use in scripting
virtual QString scriptName() const = 0;
//! \brief Return the list of names of the measures defined by the plugin
virtual QStringList names() const = 0;
//! \brief Display the settings dialog box for measurement \a i
virtual void settings(int i) = 0;
//! \brief Change the setting with label \a label to \a value
virtual void setParameter(QString label, QVariant value) = 0;
//! \brief Return a list of pointers to WaveformData objects calculated by measurement \a i, from \a data
virtual void calculate(int i, WaveformData *data) = 0;
//! \brief A convenience overload to allow measures to be called by name
virtual void calculate(QString name, WaveformData *data) = 0;
signals:
void waveformCreated(WaveformData *data);
};
/*! \class AbstractWaveform2SpectrogramMeasure
\ingroup Plugin
\brief Base class for other plugins that create spectrograms from waveforms
*/
class AbstractWaveform2SpectrogramMeasure : public AbstractMeasurement
{
Q_OBJECT
public:
AbstractWaveform2SpectrogramMeasure() {}
virtual ~AbstractWaveform2SpectrogramMeasure() {}
virtual AbstractWaveform2SpectrogramMeasure* copy () const = 0;
public slots:
//! \brief Return the name of the plugin library
virtual QString name() const = 0;
//! \brief Return the name the plugin should have for use in scripting
virtual QString scriptName() const = 0;
//! \brief Return the list of names of the measures defined by the plugin
virtual QStringList names() const = 0;
//! \brief Display the settings dialog box for measurement \a i
virtual void settings(int i) = 0;
//! \brief Change the setting with label \a label to \a value
virtual void setParameter(QString label, QVariant value) = 0;
//! \brief Return a list of pointers to SpectrogramData objects calculated by measurement \a i, from \a data
virtual void calculate(int i, WaveformData *data) = 0;
//! \brief A convenience overload to allow measures to be called by name
virtual void calculate(QString name, WaveformData *data) = 0;
signals:
void spectrogramCreated(SpectrogramData *data);
};
/*! \class AbstractSpectrogram2WaveformMeasure
\ingroup Plugin
\brief Base class for other plugins that create waveforms from spectrograms
*/
class AbstractSpectrogram2WaveformMeasure : public AbstractMeasurement
{
Q_OBJECT
public:
AbstractSpectrogram2WaveformMeasure() {}
virtual ~AbstractSpectrogram2WaveformMeasure() {}
virtual AbstractSpectrogram2WaveformMeasure* copy () const = 0;
//! \brief Return the name of the plugin library
virtual QString name() const = 0;
//! \brief Return the name the plugin should have for use in scripting
virtual QString scriptName() const = 0;
//! \brief Return the list of names of the measures defined by the plugin
virtual QStringList names() const = 0;
//! \brief Display the settings dialog box for measurement \a i
virtual void settings(int i) = 0;
//! \brief Change the setting with label \a label to \a value
virtual void setParameter(QString label, QVariant value) = 0;
//! \brief Return a list of pointers to WaveformData objects calculated by measurement \a i, from \a data
virtual void calculate(int i, SpectrogramData *data) = 0;
//! \brief A convenience overload to allow measures to be called by name
virtual void calculate(QString name, SpectrogramData *data) = 0;
signals:
void waveformCreated(WaveformData *data);
};
/*! \class AbstractSpectrogram2SpectrogramMeasure
\ingroup Plugin
\brief Base class for other plugins that create new spectrograms from old spectrograms
*/
class AbstractSpectrogram2SpectrogramMeasure : public AbstractMeasurement
{
Q_OBJECT
public:
AbstractSpectrogram2SpectrogramMeasure() {}
virtual ~AbstractSpectrogram2SpectrogramMeasure() {}
virtual AbstractSpectrogram2SpectrogramMeasure* copy () const = 0;
//! \brief Return the name of the plugin library
virtual QString name() const = 0;
//! \brief Return the name the plugin should have for use in scripting
virtual QString scriptName() const = 0;
//! \brief Return the list of names of the measures defined by the plugin
virtual QStringList names() const = 0;
//! \brief Display the settings dialog box for measurement \a i
virtual void settings(int i) = 0;
//! \brief Change the setting with label \a label to \a value
virtual void setParameter(QString label, QVariant value) = 0;
//! \brief Return a list of pointers to SpectrogramData objects calculated by measurement \a i, from \a data
virtual void calculate(int i, SpectrogramData *data) = 0;
//! \brief A convenience overload to allow measures to be called by name
virtual void calculate(QString name, SpectrogramData *data) = 0;
signals:
void spectrogramCreated(SpectrogramData *data);
};
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(AbstractWaveform2WaveformMeasure,"acousticworkspace.qt.abstractwaveform2waveformmeasure/1.0")
Q_DECLARE_INTERFACE(AbstractWaveform2SpectrogramMeasure,"acousticworkspace.qt.abstractwaveform2spectrogrammeasure/1.0")
Q_DECLARE_INTERFACE(AbstractSpectrogram2WaveformMeasure,"acousticworkspace.qt.abstractspectrogram2waveformmeasure/1.0")
Q_DECLARE_INTERFACE(AbstractSpectrogram2SpectrogramMeasure,"acousticworkspace.qt.abstractspectrogram2spectrogrammeasure/1.0")
QT_END_NAMESPACE
#endif // INTERFACES_H
|
817a95575923ce36bb9a1b69812e9f32e9658b01
|
eb1315ed71378aef035e7f20f14703aa7c0c85fd
|
/LiveRange.h
|
ab2dc611dffa869c606655fd141df1a3db0f50c9
|
[] |
no_license
|
yuzhenyang/llc-olive
|
8036712eb797e256a8a4897ebdba5a717c668430
|
48d2a575a6d7913604e7bde5d51085443d8b1982
|
refs/heads/master
| 2021-01-19T04:33:14.322166
| 2016-04-13T00:28:31
| 2016-04-13T00:28:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,346
|
h
|
LiveRange.h
|
#ifndef LIVERANGE_H
#define LIVERANGE_H
#include <string>
#include <vector>
#include <climits>
#include "assert.h"
class LiveRange {
public:
// these used by simple register allocator
int startpoint;
int endpoint;
std::vector<int> innerpoints;
// these below used by register allocator
int pos; // register_id or stack_pos
bool is_in_register = false;
bool is_in_stack = false;
void set_in_register (int pos) {
this->pos = pos;
this->is_in_register = true;
this->is_in_stack = false;
}
void set_in_stack (int pos) {
this->pos = pos;
this->is_in_register = false;
this->is_in_stack = true;
}
bool isInRange (int pos) {
return startpoint <= pos && pos <= endpoint;
}
LiveRange(int start) {
startpoint = start;
endpoint = -1;
innerpoints.push_back(start);
}
LiveRange(int start, int stop) {
startpoint = start;
endpoint = stop;
innerpoints.push_back(start);
}
void AddInnerPoint(int p) {
innerpoints.push_back(p);
if (p > endpoint) endpoint = p;
}
};
class Interval {
public:
std::vector<LiveRange> liveranges; // increasing order of startpoint
std::vector<LiveRange> holes; // increasing order of startpoint
int register_id; //
std::string location; // location information
Interval (int start, int stop) {
LiveRange lr (start, stop);
liveranges.push_back(lr);
}
void addRange(int start, int end) {
// 1. look for those live ranges where start and end reside
int start_lr_idx = -1, end_lr_idx = -2;
int num_live_ranges = liveranges.size();
for (int i = 0; i < num_live_ranges; i++)
if (liveranges[i].startpoint <= start && start <= liveranges[i].endpoint)
start_lr_idx = i;
for (int i = 0; i < num_live_ranges; i++)
if (liveranges[i].startpoint <= end && end <= liveranges[i].endpoint)
end_lr_idx = i;
#if 0
if (start == 0 && end == 14) {
std::cout << start_lr_idx << ":::" << end_lr_idx << std::endl;
}
#endif
// get merged
if (start_lr_idx == end_lr_idx) return ;
// 2. compute updated startpoint and endpoint
int updated_startpoint, updated_endpoint;
if (start_lr_idx < 0) {
start_lr_idx = 0;
updated_startpoint = start;
} else updated_startpoint = liveranges[start_lr_idx].startpoint;
if (end_lr_idx < 0) {
updated_endpoint = end;
} else updated_endpoint = liveranges[end_lr_idx].endpoint;
// 3. look for all live ranges between [updated_start, updated_end]
int max_include_idx = INT_MIN, min_include_idx = INT_MAX;
bool include_found = false; // found liverange included in [start, end]
for (int i = 0; i < num_live_ranges; i++)
if (updated_startpoint <= liveranges[i].startpoint &&
liveranges[i].endpoint <= updated_endpoint) {
if (!include_found) include_found = !include_found;
max_include_idx = std::max(max_include_idx, i);
min_include_idx = std::min(min_include_idx, i);
}
// 4. modify liveranges
auto begin_iter = liveranges.begin();
if (include_found)
liveranges.erase(begin_iter+min_include_idx, begin_iter+max_include_idx+1);
begin_iter = liveranges.begin();
LiveRange new_insert_lr (updated_startpoint, updated_endpoint);
liveranges.insert(begin_iter+start_lr_idx, new_insert_lr);
}
void setFrom(int from, int end_block) {
LiveRange* lr = &(liveranges[0]);
// std::cout << "setFrom: " << lr->startpoint << "," << lr->endpoint << std::endl;
// look for the live range where from resides
if ( lr->startpoint < from && from < lr->endpoint ) {
// case 1: shorten point is within the endpoint
lr->startpoint = from;
} /*
else if (from == lr->endpoint) {
// case 2: shorten point is exactly the endpoint (imfromsible)
assert(false && "shorten point cannot be the endpoint");
}
*/
}
};
#endif /* end of include guard: LIVERANGE_H */
|
c97e9b44f7fd17f89ade3c0bdb3f8a72c2114a66
|
924f21b8066b0167d28f6545ba4f3729b084602a
|
/src/yds_render_geometry_channel.cpp
|
3c1c976e0ee37c1dc37e12b26a110bd003181520
|
[
"MIT"
] |
permissive
|
ArwinSaleh/delta-studio
|
34a3bd24b07679d3f105430f113f489d4532ffdf
|
a06675cfa7c8981093bb7da6cec204c2216a4371
|
refs/heads/master
| 2023-03-04T09:10:35.447322
| 2021-01-30T21:55:18
| 2021-01-30T21:55:18
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 299
|
cpp
|
yds_render_geometry_channel.cpp
|
#include "../include/yds_render_geometry_channel.h"
ysRenderGeometryChannel::ysRenderGeometryChannel() : ysObject("RENDER_GEOMETRY_CHANNEL") {
m_name[0] = '\0';
m_offset = 0;
m_format = ChannelFormat::Undefined;
}
ysRenderGeometryChannel::~ysRenderGeometryChannel() {
/* void */
}
|
8ca64d6821a00a7ca4020b4af15abc5bc3b93917
|
37137e3e5b5d739f911e1beb4d4cd6c485874256
|
/codes/CppPrimer/ch03_Strings_Vectors_and_Arrays/exercise_3_19.cpp
|
a38de27cf3a4f76da992a900216b5a740e49f885
|
[] |
no_license
|
demon90s/CppStudy
|
3710f6188d880ec1633df8be79f8025453103c94
|
f3dc951b77bd031e7ffdef60218fe13fe34b7145
|
refs/heads/master
| 2021-12-01T14:42:34.162240
| 2021-11-27T16:10:21
| 2021-11-27T16:10:21
| 104,697,460
| 157
| 63
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 498
|
cpp
|
exercise_3_19.cpp
|
/*
* 练习3.19:如果想定义一个含有10个元素的vector对象,所有元素的值都是42,请列举三种不同的实现方法。哪种方法更好呢?为什么?
*/
/*
* 如下,第一种更好。因为10个元素都一样。参见书本p91。
*/
#include <vector>
using std::vector;
int main()
{
vector<int> ivec1(10, 42);
vector<int> ivec2{42, 42, 42, 42, 42, 42, 42, 42, 42, 42};
vector<int> ivec3;
for (int i = 0; i < 10; ++i)
ivec3.push_back(42);
return 0;
}
|
5e1837866b5e9eb2695171cdee135d219a24cd7e
|
3907daeec7e645284133c5f286bd5b6f8c456de9
|
/project3/jinn/heap.cpp
|
643a93d68ff1054eb9c515ab4e7aa5faeec8429f
|
[] |
no_license
|
nanxinjin/CS251
|
bc45c3906d4af5ca6dc2854c3febc66e09ceb4e8
|
3f68cc47529d51e7534df9a9128e518ef5e0ccfa
|
refs/heads/master
| 2021-01-22T01:55:40.491840
| 2016-09-20T20:27:22
| 2016-09-20T20:27:22
| 68,748,655
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,309
|
cpp
|
heap.cpp
|
#include <iostream>
#include <cstdlib>
#include "heap.h"
using namespace std;
bool TreeNode::operator < (const TreeNode& anotherNode) {
// TODO : add your logic here.
return false;
}
bool TreeNode::operator > (const TreeNode& anotherNode) {
// TODO : add your logic here.
return false;
}
/*
* If isMaxHeap == true, initialize as a MaxHeap.
* Else, initialize as a MinHeap.
*/
BinaryHeap::BinaryHeap(bool isMaxHeap) {
// TODO : add your logic here.
root = NULL;
heap_size = 0;
this->isMaxHeap = isMaxHeap;
}
/*
* Given an array of TreeNode elements, create the heap.
* Assume the heap is empty, when this is called.
*/
void BinaryHeap::heapify(int size, TreeNode * nodes) {
// TODO : add your logic here.
int i = 0;
for(i;i<size;i++){
insert(nodes);
nodes++;
}
}
/*
* insert the node into the heap.
* return false, in case of failure.
* return true for success.
*/
bool BinaryHeap::insert(TreeNode * node) {
// TODO : add your logic here.
if(root == NULL){
root = node;
heap_size ++;
return true;
}
TreeNode * n = root;
int find_last_node[32];
int a;
int i = 0;
int count = 0;
heap_size = heap_size + 1;
int temp_size = heap_size;
while(temp_size != 0){
a = temp_size%2;
temp_size = temp_size/2;
find_last_node[count] = a;
count++;
}
i = count-2;
for(i ; i >= 1; i--){
if(find_last_node[i] == 0){
n = n->leftChild;
}else{
n = n->rightChild;
}
}
node->parent = n;
if(find_last_node[i] == 0){
n->leftChild = node;
}else{
n->rightChild = node;
}
int temp_key;
int temp_value;
int flag = 0;
while(n != NULL){
if(isMaxHeap == 1){
if(node->key > n->key){
temp_key = node->key;
temp_value = node->value;
node->key = n->key;
node->value = n->value;
n->key = temp_key;
n->value = temp_value;
node = node->parent;
n = n->parent;
}else{
flag = 1;
break;
}
}else{
if(node->key < n->key){
temp_key = node->key;
temp_value = node->value;
node->key = n->key;
node->value = n->value;
n->key = temp_key;
n->value = temp_value;
node = node->parent;
n = n->parent;
}else{
flag = 1;
break;
}
}
}
return true;
}
/*
* Return the minimum element of the min-heap [max element of max-heap]
*/
TreeNode * BinaryHeap::extract() {
// TODO : add your logic here
if(root == NULL){
// cout << "empty"<<endl;
return NULL;
}
TreeNode * just_root = root;
if(heap_size == 1){
root = NULL;
heap_size--;
return just_root;
}
TreeNode * n = root;
int find_last_node[32];
int a;
int i = 0;
int count = 0;
int temp_size = heap_size;
int temp_key;
int temp_value;
//convert heap_size to binary
while(temp_size != 0){
a = temp_size%2;
temp_size = temp_size/2;
find_last_node[count] = a;
count++;
}
i = count-2;
int is_left_or_right;
//find last node
for(i ; i >= 0; i--){
if(find_last_node[i] == 0){
n = n->leftChild;
is_left_or_right = 0;
}else{
n = n->rightChild;
is_left_or_right = 1;
}
}
//swap last node and root
temp_key = root->key;
temp_value = root->value;
root->key = n->key;
root->value = n->value;
n->key = temp_key;
n->value = temp_value;
if(is_left_or_right == 0){
n->parent->leftChild = NULL;
n->parent = NULL;
}else{
n->parent->rightChild = NULL;
n->parent = NULL;
}
heap_size --;
TreeNode * m = root;
while(1){
if(isMaxHeap == 1){
if(m->leftChild == NULL && m->rightChild == NULL){
break;
}else if(m->leftChild != NULL && m->rightChild == NULL){
if(m->leftChild->key > m->key){
temp_key = m->key;
temp_value = m->value;
m->key = m->leftChild->key;
m->value = m->leftChild->value;
m->leftChild->key = temp_key;
m->leftChild->value = temp_value;
m = m->leftChild;
}else{
break;
}
}else{
if((m->leftChild->key > m->key) || (m->rightChild->key > m->key)){
if(m->leftChild->key > m->rightChild->key){
temp_key = m->key;
temp_value = m->value;
m->key = m->leftChild->key;
m->value = m->leftChild->value;
m->leftChild->key = temp_key;
m->leftChild->value = temp_value;
m = m->leftChild;
}else{
temp_key = m->key;
temp_value = m->value;
m->key = m->rightChild->key;
m->value = m->rightChild->value;
m->rightChild->key = temp_key;
m->rightChild->value = temp_value;
m = m->rightChild;
}
}else{
break;
}
}
}else{
if(m->leftChild == NULL && m->rightChild == NULL){
break;
}else if(m->leftChild != NULL && m->rightChild == NULL){
if(m->leftChild->key < m->key){
temp_key = m->key;
temp_value = m->value;
m->key = m->leftChild->key;
m->value = m->leftChild->value;
m->leftChild->key = temp_key;
m->leftChild->value = temp_value;
m = m->leftChild;
}else{
break;
}
}else{
if((m->leftChild->key < m->key) || (m->rightChild->key < m->key)){
if(m->leftChild->key < m->rightChild->key){
temp_key = m->key;
temp_value = m->value;
m->key = m->leftChild->key;
m->value = m->leftChild->value;
m->leftChild->key = temp_key;
m->leftChild->value = temp_value;
m = m->leftChild;
}else{
temp_key = m->key;
temp_value = m->value;
m->key = m->rightChild->key;
m->value = m->rightChild->value;
m->rightChild->key = temp_key;
m->rightChild->value = temp_value;
m = m->rightChild;
}
}else{
break;
}
}
}
}
return n;
}
/*
* Return the current size of the Heap.
*/
int BinaryHeap::size() {
// TODO : add your logic here.
return heap_size;
}
void heapSort(int size, TreeNode * elements, bool isReverseOrder) {
// TODO : add your logic here.
BinaryHeap b(isReverseOrder);
b.heapify(size, elements);
int i = 0;
TreeNode * temp;
for(i ; i < size; i++){
temp = b.extract();
cout << temp->key << " " << temp->value << endl;
}
}
TreeNode* BinaryHeap::peak(){
TreeNode * n = root;
return n;
}
|
1bd2c6220d426ed39d2a59836e2d3797512da224
|
8c8a8af67076b2b7ac9808d614be8e40728d7854
|
/jni/Graphics/Sprite/SpriteBatcher.cpp
|
ec7e3664c7b4946621baf0a820ba8db27644bb7f
|
[] |
no_license
|
MihaiBabiac/Framework
|
694d5185c6a394c0a453f9812db327550612eb67
|
ad97160286a7fb69d9f3667e2ed736c0a2a0dbfe
|
refs/heads/master
| 2021-05-28T10:14:12.218635
| 2013-07-25T09:51:31
| 2013-07-25T09:51:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,459
|
cpp
|
SpriteBatcher.cpp
|
/*
This file is owned by Murtaza Alexandru and may not be distributed, edited or used without written permission of the owner
When using this work you accept to keep this header
E-mails from murtaza_alexandru73@yahoo.com with permissions can be seen as valid.
*/
#include "SpriteBatcher.hpp"
#include "Global.hpp"
#include "Render.hpp"
#include "Camera2D.hpp"
#include "Debug.hpp"
using namespace Math;
SpriteBatch::SpriteBatch(GLushort indexSize, Texture2D *texture, IndexData::Type type)
: m_indexSize(indexSize), m_texture(texture), m_type(type)
{
}
map<GLfloat, SpriteBatcher*> SpriteBatcher::s_spriteBatcherLayer;
bool SpriteBatcher::s_useCamera=false;
SpriteBatcher::SpriteBatcher()
: m_currentIndexBatchSize(0), m_lastTexture(NULL)
{
}
void SpriteBatcher::SendDebugPolygon(Vector2f *posPointer,GLuint count,Vector4f color,TransformState2f transformState,GLfloat layer)
{
if(!s_spriteBatcherLayer.count(layer))
{
s_spriteBatcherLayer[layer]=new SpriteBatcher;
}
vector<SpriteVertex> vertexData;
for(GLuint index=0;index<count;++index)
{
Vector2f point=posPointer[index];
transformState.Transform(point);
SpriteVertex vertex;
vertex.x=point.x;
vertex.y=point.y;
vertex.s=vertex.t=0.0f;
vertex.r=color.x;
vertex.g=color.y;
vertex.b=color.z;
vertex.a=color.w;
vertex.stype=SpriteVertex::NOTEXTURE;
vertexData.push_back(vertex);
}
vector<GLushort> indexData;
GLushort lastPoint=count-1;
for(GLushort currentPoint=0;currentPoint<count;++currentPoint)
{
indexData.push_back(lastPoint);
indexData.push_back(currentPoint);
lastPoint=currentPoint;
}
s_spriteBatcherLayer[layer]->Send(&vertexData[0],vertexData.size(),&indexData[0],indexData.size(),NULL,IndexData::LINES);
}
void SpriteBatcher::SendDebugCircle(GLuint count,Vector4f color,TransformState2f transformState,GLfloat layer)
{
if(!s_spriteBatcherLayer.count(layer))
{
s_spriteBatcherLayer[layer]=new SpriteBatcher;
}
if(count<3)
{
count=3;
}
vector<SpriteVertex> vertexData;
GLfloat angle=0.0f;
GLfloat angleStep=360.0f/count;
for(GLuint index=0;index<count;++index)
{
Vector2f point=Vector2f(1.0f,0.0f);
point.Rotate(angle);
angle+=angleStep;
transformState.Transform(point);
SpriteVertex vertex;
vertex.x=point.x;
vertex.y=point.y;
vertex.s=vertex.t=0.0f;
vertex.r=color.x;
vertex.g=color.y;
vertex.b=color.z;
vertex.a=color.w;
vertex.stype=SpriteVertex::NOTEXTURE;
vertexData.push_back(vertex);
}
vector<GLushort> indexData;
GLushort lastPoint=count-1;
for(GLushort currentPoint=0;currentPoint<count;++currentPoint)
{
indexData.push_back(lastPoint);
indexData.push_back(currentPoint);
lastPoint=currentPoint;
}
s_spriteBatcherLayer[layer]->Send(&vertexData[0],vertexData.size(),&indexData[0],indexData.size(),NULL,IndexData::LINES);
}
void SpriteBatcher::SendQuad(SpriteVertex *vertexPointer,GLuint vertexCount, Texture2D *texture, IndexData::Type type, GLfloat layer)
{
if(!s_spriteBatcherLayer.count(layer))
{
s_spriteBatcherLayer[layer]=new SpriteBatcher;
}
s_spriteBatcherLayer[layer]->SendQuad(vertexPointer,vertexCount,texture,type);
}
void SpriteBatcher::Send(SpriteVertex *vertexPointer,GLuint vertexCount, GLushort *indexPointer, GLushort indexCount, Texture2D *texture, IndexData::Type type, GLfloat layer)
{
if(!s_spriteBatcherLayer.count(layer))
{
s_spriteBatcherLayer[layer]=new SpriteBatcher;
}
s_spriteBatcherLayer[layer]->Send(vertexPointer,vertexCount,indexPointer,indexCount,texture,type);
}
void SpriteBatcher::FlushAll()
{
for(map<GLfloat,SpriteBatcher*>::iterator it=s_spriteBatcherLayer.begin();it!=s_spriteBatcherLayer.end();++it)
{
(*it).second->Flush();
}
}
void SpriteBatcher::EnableCamera()
{
s_useCamera=true;
}
void SpriteBatcher::DisableCamera()
{
s_useCamera=false;
}
void SpriteBatcher::SendQuad(SpriteVertex *vertexPointer,GLuint vertexCount, Texture2D *texture, IndexData::Type type)
{
if(vertexCount&3!=0)
{
LOGE("SpriteBatcher::Send quad data is corrupted");
return;
}
PushMergeBatch(texture,type);
GLushort indexOffset=m_vertexData.size();
PushVertexData(vertexPointer,vertexCount);
GLushort quadIndex[]={ 0,1,2,
2,3,0 };
GLushort quadCount=vertexCount>>2;
for(GLushort quad=0;quad<quadCount;++quad)
{
for(GLushort i=0;i<6;++i)
{
m_indexData.push_back(indexOffset+quad*4+quadIndex[i]);
}
}
m_currentIndexBatchSize+=quadCount*6;
}
void SpriteBatcher::Send(SpriteVertex *vertexPointer,GLuint vertexCount, GLushort *indexPointer, GLushort indexCount, Texture2D *texture, IndexData::Type type)
{
PushMergeBatch(texture,type);
GLushort indexOffset=m_vertexData.size();
PushVertexData(vertexPointer,vertexCount);
GLushort *indexPointerEnd=indexPointer+indexCount;
for(;indexPointer<indexPointerEnd;++indexPointer)
{
m_indexData.push_back((*indexPointer)+indexOffset);
}
m_currentIndexBatchSize+=indexCount;
}
void SpriteBatcher::Flush()
{
CompleteBatch();
VertexBufferObject::UnbindCurrentBuffer();
IndexBufferObject::UnbindCurrentBuffer();
Sprite_Program->BindShader();
Sprite_Program->UpdateUniforms();
Sprite_Program->EnableVertexAttributes();
Sprite_Program->SendVertexBuffer((GLfloat*)(&m_vertexData[0]));
//LOGD("Sprite::Batcher batches = %d vertex size = %d",m_batches.size(),m_vertexData.size());
GLuint firstVertex=0;
GLuint firstIndex=0;
for(vector<SpriteBatch>::iterator it=m_batches.begin();it!=m_batches.end();++it)
{
//LOGD("Batch index size = %d type = %d",it->m_indexSize,it->m_type);
if(it->m_texture)
{
it->m_texture->Bind(GL_TEXTURE0);
}
glDrawElements(GetGLType(it->m_type),it->m_indexSize,GL_UNSIGNED_SHORT,&m_indexData[firstIndex]);
Debug::AssertGL("ERROR!");
firstIndex+=it->m_indexSize;
}
Sprite_Program->DisableVertexAttributes();
m_batches.clear();
m_vertexData.clear();
m_indexData.clear();
m_lastTexture=NULL;
m_lastType=IndexData::NONE;
}
void SpriteBatcher::CompleteBatch()
{
if(m_currentIndexBatchSize)
{
m_batches.push_back(SpriteBatch(m_currentIndexBatchSize,m_lastTexture,m_lastType));
m_currentIndexBatchSize=0;
}
}
void SpriteBatcher::PushMergeBatch(Texture2D *texture, IndexData::Type type)
{
if(!m_lastTexture)
{
m_lastTexture=texture;
}
if(m_lastType==IndexData::NONE)
{
m_lastType=type;
}
if(m_lastTexture!=texture || m_lastType!=type)
{
CompleteBatch();
m_lastTexture=texture;
m_lastType=type;
}
}
void SpriteBatcher::PushVertexData(SpriteVertex *vertexPointer, GLint vertexCount)
{
SpriteVertex *vertexPointerEnd=vertexPointer+vertexCount;
for(;vertexPointer<vertexPointerEnd;++vertexPointer)
{
Vector2f point(vertexPointer->x,vertexPointer->y);
if(s_useCamera && Global::pActiveCamera)
{
Global::pActiveCamera->Transform(point);
}
SpriteVertex vertex=*vertexPointer;
vertex.x=point.x;
vertex.y=point.y;
vertex.y=Render::GetScreenHeight()-vertex.y;
m_vertexData.push_back(vertex);
}
}
GLenum SpriteBatcher::GetGLType(const GLint type)
{
if(type==IndexData::POINTS)
{
return GL_POINTS;
}
if(type==IndexData::LINES)
{
return GL_LINES;
}
if(type==IndexData::TRIANGLES)
{
return GL_TRIANGLES;
}
return -1;
}
|
20428e0bd49a1c1f9686a15beb166fd810fbae8e
|
2688dd4eca965e1d1d90e0e795f0835bbd286366
|
/celsius to fahrenhiet.cpp
|
fa93a99967a3ff9d217a7de3b0d19592ec9b289f
|
[] |
no_license
|
Shihab90-ad/Convert-celcius-to-fahrenhiet
|
5e086e009cee52d8e45dfc698c7e5bb7fc2cd936
|
e1f4a83c989397d16669bcdb4511221ee30c5bfa
|
refs/heads/master
| 2021-02-15T15:21:10.017924
| 2020-07-18T12:37:56
| 2020-07-18T12:37:56
| 244,910,796
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 355
|
cpp
|
celsius to fahrenhiet.cpp
|
/*@Shihab Sadekatul
Matric no:1821581
lab #1 Section #3*/
#include<iostream>
using namespace std;
int main()
{
int a=32;
double celsius,fahrenhiet,x=9,y=5;
cout<<"Enter a degree in Celsius: ";
cin>>celsius;
fahrenhiet=(x/y)*celsius+32;
cout<<celsius<<" Celsius is "<<fahrenhiet<<" Fahrenhiet"<<endl;
system("pause");
return 0;
}
|
eadabc77f83490929cb6c9ae9558eda578589b76
|
fe02127ac0573368ccff190a43925154ce115d73
|
/mergeintervals.cpp
|
965c968588f1faca1e2a642ac4395bed8c7cec56
|
[] |
no_license
|
tariyal/vector-codes
|
00405413dd9c64411727251e7ae68a56bce7ee52
|
ec617c9c2d03bac41ed16c2891bfbda9e26e4630
|
refs/heads/master
| 2021-01-19T10:58:43.351134
| 2015-05-12T00:31:15
| 2015-05-12T00:31:15
| 27,711,545
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 688
|
cpp
|
mergeintervals.cpp
|
class Solution {
public:
static bool comp(const Interval a,const Interval b )
{
return a.start < b.start;
}
vector<Interval> merge(vector<Interval> &val) {
std::sort(val.begin(),val.end(),comp);
vector<Interval> ans;
if(val.size()==0)
return ans;
ans.push_back(val[0]);
int j=0,i;
for(i=1;i<val.size();i++)
{
if(ans[j].end >= val[i].start)
ans[j].end = val[i].end > ans[j].end ? val[i].end : ans[j].end;
else
{
ans.push_back(val[i]);
j++;
}
}
return ans;
}
};
|
0538954c7143ebac120b89c850c00c53068b0add
|
ac423c5206dfd0281418897cbebb2b2191e43684
|
/WarzoneGame/GameObservers.cpp
|
a3543306d150c4fed9c40e8a1265186ed5d034a5
|
[] |
no_license
|
lisa7012/Warzone_Game
|
7cf58d5546b2e75d5cce21217232053730ef5b1e
|
2729791044e1501f22504a5f977dea4a004a0358
|
refs/heads/main
| 2023-08-16T00:54:37.307056
| 2021-10-08T18:23:29
| 2021-10-08T18:23:29
| 415,085,298
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,642
|
cpp
|
GameObservers.cpp
|
#pragma once
#include <stdio.h>
#include <string>
#include "GameObservers.h"
#include "Map.h"
#include "GameEngine.h"
#include "Player.h"
/*--------------------
* ---Phase Observer---
* --------------------
* PhaseObserver Class
*/
//Default Constructor
PhaseObserver::PhaseObserver() {
}
//Destructor
PhaseObserver::~PhaseObserver() {
}
//Copy Constructor
PhaseObserver::PhaseObserver(const PhaseObserver& pO) {
}
//Assignment Operator
PhaseObserver& PhaseObserver::operator=(const PhaseObserver& pO) {
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const PhaseObserver& pO) {
return out;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* ConcretePhaseObserver Class, derived from PhaseObserver Class
*/
//Default Constructor
ConcretePhaseObserver::ConcretePhaseObserver() {
_phaseSubject = nullptr;
}
//Parametrized constructor
ConcretePhaseObserver::ConcretePhaseObserver(Player* p) {
_phaseSubject = p;
_phaseSubject->phaseAttach(this);
}
//Destructor
ConcretePhaseObserver::~ConcretePhaseObserver() {
_phaseSubject->phaseDetach(this);
}
//Copy Constructor
ConcretePhaseObserver::ConcretePhaseObserver(const ConcretePhaseObserver& pO) {
this->_phaseSubject = pO._phaseSubject;
}
//Assignment Operator
ConcretePhaseObserver& ConcretePhaseObserver::operator=(const ConcretePhaseObserver& pO) {
this->_phaseSubject = pO._phaseSubject;
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const ConcretePhaseObserver& pO) {
out << "ConcretePhaseObserver of: " << pO._phaseSubject;
return out;
}
//Update attack method which override update attack from Phase Observer and calls the display method of the concrete phase observer
void ConcretePhaseObserver::updateAttack(string cntr, string cntrA, string nmA, int res, int roArm, string roCntr, int attArm, string name) {
displayAttack(cntr, cntrA, nmA, res, roArm, roCntr, attArm, name);
}
//Update defense method which override update defense from Phase Observer and calls the display method of the concrete phase observer
void ConcretePhaseObserver::updateDefense(string cntr, string rCntr, int cArm, int fArm, string name) {
displayDefense(cntr, rCntr, cArm, fArm, name);
}
//Update reinforce method which override update reinforce from Phase Observer and calls the display method of the concrete phase observer
void ConcretePhaseObserver::updateReinforce(int nbA, string cntr, string name) {
displayReinforce(nbA, cntr, name);
}
//Method to display what happened during the attack phase with relevent information
void ConcretePhaseObserver::displayAttack(string c, string cA, string nA, int r, int roA, string roC, int attA, string name) {
cout << endl << name << ": Attack phase" << endl << name << " attacked " << cA << ", which belongs to " << nA << ", from " << c << endl;
if (r == 0) {
cout << "After the attack " << name << " has " << roA << " on " << roC << "." << endl;
cout << nA << " has " << attA << " on " << cA << "." << endl << endl;
}
else {
cout << "After the attack " << name << " has " << roA << " on " << roC << "." << endl;
cout << name << " conquered " << cA << "." << endl << endl;
}
}
//Method to display what happened during the defense phase with relevent information
void ConcretePhaseObserver::displayDefense(string c, string rC, int cA, int fA, string name) {
cout << endl << name << ": Defense phase" << endl << name << " chose armies from " << c << " and reinforced " << rC << "." << endl;
cout << c << " now has " << cA << " armies." << endl;
cout << rC << " now has " << fA << " armies." << endl << endl;
}
//Method to display what happened during the reinforcement phase with relevent information
void ConcretePhaseObserver::displayReinforce(int nA, string c, string name) {
cout << endl << name << ": Reinforcement phase" << endl << name << " put " << nA << " armies on the country " << c << "." << endl << endl;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* PhaseSubject Class
*/
//Default Constructor
PhaseSubject::PhaseSubject() {
_phaseObservers = new vector<PhaseObserver*>;
}
//Destructor
PhaseSubject ::~PhaseSubject() {
}
//Copy Constructor
PhaseSubject::PhaseSubject(const PhaseSubject& pO) {
this->_phaseObservers = pO._phaseObservers;
}
//Assignment Operator
PhaseSubject& PhaseSubject::operator=(const PhaseSubject& pO) {
this->_phaseObservers = pO._phaseObservers;
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const PhaseSubject& pO) {
out << "PhaseSubject of: " << pO._phaseObservers;
return out;
}
//Detaching a phase observer (deleting it from the list)
void PhaseSubject::phaseDetach(PhaseObserver* Po) {
for (int i = 0; i < (_phaseObservers->size()); i++) {
if (_phaseObservers->at(i) == Po) {
_phaseObservers->erase(_phaseObservers->begin() + i);
break;
}
}
}
//Attaching a phase observer (adding it to the list)
void PhaseSubject::phaseAttach(PhaseObserver* Po) {
_phaseObservers->push_back(Po);
}
/*
* The Subject class has a list or a collection of observers.
* When an event is triggered it calls the notify() operation which loops through all the observers by calling their update function.
*/
//Notify method for attack which will call the update attack for a phase observer
void PhaseSubject::notifyAttack(string country, string countryA, string nameA, int result, int roArmies, string roCountry, int attArmies, string name) {
for (int i = 0; i < (_phaseObservers->size()); i++) {
_phaseObservers->at(i)->updateAttack(country, countryA, nameA, result, roArmies, roCountry, attArmies, name);
}
}
//Notify method for defense which will call the update defense for a phase observer
void PhaseSubject::notifyDefense(string country, string rCountry, int cArmies, int fArmies, string name) {
for (int i = 0; i < (_phaseObservers->size()); i++) {
_phaseObservers->at(i)->updateDefense(country, rCountry, cArmies, fArmies, name);
}
}
//Notify method for reinforce which will call the update reinforce for a phase observer
void PhaseSubject::notifyReinforce(int nbArmies, string country, string name) {
for (int i = 0; i < _phaseObservers->size(); i++) {
_phaseObservers->at(i)->updateReinforce(nbArmies, country, name);
}
}
/*------------------------------
* ---Game Statistics Observer---
* ------------------------------
StatisticObserver Class
*/
//Default Constructor
StatisticObserver::StatisticObserver() {
}
//Destructor
StatisticObserver::~StatisticObserver() {
}
//Copy Constructor
StatisticObserver::StatisticObserver(const StatisticObserver& pO) {
}
//Assignment Operator
StatisticObserver& StatisticObserver::operator=(const StatisticObserver& pO) {
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const StatisticObserver& pO) {
return out;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
/*
ConcreteStatisticObserver Class, derived from StatisticObserver Class
*/
//Default Constructor
ConcreteStatisticObserver::ConcreteStatisticObserver() {
}
//Parameterized Constructor
ConcreteStatisticObserver::ConcreteStatisticObserver(Map* map, GameEngine* g) {
_subject = map;
_subject->attach(this);
gameEngine = g;
}
//Destructor
ConcreteStatisticObserver::~ConcreteStatisticObserver() {
_subject->detach(this);
}
//Copy Constructor
ConcreteStatisticObserver::ConcreteStatisticObserver(const ConcreteStatisticObserver& pO) {
this->_subject = pO._subject;
}
//Assignment Operator
ConcreteStatisticObserver& ConcreteStatisticObserver::operator=(const ConcreteStatisticObserver& pO) {
this->_subject = pO._subject;
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const ConcreteStatisticObserver& pO) {
out << "ConcreteStatisticObserver of: " << pO._subject;
return out;
}
//Update
void ConcreteStatisticObserver::update() {
display();
}
//Display
void ConcreteStatisticObserver::display() {
vector<Player*> playerList = gameEngine->getPlayerList();
Map* map = _subject;
int size = map->getTerritoryList().size();
vector<Territory*> a = map->getTerritoryList();
switch (playerList.size()) {
case 1:
for (int j = 0; j < playerList.size(); j++) {
double percent = (playerList.at(j)->getListOfTerritories().size() / (double)size) * 100;
cout << "Player " << playerList.at(j)->getPosition() << " has " << playerList.at(j)->getListOfTerritories().size() << " territories. They own " << percent << "% of the map!" << endl;
}
cout << "The winner is Player " << playerList.at(0)->getPosition() << ". Congratulations!!" << endl;
system("pause");
break;
default:
for (int j = 0; j < playerList.size(); j++) {
double percent = (playerList.at(j)->getListOfTerritories().size() / (double)size) * 100;
cout << "Player " << playerList.at(j)->getPosition() << " has " << playerList.at(j)->getListOfTerritories().size() << " territories. They own " << percent << "% of the map!" << endl;
}
}
cout << endl;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------
/*
StatisticSubject Class
*/
//Default Constructor
StatisticSubject::StatisticSubject() {
_observers = new list<StatisticObserver*>;
}
//Destructor
StatisticSubject::~StatisticSubject() {
delete _observers;
}
//Copy Constructor
StatisticSubject::StatisticSubject(const StatisticSubject& pO) {
this->_observers = pO._observers;
}
//Assignment Operator
StatisticSubject& StatisticSubject::operator=(const StatisticSubject& pO)
{
this->_observers = pO._observers;
return *this;
}
//Stream Insertion Operator
ostream& operator<<(ostream& out, const StatisticSubject& pO) {
out << "StatisticSubject of: " << pO._observers;
return out;
}
//Attach
void StatisticSubject::attach(StatisticObserver* o) {
_observers->push_back(o);
}
//Detach
void StatisticSubject::detach(StatisticObserver* o) {
_observers->remove(o);
}
//Notify
void StatisticSubject::notify() {
list<StatisticObserver*>::iterator i = _observers->begin();
for (; i != _observers->end(); ++i)
(*i)->update();
}
|
27667295ff3ea350ab0f58e1baf187a9695e6f41
|
aa5881562b8fd6d9bb59ba7e186cc9e385686bf8
|
/python_engine/source_code.hpp
|
08da33dfe6e20e52f08ccdff0ad23203e599cc78
|
[] |
no_license
|
engineerkatie/infra-ml2
|
0f6fb643f92743cf2f1763fb543f48717ebca50b
|
d5fcf191025dfa6ee36b5dec654fcd5e97eed3db
|
refs/heads/master
| 2021-01-06T13:48:43.092534
| 2020-02-18T15:57:06
| 2020-02-18T15:57:06
| 241,347,645
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,867
|
hpp
|
source_code.hpp
|
#pragma once
//------------------------------------------------------------------------------
//
// Copyright 2018-2019 Fetch.AI Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
#include <vector>
#include <string>
class SourceCode
{
public:
using const_iterator = std::vector<std::string>::const_iterator;
template<class CONTAINER>
SourceCode(const CONTAINER &input)
{
for(const auto &i : input)
{
store.push_back(i);
}
}
virtual ~SourceCode()
{
}
SourceCode()
{
}
SourceCode(SourceCode const &other)
{
copy(other);
}
SourceCode &operator=(SourceCode const &other)
{
copy(other);
return *this;
}
bool operator==(SourceCode const &other) = delete;
bool operator<(SourceCode const &other) = delete;
virtual void copy(SourceCode const &other)
{
for(const auto &i : other)
{
store.push_back(i);
}
}
virtual const_iterator begin() const
{
return store.begin();
}
virtual const_iterator end() const
{
return store.end();
}
std::vector<std::string> store;
std::string asString()
{
std::string s;
for( auto const &line : store)
{
s += line;
s += "\n";
}
return s;
}
protected:
private:
};
|
6921130145100dab021bea66381c96da2f5d96c3
|
2269bb3201ad683fd99b1a799b28d0cf2c59f1af
|
/LintCode/Wood Cut.cc
|
bb311ac16f705538f74995b5969980be13f85bfe
|
[] |
no_license
|
TissueFluid/Algorithm
|
1353ad7133c1f5482abc002ae6d81a1d4d32905a
|
befcc8e2014d0c83520f0250497e4f3828ac3120
|
refs/heads/master
| 2021-01-10T15:13:17.822059
| 2017-02-27T06:58:09
| 2017-02-27T06:58:09
| 43,377,990
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 919
|
cc
|
Wood Cut.cc
|
/*
* Wood Cut
* Binary Search
*/
#include <iostream>
#include <vector>
using namespace std;
int woodCut(vector<int> L, int k) {
int L_size = L.size();
if (L_size < 1) {
return 0;
}
long long max = L[0];
for (auto i = 1; i < L_size; ++i) {
if (L[i] > max) {
max = L[i];
}
}
long long left = 0;
long long right = max + 1;
long long mid = (left + right) / 2;
while (left < mid) {
auto tmp = 0;
for (auto i = 0; i < L_size; ++i) {
tmp += L[i] / mid;
}
if (tmp >= k) {
left = mid;
} else {
right = mid;
}
mid = (left + right) / 2;
}
return (int)left;
}
int main(int argc, char const* argv[])
{
int a[] = {232, 114, 456};
vector<int> v(a, a + 3);
cout << woodCut(v, 7) << endl;
int b[] = {2147483644,2147483645,2147483646,2147483647};
vector<int> v2(b, b + 4);
cout << woodCut(v2, 4) << endl;
return 0;
}
|
bdbbf96cdca8e9e2ac68f995d03d242a53788697
|
c98a75a0441994ab11195bf4d5cb068fd9e94026
|
/examples/physics/FullCMS/Geant4/include/MyDetectorConstruction.hh
|
229756358ebc23e65d7cd838c6c7be3c6e04caaf
|
[
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] |
permissive
|
amadio/geant
|
7d7237c8c48855cdf9225eb864366a4bdad6e125
|
a46790aa9eb3663f8324320a71e993d73ca443da
|
refs/heads/master
| 2020-04-06T04:35:44.331502
| 2019-08-27T15:23:58
| 2019-08-27T15:23:58
| 59,431,197
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,637
|
hh
|
MyDetectorConstruction.hh
|
#ifndef MyDetectorConstruction_h
#define MyDetectorConstruction_h 1
#include "G4VUserDetectorConstruction.hh"
#include "G4GDMLParser.hh"
#include "G4String.hh"
class G4VPhysicalVolume;
class G4FieldManager;
class G4UniformMagField;
class MyDetectorMessenger;
class G4ScalarRZMagFieldFromMap;
class MyDetectorConstruction : public G4VUserDetectorConstruction {
public:
MyDetectorConstruction();
~MyDetectorConstruction();
G4VPhysicalVolume* Construct() override final;
void ConstructSDandField() override final; // needed to create field in each thread
// Replaces the old 'SetMagField()'
void SetGDMLFileName(const G4String &gdmlfile) { fGDMLFileName = gdmlfile; }
void SetMagFieldValue(const G4double fieldValue)
{
fFieldValue = fieldValue;
gFieldValue = fFieldValue;
}
static void UseUniformField(G4bool val= true) { fUseUniformField= val; }
static G4double GetFieldValue() { return gFieldValue; }
static G4bool IsFieldUniform() { return fUseUniformField; }
private:
// Configuration parameters
static G4double gFieldValue; // primarily used for printout (if uniform...)
static G4bool fUseUniformField;
//
G4String fGDMLFileName;
G4double fFieldValue;
G4GDMLParser fParser;
G4VPhysicalVolume* fWorld;
// G4FieldManager* fFieldMgr; // Per-thread !!
// G4UniformMagField* fUniformMagField; // Per-thread !!
// G4ScalarRZMagFieldFromMap* fSimplifiedCMSfield; // Per-thread !!
MyDetectorMessenger* fDetectorMessenger;
};
#endif
|
3b8dc1991892d7aa79e33794922ff21fa601bc3e
|
098406f61bce623021c94c3a5d779e90041ec34e
|
/Trees/charTester.cpp
|
4e1873185167385147f1bcade6962afc631821e8
|
[] |
no_license
|
mirob2005/CPP_Data_Structures
|
730d45f04503f200472f00db95f40192a90c9457
|
118db02848afd190f5e8a1eacbc55429cb9a5c42
|
refs/heads/master
| 2020-05-30T19:22:39.072901
| 2013-07-24T22:38:31
| 2013-07-24T22:38:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,550
|
cpp
|
charTester.cpp
|
/*
* Michael Robertson
* mirob2005@gmail.com
* Completed: 7/17/13
*
* File: charTester.cpp
* Tests the basic operations of BST.h using chars
*
*/
#include <iostream>
#include "BST.h"
using namespace std;
template<class T>
void testCopyConstructor(BST<T> copyBST){
cout << "Adding d to BST in function: \n";
copyBST.addData('d');
copyBST.printBranches();
}
int main(int argc, char** argv) {
BST<char>bst;
bst.addData('e');
bst.addData('f');
bst.addData('b');
bst.addData('a');
bst.addData('h');
bst.addData('d');
bst.addData('g');
bst.traverseBFS();
bst.traverseDFSpreorder();
bst.traverseDFSinorder();
bst.traverseDFSpostorder();
cout << endl;
bst.printBranches();
cout << "Max Value: " << bst.findMax() << endl;
cout << "Min Value: " << bst.findMin() << endl;
cout << "Value z is present?: " << bst.findData('z') << endl;
cout << "Value e is present?: " << bst.findData('e') << endl;
cout << "Value f is present?: " << bst.findData('f') << endl;
cout << "Value g is present?: " << bst.findData('g') << endl;
cout << "\nCopying Tree\n";
BST<char> copy = bst.copyTree();
copy.printBranches();
cout << "Deleting root/internal/leaf nodes from copy:\n";
copy.deleteData('e');
copy.deleteData('m');
copy.deleteData('g');
copy.deleteData('b');
cout << "Copy after deletes:\n";
copy.printBranches();
cout << "Original after copy deletes:\n";
bst.printBranches();
cout << "\nDeleting original Tree:\n";
bst.deleteTree();
cout << "\nPrinting deleted tree:\n";
bst.traverseBFS();
bst.traverseDFSpreorder();
bst.traverseDFSinorder();
bst.traverseDFSpostorder();
bst.printBranches();
cout << "\nPrinting copied tree:\n";
copy.printBranches();
cout <<"\nAdding new nodes: \n";
bst.addData('y');
bst.addData('b');
bst.addData('a');
bst.addData('c');
bst.printBranches();
cout << "Max Value: " << bst.findMax() << endl;
cout << "Min Value: " << bst.findMin() << endl;
cout << "Value a is present?: " << bst.findData('a') << endl;
cout << "Value e is present?: " << bst.findData('e') << endl;
cout << "Value f is present?: " << bst.findData('f') << endl;
cout << "Value g is present?: " << bst.findData('g') << endl;
cout << "\nTesting copy constructor:\n";
testCopyConstructor(bst);
cout << "Printing BST after function:\n";
bst.printBranches();
return 0;
}
|
fd31be36bfad4d79e00648b7fafb5de9c2806176
|
abb1767094fc3e91787a08a96544ac6656049ccb
|
/MFCTool/MonsterTool.h
|
86dae7988706abeee4de667ccad1138bbb6e92bc
|
[] |
no_license
|
cjy5595/JusinMapToolTeamHomeWork
|
53d0b09aa4169123f75d8bd7a0981fbca56ae3ed
|
5c961fec21fbffe335b8021b8923341d37deec0f
|
refs/heads/main
| 2023-01-21T18:37:26.874963
| 2020-12-04T05:49:43
| 2020-12-04T05:49:43
| 317,226,750
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 450
|
h
|
MonsterTool.h
|
#pragma once
// CMonsterTool 대화 상자입니다.
class CMonsterTool : public CDialog
{
DECLARE_DYNAMIC(CMonsterTool)
public:
CMonsterTool(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CMonsterTool();
// 대화 상자 데이터입니다.
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_MONSTERTOOL };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
};
|
9f091e2eb6c0db4246f574ec41fe47a73a487daf
|
dff5aa031a90e93f7ca7aed4ec589b251c053893
|
/Server/extensions/buffer_lazy/buffer_lazy.cpp
|
156f685727a5f5681a1aa50541c2e177435c9334
|
[] |
no_license
|
rotators/fo2238
|
a614912db85ea66801020fe70c3e36bc27c0aa66
|
5d15427e9470fc22fa031529bebc53bddf7c0f88
|
refs/heads/master
| 2023-05-11T11:16:12.546327
| 2021-02-23T21:25:55
| 2021-02-23T21:25:55
| 11,121,442
| 22
| 27
| null | 2023-04-26T10:56:14
| 2013-07-02T09:27:11
|
AngelScript
|
UTF-8
|
C++
| false
| false
| 2,651
|
cpp
|
buffer_lazy.cpp
|
/*
*
* WHINE TEAM
* We Had Ini, Now Engine
*
*/
#ifndef __BUFFER_LAZY__
#define __BUFFER_LAZY__
#define SKIP_PRAGMAS
#define FO2238
#ifdef FO2238
#include "../fonline2238.h"
#else
#include "../fonline_tla.h"
#endif
#ifdef __MAPPER
#error "This is NOT mapper dll"
#endif
#include <string>
using namespace std;
// There's a blood on this code.
bool ParseLocalScriptName( const ScriptString& scriptfunc, string& module, string& function )
{
int pos = scriptfunc.c_std_str().find_first_of( "@" );
if( pos > 0 )
{
string moduleName = scriptfunc.c_std_str().substr( 0, pos );
string functionDecl = "void ";
functionDecl += scriptfunc.c_std_str().substr( pos + 1 );
#if defined(__CLIENT)
functionDecl += "(int,int,int,string@,int[]@)";
#elif defined(__SERVER)
functionDecl += "(Critter&,int,int,int,string@,int[]@)";
#endif
module = moduleName;
function = functionDecl;
return( true );
}
else
return( false );
}
EXPORT bool Global_IsLocalScript( const ScriptString& scriptfunc )
{
string module;
string function;
if( ParseLocalScriptName( scriptfunc, module, function ))
{
asIScriptModule* as_module = ASEngine->GetModule( module.c_str(), asGM_ONLY_IF_EXISTS );
if( !as_module )
return( false );
asIScriptFunction* as_function = as_module->GetFunctionByDecl( function.c_str() );
if( as_function )
return( true );
}
return( false );
}
#if defined(__CLIENT)
EXPORT void Global_RunLocalScript( const ScriptString& scriptfunc, int p0, int p1, int p2, const ScriptString* p3, ScriptArray* p4 )
#elif defined(__SERVER)
EXPORT void Critter_RunLocalScript( Critter& cr, const ScriptString& scriptfunc, int p0, int p1, int p2, const ScriptString* p3, ScriptArray* p4 )
#endif
{
if( Global_IsLocalScript( scriptfunc ))
{
string module, function;
if( ParseLocalScriptName( scriptfunc, module, function ))
{
int bindId = FOnline->ScriptBind( module.c_str(), function.c_str(), true );
if( bindId > 0 && FOnline->ScriptPrepare( bindId ))
{
#ifdef __SERVER
FOnline->ScriptSetArgObject( &cr );
#endif
FOnline->ScriptSetArgInt( p0 );
FOnline->ScriptSetArgInt( p1 );
FOnline->ScriptSetArgInt( p2 );
FOnline->ScriptSetArgObject( (void*)p3 );
FOnline->ScriptSetArgObject( p4 );
FOnline->ScriptRunPrepared();
}
else
{
Log( "RunLocalScript : cannot bind module<%s> function<%s>\n",
module.c_str(), function.c_str() );
}
}
else
{
Log( "RunLocalScript : invalid function name<%s>\n", scriptfunc.c_str() );
}
}
else
{
Log( "RunLocalScript : function<%s> not found\n", scriptfunc.c_str() );
}
}
#endif // __BUFFER_LAZY__ //
|
c17b71319df1bfb393625f335c2f55a2851dc6a4
|
354f4ce35b000236210e00345782891919a8d07a
|
/CTALK/Exercise1Solutions.cpp
|
47c3ff23428d0bf28fe68f92bd2b4a1abd9b4c34
|
[] |
no_license
|
slipschutz/CPPTalk2015
|
24c0cb214be6604c4f4cef4a6257c7891f082879
|
11d7f798337c1baf02a36d3342c6cc5ab665002d
|
refs/heads/master
| 2021-05-30T02:09:15.611222
| 2015-11-13T15:51:52
| 2015-11-13T15:51:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,945
|
cpp
|
Exercise1Solutions.cpp
|
#include <iostream>
#include <stdio.h>
using namespace std;
void PrintSpacerLine(char c){
for (int i=0;i<60;i++){
printf("%c",c);
}
printf("\n");
}
int main(){
cout<<endl<<endl;
int MyEasierArray[]={1,6,3,8};
for (int i=0;i<4;i++){
cout<<"MyEasierArray["<<i<<"] = "<<MyEasierArray[i]<<endl;
}
cout<<endl<<endl;
/********************************Question ONE******************************
What do you think the expression:
3[MyEasierArray]
will do? Will it even compile??
Uncomment below to find out
*/
cout<<endl<<endl;
for (int i=0;i<4;i++){
cout<<i<<"[MyEasierArray] = "<<i[MyEasierArray]<<endl;
}
cout<<endl<<endl;
/********Question One Answer****************************************
Yes it does compile
When you say array[5] it takes the address of the array (say 1004)
and moves 5 address over (address 1009) and dereferences the pointer
gving you the 5 element of the array
Saying 5[array] means it takes the address of 5 (which is 5) and
moves over 1004 spaces (arriving again at 1009) and then derefences
the pointer giving you the 5th element of the array
***/
/*And now yet ANOTHER way to refer to the elements of an array
*/
cout<<endl<<endl;
int * PointerToArray =MyEasierArray;
for (int i=0;i<4;i++){
cout<<"*(PointerToArray+"<<i<<") = "<< *(PointerToArray+i)<<endl;
}
cout<<endl<<endl;
/*****************************Question TWO**************************
Print the Address off the first element of MyEasierArray and the
Address of the Array. Are they same?
*/
/****************************Question Two Answer******************/
/*
Yes they are the same. The Address of the first element of
the array IS the array.
*/
cout<<"They are the same "<<&MyEasierArray[0]<<" = "<<MyEasierArray<<endl;
return 0;
}
|
83b442a199f6e7160878fc14b7787b775ae2d2b2
|
299adc750db8d36bacdaa0ba49eedd507301459a
|
/ESPAlarmController/test/AlarmPersistentState_unittest.cpp
|
40fb18e5b6d31d86f09cc74a05dd1708f5724406
|
[] |
no_license
|
jludwig75/ESPAlarmSystem
|
c5db08a14fd93e8d114c56730bb9c91ad9f01601
|
7b51fb5371b60713af393618e6d43b448130ac52
|
refs/heads/master
| 2023-03-22T11:02:29.101574
| 2021-03-20T16:54:40
| 2021-03-20T16:54:40
| 338,482,844
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,427
|
cpp
|
AlarmPersistentState_unittest.cpp
|
#include <catch.hpp>
#include "AlarmPersistentState.h"
#include <SPIFFS.h>
SCENARIO( "Test AlarmPersistentState", "" )
{
REQUIRE(SPIFFS.format());
AlarmPersistentState persistState;
REQUIRE(persistState.begin());
REQUIRE(persistState.get() == AlarmPersistentState::AlarmState::Disarmed); // Default value
WHEN( "The state is set and reloaded" )
{
REQUIRE(persistState.set(AlarmPersistentState::AlarmState::Armed));
persistState = AlarmPersistentState();
REQUIRE(persistState.begin());
THEN( "the state is restored" )
{
REQUIRE(persistState.get() == AlarmPersistentState::AlarmState::Armed);
}
}
WHEN( "the state is set to triggered" )
{
REQUIRE(persistState.set(AlarmPersistentState::AlarmState::Triggerd));
persistState = AlarmPersistentState();
REQUIRE(persistState.begin());
THEN( "triggered is persisted" )
{
REQUIRE(persistState.get() == AlarmPersistentState::AlarmState::Triggerd);
}
}
WHEN( "the state is set to error" )
{
REQUIRE(persistState.set(AlarmPersistentState::AlarmState::Error));
persistState = AlarmPersistentState();
REQUIRE(persistState.begin());
THEN( "triggered is persisted" )
{
REQUIRE(persistState.get() == AlarmPersistentState::AlarmState::Error);
}
}
}
|
fcc0018e44900a1cdcb41379e063aa32d8b9f548
|
f1a65cb6b467b6852b043945f25249387df70630
|
/gldcore/fsm.cpp
|
1001451469deee6a3798ecea08c71d0f9e06d4b6
|
[
"BSD-3-Clause"
] |
permissive
|
aivanova5/gridlabd_891
|
73e815c2de94ae025840916a12782a548eefa1b4
|
d16870f70678383d3cde43905f57ac53bae0a280
|
refs/heads/master
| 2020-03-22T06:13:49.074615
| 2018-10-24T17:46:08
| 2018-10-24T17:46:08
| 139,619,366
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 22,162
|
cpp
|
fsm.cpp
|
// $Id: fsm.cpp 4984 2014-12-19 22:05:13Z dchassin $
// Finite State Machine
//
#include <ctype.h>
#include "module.h"
#include "output.h"
#include "fsm.h"
#define MAXSTATES 256
static statemachine *first_machine = NULL;
static unsigned int n_machines = 0;
double cast_double(PROPERTYTYPE ptype, void *addr, size_t index=0)
{
switch (ptype)
{
case PT_void: return 0.0;
case PT_double: return (double)((double*)addr)[index];
case PT_complex: return (double)((char*)addr)[index];
case PT_enumeration: return (double)((enumeration*)addr)[index];
case PT_set: return (double)((set*)addr)[index];
case PT_int16: return (double)((int16*)addr)[index];
case PT_int32: return (double)((int32*)addr)[index];
case PT_int64: return (double)((int64*)addr)[index];
case PT_char8: return (double)((char*)addr)[index];
case PT_char32: return (double)((char*)addr)[index];
case PT_char256: return (double)((char*)addr)[index];
case PT_char1024: return (double)((char*)addr)[index];
//case PT_object: return (double)((object*)addr)[index];
//case PT_delegated: return (double)((delegated*)addr)[index];
case PT_bool: return (double)((bool*)addr)[index];
case PT_timestamp: return (double)((char*)addr)[index];
case PT_double_array: return (double)((double*)addr)[index];
// case PT_complex_array: return (double)((complex*)addr)[index];
case PT_real: return (double)((real*)addr)[index];
case PT_float: return (double)((float*)addr)[index];
// case PT_loadshape: return (double)((loadshape*)addr)[index];
// case PT_enduse: return (double)((enduse*)addr)[index];
// case PT_random: return (double)((random*)addr)[index];
// case PT_statemachine: return (double)((statemachine*)addr)[index];
default:
throw "cast_double given unsupported property type";
}
}
extern "C" int fsm_create(statemachine *machine, OBJECT *context)
{
// set up
memset(machine,0,sizeof(statemachine));
machine->next = first_machine;
first_machine = machine;
n_machines++;
// connect to object
machine->context = context;
machine->interval = 60;
// done
return 1;
}
extern "C" int fsm_init(statemachine *machine)
{
machine->hold_time = TS_NEVER;
machine->entry_time = global_clock;
return 0;
}
extern "C" int fsm_initall(void)
{
statemachine *machine;
for ( machine=first_machine ; machine!=NULL ; machine=machine->next )
{
if ( fsm_init(machine)==1 )
return FAILED;
}
return SUCCESS;
}
void fsm_do_entry(statemachine *machine)
{
uint64 state = (uint64)(machine->value);
if ( machine->transition_calls && machine->transition_calls[state].entry )
machine->transition_calls[state].entry(machine);
}
void fsm_do_during(statemachine *machine)
{
uint64 state = (uint64)(machine->value);
if ( machine->transition_calls && machine->transition_calls[state].during )
machine->transition_calls[state].during(machine);
}
void fsm_do_exit(statemachine *machine)
{
uint64 state = (uint64)(machine->value);
if ( machine->transition_calls && machine->transition_calls[state].exit )
machine->transition_calls[state].exit(machine);
}
extern "C" TIMESTAMP fsm_sync(statemachine *machine, PASSCONFIG pass, TIMESTAMP t1)
{
if ( !fsm_isprogrammed(machine) )
return TS_NEVER;
int64 state = *machine->variable;
// update timer
machine->runtime = (double)(global_clock - machine->entry_time);
// check hold time
if ( global_clock<machine->hold_time && machine->hold_time<t1 )
return machine->hold_time;
// exit timer expired
machine->hold_time = TS_NEVER;
// process rules
FSMRULE *rule = machine->transition_rules[state];
while ( rule!=NULL ) // ; rule=(rule->next_and==NULL?rule->next_or:rule->next_and) )
{
// get test data
double a = cast_double(rule->lhtype,rule->lhs);
double b = cast_double(rule->rhtype,rule->rhs);
double tolerance = 0.0;
output_debug("In SYNC, transition rule '%s' active", rule->spec );
char tmp[1024];
// if test fails
char *copstr[] = {"==","<=",">=","!=","<",">","in","not in"};
output_debug("Testing: %g %s %g ?", a, copstr[rule->cop], b);
if ( property_compare_basic(PT_double,rule->cop,&a,&b,&tolerance,NULL) )
{
output_debug("Test passes");
// last test in 'and' chain implies this is the rule to apply
if ( rule->next_and==NULL )
{
output_debug("Last test in 'and' chain implies this is the rule to apply. ");
fsm_do_exit(machine);
TIMESTAMP hold = (TIMESTAMP)machine->transition_holds->get_at((size_t)rule->to,0);
machine->entry_time = t1;
machine->hold_time = ( hold>0 && hold<TS_NEVER ? t1+hold : TS_NEVER );
*(machine->variable) = (enumeration)(rule->to);
rule = rule->next_or;
}
else
{
rule = rule->next_and;
}
}
else
{
output_debug("Test fails");
rule = rule->next_or;
}
}
output_debug("No further tests.");
// processing during call if no state change occurred
if ( machine->value==*(machine->variable) )
{
output_debug("Remaining in this state");
fsm_do_during(machine);
}
else
{
// copy state to local variable
machine->value = *(machine->variable);
// process entry call
output_debug("Entering the new state");
fsm_do_entry(machine);
}
// hold time is next transition time (soft event)
TIMESTAMP t2 = ((t1/machine->interval)+1)*machine->interval;
t2 = (machine->hold_time < TS_NEVER && machine->hold_time > t2 ? machine->hold_time : t2);
char buffer[64];
output_debug("FSM next time return is SOFT %s", convert_from_timestamp(t2,buffer,sizeof(buffer))?buffer:"(invalid)");
return soften_timestamp(t2);
}
extern "C" TIMESTAMP fsm_syncall(TIMESTAMP t1)
{
// TODO use MTI
statemachine *machine;
TIMESTAMP t2 = TS_NEVER;
for (machine=first_machine; machine!=NULL; machine=machine->next)
{
TIMESTAMP t3 = fsm_sync(machine, PC_PRETOPDOWN, t1);
if ( absolute_timestamp(t3)<absolute_timestamp(t2) ) t2 = t3;
}
return t2;
}
extern "C" int fsm_set_state_variable(statemachine *machine, char *name)
{
char tmp[1024];
// find the property
machine->prop = object_get_property(machine->context,name,NULL);
if ( machine->prop==NULL )
{
output_error("the finite state machine variable '%s' is not defined in the object '%s'", name, object_name(machine->context,tmp,sizeof(tmp)));
return 0;
}
if ( machine->prop->ptype!=PT_enumeration )
{
output_error("finite state machine requires state variable '%s.%s' be an enumeration", object_name(machine->context,tmp,sizeof(tmp)),name);
return 0;
}
machine->variable = object_get_enum(machine->context,machine->prop);
// count the number of states
KEYWORD *key;
for ( key=machine->prop->keywords ; key!=NULL ; key=key->next )
{
if ( key->value+1 > machine->n_states )
machine->n_states = key->value+1;
else if ( key->value<0 )
output_warning("finite state machine will ignore states corresponding to negative values of state variable '%s.%s'", object_name(machine->context,tmp,sizeof(tmp)),name);
else if ( key->value>MAXSTATES )
output_warning("finite state machine will ignore states corresponding to values of state variable '%s.%s' larger than %d", object_name(machine->context,tmp,sizeof(tmp)),name, MAXSTATES);
}
if ( machine->n_states<2 )
{
output_error("finite state machine requires state variable '%s.%s' must have two or more distinct states", object_name(machine->context,tmp,sizeof(tmp)),name);
return 0;
}
// allocate machine rules, calls array and hold data
machine->transition_rules = (FSMRULE**)malloc(sizeof(FSMRULE*)*machine->n_states);
memset(machine->transition_rules,0,sizeof(FSMRULE*)*machine->n_states);
machine->transition_calls = (FSMCALL*)malloc(sizeof(FSMCALL)*machine->n_states);
memset(machine->transition_calls,0,sizeof(FSMCALL)*machine->n_states);
machine->transition_holds->grow_to(machine->n_states-1,0);
return 1;
}
extern "C" int fsm_add_transition_rule(statemachine *machine, char *spec)
{
// parse transition specs
char tmp[1024];
char from[64], to[64], test[1024];
char *speccopy = new char[strlen(spec)+1];
strcpy(speccopy,spec);
if ( sscanf(spec,"%[A-Za-z0-9_]->%[A-Za-z0-9_]=%[^\n]",from,to,test)<3 )
{
output_error("finite state machine in '%s' rule '%s' is invalid", object_name(machine->context,tmp,sizeof(tmp)),spec);
return 0;
}
// get from and to keys
uint64 from_key, to_key;
if ( !property_get_keyword_value(machine->prop,from,&from_key) || from_key>MAXSTATES )
{
output_error("finite state machine in '%s' rule '%s' uses invalid from state '%s'", object_name(machine->context,tmp,sizeof(tmp)),spec,from);
return 0;
}
if ( !property_get_keyword_value(machine->prop,to,&to_key) || to_key>MAXSTATES )
{
output_error("finite state machine in '%s' rule '%s' uses invalid from state '%s'", object_name(machine->context,tmp,sizeof(tmp)),spec,to);
return 0;
}
FSMRULE *rule = NULL;
// previous or
FSMRULE *next_or = machine->transition_rules[from_key];
// parse test
char *token=NULL, *next=NULL;
while ( (token=strtok_s(token==NULL?test:NULL,",",&next))!=NULL )
{
double *lvalue, *rvalue;
PROPERTYCOMPAREOP cop;
PROPERTYTYPE lptype = PT_void;
PROPERTY *lhsprop = NULL;
//PROPERTYTYPE lptype_double = PT_void;
PROPERTYTYPE rptype = PT_void;
output_debug("Parser: rule being parsed %s", token);
// remote leading whitespace
while ( *token!='\0' && isspace(*token) ) token++;
if ( *token=='\0' )
{
output_warning("empty rule in '%s' rule '%s'", object_name(machine->context,tmp,sizeof(tmp)),spec);
continue;
}
// extract operands and operator
char lhs[64], rhs[64], op[8];
if ( sscanf(token,"%[$-+A-Za-z0-9._#]%[<=>!]%[-+A-Za-z0-9._#]",lhs,op,rhs)!=3 )
{
output_error("finite state machine in '%s' test '%s' is invalid", object_name(machine->context,tmp,sizeof(tmp)),token);
return 0;
}
// get left operand
if ( strcmp(lhs,"$timer")==0 )
{
output_debug("FSM: In parser of the left hand side of expression (TIMER)");
lvalue = &(machine->runtime);
lptype = PT_double;
lhsprop = object_get_property(machine->context,lhs, NULL);
output_debug("finite state machine in '%s' test '%s' refers to property type '%d'", object_name(machine->context,tmp,sizeof(tmp)),token, lhsprop->name);
}
else if ( strcmp(lhs,"$state")==0 )
{
output_debug("FSM: In parser of the left hand side of expression (STATE)");
lvalue = &(machine->value);
lptype = PT_double;
}
else if ( !isalpha(lhs[0]) )
{
lvalue = new double;
*lvalue = atof(lhs);
lptype = PT_double;
output_debug("FSM: In parser of the left hand side of expression (DOUBLE)");
}
else
{
lhsprop = object_get_property(machine->context,lhs, NULL);
output_debug("FSM: In parser of the left hand side of expression (KEYWORD PARSER)");
unsigned int64 index = 0;
char *pindex = strchr(lhs,'#');
output_debug("FSM: In parser of the left hand side of expression, lhs : %s", lhs);
output_debug("finite state machine in '%s' test '%s' refers to property type '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, lhsprop->name);
if ( pindex!=NULL )
{
// lookup keyword from state variable
if ( !property_get_keyword_value(lhsprop,pindex+1,&index) )
{
output_error("finite state machine in '%s' test '%s' refers to non-existent state '%s' of property type '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, pindex+1, machine->prop->name);
return 0;
}
else // split string
*pindex = '\0';
}
lvalue = object_get_double_by_name(machine->context,lhs);
//output_debug("FSM: In parser of the left hand side of expression, lvalue : %s.%s = %f", object_name(machine->context,tmp,sizeof(tmp)),lhs,*lvalue);
if ( lvalue==NULL )
{
output_error("finite state machine in '%s' test '%s' refers to non-existent property '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, lhs);
return 0;
}
else
lvalue += index;
if ( lhsprop==NULL )
{
output_error("finite state machine in '%s' test '%s' refers to invalid l-value property type in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, lhs);
return 0;
}
lptype = lhsprop->ptype;
output_debug("FSM: lptype: '%s'", property_getspec(lptype)->name);
}
// get right operand
if ( strcmp(rhs,"$timer")==0 )
{
output_debug("FSM: In parser of the right hand side of expression (TIMER)");
rvalue = &(machine->runtime);
rptype = PT_double;
}
else if ( strcmp(rhs,"$state")==0 )
{
rvalue = &(machine->value);
rptype = PT_double;
}
else if ( strchr("+-0123456789",rhs[0]) != NULL ) // constant
{
output_debug("FSM: In parser of the right hand side of expression (DOUBLE)");
output_debug("FSM: '%s' rhs : '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs[0]);
rvalue = new double;
*rvalue = atof(rhs);
rptype = PT_double;
output_debug("FSM: In parser of the right hand side of expression (DOUBLE), rvalue: %s.%s = %f", object_name(machine->context,tmp,sizeof(tmp)), rhs, *rvalue);
}
else // keyword
{
PROPERTY *rhsprop = machine->prop; // assume context of lhs, or target if lhs has none
output_debug("In parser of the right hand side of expression (KEYWORD)");
unsigned int64 index = 0;
char *pindex = strchr(rhs,'#'); //search for hashtag (ie context)
char *cindex = strchr(rhs,'.'); //search for period (ie keyword)
//if ( pindex == rhs )
//{
// rhsprop = lhsprop;
//}
output_debug("finite state machine in '%s' test '%s' refers to property type '%d'", object_name(machine->context,tmp,sizeof(tmp)), token, rhsprop->ptype);
output_debug("RHS KEYWORD : %s and pindex is: %s", rhs, pindex);
if ( pindex == NULL ) // missing #
{
output_error("finite state machine in '%s' test '%s' refers to r-value property missing keyword # mark in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs);
return 0;
}
if (cindex == NULL)
{
output_error("finite state machine in '%s' test '%s' refers to r-value property missing keyword . mark in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs);
return 0;
}
*pindex++ = '\0';
*cindex++ = '\0';
if ( rhs[0] != '#' ) // refers to an array (ex. state_duration#....)
{
if ( rhsprop == NULL )
rhsprop = object_get_property(machine->context,rhs, NULL);
output_debug("finite state machine in '%s' test '%s' refers to rhs property type '%d'", object_name(machine->context,tmp,sizeof(tmp)),token, rhsprop->name);
if ( rhsprop==NULL )
{
output_error("finite state machine in '%s' test '%s' refers to invalid r-value property type in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs);
return 0;
}
}
output_debug("FSM: RHS pindex is : %s ", pindex);
// lookup keyword from state variable
if ( !property_get_keyword_value(rhsprop,pindex,&index) )
{
output_error("finite state machine in '%s' test '%s' refers to non-existent state '%s' of '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, pindex, rhsprop->name);
return 0;
}
double_array *avalue = (double_array*)object_get_addr(machine->context,rhs[0]=='\0' ? lhs : rhs);
if ( avalue==NULL )
{
output_error("finite state machine in '%s' test '%s' refers to non-existent property '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs);
return 0;
}
else
{
if ( avalue == NULL )
{
output_error("finite state machine in '%s' test '%s' refers to invalid index %d in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, index, rhs);
return 0;
}
else
{
rvalue = avalue->get_addr(index,0);
if ( rvalue == NULL )
{
output_error("finite state machine in '%s' test '%s' refers to invalid r-value in '%s'", object_name(machine->context,tmp,sizeof(tmp)),token, rhs);
return 0;
}
}
}
rptype = rhsprop->ptype;
}
// get operator for property type
cop = property_compare_op(PT_double,op);
// create rule
rule = new FSMRULE;
rule->to = to_key;
rule->lhs = lvalue;
rule->lhtype = lptype;
rule->rhs = rvalue;
rule->rhtype = rptype;
rule->cop = cop;
rule->spec = speccopy;
output_debug("FSM: rule operator : %d ", cop);
// link rule to last rule in state machine (or)
if ( next_or!=NULL )
{
output_debug("FSM : OR rule is linked");
rule->next_or = next_or;
rule->next_and = NULL;
}
// link rule to previous rule in this transition (and)
else
{
output_debug("FSM: AND rule linked");
rule->next_and = machine->transition_rules[from_key];
rule->next_or = NULL;
}
machine->transition_rules[from_key] = rule;
}
return 1;
}
extern "C" int fsm_add_transition_hold(statemachine *machine, char *hold)
{
char tmp[1024];
char state[64], unit[256]="s";
double duration;
uint64 key;
output_debug("Duration : '%s'", sscanf(hold,"%[A-Za-z0-9_]=%f%s",state,&duration,unit));
if ( sscanf(hold,"%[A-Za-z0-9_]=%f%s",state,&duration,unit)<2 )
{
output_error("finite state machine in '%s' hold '%s' is not valid", object_name(machine->context,tmp,sizeof(tmp)),hold);
return 0;
}
if ( !property_get_keyword_value(machine->prop,state,&key) || key>MAXSTATES )
{
output_error("finite state machine in '%s' hold '%s' uses a state value that is ignored", object_name(machine->context,tmp,sizeof(tmp)),hold);
return 0;
}
// convert units
if ( !unit_convert(unit,"s",&duration) )
{
output_error("finite state machine in '%s' hold '%s' uses duration unit '%s', which cannot be converted to seconds", object_name(machine->context,tmp,sizeof(tmp)),hold,unit);
return 0;
}
// done
machine->transition_holds->set_at((size_t)key,0,duration);
return 1;
}
extern "C" int fsm_set_external_machine(statemachine *machine, char *spec)
{
char tmp[1024];
// TODO implement linkage
output_error("%s: external finite state machine not implemented yet", object_name(machine->context,tmp,sizeof(tmp)));
// char dllname[1024];
// sprintf(dllname,"%s_%s.dll", machine->context->oclass->name, machine->context->name);
return 0;
}
bool fsm_isprogrammed(statemachine *machine)
{
return machine->variable!=NULL;
};
void fsm_reset(statemachine *machine)
{
if ( fsm_isprogrammed(machine) )
machine->value = *(machine->variable) = 0;
else
{
char tmp[64];
output_warning("fsm_reset(machine.context='%s'): state machine is not programmed",
object_name(machine->context,tmp,sizeof(tmp)));
}
}
void fsm_clear(statemachine *machine)
{
// release memory used by the machine
if ( machine->transition_calls!=NULL ) free(machine->transition_calls);
machine->transition_calls = NULL;
for ( size_t n=0 ; n<machine->n_states ; n++ )
{
machine->transition_holds->set_at(n,0,(double*)NULL);
struct s_fsmrule *rule=machine->transition_rules[n];
while ( rule!=NULL )
{
struct s_fsmrule *next = ( rule->next_and ? rule->next_and : rule->next_or );
free(rule);
rule = next;
}
machine->transition_rules[n] = NULL;
}
// save important values
OBJECT *context = machine->context;
statemachine *next = machine->next;
// obliterate the machine
memset(machine,0,sizeof(statemachine));
// restore important values
machine->context = context;
machine->next = next;
machine->interval = 60;
}
void fsm_interval(statemachine *machine, char *interval)
{
unsigned int64 value = atoi(interval);
if ( value == 0 )
{
output_error("interval %s for statemachine is not valid, using NEVER",interval);
machine->interval = TS_NEVER;
}
else
{
machine->interval = atoi(interval);
output_debug("interval being processed: %d", machine->interval);
}
}
extern "C" int convert_to_fsm(char *string, void *data, PROPERTY *prop)
{
statemachine *machine= (statemachine*)data;
// basic incoming double value (
if ( isdigit(string[0]) )
{
machine->value = atof(string);
return 1;
}
// copy string to local buffer because it's going to get trashed
char buffer[1025];
if (strlen(string)>sizeof(buffer)-1)
{
output_error("convert_to_fsm(string='%-.64s...',...) input string is too long", string);
return 0;
}
strcpy(buffer,string);
// parse tuples separated by semicolons
char *token = NULL, *next = NULL;
while ( (token=strtok_s(token==NULL?buffer:NULL,";",&next))!=NULL )
{
/* colon separate tuple parts */
char *param = token;
while ( *param!='\0' && (isspace(*param) || iscntrl(*param)) ) param++;
if ( *param=='\0' ) break;
/* isolate param and token and eliminte leading whitespaces */
char *value = strchr(token,':');
if (value==NULL)
value="1";
else
*value++ = '\0'; /* separate value from param */
while ( isspace(*value) || iscntrl(*value) ) value++;
// parse params
if ( strcmp(param,"value")==0 )
machine->value = atof(value);
else if ( strcmp(param,"state")==0 )
{
if ( !fsm_set_state_variable(machine,value) )
{
output_error("convert_to_fsm(string='%-.64s...',...) unable to set state variable name", string);
return 0;
}
}
else if ( strcmp(param,"reset")==0 )
{
fsm_reset(machine);
}
else if ( strcmp(param,"clear")==0 )
{
fsm_clear(machine);
}
else if ( strcmp(param,"interval")==0 )
{
fsm_interval(machine,value);
}
else if ( strcmp(param,"rule")==0 )
{
if ( !fsm_add_transition_rule(machine,value) )
{
output_error("convert_to_fsm(string='%-.64s...',...) unable to add transition rule", string);
return -1;
}
}
else if ( strcmp(param,"hold")==0 )
{
if ( !fsm_add_transition_hold(machine,value) )
{
output_error("convert_to_fsm(string='%-.64s...',...) unable to set transition hold", string);
return 0;
}
}
else if ( strcmp(param,"external")==0 )
{
if ( !fsm_set_external_machine(machine,value) )
{
output_error("convert_to_fsm(string='%-.64s...',...) unable to set external machine", string);
return 0;
}
}
else
{
output_error("convert_to_fsm(string='%-.64s...',...) '%s' is not recognized", string, param);
return 0;
}
}
return 1;
}
extern "C" int convert_from_fsm(char *buffer, int size, void *data, PROPERTY *prop)
{
statemachine *machine = (statemachine*)data;
return convert_from_double(buffer,size,&machine->value,prop);
}
|
d8d0a8296defcd23c17e65653cae42f1b2556829
|
05e1f94ae1a5513a222d38dfe4c3c6737cb84251
|
/Mulberry/branches/users/shared/externals/v4.1d1/XMLLib/Source/XMLSAXlibxml2.cp
|
da445e9cd39d8866dcfcbb22befe824a7a38b2e1
|
[
"Apache-2.0"
] |
permissive
|
eskilblomfeldt/mulberry-svn
|
16ca9d4d6ec05cbbbd18045c7b59943b0aca9335
|
7ed26b61244e47d4d4d50a1c7cc2d31efa548ad7
|
refs/heads/master
| 2020-05-20T12:35:42.340160
| 2014-12-24T18:03:50
| 2014-12-24T18:03:50
| 29,127,476
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,433
|
cp
|
XMLSAXlibxml2.cp
|
/*
Copyright (c) 2007 Cyrus Daboo. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Source for XMLSAXlibxml2 class
#include "XMLSAXlibxml2.h"
#include <libxml/parserInternals.h>
#include <cstdarg>
#include <strstream>
using namespace xmllib;
XMLSAXlibxml2::XMLSAXlibxml2()
{
mParseContext = NULL;
xmlSAXHandler handlers =
{
NULL, // internalSubset
NULL, // isStandalone
NULL, // hasInternalSubset
NULL, // hasExternalSubset
NULL, // resolveEntity
NULL, // getEntity
NULL, // entityDecl
NULL, // notationDecl
NULL, // attributeDecl
NULL, // elementDecl
NULL, // unparsedEntityDecl
NULL, // setDocumentLocator
_StartDocument, // startDocument
_EndDocument, // endDocument
_StartElement, // startElement
_EndElement, // endElement
NULL, // reference
_Characters, // characters
NULL, // ignorableWhitespace
NULL, // processingInstruction
_Comment, // comment
_Warning, // warning
_Error, // error
_FatalError, // fatalError
NULL, // getParameterEntity
NULL, // cdataBlock
NULL // externalSubset
};
mSAXHandler = handlers;
mError = false;
}
XMLSAXlibxml2::~XMLSAXlibxml2()
{
if(mParseContext)
::xmlFreeParserCtxt(mParseContext);
}
void XMLSAXlibxml2::ParseData(const char* data)
{
mParseContext = ::xmlCreateFileParserCtxt("test.xml");
mParseContext->sax = &mSAXHandler;
mParseContext->userData = this;
::xmlKeepBlanksDefault(0);
::xmlParseDocument(mParseContext);
mParseContext->sax = NULL;
::xmlFreeParserCtxt(mParseContext);
mParseContext = NULL;
}
void XMLSAXlibxml2::ParseFile(const char* file)
{
mParseContext = ::xmlCreateFileParserCtxt(file);
mParseContext->sax = &mSAXHandler;
mParseContext->userData = this;
::xmlKeepBlanksDefault(0);
::xmlParseDocument(mParseContext);
mParseContext->sax = NULL;
::xmlFreeParserCtxt(mParseContext);
mParseContext = NULL;
}
void XMLSAXlibxml2::HandleException(const std::exception& ex)
{
XMLParserSAX::HandleException(ex);
::xmlStopParser(mParseContext);
}
#pragma mark ____________________________callbacks
void XMLSAXlibxml2::_StartDocument(void* parser)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Do callback method
try
{
xmlparser->StartDocument();
}
catch(const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_EndDocument(void* parser)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Don't bother if on error state
if (xmlparser->mError)
return;
// Do callback method
try
{
xmlparser->EndDocument();
}
catch (const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_StartElement(void* parser, const xmlChar* name, const xmlChar** p)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Get attributes
XMLAttributeList attrs;
if (p)
{
for(const xmlChar** item = p; item && *item; item++)
{
std::string name = (const char *) *item++;
std::string value = (const char *) *item;
attrs.push_back(new XMLAttribute(name, value));
}
}
// Do callback method
try
{
xmlparser->StartElement(std::string((const char *) name), attrs);
}
catch (const std::exception& e)
{
xmlparser->HandleException(e);
}
// Clean-up
XMLAttributeList_DeleteItems(attrs);
};
void XMLSAXlibxml2::_EndElement(void* parser, const xmlChar* name)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Do callback method
try
{
xmlparser->EndElement(std::string((const char *) name));
}
catch(const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_Characters(void* parser, const xmlChar* ch, int len)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Do callback method
try
{
xmlparser->Characters(std::string((const char *) ch, len));
}
catch(const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_Comment(void* parser, const xmlChar* value)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Do callback method
try
{
xmlparser->Comment(std::string((const char *) value));
}
catch(const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_Warning(void* parser, const char* fmt, ...)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Get arguments
std::va_list arg;
char buff[1024];
va_start(arg, fmt);
std::vsprintf(buff, fmt, arg);
va_end(arg);
// Do callback method
try
{
xmlparser->Warning(std::string(buff));
}
catch (const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_Error(void* parser, const char* fmt, ...)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Don't bother if on error state
if (xmlparser->mError)
return;
// Get arguments
std::va_list arg;
char buff[1024];
va_start(arg, fmt);
std::vsprintf(buff, fmt, arg);
va_end(arg);
// Do callback method
try
{
xmlparser->Error(std::string(buff));
}
catch (const std::exception& e)
{
xmlparser->HandleException(e);
}
};
void XMLSAXlibxml2::_FatalError(void* parser, const char *fmt, ...)
{
// Get parser object
XMLSAXlibxml2* xmlparser = static_cast<XMLSAXlibxml2*>(parser);
// Don't bother if on error state
if (xmlparser->mError)
return;
// Get arguments
std::va_list arg;
char buff[1024];
va_start(arg, fmt);
std::vsprintf(buff, fmt, arg);
va_end(arg);
// Do callback method
try
{
xmlparser->FatalError(std::string(buff));
}
catch (const std::exception& e)
{
xmlparser->HandleException(e);
}
};
|
700d6fd3a327353833a045e0f4ee625147e33243
|
0cc681e190afaf1d3055c3f7fa9327d2ae6632ae
|
/Templates/template-list.cpp
|
7be7f31f119fe5c57bf5e3c37b991c1b13519af4
|
[] |
no_license
|
rtspeaks360/dsa-implementations
|
06ffb7cede0b62ac3ed70a3af2b5e7881f19e2e4
|
437d0035adaaea58cd071c07f85923acc97dba9f
|
refs/heads/master
| 2021-09-16T05:36:10.358330
| 2018-06-17T07:41:25
| 2018-06-17T07:41:25
| 103,792,527
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 887
|
cpp
|
template-list.cpp
|
/*
* @Author: sherlock
* @Date: 2017-08-04 19:22:08
* @Last Modified by: sherlock
* @Last Modified time: 2017-09-14 11:32:16
*/
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;
int main(){
list<int> l;
l.push_back(0);
for(int i = 0; i< 10; i++){
l.push_back(i + 1);
}
for(list<int>::iterator itr = l.begin(); itr!=l.end(); itr++){
cout << *itr << endl;
}
cout << endl;
list<int>::iterator it = find(l.begin(), l.end(), 8);
l.insert(it, 5);
// for(list<int>::iterator itr = l.begin(); itr!=l.end(); itr++){
// cout << *itr << endl;
// }
// cout << endl;
it = find(l.begin(), l.end(), 7);
cout << *it;
cout << endl;
l.erase(it);
for(list<int>::iterator itr = l.begin(); itr!=l.end(); itr++){
cout << *itr << endl;
}
cout << endl;
l.pop_front()
// cout << l.pop_front();
// cout << l.pop_back();
return 0;
}
|
db2a2e6d517c693b6fe35a31dba353ba4e0ea8e1
|
9b5116e70ae1cbc10a058747bc2c36bc4159158d
|
/filterdoubleFcb/Data.cpp
|
b0ee5c2754e0bc659a82e6aa5b6ee3fdd7836d33
|
[] |
no_license
|
wjcsharp/SfilterdoubleFcb
|
37da44edff73fc453cded1af1cb7e8458c8706dd
|
0257b1b22ba302fa3150dae9148acaee95dac018
|
refs/heads/master
| 2020-06-05T03:20:22.594044
| 2019-06-09T17:02:32
| 2019-06-09T17:02:32
| 192,295,926
| 1
| 0
| null | 2019-06-17T07:25:12
| 2019-06-17T07:25:11
| null |
GB18030
|
C++
| false
| false
| 21,431
|
cpp
|
Data.cpp
|
#include "Data.h"
#include "Utils.h"
#include "Common.h"
#include "WDK.h"
#include "Data_Extern_C.h"
//#include "Log.h"
PCHAR ImportFunName = "StartGuard";//"InitDll";
CHAR DllNameStr[MAX_PATH] = { 0 };// = "Guard.dll";
CHAR DllNameStr64[MAX_PATH] = { 0 };// = "Guard64.dll";
//CHAR DllNameStr[MAX_PATH] = "C:\\Guard.dll";
//CHAR DllNameStr64[MAX_PATH] = "C:\\Guard64.dll";
//CHAR DllNameStr[MAX_PATH] = "Guard.dll";
//WCHAR BackupDriveLetter[MAX_PATH] = {0};
//WCHAR BackupDir[MAX_PATH] = {0};
WCHAR BackupDriveLetter[MAX_PATH] = L"\\??\\C:";
WCHAR BackupDir[MAX_PATH] = L"\\$BackupDir$";
WCHAR SystemRootDriveLetter[10] = { 0 };
WCHAR SystemRootPathName[MAX_PATH] = { 0 };
WCHAR PolicyPath[MAX_PATH] = { 0 };
WCHAR DriverPath[MAX_PATH] = { 0 };
//PWCHAR BackupDriveLetter = L"\\??\\C:";
//PWCHAR BackupDriveLetter = L"\\Device\\LanmanRedirector";
//PWCHAR BackupDir = L"\\$BackupDir$";
//PWCHAR BackupDir = L"\\192.168.0.195\\share\\BackupDir";
int nTime = 0;
SFS_DATA SFSData;
ReprocessInfo ReprocInfo;
ZwWriteVirtualMemoryType pZwWriteVirtualMemory;
ZwProtectVirtualMemoryType pZwProtectVirtualMemory;
FsRtlRegisterFileSystemFilterCallbacksType pFsRtlRegisterFileSystemFilterCallbacks;
IoAttachDeviceToDeviceStackSafeType pIoAttachDeviceToDeviceStackSafe;
IoEnumerateDeviceObjectListType pIoEnumerateDeviceObjectList;
IoGetLowerDeviceObjectType pIoGetLowerDeviceObject;
IoGetDeviceAttachmentBaseRefType pIoGetDeviceAttachmentBaseRef;
IoGetDiskDeviceObjectType pIoGetDiskDeviceObject;
IoGetAttachedDeviceReferenceType pIoGetAttachedDeviceReference;
RtlGetVersionType pRtlGetVersion;
ObCreateObjectType pObCreateObject;
PsRemoveLoadImageNotifyRoutineType pPsRemoveLoadImageNotifyRoutine;
// ZwWaitForSingleObject start
// ZwUnlockFile end
VOID InitData(PDRIVER_OBJECT DriverObject) {
SFSData.NodeTypeCode = SFS_NTC_DATA_HEADER;
SFSData.NodeByteSize = sizeof(SFS_DATA);
SFSData.DriverObject = DriverObject;
SFSData.CurrentProcess = PsGetCurrentProcess();
SFSData.WorkModeFlag = FALSE;
SFSData.OnlineFlag = FALSE;
InitializeListHead(&SFSData.ProcessInfoList);
/////////////////////////////////////////////////
InitializeListHead(&ReprocInfo.ProcessInfoList);
/////////////////////////////////////////////////
ExInitializeResourceLite(&SFSData.ProcessInfoListResource);
InitPathLookasideList();
}
#ifdef _WIN64
ULONG_PTR GetPreviousFunctionAddress64(PWCHAR FunctionName, ULONG PreviousCount)
{
PUCHAR Begin = 0;
PUCHAR End = 0;
ULONG Index = 0;
UNICODE_STRING RoutineName;
UNICODE_STRING EndRoutineName;
RtlInitUnicodeString(&EndRoutineName, L"ZwWaitForSingleObject");
RtlInitUnicodeString(&RoutineName, FunctionName);
Begin = (PUCHAR) MmGetSystemRoutineAddress(&RoutineName);
if (!Begin)
{
return 0;
}
End = (PUCHAR) MmGetSystemRoutineAddress(&EndRoutineName);
if (!End)
{
return 0;
}
if (0x48 == *Begin && 0x8B == *(Begin + 1) && 0xC4 == *(Begin + 2))
{
Begin--;
for (; Begin >= End; Begin--)
{
if (0x48 == *Begin && 0x8B == *(Begin + 1) && 0xC4 == *(Begin + 2))
{
PreviousCount--;
if (PreviousCount == 0)
{
return (ULONG_PTR) Begin;
}
}
}
return 0;
}
return 0;
}
#else
ULONG GetPreviousFunctionAddress32(PWCHAR FunctionName, ULONG PreCount)
{
PUCHAR Begin = 0;
PUCHAR End = 0;
ULONG Index = 0;
UNICODE_STRING RoutineName;
UNICODE_STRING EndRoutineName;
RtlInitUnicodeString(&EndRoutineName, L"ZwAccessCheckAndAuditAlarm");
RtlInitUnicodeString(&RoutineName, FunctionName);
Begin = (PUCHAR) MmGetSystemRoutineAddress(&RoutineName);
if (!Begin)
{
return 0;
}
End = (PUCHAR) MmGetSystemRoutineAddress(&EndRoutineName);
if (0xB8 == *Begin)
{
Begin++;
Index = *(PULONG) Begin;
Index -= PreCount;
Begin -= sizeof(ULONG);
for (; Begin >= End; Begin--)
{
if (0xB8 == *Begin
&& Index == *(PULONG) (Begin + 1)
&& 0x8D == *(Begin + 1 + sizeof(ULONG)))
{
return (ULONG) Begin;
}
}
return 0;
}
return 0;
}
ULONG GetNextFunctionAddress32(PWCHAR FunctionName, ULONG NextCount)
{
PUCHAR Begin = 0;
PUCHAR End = 0;
ULONG Index = 0;
UNICODE_STRING RoutineName;
UNICODE_STRING EndRoutineName;
RtlInitUnicodeString(&EndRoutineName, L"ZwYieldExecution");
RtlInitUnicodeString(&RoutineName, FunctionName);
Begin = (PUCHAR) MmGetSystemRoutineAddress(&RoutineName);
if (!Begin)
{
return 0;
}
End = (PUCHAR) MmGetSystemRoutineAddress(&EndRoutineName);
if (0xB8 == *Begin)
{
Begin++;
Index = *(PULONG) Begin;
Index += NextCount;
Begin += sizeof(ULONG);
for (; Begin <= End; Begin++)
{
if (0xB8 == *Begin
&& Index == *(PULONG) (Begin + 1)
&& 0x8D == *(Begin + 1 + sizeof(ULONG)))
{
return (ULONG) Begin;
}
}
return 0;
}
return 0;
}
#endif
ULONG_PTR GetZwSetInformationToken()
{
UNICODE_STRING RoutineName;
PVOID FunAddr = NULL;
RtlInitUnicodeString(&RoutineName, L"ZwSetInformationToken");
FunAddr = MmGetSystemRoutineAddress(&RoutineName);
if (FunAddr)
{
return (ULONG_PTR) FunAddr;
}
#ifdef _WIN64
return GetPreviousFunctionAddress64(L"ZwSetSecurityObject", 7);
#else
return GetNextFunctionAddress32(L"ZwSetInformationThread", 1);
#endif
}
ULONG_PTR GetZwProtectVirtualMemory()
{
/*
#ifdef _WIN64
return GetPreviousFunctionAddress64(L"ZwQuerySection", 1);
#else
return GetPreviousFunctionAddress32(L"ZwPulseEvent", 1);
#endif
*/
#if (WINVER <= _WIN32_WINNT_WINXP)
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> _WIN32_WINNT_WINXP\n"));
return GetPreviousFunctionAddress32(L"ZwPulseEvent", 1);
#elif (WINVER <= _WIN32_WINNT_WIN7)
#ifdef _WIN64
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> _WIN32_WINNT_WIN7 WIN64\n"));
return GetPreviousFunctionAddress64(L"ZwQuerySection", 1);
#else
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> _WIN32_WINNT_WIN7 WIN32\n"));
return GetPreviousFunctionAddress32(L"ZwPulseEvent", 1);
#endif
#elif (WINVER <= _WIN32_WINNT_WINBLUE)
#ifdef _WIN64
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> _WIN32_WINNT_WIN8 WIN64\n"));
return GetPreviousFunctionAddress64(L"ZwQuerySection", 1);
#else
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> _WIN32_WINNT_WIN8 WIN32\n"));
return GetNextFunctionAddress32(L"ZwPulseEvent", 1);
#endif
#else
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!GetZwProtectVirtualMemory -> WINVER = %x\n", WINVER));
return 0;
#endif
}
//
//NTSTATUS IoSuccessCompleteRequest(PIRP Irp)
//{
// Irp->IoStatus.Status = STATUS_SUCCESS;
// Irp->IoStatus.Information = FILE_OPENED;
//
// IoCompleteRequest(Irp, IO_NO_INCREMENT);
//
// return STATUS_SUCCESS;
//}
//// Device Info List
//
//VOID DeviceInfoListInit()
//{
// InitializeListHead(&SFSData.DeviceInfoList);
// ExInitializeResourceLite(&SFSData.DeviceInfoListResource);
//}
//BOOLEAN IsExsitDeviceInfoForMiniFsDevice(IN PVOID Object)
//{
// PLIST_ENTRY Links;
// PDEVICE_INFO_NODE Node;
//
// for(Links = SFSData.DeviceInfoList.Flink; Links != &SFSData.DeviceInfoList; Links = Links->Flink)
// {
// Node =(PDEVICE_INFO_NODE)Links;
// if(Node->MiniFsDevice == Object)
// {
// return TRUE;
// }
// }
//
// return FALSE;
//}
//
//PDEVICE_INFO_NODE GetDeviceInfoForMiniFsDevice(IN PVOID Object)
//{
// PLIST_ENTRY Links;
// PDEVICE_INFO_NODE Node;
//
// ExAcquireResourceSharedLite(&SFSData.DeviceInfoListResource, TRUE);
//
// for(Links = SFSData.DeviceInfoList.Flink; Links != &SFSData.DeviceInfoList; Links = Links->Flink)
// {
// Node =(PDEVICE_INFO_NODE)Links;
// if(Node->MiniFsDevice == Object)
// {
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
// return Node;
// }
// }
//
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
//
// return NULL;
//}
//
//
//PDEVICE_INFO_NODE GetDeviceInfoForRealDiskDevice(IN PVOID Object)
//{
// PLIST_ENTRY Links;
// PDEVICE_INFO_NODE Node;
//
// ExAcquireResourceSharedLite(&SFSData.DeviceInfoListResource, TRUE);
//
// for (Links = SFSData.DeviceInfoList.Flink; Links != &SFSData.DeviceInfoList; Links = Links->Flink)
// {
// Node = (PDEVICE_INFO_NODE)Links;
// if (Node->RealDevice == Object)
// {
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
// return Node;
// }
// }
//
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
//
// return NULL;
//}
//VOID
//AddDeviceInfo(
// PDEVICE_OBJECT MiniFsDevice,
// PFS_DEVICE_OBJECT FsDevice,
// PDEVICE_OBJECT Device,
// PDEVICE_OBJECT RealDevice
// )
//{
// PDEVICE_INFO_NODE Node;
// ExAcquireResourceExclusiveLite(&SFSData.DeviceInfoListResource, TRUE);
//
// if(!IsExsitDeviceInfoForMiniFsDevice(MiniFsDevice))
// {
// Node =(PDEVICE_INFO_NODE)ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_INFO_NODE), 'tagN');
// if(!Node)
// {
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
// return;
// }
//
// Node->MiniFsDevice = MiniFsDevice;
// Node->FsDevice = FsDevice;
// Node->Device = Device;
// Node->RealDevice = RealDevice;
//
// InsertHeadList(&SFSData.DeviceInfoList, (PLIST_ENTRY)Node);
//
// }
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
//}
//
//VOID RemoveDeviceInfo(IN PVOID Object)
//{
// PLIST_ENTRY Links;
// PDEVICE_INFO_NODE Node;
//
// ExAcquireResourceExclusiveLite(&SFSData.DeviceInfoListResource, TRUE);
//
// for(Links = SFSData.DeviceInfoList.Flink; Links != &SFSData.DeviceInfoList; Links = Links->Flink)
// {
// Node =(PDEVICE_INFO_NODE)Links;
// if(Node->MiniFsDevice == Object)
// {
// RemoveEntryList((PLIST_ENTRY)Links);
// ExFreePool(Node);
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
// return;
// }
// }
//
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
//}
//
//VOID RemoveDeviceInfoForRealDiskDevice(IN PVOID Object)
//{
// PLIST_ENTRY Links;
// PDEVICE_INFO_NODE Node;
//
// ExAcquireResourceExclusiveLite(&SFSData.DeviceInfoListResource, TRUE);
//
// for (Links = SFSData.DeviceInfoList.Flink; Links != &SFSData.DeviceInfoList; Links = Links->Flink)
// {
// Node = (PDEVICE_INFO_NODE)Links;
// if (Node->RealDevice == Object)
// {
// RemoveEntryList((PLIST_ENTRY)Links);
// ExFreePool(Node);
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
// return;
// }
// }
//
// ExReleaseResourceLite(&SFSData.DeviceInfoListResource);
//}
// Fcb List
BOOLEAN IsExistFcbFromVcbList(IN PVCB Vcb, IN PFCB Fcb)
{
PLIST_ENTRY Links;
PFCB_NODE Node;
for (Links = Vcb->FcbList.Flink; Links != &Vcb->FcbList; Links = Links->Flink)
{
Node = (PFCB_NODE) Links;
if (Node->Fcb == Fcb)
{
return TRUE;
}
}
return FALSE;
}
PFCB GetFcbFromVcbList(IN PVCB Vcb, IN UNICODE_STRING FullFileName)
{
PLIST_ENTRY Links;
PFCB_NODE Node;
for (Links = Vcb->FcbList.Flink; Links != &Vcb->FcbList; Links = Links->Flink)
{
Node = (PFCB_NODE) Links;
if (RtlCompareUnicodeString(&Node->Fcb->FullFileName, &FullFileName, TRUE) == 0)
{
return Node->Fcb;
}
}
return NULL;
}
VOID AddFcbToVcbList(IN PVCB Vcb, IN PFCB Fcb)
{
PFCB_NODE Node;
if (!IsExistFcbFromVcbList(Vcb, Fcb))
{
Node = (PFCB_NODE) ExAllocatePoolWithTag(NonPagedPool, sizeof(FCB_NODE), 'tagN');
if (Node)
{
Node->Fcb = Fcb;
InsertHeadList(&Vcb->FcbList, (PLIST_ENTRY) Node);
}
}
}
VOID RemoveFcbFromVcbList(IN PVCB Vcb, IN PFCB Fcb)
{
PLIST_ENTRY Links;
PFCB_NODE Node;
for (Links = Vcb->FcbList.Flink; Links != &Vcb->FcbList; Links = Links->Flink)
{
Node = (PFCB_NODE) Links;
if (Node->Fcb == Fcb)
{
RemoveEntryList((PLIST_ENTRY) Links);
ExFreePool(Node);
return;
}
}
}
/*
* 获取ring0层函数SSDT地址
*/
BOOLEAN InitFunction()
{
UNICODE_STRING DestinationString;
RtlInitUnicodeString(&DestinationString, L"FsRtlRegisterFileSystemFilterCallbacks");
pFsRtlRegisterFileSystemFilterCallbacks = (FsRtlRegisterFileSystemFilterCallbacksType) MmGetSystemRoutineAddress(&DestinationString);
if (!pFsRtlRegisterFileSystemFilterCallbacks)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoAttachDeviceToDeviceStackSafe");
pIoAttachDeviceToDeviceStackSafe = (IoAttachDeviceToDeviceStackSafeType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoAttachDeviceToDeviceStackSafe)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoEnumerateDeviceObjectList");
pIoEnumerateDeviceObjectList = (IoEnumerateDeviceObjectListType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoEnumerateDeviceObjectList)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoGetLowerDeviceObject");
pIoGetLowerDeviceObject = (IoGetLowerDeviceObjectType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoGetLowerDeviceObject)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoGetDeviceAttachmentBaseRef");
pIoGetDeviceAttachmentBaseRef = (IoGetDeviceAttachmentBaseRefType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoGetDeviceAttachmentBaseRef)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoGetDiskDeviceObject");
pIoGetDiskDeviceObject = (IoGetDiskDeviceObjectType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoGetDiskDeviceObject)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"IoGetAttachedDeviceReference");
pIoGetAttachedDeviceReference = (IoGetAttachedDeviceReferenceType) MmGetSystemRoutineAddress(&DestinationString);
if (!pIoGetAttachedDeviceReference)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"RtlGetVersion");
pRtlGetVersion = (RtlGetVersionType) MmGetSystemRoutineAddress(&DestinationString);
if (!pRtlGetVersion)
{
return FALSE;
}
RtlInitUnicodeString(&DestinationString, L"ObCreateObject");
pObCreateObject = (ObCreateObjectType) MmGetSystemRoutineAddress(&DestinationString);
if (!pObCreateObject)
{
return FALSE;
}
#if 1
pZwProtectVirtualMemory = (ZwProtectVirtualMemoryType) GetZwProtectVirtualMemory();
if (!pZwProtectVirtualMemory)
{
return FALSE;
}
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitFunction -> ZwProtectVirtualMemory = %p \n", pZwProtectVirtualMemory));
#endif
//pZwWriteVirtualMemory = (ZwWriteVirtualMemoryType)GetZwWriteVirtualMemory();
return TRUE;
}
NTSTATUS InitSystemRootPath()
{
NTSTATUS Status = STATUS_UNSUCCESSFUL;
WCHAR SystemRootName[20] = { 0 };
WCHAR DriveLetter[2] = { 0 };
PWCHAR SystemRootPathBuf = NULL;
PWCHAR VolumeNameBuf = NULL;
PWCHAR SystemRootNameTemp = NULL;
UNICODE_STRING SystemRootLinkName;
UNICODE_STRING SystemRootPath;
UNICODE_STRING VolumeName;
__try
{
SystemRootPathBuf = AllocPathLookasideList();
if (!SystemRootPathBuf)
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> AllocPathLookasideList is null.\n"));
__leave;
}
VolumeNameBuf = AllocPathLookasideList();
if (!VolumeNameBuf)
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> AllocPathLookasideList is null.\n"));
__leave;
}
RtlInitUnicodeString(&SystemRootLinkName, L"\\SystemRoot");
RtlInitEmptyUnicodeString(&SystemRootPath, SystemRootPathBuf, MAX_PATH_SIZE);
RtlInitEmptyUnicodeString(&VolumeName, VolumeNameBuf, MAX_PATH_SIZE);
Status = GetSymbolicLink(&SystemRootLinkName, &SystemRootPath);
if (!NT_SUCCESS(Status))
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> GetSymbolicLink fail. Status = %x \n", Status));
__leave;
}
//win8以上以\结尾, 去除掉
SystemRootNameTemp = (SystemRootPath.Buffer + wcslen(SystemRootPath.Buffer) - 1);
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> GetSymbolicLink SystemRootPath1 = %S \n", SystemRootNameTemp));
if (*SystemRootNameTemp == L'\\') {
*SystemRootNameTemp = 0;
SystemRootPath.Length -= sizeof(wchar_t);
}
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> GetSymbolicLink SystemRootPath = %S \n", SystemRootPath.Buffer));
SystemRootNameTemp = wcsrchr(SystemRootPath.Buffer, L'\\');
if (!SystemRootNameTemp)
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> wcsrchr return null\n."));
Status = STATUS_UNSUCCESSFUL;
__leave;
}
if (wcslen(SystemRootNameTemp) >= sizeof(SystemRootName) / sizeof(WCHAR))
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> length error\n."));
Status = STATUS_UNSUCCESSFUL;
__leave;
}
RtlStringCbCopyW(SystemRootName, sizeof(SystemRootName), SystemRootNameTemp);
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> SystemRootName = %S \n", SystemRootName));
SystemRootPath.Length -= (wcslen(SystemRootName) * sizeof(WCHAR));
while (TRUE)
{
Status = GetSymbolicLink(&SystemRootPath, &VolumeName);
if (!NT_SUCCESS(Status))
{
break;
}
RtlZeroMemory(SystemRootPath.Buffer, SystemRootPath.MaximumLength);
SystemRootPath.Length = 0;
RtlAppendUnicodeStringToString(&SystemRootPath, &VolumeName);
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> VolumeName = %S \n", VolumeName.Buffer));
}
if (!GetDriverLetter(&VolumeName, DriveLetter))
{
//DebugTrace(DEBUG_TRACE_ERROR, ("Data!InitSystemRootPath -> GetDriverLetter return FALSE.\n"));
// RtlStringCchPrintfW(DriveLetter, MAX_PATH, L"%c", 65);
DriveLetter[0] = L'C';
// Status = STATUS_UNSUCCESSFUL;
// __leave;
}
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> DriveLetter = %S \n", DriveLetter));
RtlStringCbCopyW(SystemRootDriveLetter, sizeof(SystemRootDriveLetter), L"\\??\\");
RtlStringCbCatW(SystemRootDriveLetter, sizeof(SystemRootDriveLetter), DriveLetter);
RtlStringCbCatW(SystemRootDriveLetter, sizeof(SystemRootDriveLetter), L":");
RtlStringCbCatW(SystemRootPathName, sizeof(SystemRootPathName), SystemRootName);
RtlStringCbCopyW(PolicyPath, sizeof(PolicyPath), L"\\??\\");
RtlStringCbCatW(PolicyPath, sizeof(PolicyPath), DriveLetter);
RtlStringCbCatW(PolicyPath, sizeof(PolicyPath), L":");
RtlStringCbCatW(PolicyPath, sizeof(PolicyPath), SystemRootName);
RtlStringCbCatW(PolicyPath, sizeof(PolicyPath), L"\\iSafe.dat");
RtlStringCbCopyW(DriverPath, sizeof(DriverPath), L"\\??\\");
RtlStringCbCatW(DriverPath, sizeof(DriverPath), DriveLetter);
RtlStringCbCatW(DriverPath, sizeof(DriverPath), L":");
RtlStringCbCatW(DriverPath, sizeof(DriverPath), SystemRootName);
RtlStringCbCatW(DriverPath, sizeof(DriverPath), L"\\system32\\drivers\\FileSafe.sys");
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> PolicyPath = %S \n", PolicyPath));
//DebugTrace(DEBUG_TRACE_DEBUG, ("Data!InitSystemRootPath -> DriverPath = %S \n", DriverPath));
Status = STATUS_SUCCESS;
}
__finally
{
if (SystemRootPathBuf)
{
FreePathLookasideList(SystemRootPathBuf);
}
if (VolumeNameBuf)
{
FreePathLookasideList(VolumeNameBuf);
}
}
return Status;
}
// Process Name
ULONG EprocessNameOffset = 0;
BOOLEAN GetEProcessNameOffset()
{
ULONG i;
UCHAR *Eprocess;
Eprocess = (UCHAR *) IoGetCurrentProcess();
for (i = 0; i < 0x3000; i++)
{
if (0 == strncmp("System", (const char*) (Eprocess + i), 6))
{
EprocessNameOffset = i;
return TRUE;
}
}
return FALSE;
}
PCHAR GetCurrentProcessName()
{
PCHAR Eprocess;
if (!EprocessNameOffset)
{
return NULL;
}
Eprocess = (PCHAR) IoGetCurrentProcess();
return(Eprocess + EprocessNameOffset);
}
BOOLEAN CheckProcess(PCHAR ProcessName)
{
PCHAR CurrentProcessName;
CurrentProcessName = GetCurrentProcessName();
if (0 == _stricmp(CurrentProcessName, ProcessName))
{
return TRUE;
}
return FALSE;
}
BOOLEAN CheckProcessW(PWCHAR ProcessName)
{
PAGED_CODE();
BOOLEAN Result = FALSE;
ANSI_STRING AnsiString;
UNICODE_STRING UnicodeString;
UNICODE_STRING NewUnicodeString;
PWCHAR ProcessNameBuf;
PCHAR CurrentProcessName;
RtlInitUnicodeString(&UnicodeString, ProcessName);
CurrentProcessName = GetCurrentProcessName();
RtlInitAnsiString(&AnsiString, CurrentProcessName);
ProcessNameBuf = (PWCHAR) ExAllocatePoolWithTag(NonPagedPool, MAX_PATH_SIZE, 'pnam');
if (!ProcessNameBuf)
{
return FALSE;
}
RtlZeroMemory(ProcessNameBuf, MAX_PATH_SIZE);
RtlInitEmptyUnicodeString(&NewUnicodeString, ProcessNameBuf, MAX_PATH_SIZE);
RtlAnsiStringToUnicodeString(&NewUnicodeString, &AnsiString, FALSE);
if (RtlCompareUnicodeString(&NewUnicodeString, &UnicodeString, TRUE) == 0)
{
Result = TRUE;
}
ExFreePool(ProcessNameBuf);
return Result;
}
NPAGED_LOOKASIDE_LIST PathNameBufferPagedList;
VOID InitPathLookasideList()
{
ExInitializeNPagedLookasideList(&PathNameBufferPagedList, NULL, NULL, 0, MAX_PATH_SIZE, 'PNAM', 0);
}
VOID DeletePathLookasideList()
{
ExDeleteNPagedLookasideList(&PathNameBufferPagedList);
}
PWCHAR AllocPathLookasideList()
{
PWCHAR PathName;
PathName = (PWCHAR) ExAllocateFromNPagedLookasideList(&PathNameBufferPagedList);
if (!PathName)
{
return NULL;
}
RtlZeroMemory(PathName, MAX_PATH_SIZE);
return PathName;
}
VOID FreePathLookasideList(PVOID Path)
{
ExFreeToNPagedLookasideList(&PathNameBufferPagedList, Path);
}
PWCHAR AllocBufferNonPagedPool()
{
PWCHAR Buffer;
Buffer = (PWCHAR) ExAllocatePoolWithTag(NonPagedPool, MAX_PATH_SIZE, 'BUFF');
if (!Buffer)
{
return NULL;
}
RtlZeroMemory(Buffer, MAX_PATH_SIZE);
return Buffer;
}
|
b08f51cdc50bef1706919c64444311334a1d177c
|
9ffbb822643b959ec0e3f56669e29c582c76b266
|
/OOP WORKSHOPS/Workshop 7/in_lab/Hero.cpp
|
b7c63f09caaa08532063925ed7fc8160257b7c20
|
[] |
no_license
|
ihalemi/Object-Oriented-Software-Development-C-
|
c1d7410c5312ab254f5173de9755c7b4a2b9e5aa
|
b74a1a0eb01f76e181848f2182e44020958ed863
|
refs/heads/master
| 2021-07-13T03:49:05.791288
| 2020-06-22T01:53:55
| 2020-06-22T01:53:55
| 134,783,380
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,921
|
cpp
|
Hero.cpp
|
#include <iostream>
#include <iomanip>
#include "Hero.h"
using namespace std;
namespace sict {
Hero::Hero()
{
m_name[0] = '\0';
m_health = 0;
m_attack = 0;
}
Hero::Hero(const char* name, int health, int attack)
{
if (name[0] != '\0' && health > 0 && attack > 0) {
strncpy(m_name, name, 41);
m_health = health;
m_attack = attack;
}
else {
*this = Hero();
}
}
void Hero::operator-=(int attack)
{
if (attack > 0 && m_health > 0) {
m_health -= attack;
}
if (m_health < 0) {
m_health = 0;
}
}
bool Hero::isAlive() const
{
return (m_health > 0);
}
int Hero::attackStrength() const
{
if (m_name[0] != '\0' && m_health != 0 && m_attack != 0) {
return m_attack;
}
else {
return 0;
}
}
std::ostream& operator<<(std::ostream& os, const Hero& hero)
{
if (hero.m_name[0] != '\0' && hero.m_health != 0 && hero.m_attack != 0) {
os << hero.m_name;
}
else {
cout << "No hero" << endl;
}
return os;
}
const Hero& operator*(const Hero& first, const Hero& second)
{
cout << "Ancient Battle! " << first << " vs " << second << " : ";
// make copies of each hero
Hero a = first;
Hero b = second;
// pointer to the winner object
const Hero *winner = nullptr;
int round = 0;
for (int i = 0; i < max_rounds && (a.isAlive() && b.isAlive()); ++i)
{
a -= b.attackStrength();
b -= a.attackStrength();
round = i;
}
round++;
// in case both alive after 100 rounds have passed
bool isDraw = (a.isAlive() && b.isAlive());
// determine the winner if there is a draw
if (isDraw) {
winner = &first;
}
else if (a.isAlive()) {
winner = &first;
}
else {
winner = &second;
}
cout << "Winner is " << *winner << " in " << round << " rounds." << endl;
return *winner;
}
} // END OF NAMESPACE
|
176b227b30e7161d98ac502b150c69aec3eefcb6
|
33d1a04576a111496076f2295a977f28df3ea86e
|
/include/hera/metafunction.hpp
|
4ec4b2d9db0ebb1f0a05ee1b900f7be960b02b20
|
[
"MIT"
] |
permissive
|
frengels/hera
|
5f6bf60427eb956c94e05a9d2833a2373cca5b67
|
c043df47bd0c8315cfdfc39a41ede8f3785b1a5d
|
refs/heads/master
| 2022-12-09T23:30:07.893461
| 2020-09-01T01:27:48
| 2020-09-01T01:27:48
| 203,093,555
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 174
|
hpp
|
metafunction.hpp
|
#pragma once
namespace hera
{
template<typename T>
concept metafunction = requires
{
typename T::type;
}
&&std::is_trivial_v<T>&& std::is_empty_v<T>;
} // namespace hera
|
bb3e690554ca52a8eda0d257d6ec7ce3e4a69fba
|
bf66a97682a10e020e311538b2be16978761db57
|
/BSTree.h
|
d25767f393157f5eb0299cc88d42e6a71d76036e
|
[] |
no_license
|
Luis-Lamat/Integer-Binary-Search-Tree
|
5b0e90435260185545d83e17451f20fc9ddbcd29
|
477ca9d897568743c732071cf39eddca6e960fd8
|
refs/heads/master
| 2021-01-10T18:25:39.133599
| 2014-04-02T06:04:07
| 2014-04-02T06:04:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,768
|
h
|
BSTree.h
|
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
#include "tnode.h"
class BSTree //integer Binary Search Tree
{
private:
tnode *root;
void preorden(tnode *r);
void inorden(tnode *r);
void postorden(tnode *r);
void print_Leaf(tnode *r); //recursive leaf printing method
void dest(tnode *r);
int how_Many_Children_In(tnode *r);
int predecessor(tnode *r);
int successor(tnode *r);
int countRec(tnode *r); //recursive node counting method
int heightRec(tnode *r); //recursive height count
int get_Width_Rec(tnode* r, int level); //recursive level width count
int get_Max_Width_Rec(tnode* r); //recursive max width on tree count
public:
BSTree();
~BSTree();
bool find(int d);
bool insert(int d);
bool erase(int d);
void print(int option);
int count();
void ancestors(int d);
int height();
int level_Of_Number(int d);
int max_Width();
};
void BSTree::dest(tnode *r){
if (r != NULL){
dest(r->getLeft());
dest(r->getRight());
delete r;
}
}
BSTree::BSTree(){
root = NULL;
}
BSTree::~BSTree(){
dest(root);
}
bool BSTree::find(int d){
tnode *aux = root;
while (aux != NULL)
{
if (aux->getData() == d)
return true;
aux = (d < aux->getData()) ? aux->getLeft() : aux->getRight();
}
return false;
}
bool BSTree::insert(int d){
if (root == NULL)
root = new tnode(d);
else {
tnode *parent = NULL, *aux = root;
while (aux != NULL){
if (aux->getData() == d)
return false;
parent = aux;
aux = (d < aux->getData()) ? aux->getLeft() : aux->getRight();
}
tnode *added_Node = new tnode(d);
if (d < parent->getData()) {
parent->setLeft(added_Node);
} else {
parent->setRight(added_Node);
}
}
return true;
}
void BSTree::preorden(tnode *r){
if (r != NULL) {
cout << r->getData() << " ";
preorden(r->getLeft());
preorden(r->getRight());
}
}
void BSTree::inorden(tnode *r){
if (r != NULL) {
inorden(r->getLeft());
cout << r->getData() << " ";
inorden(r->getRight());
}
}
void BSTree::postorden(tnode *r){
if (r != NULL) {
postorden(r->getLeft());
postorden(r->getRight());
cout << r->getData() << " ";
}
}
void BSTree::print_Leaf(tnode *r){ //recursive leaf printing method
if (r != NULL){
if (how_Many_Children_In(r) == 0){
cout << r->getData() << " ";
} else {
print_Leaf(r->getLeft());
print_Leaf(r->getRight());
}
}
}
void BSTree::print(int option){
switch (option){
case 1: preorden(root);
break;
case 2: inorden(root);
break;
case 3: postorden(root);
break;
case 4: print_Leaf(root);
break;
}
cout << endl;
}
int BSTree::how_Many_Children_In(tnode *r){
int count = 0;
if (r->getLeft())
count++;
if (r->getRight())
count++;
return count;
}
int BSTree::predecessor(tnode *r){
tnode *aux = r->getLeft();
while (aux->getRight() != NULL){
aux = aux->getRight();
}
return aux->getData();
}
int BSTree::successor(tnode *r){
tnode *aux = r->getRight();
while (aux->getLeft() != NULL){
aux = aux->getLeft();
}
return aux->getData();
}
bool BSTree::erase(int d){
if (root == NULL)
return false;
tnode *parent = NULL;
tnode *aux = root;
while (aux->getData() != d){
parent = aux;
aux = (d < aux->getData()) ? aux->getLeft() : aux->getRight();
if (aux == NULL)
return false;
}
int number_Of_Children = how_Many_Children_In(aux);
if (number_Of_Children == 0){
if (parent == NULL){
delete root;
root = NULL;
} else {
if (parent->getData() > d)
parent->setLeft(NULL);
else
parent->setRight(NULL);
delete aux;
}
}
else if (number_Of_Children == 1){
if (parent == NULL)
root = (root->getLeft() != NULL) ? root->getLeft() : root->getRight();
else {
if (parent->getData() > d){
if (aux->getLeft() != NULL)
parent->setLeft(aux->getLeft());
else
parent->setLeft(aux->getRight());
}
else {
if (aux->getLeft() != NULL)
parent->setRight(aux->getLeft());
else
parent->setRight(aux->getRight());
}
}
delete aux;
}
else {
int p = predecessor(aux);
erase(p);
aux->setData(p);
}
return true;
}
int BSTree::countRec(tnode *r){ //recursive counting method
if (r != NULL)
//returning a count of 1 (root) + any nodes on the left or right from root...
return 1 + countRec(r->getLeft()) + countRec(r->getRight());
return 0;
}
int BSTree::count(){
return countRec(root);
}
void BSTree::ancestors(int d){
tnode *aux = root;
stack<int> lineage;
while (aux != NULL)
{
if (aux->getData() == d)
break;
lineage.push(aux->getData());
aux = (d < aux->getData()) ? aux->getLeft() : aux->getRight();
}
int size = lineage.size();
for (int i = 0; i < size; ++i){
cout << lineage.top() << " ";
lineage.pop();
}
}
int BSTree::heightRec(tnode *r){
if(r == NULL)
return 0;
int left = heightRec(r->getLeft());
int right = heightRec(r->getRight());
return (1 + ((left > right)? left : right));
}
int BSTree::height(){
return heightRec(root);
}
int BSTree::level_Of_Number(int d){
tnode *aux = root;
int level = 0;
while (aux != NULL)
{
if (aux->getData() == d)
return level;
aux = (d < aux->getData()) ? aux->getLeft() : aux->getRight();
level++;
}
return -1;
}
int BSTree::get_Max_Width_Rec(tnode* r){
int maxWidth = 0, width, h = heightRec(r);
for(int i = 1; i <= h; i++){
width = get_Width_Rec(r,i);
if(width > maxWidth)
maxWidth = width;
}
return maxWidth;
}
int BSTree::get_Width_Rec(tnode* r, int level){ //getting width of a level
if(r == NULL)
return 0;
if(level == 1)
return 1;
return get_Width_Rec(r->getLeft(), level-1) + get_Width_Rec(r->getRight(), level-1);
}
int BSTree::max_Width(){
return get_Max_Width_Rec(root);
}
|
a93673e2a8a16b1c88526475194673ec630c131b
|
4b18667dc583b6fb07abbca596bb44586219b80e
|
/src/TopicModel/SLDAModel.hpp
|
b3e749e585eb4b12a6150f283004cb6325fa5ca6
|
[
"MIT",
"BSD-3-Clause",
"MPL-2.0"
] |
permissive
|
bab2min/tomotopy
|
720e5a242773104d364a94d645ce8fa97f16a627
|
6ef712c63bad504801a981a4a52aa938c80f0bda
|
refs/heads/main
| 2023-08-17T08:21:38.380731
| 2023-07-16T12:17:14
| 2023-07-16T12:17:14
| 186,155,463
| 512
| 71
|
MIT
| 2023-03-29T19:29:06
| 2019-05-11T16:19:29
|
C++
|
UTF-8
|
C++
| false
| false
| 15,530
|
hpp
|
SLDAModel.hpp
|
#pragma once
#include "LDAModel.hpp"
#include "../Utils/PolyaGamma.hpp"
#include "SLDA.h"
/*
Implementation of sLDA using Gibbs sampling by bab2min
* Mcauliffe, J. D., & Blei, D. M. (2008). Supervised topic models. In Advances in neural information processing systems (pp. 121-128).
* Python version implementation using Gibbs sampling : https://github.com/Savvysherpa/slda
*/
namespace tomoto
{
namespace detail
{
template<typename _WeightType>
struct GLMFunctor
{
Vector regressionCoef; // Dim : (K)
GLMFunctor(size_t K = 0, Float mu = 0) : regressionCoef(Vector::Constant(K, mu))
{
}
virtual ISLDAModel::GLM getType() const = 0;
virtual std::unique_ptr<GLMFunctor> copy() const = 0;
virtual void updateZLL(
Vector& zLikelihood,
Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic, size_t docId, Float docSize) const = 0;
virtual void optimizeCoef(
const Matrix& normZ,
Float mu, Float nuSq,
Eigen::Block<Matrix, -1, 1, true> ys
) = 0;
virtual double getLL(Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const = 0;
virtual Float estimate(const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const = 0;
virtual ~GLMFunctor() {};
DEFINE_SERIALIZER_VIRTUAL(regressionCoef);
static void serializerWrite(const std::unique_ptr<GLMFunctor>& p, std::ostream& ostr)
{
if (!p) serializer::writeToStream<uint32_t>(ostr, 0);
else
{
serializer::writeToStream<uint32_t>(ostr, (uint32_t)p->getType() + 1);
p->serializerWrite(ostr);
}
}
static void serializerRead(std::unique_ptr<GLMFunctor>& p, std::istream& istr);
};
template<typename _WeightType>
struct LinearFunctor : public GLMFunctor<_WeightType>
{
Float sigmaSq = 1;
LinearFunctor(size_t K = 0, Float mu = 0, Float _sigmaSq = 1)
: GLMFunctor<_WeightType>(K, mu), sigmaSq(_sigmaSq)
{
}
ISLDAModel::GLM getType() const override { return ISLDAModel::GLM::linear; }
std::unique_ptr<GLMFunctor<_WeightType>> copy() const override
{
return std::make_unique<LinearFunctor>(*this);
}
void updateZLL(
Vector& zLikelihood,
Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic, size_t docId, Float docSize) const override
{
Float yErr = y -
(this->regressionCoef.array() * numByTopic.array().template cast<Float>()).sum()
/ docSize;
zLikelihood.array() *= (this->regressionCoef.array() / docSize / 2 / sigmaSq *
(2 * yErr - this->regressionCoef.array() / docSize)).exp();
}
void optimizeCoef(
const Matrix& normZ,
Float mu, Float nuSq,
Eigen::Block<Matrix, -1, 1, true> ys
) override
{
Matrix selectedNormZ = normZ.array().rowwise() * (!ys.array().transpose().isNaN()).template cast<Float>();
Matrix normZZT = selectedNormZ * selectedNormZ.transpose();
normZZT += Matrix::Identity(normZZT.cols(), normZZT.cols()) / nuSq;
this->regressionCoef = normZZT.colPivHouseholderQr().solve(selectedNormZ * ys.array().isNaN().select(0, ys).matrix());
}
double getLL(Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const override
{
Float estimatedY = estimate(numByTopic, docSize);
return -pow(estimatedY - y, 2) / 2 / sigmaSq;
}
Float estimate(const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const override
{
return (this->regressionCoef.array() * numByTopic.array().template cast<Float>()).sum()
/ std::max(docSize, 0.01f);
}
DEFINE_SERIALIZER_AFTER_BASE(GLMFunctor<_WeightType>, sigmaSq);
};
template<typename _WeightType>
struct BinaryLogisticFunctor : public GLMFunctor<_WeightType>
{
Float b = 1;
Vector omega;
BinaryLogisticFunctor(size_t K = 0, Float mu = 0, Float _b = 1, size_t numDocs = 0)
: GLMFunctor<_WeightType>(K, mu), b(_b), omega{ Vector::Ones(numDocs) }
{
}
ISLDAModel::GLM getType() const override { return ISLDAModel::GLM::binary_logistic; }
std::unique_ptr<GLMFunctor<_WeightType>> copy() const override
{
return std::make_unique<BinaryLogisticFunctor>(*this);
}
void updateZLL(
Vector& zLikelihood,
Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic, size_t docId, Float docSize) const override
{
Float yErr = b * (y - 0.5f) -
(this->regressionCoef.array() * numByTopic.array().template cast<Float>()).sum()
/ docSize * omega[docId];
zLikelihood.array() *= (this->regressionCoef.array() / docSize *
(yErr - omega[docId] / 2 * this->regressionCoef.array() / docSize)).exp();
}
void optimizeCoef(
const Matrix& normZ,
Float mu, Float nuSq,
Eigen::Block<Matrix, -1, 1, true> ys
) override
{
Matrix selectedNormZ = normZ.array().rowwise() * (!ys.array().transpose().isNaN()).template cast<Float>();
Matrix normZZT = selectedNormZ * Eigen::DiagonalMatrix<Float, -1>{ omega } * selectedNormZ.transpose();
normZZT += Matrix::Identity(normZZT.cols(), normZZT.cols()) / nuSq;
this->regressionCoef = normZZT
.colPivHouseholderQr().solve(selectedNormZ * ys.array().isNaN().select(0, b * (ys.array() - 0.5f)).matrix()
+ Vector::Constant(selectedNormZ.rows(), mu / nuSq));
RandGen rng;
for (size_t i = 0; i < (size_t)omega.size(); ++i)
{
if (std::isnan(ys[i])) continue;
omega[i] = math::drawPolyaGamma(b, (this->regressionCoef.array() * normZ.col(i).array()).sum(), rng);
}
}
double getLL(Float y, const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const override
{
Float z = (this->regressionCoef.array() * numByTopic.array().template cast<Float>()).sum()
/ std::max(docSize, 0.01f);
return b * (y * z - log(1 + exp(z)));
}
Float estimate(const Eigen::Matrix<_WeightType, -1, 1>& numByTopic,
Float docSize) const override
{
Float z = (this->regressionCoef.array() * numByTopic.array().template cast<Float>()).sum()
/ std::max(docSize, 0.01f);
return 1 / (1 + exp(-z));
}
DEFINE_SERIALIZER_AFTER_BASE(GLMFunctor<_WeightType>, b, omega);
};
struct CopyGLMFunctor
{
template<typename Wt>
std::vector<std::unique_ptr<GLMFunctor<Wt>>> operator()(const std::vector<std::unique_ptr<GLMFunctor<Wt>>>& o)
{
std::vector<std::unique_ptr<GLMFunctor<Wt>>> ret;
for (auto& p : o) ret.emplace_back(p->copy());
return ret;
}
};
}
template<TermWeight _tw, typename _RandGen,
size_t _Flags = flags::partitioned_multisampling,
typename _Interface = ISLDAModel,
typename _Derived = void,
typename _DocType = DocumentSLDA<_tw>,
typename _ModelState = ModelStateLDA<_tw>>
class SLDAModel : public LDAModel<_tw, _RandGen, _Flags, _Interface,
typename std::conditional<std::is_same<_Derived, void>::value, SLDAModel<_tw, _RandGen, _Flags>, _Derived>::type,
_DocType, _ModelState>
{
protected:
using DerivedClass = typename std::conditional<std::is_same<_Derived, void>::value, SLDAModel<_tw, _RandGen>, _Derived>::type;
using BaseClass = LDAModel<_tw, _RandGen, _Flags, _Interface, DerivedClass, _DocType, _ModelState>;
friend BaseClass;
friend typename BaseClass::BaseClass;
using WeightType = typename BaseClass::WeightType;
static constexpr auto tmid()
{
return serializer::to_key("SLDA");
}
uint64_t F; // number of response variables
std::vector<ISLDAModel::GLM> varTypes;
std::vector<Float> glmParam;
Vector mu; // Mean of regression coefficients, Dim : (F)
Vector nuSq; // Variance of regression coefficients, Dim : (F)
DelegateCopy<std::vector<std::unique_ptr<detail::GLMFunctor<WeightType>>>, detail::CopyGLMFunctor> responseVars;
Matrix normZ; // topic proportions for all docs, Dim : (K, D)
Matrix Ys; // response variables, Dim : (D, F)
template<bool _asymEta>
Float* getZLikelihoods(_ModelState& ld, const _DocType& doc, size_t docId, size_t vid) const
{
const size_t V = this->realV;
assert(vid < V);
auto etaHelper = this->template getEtaHelper<_asymEta>();
auto& zLikelihood = ld.zLikelihood;
zLikelihood = (doc.numByTopic.array().template cast<Float>() + this->alphas.array())
* (ld.numByTopicWord.col(vid).array().template cast<Float>() + etaHelper.getEta(vid))
/ (ld.numByTopic.array().template cast<Float>() + etaHelper.getEtaSum());
for (size_t f = 0; f < F; ++f)
{
if (std::isnan(doc.y[f])) continue;
responseVars[f]->updateZLL(zLikelihood, doc.y[f], doc.numByTopic,
docId, doc.getSumWordWeight());
}
sample::prefixSum(zLikelihood.data(), this->K);
return &zLikelihood[0];
}
void optimizeRegressionCoef()
{
for (size_t i = 0; i < this->docs.size(); ++i)
{
normZ.col(i) = this->docs[i].numByTopic.array().template cast<Float>() /
std::max((Float)this->docs[i].getSumWordWeight(), 0.01f);
}
for (size_t f = 0; f < F; ++f)
{
responseVars[f]->optimizeCoef(normZ, mu[f], nuSq[f], Ys.col(f));
}
}
void optimizeParameters(ThreadPool& pool, _ModelState* localData, _RandGen* rgs)
{
BaseClass::optimizeParameters(pool, localData, rgs);
}
void updateGlobalInfo(ThreadPool& pool, _ModelState* localData)
{
optimizeRegressionCoef();
}
template<typename _DocIter>
double getLLDocs(_DocIter _first, _DocIter _last) const
{
const auto K = this->K;
double ll = 0;
for (; _first != _last; ++_first)
{
auto& doc = *_first;
ll -= math::lgammaT(doc.getSumWordWeight() + this->alphas.sum()) - math::lgammaT(this->alphas.sum());
for (size_t f = 0; f < F; ++f)
{
if (std::isnan(doc.y[f])) continue;
ll += responseVars[f]->getLL(doc.y[f], doc.numByTopic, doc.getSumWordWeight());
}
for (Tid k = 0; k < K; ++k)
{
ll += math::lgammaT(doc.numByTopic[k] + this->alphas[k]) - math::lgammaT(this->alphas[k]);
}
}
return ll;
}
double getLLRest(const _ModelState& ld) const
{
double ll = BaseClass::getLLRest(ld);
for (size_t f = 0; f < F; ++f)
{
ll -= (responseVars[f]->regressionCoef.array() - mu[f]).pow(2).sum() / 2 / nuSq[f];
}
return ll;
}
void prepareDoc(_DocType& doc, size_t docId, size_t wordSize) const
{
BaseClass::prepareDoc(doc, docId, wordSize);
}
void initGlobalState(bool initDocs)
{
BaseClass::initGlobalState(initDocs);
if (initDocs)
{
for (size_t f = 0; f < F; ++f)
{
std::unique_ptr<detail::GLMFunctor<WeightType>> v;
switch (varTypes[f])
{
case ISLDAModel::GLM::linear:
v = std::make_unique<detail::LinearFunctor<WeightType>>(this->K, mu[f],
f < glmParam.size() ? glmParam[f] : 1.f);
break;
case ISLDAModel::GLM::binary_logistic:
v = std::make_unique<detail::BinaryLogisticFunctor<WeightType>>(this->K, mu[f],
f < glmParam.size() ? glmParam[f] : 1.f, this->docs.size());
break;
}
responseVars.emplace_back(std::move(v));
}
}
Ys.resize(this->docs.size(), F);
normZ.resize(this->K, this->docs.size());
for (size_t i = 0; i < this->docs.size(); ++i)
{
Ys.row(i) = Eigen::Map<Eigen::Matrix<Float, 1, -1>>(this->docs[i].y.data(), F);
}
}
public:
DEFINE_SERIALIZER_AFTER_BASE_WITH_VERSION(BaseClass, 0, F, responseVars, mu, nuSq);
DEFINE_TAGGED_SERIALIZER_AFTER_BASE_WITH_VERSION(BaseClass, 1, 0x00010001, F, responseVars, mu, nuSq);
SLDAModel(const SLDAArgs& args)
: BaseClass(args), F(args.vars.size()), varTypes(args.vars),
glmParam(args.glmParam)
{
for (auto t : varTypes)
{
if ((size_t)t > (size_t)ISLDAModel::GLM::binary_logistic) THROW_ERROR_WITH_INFO(exc::InvalidArgument, "unknown var GLM type in `vars`");
}
if (args.mu.size() == 0)
{
mu = Vector::Zero(F);
}
else if (args.mu.size() == 1)
{
mu = Vector::Constant(F, args.mu[0]);
}
else if (args.mu.size() == F)
{
mu = Eigen::Map<const Vector>(args.mu.data(), args.mu.size());
}
else
{
THROW_ERROR_WITH_INFO(exc::InvalidArgument, text::format("wrong mu value (len = %zd)", args.mu.size()));
}
if (args.nuSq.size() == 0)
{
nuSq = Vector::Ones(F);
}
else if (args.nuSq.size() == 1)
{
nuSq = Vector::Constant(F, args.nuSq[0]);
}
else if (args.nuSq.size() == F)
{
nuSq = Eigen::Map<const Vector>(args.nuSq.data(), args.nuSq.size());
}
else
{
THROW_ERROR_WITH_INFO(exc::InvalidArgument, text::format("wrong nuSq value (len = %zd)", args.nuSq.size()));
}
}
std::vector<Float> getRegressionCoef(size_t f) const override
{
return { responseVars[f]->regressionCoef.data(), responseVars[f]->regressionCoef.data() + this->K };
}
GETTER(F, size_t, F);
ISLDAModel::GLM getTypeOfVar(size_t f) const override
{
return responseVars[f]->getType();
}
template<bool _const = false>
_DocType& _updateDoc(_DocType& doc, const std::vector<Float>& y)
{
if (_const)
{
if (y.size() > F) throw std::runtime_error{ text::format(
"size of `y` is greater than the number of vars.\n"
"size of `y` : %zd, number of vars: %zd", y.size(), F) };
doc.y = y;
while (doc.y.size() < F)
{
doc.y.emplace_back(NAN);
}
}
else
{
if (y.size() != F) throw std::runtime_error{ text::format(
"size of `y` must be equal to the number of vars.\n"
"size of `y` : %zd, number of vars: %zd", y.size(), F) };
doc.y = y;
}
return doc;
}
size_t addDoc(const RawDoc& rawDoc, const RawDocTokenizer::Factory& tokenizer) override
{
auto doc = this->template _makeFromRawDoc<false>(rawDoc, tokenizer);
return this->_addDoc(_updateDoc(doc, rawDoc.template getMiscDefault<std::vector<Float>>("y")));
}
std::unique_ptr<DocumentBase> makeDoc(const RawDoc& rawDoc, const RawDocTokenizer::Factory& tokenizer) const override
{
auto doc = as_mutable(this)->template _makeFromRawDoc<true>(rawDoc, tokenizer);
return std::make_unique<_DocType>(as_mutable(this)->template _updateDoc<true>(doc, rawDoc.template getMiscDefault<std::vector<Float>>("y")));
}
size_t addDoc(const RawDoc& rawDoc) override
{
auto doc = this->_makeFromRawDoc(rawDoc);
return this->_addDoc(_updateDoc(doc, rawDoc.template getMiscDefault<std::vector<Float>>("y")));
}
std::unique_ptr<DocumentBase> makeDoc(const RawDoc& rawDoc) const override
{
auto doc = as_mutable(this)->template _makeFromRawDoc<true>(rawDoc);
return std::make_unique<_DocType>(as_mutable(this)->template _updateDoc<true>(doc, rawDoc.template getMiscDefault<std::vector<Float>>("y")));
}
std::vector<Float> estimateVars(const DocumentBase* doc) const override
{
std::vector<Float> ret;
auto pdoc = dynamic_cast<const _DocType*>(doc);
if (!pdoc) return ret;
for (auto& f : responseVars)
{
ret.emplace_back(f->estimate(pdoc->numByTopic, pdoc->getSumWordWeight()));
}
return ret;
}
};
template<typename _WeightType>
void detail::GLMFunctor<_WeightType>::serializerRead(
std::unique_ptr<detail::GLMFunctor<_WeightType>>& p, std::istream& istr)
{
uint32_t t = serializer::readFromStream<uint32_t>(istr);
if (!t) p.reset();
else
{
switch ((ISLDAModel::GLM)(t - 1))
{
case ISLDAModel::GLM::linear:
p = std::make_unique<LinearFunctor<_WeightType>>();
break;
case ISLDAModel::GLM::binary_logistic:
p = std::make_unique<BinaryLogisticFunctor<_WeightType>>();
break;
default:
throw std::ios_base::failure(text::format("wrong GLMFunctor type id %d", (t - 1)));
}
p->serializerRead(istr);
}
}
}
|
1dc7cb402e3807e38bc0508783d5759d36c7f435
|
93e058780c3fd4d7f40dbcac263fb58f63b51b6f
|
/libmuscle/cpp/src/libmuscle/close_port.cpp
|
06516efeefaa42fb2ed39c6d9cce39c685246460
|
[
"Apache-2.0"
] |
permissive
|
multiscale/muscle3
|
2b6ffc34240b92bb2ade3e28e4dde1b6d3f8e3e7
|
be8b21cfe97218d2a941b63d5762387716a9b3f8
|
refs/heads/develop
| 2023-07-12T06:12:03.510684
| 2023-07-06T20:11:41
| 2023-07-06T20:11:41
| 122,876,985
| 24
| 15
|
Apache-2.0
| 2023-09-01T19:47:16
| 2018-02-25T21:07:17
|
Fortran
|
UTF-8
|
C++
| false
| false
| 600
|
cpp
|
close_port.cpp
|
#include <libmuscle/close_port.hpp>
#include <libmuscle/mcp/ext_types.hpp>
using libmuscle::_MUSCLE_IMPL_NS::mcp::ExtTypeId;
namespace libmuscle { namespace _MUSCLE_IMPL_NS {
ClosePort::ClosePort()
: Data()
{
char * zoned_mem = zone_alloc_<char>(1);
zoned_mem[0] = static_cast<char>(ExtTypeId::close_port);
*mp_obj_ << msgpack::type::ext_ref(zoned_mem, 1);
}
bool is_close_port(DataConstRef const & data) {
return (data.mp_obj_->type == msgpack::type::EXT &&
data.mp_obj_->via.ext.type() ==
static_cast<int8_t>(ExtTypeId::close_port));
}
} }
|
a83836dcb5c4d7e536bb772a143ba7e3f3b22c3c
|
bbe148281c401589bc0cb07a22287fc8c7fc8bc7
|
/BrainApp/BrainApp/Image.cpp
|
36eb1a381d3693d309c2fb635c894883a41c44cf
|
[] |
no_license
|
EdwardSeley/BrainApp
|
1d4e3014f8923f4581e96c63cc67186beb22637d
|
fd5b92c96db446e5d8bed9ab5c49c1860b58e443
|
refs/heads/master
| 2021-01-19T14:50:26.173612
| 2017-05-07T21:14:03
| 2017-05-07T21:14:03
| 88,190,328
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,055
|
cpp
|
Image.cpp
|
#include <BrainApp\Image.h>
#include <SDL\SDL.h>
#include <SDL\SDL_image.h>
#include <iostream>
#include <string>
using namespace std;
void Image::load(char * fileLocation, SDL_Renderer * pRen, int x, int y, int numOfFrames)
{
coordinates = make_pair(x, y);
SDL_Surface * pSurface = IMG_Load(fileLocation);
pRenderer = pRen;
frames = numOfFrames;
if (pSurface == 0)
{
SDL_Log("Surface did not load: ", SDL_GetError());
}
pTexture = SDL_CreateTextureFromSurface(pRenderer, pSurface);
if (pTexture == 0)
{
SDL_Log("Texture did not load: ", SDL_GetError());
}
SDL_FreeSurface(pSurface);
}
void Image::draw()
{
SDL_Rect * srcRect = new SDL_Rect();
SDL_Rect * destRect = new SDL_Rect();
SDL_QueryTexture(pTexture, NULL, NULL, &(srcRect->w), &(srcRect->h));
srcRect->x = srcRect->y = 0;
destRect->x = get<0>(coordinates);
destRect->y = get<1>(coordinates);
destRect->w = srcRect->w;
destRect->h = srcRect->h;
SDL_RenderCopy(pRenderer, pTexture, srcRect, destRect);
}
SDL_Texture * Image::getTexture()
{
return pTexture;
}
|
ec80ecb6cd4e1b3e6873f81d00e054a6d08b09bd
|
ff12aeb63a73fe48b8fcf94f33287db251f31fc1
|
/git_hub_test/git_hub_test/bbb.hpp
|
2a9be36a55cefd086ba33ae3abb579dc5ddd4dbb
|
[] |
no_license
|
JIN-EX/git_hub_test
|
68bc4ecb4e714231367f4f53750c145165caa3e0
|
8d92157bf22ca1d94bfe03a19b5be801c02cfebf
|
refs/heads/master
| 2021-01-10T17:55:17.155755
| 2015-12-03T01:57:54
| 2015-12-03T01:57:54
| 47,298,831
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 332
|
hpp
|
bbb.hpp
|
//
// bbb.hpp
// git_hub_test
//
// Created by jin on 2015. 12. 3..
// Copyright © 2015년 test. All rights reserved.
//
#ifndef bbb_hpp
#define bbb_hpp
#include <stdio.h>
#include <iostream>
class bbb{
public:
bbb();
virtual ~bbb();
private:
void func_B();
protected:
};
#endif /* bbb_hpp */
|
67ae4865763f36d5da46ae312ffada4c8a167df0
|
3a1613edc9921e28780a0f6297b1b248009e7147
|
/MNUM_Codes/bisection.cpp
|
5805ee54cc9598d0d43efc9db841966ac65565b7
|
[] |
no_license
|
diogoabnunes/MNUM
|
f1db744f809a5a1649653b3b3d39de07c5a18630
|
26ed9ff00c28453b4ab6ef55194d633ded4be58a
|
refs/heads/master
| 2020-12-08T07:48:46.775575
| 2020-03-04T15:27:41
| 2020-03-04T15:27:41
| 244,935,663
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 849
|
cpp
|
bisection.cpp
|
// Bisection
#include <iostream>
using namespace std;
#define ERROR 0.00001
void abs_error(double exato, double aproximado) { cout << (exato - aproximado) * 100 << " %" << endl; }
void rel_error(double exato, double aproximado) { cout << (exato - aproximado) / exato * 100; }
double f(double x) { return x * x * x * x + 2 * x * x * x - x - 1; }
void bisection(double a, double b)
{
double m, count = 0;
while (abs(a - b) >= ERROR && count < MAXREP)
//for (int i = 1; i <=3; i++)
{
m = (a + b) / 2;
//cout << a << "\t" << b << "\t" << m << "\t" << f(a) << "\t" << f(b) << "\t" << f(m) << endl;
if (f(m) == 0.0) break;
else if (f(a) * f(m) < 0) b = m;
else a = m;
count++;
}
cout << "Bisection: " << m << endl;
//cout << "Abs Error: "; abs_error(1, m);
//cout << "Rel Error: "; rel_error(1, m);
}
int main()
{
return 0;
}
|
cb959f5441186217062215f543502dfcdd2a080b
|
f843cdc661a3cfbe0d2abac25ae5175bd1049bf4
|
/Test.cpp
|
89142b8e85502d4f870056b7a333ff5466c89893
|
[
"MIT"
] |
permissive
|
miniprime1/bit
|
14ff15ca044a7442b19853d340ad9360e6a6da82
|
147432a55ade5a68d060b96f3d39c14c3a05aa21
|
refs/heads/main
| 2023-09-01T20:17:55.744198
| 2021-10-25T07:03:55
| 2021-10-25T07:03:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 256
|
cpp
|
Test.cpp
|
#include <cstdio>
#include "Bit.h"
int main() {
Bit bit1 = 2;
Bit bit2 = bit1.GetFlipBit();
printf("%d %d\n", bit1, bit2);
if (bit1 != bit2) {
printf("not equal\n");
}
else if (bit1 == bit2) {
printf("equal\n");
}
return 0;
}
|
15ad502a22cc5f5e8536126f86ff1e8b5b61bd44
|
5ca4a482d1dcd4d0feb17dea5da072d37b5f571b
|
/Dungeon/Dungeon/cPlayer.h
|
bb2ac45e0249c2c7f3d5f28eac7601ae2652089c
|
[] |
no_license
|
Dave-SSU/UnitProjects
|
3e628c86dd2fd309bf907561077b664c32fa2600
|
3811fc7ce7bf307f3468ce1c72bfa488bcb214b5
|
refs/heads/master
| 2021-01-11T00:02:05.060707
| 2017-04-05T20:10:02
| 2017-04-05T20:10:02
| 70,743,851
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 352
|
h
|
cPlayer.h
|
#pragma once
#include "cInput.h"
#include "cGameObj.h"
class cPlayer : public cInputHandler, public cGameObj
{
public:
cPlayer();
virtual ~cPlayer();
virtual bool handler(const INPUT_RECORD& event);
void init();
void resetPos(const cPos& newPos);
private:
int nFood = 0;
int nSpades = 0;
};
|
45bac6459f9887a574088101adf067332f10c682
|
16eb53173ece55d5c35c511ee9f7140a4c3fcb61
|
/maopaoSort.cpp
|
dd5ccd02bc188b617106e4d0eae22391dd3204db
|
[] |
no_license
|
Iyiren/SortStudy
|
4103ccf2bb0e90c7c205dfb3c08a316bb5162696
|
d41d2ede9e03b1bc2f490944a40d484a9bdd3f13
|
refs/heads/master
| 2020-03-27T07:51:28.436144
| 2018-08-27T13:22:21
| 2018-08-27T13:22:21
| 146,197,473
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 366
|
cpp
|
maopaoSort.cpp
|
void maopaoSort(unsigned int array[], unsigned int size)
{
int i, j;
i = j = 0;
for (i = 0; i< size; i++)
{
for (j = size - 1; j > i; j--)
{
unsigned int temp = array[j-1];
if (array[j-1] >= array[j])
{
array[j-1] = array[j];
array[j] = temp;
}
}
}
i = 0;
while (i < size)
{
cout << array[i] << " ";
i++;
}
cout << endl;
}
|
35f60e086d3be1d53b5585e217217906e7d4df32
|
f5055330eb2a66958e9c6a88e1c981cf5373bc87
|
/src/channel/hdr/codec_int.hpp
|
7afe3a675d6c29f5d0b762e4d1b8c6648d738586
|
[] |
no_license
|
snikulov/vidstream
|
4c671c476c2b2478c78bd088a54e899cd665f6ab
|
76689e96d0201056092f937221ef66b1c997aa9f
|
refs/heads/master
| 2022-08-02T15:30:07.984508
| 2020-05-29T10:06:26
| 2020-05-29T10:06:26
| 262,551,939
| 0
| 0
| null | 2020-05-29T06:54:46
| 2020-05-09T11:03:43
|
BitBake
|
UTF-8
|
C++
| false
| false
| 356
|
hpp
|
codec_int.hpp
|
#ifndef CODEC_INT_HPP__
#define CODEC_INT_HPP__
#include <boost/shared_ptr.hpp>
namespace itpp
{
class Channel_Code;
}
class itpp_codec
{
public:
itpp_codec(int n_=7, int t = 3);
std::string encode(uint8_t src);
uint8_t decode(std::string src);
private:
int n_;
int t_;
boost::shared_ptr<itpp::Channel_Code> codec_;
};
#endif
|
30d9a9b716f3f5f74f477606c1147071b416db3c
|
6b77b97fdc3383d0d24715393deb107a122aa333
|
/DS/DS/Employee.cpp
|
d003412920c9033e46d025225028984329c742b2
|
[] |
no_license
|
eslamabdelbasset1/Bank-Management-System-
|
ac65ef76d4e13f7462346419dc2995bcd6167193
|
b399d1b1bbf50a51569d46aa05263b02414662bb
|
refs/heads/master
| 2023-01-06T20:14:17.696418
| 2020-11-08T00:29:03
| 2020-11-08T00:29:03
| 310,954,793
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,918
|
cpp
|
Employee.cpp
|
#include "Employee.h"
#include "users.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <Windows.h>
using namespace std;
void Employee::clrscr()
{
cout << string(100, '\n');
}
void Employee::createAccount()
{
system("color 3");
cout << "\n\tEnter your First name: ";
cin >> fname;
cin.clear();
cout << "\n\tEnter Last name: ";
cin >> lname;
cin.clear();
string temp_phone;
cout << "\n\tEnter phone number: ";
cin >> temp_phone;
cin.clear();
if (temp_phone.length() == 11)
{
phone = temp_phone;
}
else
{
while (temp_phone.length() != 11)
{
cout << "phone number must be 11 digit\n";
cout << "\n input chone number: ";
cin >> temp_phone;
phone = temp_phone;
}
}
cout << "\n\tEnter Birthday(01/01/1900): ";
cin >> dob;
cin.ignore();
char atype = '\0';
cout << "\n\tSelect Accounts Type(Savings s / Creating c): ";
cin >> atype;
if (tolower(atype) == 's')
{
type = "Saved";
}
else if (tolower(atype) == 'c')
{
type = "Created";
}
else
{
type = "Other";
}
accountNumber = get_last_index();
cout << "\n\t Your Accounts Number: " << accountNumber;
cout << "\n\t Enter 4 digit account_pass: ";
cin >> account_pass;
cout << "\n\t Enter Primary Balance: ";
cin >> balance;
ofstream file("account_details.txt", ios::out | ios::app);
file << fname << " " << lname << " " << phone << " " << dob << " " << type << " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
cout << endl;
number_system_put(accountNumber);
file.close();
}
void Employee::searchDetails(int user_no) //user_no for user session for only specified user can show
{
int flag = 0;
Accounts();//constructor call to empty variables;
ifstream file_read("account_details.txt", ios::in);
system("color 5");
cout <<"\n\tEnter Accounts number: ";
cin >> user_no;
//cin.clear();
while (file_read)
{
file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;
file_read >> close;
if (file_read.eof())
{
break;
}
if (user_no == accountNumber)
{
cout << "\n\tAccounts Number is :" << accountNumber;
cout << "\n\tName :" << fname << " " << lname;
cout << "\n\tPhone :" << phone;
cout << "\n\tDate of birth :" << dob;
cout << "\n\tAccounts Type :" << type;
cout << "\n\tBalance :" << balance << " Egy.";
cout << "\n\tAccount Status :" << close;
cout << "\n\n\n";
flag = 1;
}
}
if (flag != 1)
{
cout << "\n\tNo record found";
}
file_read.close();
}
void Employee::delete_details(int user_no)
{
char buff;
int flag = 0;
string a = "account_details.txt";
string b = "temp.txt";
Accounts();//constructor call to empty variables;
ifstream file_read("account_details.txt", ios::in);
ofstream file_temp("temp.txt", ios::out | ios::app);
system("color 4");
cout << "\n\tEnter Accounts number: ";
cin >> user_no;
//cin.clear();
while (!file_read.eof())
{
file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;
file_read >> close;
if (file_read.eof())
{
break;
}
if (user_no == accountNumber)
{
cout << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
flag = 1;
}
else
{
file_temp << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
}
}
if (flag != 1)
{
cout << "\n\tNo record found";
}
file_temp.close();
file_read.close();
copy_content(b,a);
cout << "\n\tAccounts Is Removed!\n";
temp_file_clear();
}
void Employee::close_details(int user_no)
{
int ch;
char buff;
int flag = 0;
string a = "account_details.txt";
string b = "temp.txt";
Accounts();//constructor call to empty variables;
ifstream file_read("account_details.txt", ios::in);
ofstream file_temp("temp.txt", ios::out | ios::app);
system("color 2");
cout << "\n\tEnter Account number: ";
cin >> user_no;
//cin.clear();
while (!file_read.eof())
{
file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;
file_read >> close;
if (file_read.eof())
{
break;
}
if (user_no == accountNumber)
{
cout << "\n\tAccount Number is: " << accountNumber;
cout << "\n\tFill up Details with new records: \n";
cout << "\n\n\t New Status: ";
cin >> close;
cin.clear();
cout << "\n\t Current Account Type:" << type;
cout << "\n\t Change Type (Saving s /Other o) otherwiese press (N) :";
char ans;
cin >> ans;
cin.clear();
if (tolower(ans) == 'n')
{
cout << "\n\tOk !account type is not chenged !\n ";
}
else if (tolower(ans) == 's')
{
type = "Saving";
}
else
{
type = "Other";
}
file_temp << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " "<< close << endl;
flag = 1;
}
else
{
file_temp << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
}
}
if (flag != 1)
{
cout << "\n\tNo record found";
}
file_temp.close();
file_read.close();
copy_content(b, a);
cout << "\n\t Done ! Details Updated THank You.\n";
temp_file_clear();
}
/* End View All Transection */
void Employee::update_details(int user_no)
{
int flag = 0;
string a = "account_details.txt";
string b = "temp.txt";
Accounts();//constructor call to empty variables;
ifstream file_read("account_details.txt", ios::in);
ofstream file_temp("temp.txt", ios::out | ios::app);
system("color 2");
cout << "\n\tEnter Account number: ";
cin >> user_no;
//cin.clear();
while (!file_read.eof())
{
file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;
file_read >> close;
if (file_read.eof())
{
break;
}
if (user_no == accountNumber)
{
cout << "\n\tAccount Number is: " << accountNumber;
cout << "\n\tFill up Details with new records: \n";
cout << "\n\n\t New First name: ";
cin >> fname;
cin.clear();
cout << "\n\t New Last name: ";
cin >> lname;
cin.clear();
cout << "\n\t New phone: ";
cin >> phone;
cin.clear();
cout << "\n\t New Dob: ";
cin >> dob;
cin.clear();
cout << "\n\t Current Account Type:" << type;
cout << "\n\t Change Type (Saving S/Other O) otherwiese press (N) :";
char ans;
cin >> ans;
cin.clear();
if (tolower(ans) == 'n')
{
cout << "\n\tOk !account type is not chenged !\n ";
}
else if (tolower(ans) == 's')
{
type = "Saving";
}
else
{
type = "Other";
}
file_temp << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
flag = 1;
}
else
{
file_temp << fname << " " << lname << " " << phone << " " << dob << " " << type
<< " " << accountNumber << " " << account_pass << " " << balance << " " << close << endl;
}
}
if (flag != 1)
{
cout << "\n\tNo record found";
}
file_temp.close();
file_read.close();
copy_content(b, a);
cout << "\n\t Done ! Details Updated THank You.\n";
temp_file_clear();
}
/*
copy content function for copy text to other file
*/
void Employee::copy_content(string a, string b)
{
char ch;
int flag = 0;
ifstream temp_read(a.c_str(), ios::in);
ofstream file_write(b.c_str(), ios::out);
while (!temp_read.eof())
{
temp_read.get(ch);
file_write.put(ch);
flag = 1;
}
if (flag != 1)
{
cout << "\n\tFile Error !";
}
}
int Employee::get_last_index() {
ifstream infile("number.txt");
string sLine;
if (infile.good())
{
getline(infile, sLine);
cout << sLine << endl;
}
infile.close();
int last = std::stoi(sLine);
return last++;
}
void Employee::number_system_put(int n1)
{
n1 = n1 + 1;
ofstream number_write("number.txt", ios::out);
number_write << n1;
}
////functions for account number automation
/*
int number_system_get()
{
int number;
ifstream number_read("number.txt", ios::in);
number_read >> number;
return number;
}*/
void Employee::temp_file_clear()
{
char ch;
int flag = 0;
ofstream temp_write("temp.txt", ios::out);
temp_write << " ";
temp_write.close();
}
/*Start entmini statem function */
void Employee::ministatement(int user_no)
{
int number, amount, flag = 0, pbalance = 0;
string status;
Accounts();//constructor call to empty variables;
ifstream file_read("account_details.txt", ios::in);
while (file_read)
{
file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;
file_read >> close;
if (file_read.eof())
{
break;
}
if (user_no == accountNumber)
{
pbalance = balance;
}
}
file_read.close();
//transection part
system("color B");
cout << "\n\n\n\n\n\n\n\n\n\n" << endl;
cout << "\n\tAccounts Number : " << accountNumber << endl;
cout << "\n\n";
ifstream tr_file_read("transec.txt", ios::in);
//cin.clear();
cout << "\n\t" << "Date"
<< " | " << "Amount" << " | " << "CR / DR " << endl;
while (tr_file_read)
{
tr_file_read >> number;
tr_file_read >> amount;
tr_file_read >> status;
if (tr_file_read.eof())
{
break;
}
if (user_no == number)
{
cout << "\t" << " | " << amount << " | " << status << " | " << endl;
flag = 1;
}
}
if (flag != 1)
{
cout << "\n\tNo record found";
}
cout << "\n\n";
cout << "Total Primary Balance :" << pbalance << "/." << endl;
tr_file_read.close();
}
/*End mini statement function */
void Employee::showDetails()
{
int count = 1;
//Employee e;
//ifstream inFile;
ifstream file_read("account_details.txt", ios::in);
if (!file_read)
{
system("color C");
cout << "File could not be open !! Press any Key...";
return;
}
system("color C");
cout << "\n\n\t\tACCOUNTS LIST\n\n";
cout << "===============================================================================================\n";
cout << "Name" << " " << "Phone" << " " << "Data Birthday" << " " << "Type" << " " << "Account No." << " " << "Password" << " " << "Balance"<< " " << "Status" << endl;
cout << "===============================================================================================\n";
string word;
while (file_read >> word)
{
cout << word << " ";
if (count>=9)
{
cout << endl;
count = 0;
}
count++;
/*file_read >> fname;
file_read >> lname;
file_read >> phone;
file_read >> dob;
file_read >> type;
file_read >> accountNumber;
file_read >> account_pass;
file_read >> balance;*/
/*if (file_read.eof() != NULL)
{
cout << fname << " " << lname << "\t" << phone << "\t"
<< dob << "\t" << type << "\t" << accountNumber << "\t" << account_pass << "\t" << balance << endl;
system("pause");
}*/
}
/*if (flag != 1)
{
cout << "\n\tNo record found";
}*/
file_read.close();
cout << "\n\n\n";
}
//menu for register user
void Employee::employee_menu(int user_sesstion)
{
int ch;
int amount = 0;
Employee e;
do {
system("color 9");
cout << "\n\t\t\t 1- Create An Account";
cout << "\n\t\t\t 2- View Info Of Account";
cout << "\n\t\t\t 3- Show All Accounts";
cout << "\n\t\t\t 4- Delete Account";
cout << "\n\t\t\t 5- Close Account";
cout << "\n\t\t\t 6- Update Your Details";
cout << "\n\t\t\t 7- MiniStatement";
cout << "\n\t\t\t 0- Exit";
cout << "\n\t\t\t Enter your Choice (0-6): ";
if (cin >> ch)
{
switch (ch)
{
case 0:
system("CLS");
cout << "\n\n Employees \n\n ";
break;
case 1:
system("cls");
e.createAccount();
break;
case 2:
system("cls");
e.searchDetails(user_sesstion);
break;
case 3:
system("cls");
e.showDetails();
break;
case 4:
e.delete_details(user_sesstion);
break;
case 5:
e.close_details(user_sesstion);
break;
case 6:
system("cls");
e.update_details(user_sesstion);
break;
case 7:
e.ministatement(user_sesstion);
break;
default:
cout << "\n\tWorng choise \n";
break;
}
}
else
{
cout << "\n\t Input only Digits please !";
cin.clear();
cin.ignore();
ch = 10;
}
}while (ch != 0);
}
|
df209a18e411a8bfb4d50ee2f2950aee108c0a8a
|
0d094ff96f957ad70882b5206eeedce7400a1980
|
/Host_client/Player.cpp
|
0749c44f6d4bf3dd1c0de28d2197de92213231ba
|
[] |
no_license
|
Glowny/Korttipelimoottori
|
28bc6c75e707fbe98004c68a597dc8b93bde60f0
|
eb0945bb40a40f8bb91b1b034d4f559dd4f0e46c
|
refs/heads/master
| 2021-01-20T07:50:58.371432
| 2014-07-28T04:42:55
| 2014-07-28T04:42:55
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 286
|
cpp
|
Player.cpp
|
#include "Player.h"
Player::Player(int n, std::string na)
{
playerNumber = n;
name = na;
}
Player::~Player(void)
{
}
void Player::addCard(Kortti k)
{
deck.push_back(k);
}
std::vector<Kortti> Player::getDeck()
{
return deck;
}
int Player::getPNumber()
{
return playerNumber;
}
|
a62b9d8f515032ed12f2db167c9fc6f2a60279b0
|
a5f3b0001cdb692aeffc444a16f79a0c4422b9d0
|
/main/chart2/source/tools/LineProperties.cxx
|
5c36d75338d3fa5fe5738b6666f61d60d21c00cc
|
[
"Apache-2.0",
"CPL-1.0",
"bzip2-1.0.6",
"LicenseRef-scancode-other-permissive",
"Zlib",
"LZMA-exception",
"LGPL-2.0-or-later",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-philippe-de-muyter",
"OFL-1.1",
"LGPL-2.1-only",
"MPL-1.1",
"X11",
"LGPL-2.1-or-later",
"GPL-2.0-only",
"OpenSSL",
"LicenseRef-scancode-cpl-0.5",
"GPL-1.0-or-later",
"NPL-1.1",
"MIT",
"MPL-2.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-unknown-license-reference",
"MPL-1.0",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"BSL-1.0",
"LicenseRef-scancode-docbook",
"LicenseRef-scancode-mit-old-style",
"Python-2.0",
"BSD-3-Clause",
"IJG",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-or-later",
"LGPL-2.0-only",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown",
"BSD-2-Clause",
"Autoconf-exception-generic",
"PSF-2.0",
"NTP",
"LicenseRef-scancode-python-cwi",
"Afmparse",
"W3C",
"W3C-19980720",
"curl",
"LicenseRef-scancode-x11-xconsortium-veillard",
"Bitstream-Vera",
"HPND-sell-variant",
"ICU"
] |
permissive
|
apache/openoffice
|
b9518e36d784898c6c2ea3ebd44458a5e47825bb
|
681286523c50f34f13f05f7b87ce0c70e28295de
|
refs/heads/trunk
| 2023-08-30T15:25:48.357535
| 2023-08-28T19:50:26
| 2023-08-28T19:50:26
| 14,357,669
| 907
| 379
|
Apache-2.0
| 2023-08-16T20:49:37
| 2013-11-13T08:00:13
|
C++
|
UTF-8
|
C++
| false
| false
| 6,791
|
cxx
|
LineProperties.cxx
|
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "LineProperties.hxx"
#include "macros.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
using namespace ::com::sun::star;
using ::com::sun::star::beans::Property;
namespace chart
{
void LineProperties::AddPropertiesToVector(
::std::vector< Property > & rOutProperties )
{
// Line Properties see service drawing::LineProperties
// ---------------
rOutProperties.push_back(
Property( C2U( "LineStyle" ),
PROP_LINE_STYLE,
::getCppuType( reinterpret_cast< const drawing::LineStyle * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ));
rOutProperties.push_back(
Property( C2U( "LineDash" ),
PROP_LINE_DASH,
::getCppuType( reinterpret_cast< const drawing::LineDash * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEVOID ));
//not in service description
rOutProperties.push_back(
Property( C2U( "LineDashName" ),
PROP_LINE_DASH_NAME,
::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT
| beans::PropertyAttribute::MAYBEVOID ));
rOutProperties.push_back(
Property( C2U( "LineColor" ),
PROP_LINE_COLOR,
::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ));
rOutProperties.push_back(
Property( C2U( "LineTransparence" ),
PROP_LINE_TRANSPARENCE,
::getCppuType( reinterpret_cast< const sal_Int16 * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ));
rOutProperties.push_back(
Property( C2U( "LineWidth" ),
PROP_LINE_WIDTH,
::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ));
rOutProperties.push_back(
Property( C2U( "LineJoint" ),
PROP_LINE_JOINT,
::getCppuType( reinterpret_cast< const drawing::LineJoint * >(0)),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT ));
}
void LineProperties::AddDefaultsToMap(
::chart::tPropertyValueMap & rOutMap )
{
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_STYLE, drawing::LineStyle_SOLID );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_WIDTH, 0 );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINE_COLOR, 0x000000 ); // black
::chart::PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_LINE_TRANSPARENCE, 0 );
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINE_JOINT, drawing::LineJoint_ROUND );
}
bool LineProperties::IsLineVisible( const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xLineProperties )
{
bool bRet = false;
try
{
if( xLineProperties.is() )
{
drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
if( aLineStyle != drawing::LineStyle_NONE )
{
sal_Int16 nLineTransparence=0;
xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
if(100!=nLineTransparence)
{
bRet = true;
}
}
}
}
catch( const uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
return bRet;
}
void LineProperties::SetLineVisible( const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xLineProperties )
{
try
{
if( xLineProperties.is() )
{
drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
if( aLineStyle == drawing::LineStyle_NONE )
xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
sal_Int16 nLineTransparence=0;
xLineProperties->getPropertyValue( C2U( "LineTransparence" ) ) >>= nLineTransparence;
if(100==nLineTransparence)
xLineProperties->setPropertyValue( C2U( "LineTransparence" ), uno::makeAny( sal_Int16(0) ) );
}
}
catch( const uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
}
void LineProperties::SetLineInvisible( const ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >& xLineProperties )
{
try
{
if( xLineProperties.is() )
{
drawing::LineStyle aLineStyle(drawing::LineStyle_SOLID);
xLineProperties->getPropertyValue( C2U( "LineStyle" ) ) >>= aLineStyle;
if( aLineStyle != drawing::LineStyle_NONE )
xLineProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
}
}
catch( const uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
}
} // namespace chart
|
e03179ed51dcd395bd70424254fc59cf932ced70
|
6e1e0c0c5ae109c6f115045a0cd5b269b84dc816
|
/Wstep_Do_Informatyki/binaryring3/main.cpp
|
781213c9d045f240c9a43ebacccf718d4d33f2b6
|
[] |
no_license
|
aleqsio/Studies
|
8100b79e3ec3ba3c31fbc0b5e6d389b5e0e851ce
|
15baea38daee1654b829a9d036c61855e4b139dd
|
refs/heads/master
| 2021-01-19T18:40:03.409534
| 2018-04-05T10:54:56
| 2018-04-05T10:54:56
| 88,372,880
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 692
|
cpp
|
main.cpp
|
using namespace std;
#include <stdio.h>
#include <iostream>
int main()
{
while(true)
{
long n;
cin>>n;
long num[n];
long currstart;
long currend;
long middleindex;
for(long i=0;i<n;i++)
{
cin>>num[i];
}
currend=n-1;
currstart=1;
while(true)
{
middleindex=(currend+currstart)/2;
if(currend<=currstart)
{
if(num[currend]>num[currend-1])
{
cout<<num[currend];
}
else
{
cout<<num[currend-1];
}
break;
}
if(num[middleindex-1]<num[middleindex])
{
currstart=middleindex+1;
continue;
}else if(num[middleindex-1]>num[middleindex])
{
currend=middleindex-1;
continue;
}
}
}
return 0;
}
|
c213dad5dcfd6d2eb9a1d1dcca8e81274bb3569c
|
c7162e7c6347372d0757de4d94e99ef1badf7bd7
|
/MPI_RemovePolyLineEvent.cpp
|
bfbf2b5fd5044de091e24de9efd360ee19519c1d
|
[] |
no_license
|
johnty/different_strokes
|
f2a02c5f8646b05633c33851133aa9765c6390e0
|
52679d32097579686b76fe89ef014ce377c15b13
|
refs/heads/master
| 2021-01-10T09:57:45.527340
| 2016-02-16T06:18:08
| 2016-02-16T06:18:08
| 51,811,076
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 407
|
cpp
|
MPI_RemovePolyLineEvent.cpp
|
//
// MPI_RemovePolyLineEvent.cpp
//
#include "MPI_RemovePolyLineEvent.h"
#include "MPI_Workspace.h"
MPI_RemovePolyLineEvent::MPI_RemovePolyLineEvent( MPI_Workspace &workspace, MPI_PolyLine const &polyline ) :
workspace_( workspace ),
polyline_( polyline )
{
// empty
}
void MPI_RemovePolyLineEvent::execute( void )
{
workspace_.removePolyLine( &polyline_ );
}
// vim:sw=4:et:cindent:
|
7bf09a24da42c58d187b10a547a181e8a77e0613
|
13bc1bef1e25f84cb240677f0fbf5d4b1b6f8463
|
/thirdparty/fast_noise_2/include/FastSIMD/SIMDTypeList.h
|
bb624b2d03796ec3b5296446d1b88c779c0c134c
|
[
"MIT"
] |
permissive
|
Zylann/godot_voxel
|
8486e8de2e36c48b94f254927c09b16e5ddb5829
|
5be2ec8243bf26b1efc2cb2488c7a4617126fad4
|
refs/heads/master
| 2023-08-17T04:27:37.356056
| 2023-08-11T20:42:51
| 2023-08-11T20:42:51
| 57,851,492
| 1,935
| 243
|
NOASSERTION
| 2023-08-02T19:08:34
| 2016-05-01T21:44:28
|
C++
|
UTF-8
|
C++
| false
| false
| 999
|
h
|
SIMDTypeList.h
|
#pragma once
#include "FastSIMD.h"
namespace FastSIMD
{
template<eLevel... T>
struct SIMDTypeContainer
{
static constexpr eLevel MinimumCompiled = Level_Null;
template<eLevel L>
static constexpr eLevel GetNextCompiledAfter = Level_Null;
};
template<eLevel HEAD, eLevel... TAIL>
struct SIMDTypeContainer<HEAD, TAIL...>
{
static constexpr eLevel MinimumCompiled = (HEAD & COMPILED_SIMD_LEVELS) != 0 ? HEAD : SIMDTypeContainer<TAIL...>::MinimumCompiled;
template<eLevel L>
static constexpr eLevel GetNextCompiledAfter = (L == HEAD) ? SIMDTypeContainer<TAIL...>::MinimumCompiled : SIMDTypeContainer<TAIL...>::template GetNextCompiledAfter<L>;
};
using SIMDTypeList = SIMDTypeContainer<
Level_Scalar,
Level_SSE,
Level_SSE2,
Level_SSE3,
Level_SSSE3,
Level_SSE41,
Level_SSE42,
Level_AVX,
Level_AVX2,
Level_AVX512,
Level_NEON>;
}
|
3696f5af3bd6f6ddf44a9a0aef0cf690ada4fd50
|
a3ae0fe9f11ad29e0b0fd4e061482f29258c7299
|
/毕设/张宇轩/_74HC595/_74HC595_Arduino_Uno.cpp
|
19fe93d3cec4f4cf26d142f439291460a5f49209
|
[] |
no_license
|
zyx0129/hello-world
|
fdc11e5ef5abff47d00b64f1807d669d69029235
|
9b9a52306c84fe5b18975cf3aa670a860b7efb9e
|
refs/heads/master
| 2021-09-15T11:25:01.430920
| 2018-05-31T11:20:55
| 2018-05-31T11:20:55
| 110,202,860
| 0
| 0
| null | 2018-05-31T11:16:05
| 2017-11-10T04:34:13
|
PHP
|
GB18030
|
C++
| false
| false
| 762
|
cpp
|
_74HC595_Arduino_Uno.cpp
|
#include <Arduino.h>
#include "TL_Config.h"
#include "_74HC595_Arduino_Uno.h"
_74HC595_SERIAL_TO_PARALLEL::_74HC595_SERIAL_TO_PARALLEL(){
pinMode(_74HC595_DATA_DIGITAL_OUTPUT, OUTPUT); //74HC595的14脚 数据输入引脚SI
pinMode(_74HC595_LATCH_DIGITAL_OUTPUT, OUTPUT); //74hc595的12脚 输出存储器锁存线RCK
pinMode(_74HC595_CLOCK_DIGITAL_OUTPUT, OUTPUT); //74hc595的11脚 时钟线 SCK
}
void _74HC595_SERIAL_TO_PARALLEL::pinOut(int value){
digitalWrite(_74HC595_LATCH_DIGITAL_OUTPUT, LOW);//
shiftOut(_74HC595_DATA_DIGITAL_OUTPUT, _74HC595_CLOCK_DIGITAL_OUTPUT, MSBFIRST, value);//串行数据输出,高位在先
digitalWrite(_74HC595_LATCH_DIGITAL_OUTPUT, HIGH);//锁存
}
_74HC595_SERIAL_TO_PARALLEL TL_74HC595;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.