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
52d858444ea94359f750b4ae1d73931bccec1ea9
59905242bfd494ea490eb1babec8840c7ed407bc
/code/player.h
87d7a46e0f5c2203e8e56b3cbbeb4f4f81dd67af
[ "MIT" ]
permissive
seanballais/foxy-journey-port
ec51d014f0f4cada2ba762c5b078738e7fc7b181
55d95632c11043197e81b45ff3a1032d11210368
refs/heads/master
2023-01-22T22:23:48.539738
2020-12-05T08:41:00
2020-12-05T08:41:00
318,729,370
0
0
null
null
null
null
UTF-8
C++
false
false
357
h
player.h
#pragma once #include "physicObject.h" class Player : public physicsObject { public: Player(float px, float py); ~Player(); virtual void update(float deltaTime) override; virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const; private: int animationSpeed; int currentFrame; float accumulatedTime; };
37d1f1b7f898dea0a6dba8836ab120e70a5ee374
ca611d70f40a49deb16ca30c78ba2f0415fcaba4
/POJ 2155 Matrix(二维树状数组).cpp
baafbcf6f7fd23be94720185d44ca9716d4dcab5
[]
no_license
scaugrated/ACM-code
c3ec721f875514733ad46eee5632e6b2d3a313f0
37a501a9aa0f3186fb404a48734a968a932b3ce1
refs/heads/master
2022-11-19T21:10:58.897130
2018-08-22T09:16:57
2018-08-22T09:16:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,097
cpp
POJ 2155 Matrix(二维树状数组).cpp
#include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cstdio> using namespace std; typedef long long LL; const int INF=0x3f3f3f3f; const int maxn=1005; #define ms(a,x) memset(a,x,sizeof(a)) inline LL read() { LL x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int bit[maxn][maxn]; int n; int lowbit(int i) { return i&-i; } int sum(int x,int y) { int s=0; for(int i=x;i>0;i-=lowbit(i)) for(int j=y;j>0;j-=lowbit(j)) s+=bit[i][j]; return s; } void add(int x,int y)//单点加1 { for(int i=x;i<=n;i+=lowbit(i)) for(int j=y;j<=n;j+=lowbit(j)) bit[i][j]++; } int main() { ios::sync_with_stdio(false); int t; cin>>t; while(t--) { ms(bit,0); int q; cin>>n>>q; while(q--) { char op; int x1,y1,x2,y2; cin>>op; if(op=='C') { cin>>x1>>y1>>x2>>y2; add(x1,y1),add(x2+1,y1),add(x1,y2+1),add(x2+1,y2+1); } else { cin>>x1>>y1; cout<<sum(x1,y1)%2<<endl; } } if(t) cout<<endl; } return 0; }
54216af5d4d37bb6f576326262606ad32052396c
a9436881ed4def94b84c0597a15c34fd2d7a2328
/Linguagem C/Atividade 12.cpp
d07e9c320581eb492c2ae60183c80e1adc704beb
[]
no_license
RakelSousa17/PA
d8271f921d173acd6fdc73daf138267ea8d6c2c2
c02d7fdcb66cbfe5c65fd9d6679ccd0af2cd91a1
refs/heads/master
2020-05-17T12:06:59.474480
2019-04-26T22:46:07
2019-04-26T22:46:07
183,702,074
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
332
cpp
Atividade 12.cpp
#include<stdio.h> #include<stdlib.h> #include<locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); float h, m, s; printf("Entre com os segundos:"); scanf("%f",&s); m=s/60; h=m/60; printf ("Os segundos correpondem aos seguintes minutos: %f", m); printf("\nOs segundos correpondem ás seguintes horas: %f", h); return 0; }
e87d422cfd8cb5b66aa1761fd27909355543cb6f
abdb1ec5ec909bee16528ca0769f8f3b8a3344e7
/My_code/code library/SHAHINVAICODE/string algorithm/Hash Function.cpp
6b69640ae083edde43860bc8b69ddedfe628b5ed
[]
no_license
ronee12/Code-Library
3aba7e3d2d9097309702a4fc8ca4c86052d64073
41f6bfae5eaa9ef474b792c12b938964003a5862
refs/heads/master
2020-04-02T00:11:37.360873
2018-10-19T14:12:15
2018-10-19T14:12:15
153,792,980
0
0
null
null
null
null
UTF-8
C++
false
false
2,529
cpp
Hash Function.cpp
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<functional> #include<math.h> #include<assert.h> #include<stdarg.h> #include<time.h> #include<limits.h> #include<ctype.h> #include<string> #include<map> #include<set> #include<queue> #include<algorithm> #include<vector> #include<iostream> #include<sstream> using namespace std; // #defines #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++) #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(),(x).end() #define LPI(i,n) for(int i=0;i<(n);i++) #define LPI1(i,a,b) for(int i=(a);i<=(b);i++) #define LPIL(i,x) for(int i=0;x[i];i++) #define LPD(i,n) for(int i=(n)-1;i>=0;i--) #define LPD1(i,a,b) for(int i=(a);i>=(b);i--) #define I(x) scanf("%d",&x) #define RI(x) int x;I(x) #define II(x,y) scanf("%d%d",&x,&y) #define RII(x,y) int x,y;II(x,y) #define III(x,y,z) scanf("%d%d%d",&x,&y,&z) #define RIII(x,y,z) int x,y,z;III(x,y,z) #define RS(x) scanf("%s",x) #define PI(x) printf("%d\n",x) #define PIS(x) printf("%d ",x) #define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--) #define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n) #define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF) #define MP make_pair #define PB push_back #define MS0(x) memset(x,0,sizeof(x)) #define MS1(x) memset(x,-1,sizeof(x)) #define SEP(x) ((x)?'\n':' ') #define F first #define S second #ifdef ONLINE_JUDGE #define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout); #define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); #else #define FILEIO(x) ; #define FILEIOS ; #endif typedef pair<int,int> PII; typedef long long LL; typedef unsigned long long ULL; const double eps = 1e-9; const double pi = acos(-1.0); const int maxn = (int)1e5 + 10; const int mod = (int)1e9; vector<long long> p_pow(10000); long long hash_function(char s[]) { long long hash=0,l,i; l=strlen(s); for(i=0;i<l;i++) hash+=(s[i]-'a'+1)*p_pow[i]; return hash; } int main() { char S[100][100]; int p=31,n,i,hash,g; p_pow[0]=1; for(i=1;i<p_pow.size();i++) p_pow[i]=p_pow[i-1]*p; cin>>n; for(i=0;i<n;i++) cin>>S[i]; vector <pair <long long, int> > hashes (n); for(i=0;i<n;i++) { hash=hash_function(S[i]); hashes[i]=make_pair(hash,i); } sort(hashes.begin(),hashes.end()); g=0; for(i=0;i<n;i++) { if(i==0||hashes[i].first!=hashes[i-1].first) cout<<"\nGroup "<<++g<<": "; cout<<hashes[i].second<<" "; } return 0; }
7d7f10d26241aca83382a2b41b3eed400b6cef1e
69ca00582831c9b00f01f0ea75ac5f0ff05d1dc5
/model/HeTaoIO.cpp
4efca6a57ce818c8a642f45cc15f11ccf3d8db2b
[ "MIT" ]
permissive
zidong0822/codal-hetao
4bdcaf8ac2296f539c991309d4f1926ae3e9b8e1
3050774dcbe4d30800e23d32b1101f26c3d94a5c
refs/heads/master
2020-12-08T17:38:26.959637
2020-09-11T03:22:38
2020-09-11T03:22:38
233,050,142
0
0
null
null
null
null
UTF-8
C++
false
false
3,264
cpp
HeTaoIO.cpp
/* The MIT License (MIT) Copyright (c) 2017 Lancaster University. 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. */ /** * Class definition for MicroBit NEXT IO. * Represents a collection of all I/O pins on the device. */ #include "CodalConfig.h" #include "HeTaoIO.h" using namespace codal; /** * Constructor. * * Create a representation of all given I/O pins on the edge connector * * Accepts a sequence of unique ID's used to distinguish events raised * by MicroBitPin instances on the default EventModel. */ HeTaoIO::HeTaoIO() : mute(ID_PIN_MUTE, PA_0, PIN_CAPABILITY_DIGITAL), ttl_tx(ID_TTL_TX, PA_2, PIN_CAPABILITY_AD), ttl_rx(ID_TTL_RX, PA_3, PIN_CAPABILITY_AD), lcd_rst(ID_LCD_RST, PB_1, PIN_CAPABILITY_DIGITAL), scl(ID_SCL, PB_6, PIN_CAPABILITY_DIGITAL), sda(ID_SDA, PB_7, PIN_CAPABILITY_DIGITAL), led(ID_LED, PD_2, PIN_CAPABILITY_DIGITAL), pwr_on(ID_PWR_ON, PB_12, PIN_CAPABILITY_DIGITAL), pwr_key(ID_PWR_KEY, PB_13, PIN_CAPABILITY_DIGITAL), plugin(ID_PLUGIN, PB_14, PIN_CAPABILITY_DIGITAL), btn0(ID_BTN0, PC_0, PIN_CAPABILITY_DIGITAL), btn1(ID_BTN1, PC_1, PIN_CAPABILITY_DIGITAL), btn2(ID_BTN2, PC_2, PIN_CAPABILITY_DIGITAL), btn3(ID_BTN3, PC_3, PIN_CAPABILITY_DIGITAL), btn4(ID_BTN4, PC_4, PIN_CAPABILITY_DIGITAL), btn5(ID_BTN5, PC_5, PIN_CAPABILITY_DIGITAL), btn6(ID_BTN6, PC_6, PIN_CAPABILITY_DIGITAL), btn7(ID_BTN7, PC_7, PIN_CAPABILITY_DIGITAL), btn8(ID_BTN8, PC_8, PIN_CAPABILITY_DIGITAL), btn9(ID_BTN9, PC_9, PIN_CAPABILITY_DIGITAL), btn10(ID_BTN10, PC_10, PIN_CAPABILITY_DIGITAL), btn11(ID_BTN11, PC_11, PIN_CAPABILITY_DIGITAL), btn12(ID_BTN12, PC_12, PIN_CAPABILITY_DIGITAL), btn13(ID_BTN13, PC_13, PIN_CAPABILITY_DIGITAL), btn14(ID_BTN14, PC_14, PIN_CAPABILITY_DIGITAL), btn15(ID_BTN15, PC_15, PIN_CAPABILITY_DIGITAL), buttonUp(ID_BTN1, PC_1, PIN_CAPABILITY_DIGITAL), buttonLeft(ID_BTN8, PC_8, PIN_CAPABILITY_DIGITAL), buttonDown(ID_BTN9, PC_9, PIN_CAPABILITY_DIGITAL), buttonRight(ID_BTN10, PC_10, PIN_CAPABILITY_DIGITAL) { }
b266795c87b82cb99d65e7a4827a6f44225f72b0
469db3635bf98653cbcb8602981312706287e02f
/programsettings.cpp
fbb5326e32de1d3ee3a4df55781eeb2bd5fb419d
[]
no_license
welemir/VarModemStudy
59144610fc3f80d9764a67a25904d08860fde4b3
6a6ac5e44bafbb78cb989db779f56d3833d074cb
refs/heads/master
2021-01-16T20:41:57.511945
2013-07-23T15:41:20
2013-07-24T11:19:17
61,075,746
0
0
null
null
null
null
UTF-8
C++
false
false
159
cpp
programsettings.cpp
#include "programsettings.h" ProgramSettings::ProgramSettings(QObject *parent) : QSettings("VarModemStudy.ini", QSettings::IniFormat, parent) { }
04de617cb22e9f436e20462e835e38cf867b04ee
1e1ad5ae19f17e7db246cc3f911d3cc4c2072e65
/05 - Mathematics/01 - Ad Hoc Mathematics Problems/01 - The Simpler Ones/11614 - Etruscan Warriors Never Play Chess.cpp
9991b144e5d5c22768d7c95dc5c0325b1ccec333
[]
no_license
km36388/UVA-Solutions
5d34138fd7adc4fe338cfaeb11af6155916d3309
e5171b04d6a8bb17426245f650723d41345b7fc8
refs/heads/master
2020-12-11T18:16:27.847801
2018-08-23T16:11:29
2018-08-23T16:11:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
11614 - Etruscan Warriors Never Play Chess.cpp
#include <bits/stdc++.h> typedef long long int i64; int main() { int tt; i64 s; scanf("%d", &tt); while (tt--) { scanf("%lld", &s); printf("%lld\n", (i64)floor(-0.5 + sqrt(0.25 + 2 * s))); } return 0; } /* Author: bumpy (-_-) date: 8-Aug-2018 */
982f7a237600d915b4c8a4177da4c1426122c57e
921abfe8a10a4c0edc3035e8abc4a33d51625c1d
/BOJ/Level/10. Math2/3009.FourthDot.cpp
5614937c78e2f5183a14358bbd517977aaa74dec
[]
no_license
gudwnsgur/Algorithm
760fcff3b1e930bf1f8cf047c26253449b52cae9
016f6db056d821c918ea620d5517b00a387eff9a
refs/heads/master
2023-05-01T03:28:17.003101
2023-04-18T14:08:05
2023-04-18T14:08:05
230,247,085
4
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
3009.FourthDot.cpp
#include <iostream> using namespace std; int main() { int x, y, z; while (1) { cin >> x >> y >> z; if (!x && !y && !z) break; if (x*x + y * y == z * z || x * x + z * z == y * y || y * y + z * z == x * x) cout << "right" << "\n"; else cout << "wrong" << "\n"; } return 0; }
4b247478493c58de92a4918231b96ba8b9c186e5
27dfc0b54a9c7187bce6eb819f28bdf859b878b3
/godai_0519/util.hpp
63e87451d3323443d664081564dc0e3c1dbcc337
[]
no_license
godai0519/nightingale
c6824ea218ff066fb4ea3d0c4a7b18e7179c1681
ca7ec7420af066f48e43abbc71320e0825180697
refs/heads/master
2021-01-19T22:32:55.748032
2012-11-01T12:49:36
2012-11-01T12:49:36
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
4,811
hpp
util.hpp
template<typename Ty> inline double point_to_far(const cv::Point_<Ty>& point) { return hypot(point.x, point.y); } template<typename Type> inline double calc_distance(const cv::Point_<Type> &p1,const cv::Point_<Type> &p2) { return point_to_far(p1 - p2); } std::vector<cv::Point2f> rect_to_points(const cv::RotatedRect& rect) { cv::Point2f points[4]; rect.points(points); std::vector<cv::Point2f> result; for(int i=0; i<4; ++i) result.push_back(points[i]); return result; } void delete_overlap(const std::vector<std::vector<cv::Point>>& red, std::vector<cv::KeyPoint>& black) { for(auto red_it = red.cbegin(); red_it != red.cend(); ++red_it) { for(auto black_it = black.begin(); black_it != black.end();) { if(cv::pointPolygonTest(*red_it, black_it->pt, false) >= 0) //内側 { black_it = black.erase(black_it); } else ++black_it; } } return; } void delete_overlap(std::vector<std::pair<cv::Point2f,float>>& faces) { std::sort(faces.begin(), faces.end(), [](const std::pair<cv::Point2f,float>& lhs, const std::pair<cv::Point2f,float>& rhs) { return lhs.second < rhs.second; }); for(size_t i = 0; i<faces.size();++i) { for(size_t j=i+1; j<faces.size();) { if(calc_distance(faces[i].first, faces[j].first) < faces[j].second) { faces.erase(faces.begin() + j); } else ++j; } } } template<class T = float> class line_segment{ const cv::Point_<T> orient_vector_; const cv::Point_<T> fixed_point1_; const cv::Point_<T> fixed_point2_; public: line_segment(const T& x1,const T& y1,const T& x2,const T& y2) : orient_vector_(x2-x1,y2-y1), fixed_point1_(x1,y1), fixed_point2_(x2,y2) { } line_segment(const cv::Point_<T>& p1,const cv::Point_<T>& p2) : orient_vector_(p2.x-p1.x,p2.y-p1.y), fixed_point1_(p1), fixed_point2_(p2) { } bool is_parallel(const line_segment& other,const T& tolerance_angle = PI/36) const { const double x1 = this->orient_vector_.x, y1 = this->orient_vector_.y; const double x2 = other.orient_vector_.x, y2 = other.orient_vector_.y; const double angle = acos((x1*x2 + y1*y2) / (hypot(x1,y1)*hypot(x2,y2))); return (-tolerance_angle <= angle && angle <= tolerance_angle); } bool is_normal(const line_segment& other,const T& tolerance_angle = PI/36) const { const double x1 = this->orient_vector_.x, y1 = this->orient_vector_.y; const double x2 = other.orient_vector_.x, y2 = other.orient_vector_.y; const double angle = acos((x1*x2 + y1*y2) / (hypot(x1,y1)*hypot(x2,y2))); const double right_angle = PI/2; return (right_angle-tolerance_angle <= angle && angle <= right_angle+tolerance_angle); } T distance(const cv::Point_<T>& point) //適当 { const cv::Point_<T> vec_ab(fixed_point2_ - fixed_point1_); const cv::Point_<T> vec_ac(point - fixed_point1_); if(vec_ab.dot(vec_ac) < 0.0) return hypot(vec_ac.x ,vec_ac.y); const cv::Point_<T> vec_ba(fixed_point1_ - fixed_point2_); const cv::Point_<T> vec_bc(point - fixed_point2_); if(vec_ba.dot(vec_bc) < 0.0) return hypot(vec_bc.x, vec_bc.y); return std::abs(vec_ab.cross(vec_ac)) / hypot(vec_ab.x, vec_ab.y); } bool operator|| (const line_segment& other) const { return is_parallel(other); } bool operator+ (const line_segment& other) const { return is_normal(other); } }; template<typename Ty> inline cv::Point_<Ty> get_externally_point( const cv::Point_<Ty>& i, const cv::Point_<Ty>& j ) { return cv::Point_<Ty>(2.0*j - i); } //四隅でなく,上下左右.適当 void circle_to_four_point(std::vector<cv::Point2f>& dst, const cv::Point2f& center, const float radius) { dst.push_back(cv::Point2f(center.x + radius, center.y )); dst.push_back(cv::Point2f(center.x - radius, center.y )); dst.push_back(cv::Point2f(center.x , center.y + radius)); dst.push_back(cv::Point2f(center.x , center.y - radius)); return; } void erase_big_eye(std::vector<cv::KeyPoint>& eyes, int bigest_size) { for(auto it = eyes.begin(); it != eyes.end();) { if(it->size > bigest_size) { it = eyes.erase(it); } else ++it; } return; } void erase_small_eye(std::vector<cv::KeyPoint>& eyes, int smallest_size) { for(auto it = eyes.begin(); it != eyes.end();) { if(it->size < smallest_size) { it = eyes.erase(it); } else ++it; } return; } void erase_big_faces(std::vector<std::pair<cv::Point2f,float>>& faces, float biggest = 64) { for(auto it = faces.begin(); it != faces.end(); ) { if(it->second > biggest) { it = faces.erase(it); } else ++it; } return; }
487a61f49d8aab6ed49cf92a5b108ff9303629a8
46c937ea89163fc1bd95eb1ad61f114258cd015c
/find_single_number.cpp
2edfbd4216cd67b07e24c00150fb09ae041a9dc7
[]
no_license
hakonmagnus/Cpp-tutorials
a3597c2049b0a282e0c41477c4d1c442e169b49e
35c0aac650a9c2550846c30ad74dc762f9bbb344
refs/heads/master
2022-04-05T22:27:01.288302
2020-02-05T15:17:09
2020-02-05T15:17:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
714
cpp
find_single_number.cpp
// Given an array of integers, every element appears // twice except for one. Find that single one. // Input : [1 2 2 3 1] // Output : 3 #include <iostream> #include <vector> using namespace std; // #include <bits/stdc++.h> using namespace std; int FindSingleNumber(vector<int> nums) { // Write your code here int n = nums.size(); int single_num = 0; for(int i =0; i<n; i++){ single_num ^= (nums[i]); cout << "single_num: " << single_num << endl; } return single_num; } int main(){ int arr[] = {16,16,2, 2, 9, 77,29,29,77, 5, 8, 5, 7, 7, 9, 1, 1}; vector<int> A (arr, arr + sizeof(arr) / sizeof(arr[0]) ); int output = FindSingleNumber(A); cout << "Output: " << output << endl; }
c96d513298529d9b62b4741befc0ce9fd5fc2ebe
5152570af9240f2c6ee304ca60b231154807e8df
/DailyQuarantineApp/DailyQuarantineApp/User.h
e6d551a9fb44b9b11c2d87d12ed0b1c7b0974e56
[]
no_license
calimandaniel/DNC
e6f303bd83002e81b37022b82b42586da38d52ad
778f371a95f12d046d64a4148ae90970f64ec501
refs/heads/main
2023-04-18T13:36:55.551653
2021-04-18T19:56:26
2021-04-18T19:56:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
440
h
User.h
#pragma once #include<string> class User { public: User(); User(int id,const std::string& email); User(User&& user); User(const User& user); User& operator=(const User& user); User& operator=(User&& user); void setId(int id); void setEmail(const std::string& email); const std::string getEmail()const; int getId()const; void setDogs(int dogs); int getDogs()const; private: int m_id; int m_dogs; std::string m_email; };
a214e57e4df2945dee0d87290f16ec6ece496a96
ca4d70080ced49e6c9d5110a8563eafdbe79eec4
/src/config/metadata.cpp
a068c06fbf43f55c906d5056d87aa72b85ca9934
[]
no_license
It4innovations/espreso
f6b038dcd77f7f3677694e160a984bc45f4a4850
5acb7651287bd5114af736abc97c84de8a6ede99
refs/heads/master
2023-01-28T13:35:52.731234
2022-05-24T14:24:05
2022-06-26T06:35:31
66,345,061
18
6
null
null
null
null
UTF-8
C++
false
false
4,357
cpp
metadata.cpp
#include "metadata.h" #include "conditions.h" #include "esinfo/eslog.hpp" #include <sstream> using namespace espreso; Unit& Unit::add(UnitLibrary unit, int exponent) { this->elements.push_back({unit, exponent}); return *this; } void ECFMetaData::checkdescription(const std::string &name, size_t size) const { if (description.size() != size) { eslog::internalFailure("'%s' has incorrect number of descriptions.\n", name.c_str()); } } void ECFMetaData::checkdatatype(const std::string &name, size_t size) const { if (datatype.size() != size) { eslog::internalFailure("'%s' has incorrect number of datatypes.\n", name.c_str()); } } void ECFMetaData::checkpattern(const std::string &name, size_t size) const { if (pattern.size() != size) { eslog::internalFailure("'%s' has incorrect number of pattern values.\n", name.c_str()); } } ECFMetaData& ECFMetaData::addconstraint(const ECFAbstractCondition &condition) { delete this->condition; this->condition = condition.copy(); return *this; } ECFMetaData& ECFMetaData::removeconstraint() { delete this->condition; this->condition = new ECFCondition(); return *this; } template <typename TType> static std::vector<TType> getsuffix(size_t start, const std::vector<TType> &data) { if (start < data.size()) { return std::vector<TType>(data.begin() + start, data.end()); } return std::vector<TType>(); } ECFMetaData ECFMetaData::suffix(size_t start) const { ECFMetaData ret(*this); ret.setdescription(getsuffix(start, description)); ret.setdatatype(getsuffix(start, datatype)); ret.setpattern(getsuffix(start, pattern)); ret.tensor = NULL; return ret; } ECFMetaData::ECFMetaData(): visibleObjectName(false), tensor(NULL), tensor_row(-1), tensor_column(-1), exporting(true), range_begin(0), range_end(0), gui_type(ECFGUIType::STATIC) { condition = new ECFCondition(); isallowed = [] () { return true; }; ismandatory = [] () { return true; }; } ECFMetaData::ECFMetaData(const ECFMetaData &other) : name(other.name), description(other.description), datatype(other.datatype), pattern(other.pattern), options(other.options), variables(other.variables), visibleObjectName(other.visibleObjectName), tensor(other.tensor), tensor_row(other.tensor_row), tensor_column(other.tensor_column), tensors(other.tensors), unit(other.unit), exporting(other.exporting), range_begin(other.range_begin), range_end(other.range_end), gui_type(other.gui_type), pattern_name(other.pattern_name), pattern_item_name(other.pattern_item_name), condition(other.condition->copy()), isallowed(other.isallowed), ismandatory(other.ismandatory) { } ECFMetaData::ECFMetaData(ECFMetaData &&other) : name(std::move(other.name)), description(std::move(other.description)), datatype(std::move(other.datatype)), pattern(std::move(other.pattern)), options(std::move(other.options)), variables(std::move(other.variables)), visibleObjectName(other.visibleObjectName), tensor(std::move(other.tensor)), tensor_row(other.tensor_row), tensor_column(other.tensor_column), tensors(other.tensors), unit(std::move(other.unit)), exporting(other.exporting), range_begin(other.range_begin), range_end(other.range_end), gui_type(other.gui_type), pattern_name(other.pattern_name), pattern_item_name(other.pattern_item_name), condition(other.condition), isallowed(std::move(other.isallowed)), ismandatory(std::move(other.ismandatory)) { other.condition = NULL; } ECFMetaData& ECFMetaData::operator=(const ECFMetaData &other) { if (this != &other) { name = other.name; description = other.description; datatype = other.datatype; pattern = other.pattern; options = other.options; variables = other.variables; tensor = other.tensor; tensor_row = other.tensor_row; tensor_column = other.tensor_column; tensors = other.tensors; unit = other.unit; exporting = other.exporting; range_begin = other.range_begin; range_end = other.range_end; gui_type = other.gui_type; pattern_name = other.pattern_name; pattern_item_name = other.pattern_item_name; isallowed = other.isallowed; ismandatory = other.ismandatory; if (condition != NULL) { delete condition; } condition = other.condition->copy(); visibleObjectName = other.visibleObjectName; } return *this; } ECFMetaData::~ECFMetaData() { if (condition != NULL) { delete condition; } }
9b587fbe903226aa2a5cbb90fbaa75884e6906f6
e8940f26b6102d8db7464f05b0764d93865bde1c
/windows/collapes_window/3DvisBaseManager/3DvisBaseManager/BaseLine.h
118d0e13c077cd72361595c81a118e5e8fe0c990
[]
no_license
zr000/ShoppingCarrier
5350dc54cdf7aa175e1d861666d647ee543d50cb
1c2adcf0b7f622d52342a74abeda5b644d94545c
refs/heads/master
2021-06-24T06:01:26.492815
2020-12-10T03:15:31
2020-12-10T03:15:31
146,838,314
2
1
null
null
null
null
UTF-8
C++
false
false
393
h
BaseLine.h
#pragma once #include "BaseInner.h" // CBaseLine class CBaseLine : public CWnd { DECLARE_DYNAMIC(CBaseLine) public: CBaseLine(); virtual ~CBaseLine(); protected: DECLARE_MESSAGE_MAP() CBaseInner CBaseInner; public: afx_msg void OnNcDestroy(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnPaint(); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); };
3fa41b9e3b2f1dd442bff22e75848df9829a1754
045fc0567335ecab68e3a2b2e0b714d5b88495fd
/inheritance/multipath_argumrnt_constr.cpp
e9e10387e695e40dc686d0f30b5513d5b661d01c
[]
no_license
sachinpooojari/cpp
bf14805a16d1fdb6a22dec06506705ee19e3d7c9
46f83d6e5faa2dd17d2d14516e885e24808b28e4
refs/heads/master
2020-04-14T19:36:32.349875
2019-02-03T17:36:14
2019-02-03T17:36:14
164,064,294
0
0
null
null
null
null
UTF-8
C++
false
false
849
cpp
multipath_argumrnt_constr.cpp
#include<iostream> using namespace std; class A { public: int a; A(int x) { this->a=x; cout<<"constr"<<endl; } ~A() { cout<<"dest"<<endl; } void show() {cout<<a<<endl; } }; class B:public A { public: int b; B(int x,int y):A(a) { this->b=y; cout<<"constr"<<endl; } ~B() { cout<<"dest"<<endl; } void show() { cout<<b<<endl; } }; class C:public A { public: int c; C(int x,int z):A(x) { this->c=z; cout<<"constr"<<endl; } ~C() { cout<<"dest"<<endl; } void show() { cout<<c<<endl; } }; class D:public B,public C { public: int d; D(int x,int y,int z,int m):B(x,y),C(x,z) { this->d=m; cout<<"constr"<<endl; } ~D() { cout<<"dest"<<endl; } void show() { B::show(); C::show(); cout<<d<<endl; } }; main() { D d(10,20,30,40); d.show(); // A a; // a.show(); }
88c17e22af5643facb6e40476b62d65c0e078ddb
5cec37261e756a98b632eda290d4869461738403
/testing/unit_testing/src/1_rank/output.cpp
e5fd50b2aef811f1c6e391d78bec584c9db85fac
[ "MIT" ]
permissive
maierbn/opendihu
d78630244fbba035f34f98a4f4bd0102abe57f04
e753fb2a277f95879ef107ef4d9ac9a1d1cec16d
refs/heads/develop
2023-09-05T08:54:47.345690
2023-08-30T10:53:10
2023-08-30T10:53:10
98,750,904
28
11
MIT
2023-07-16T22:08:44
2017-07-29T18:13:32
C++
UTF-8
C++
false
false
19,237
cpp
output.cpp
#include <Python.h> // this has to be the first included header #include <iostream> #include <cstdlib> #include <fstream> #include <cassert> #include "gtest/gtest.h" #include "opendihu.h" #include "../utility.h" #include "arg.h" #include "stiffness_matrix_tester.h" #include "node_positions_tester.h" namespace SpatialDiscretization { TEST(OutputTest, UnstructuredDeformable) { std::string pythonConfig = R"( # Laplace 2D n=4 def callback(config): with open("result_callback","w") as f: f.write(str(config[0])) #import numpy as np #a = np.load("out_binary_solution.npy") #with open("result_binary","w") as f: # f.write(str(a)) config = { "disablePrinting": False, "disableMatrixPrinting": False, "FiniteElementMethod" : { "nElements": n, "physicalExtent": 4.0, "initialValues": [0], "dirichletBoundaryConditions": {0:1.0}, "relativeTolerance": 1e-15, "nodePositions": [[0,0,0], [1,0], [2,0,0], [0,1], [1,1], [2,1], [0,2], [1,2], [2,2]], # 3x3 nodes, 4 elements "elements": [[0, 1, 3, 4], [1, 2, 4, 5], [3, 4, 6, 7], [4, 5, 7, 8]], # each node is [node no, version-at-that-node no] or just node-no then it assumes version no 0 "OutputWriter" : [ {"format": "PythonFile", "filename" : "out_binary", "binary" : True}, {"format": "PythonFile", "filename" : "out_txt", "binary" : False}, {"format": "PythonCallback", "callback": callback}, ] } } )"; DihuContext settings(argc, argv, pythonConfig); FiniteElementMethod< Mesh::UnstructuredDeformableOfDimension<2>, BasisFunction::LagrangeOfOrder<1>, Quadrature::Gauss<2>, Equation::Static::Laplace > equationDiscretized(settings); equationDiscretized.run(); std::string referenceOutput = "{'meshType': 'UnstructuredDeformable', 'dimension': 2, 'nElements': 4, 'basisFunction': 'Lagrange', 'basisOrder': 1, 'onlyNodalValues': True, 'nRanks': 1, 'ownRankNo': 0, 'data': [{'name': 'geometry', 'components': [{'name': 'x', 'values': [0.0, 1.0, 0.0, 1.0, 2.0, 2.0, 0.0, 1.0, 2.0]}, {'name': 'y', 'values': [0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 2.0, 2.0]}, {'name': 'z', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': 'solution', 'components': [{'name': '0', 'values': [0.9999999999999998, 0.9999999999999991, 0.9999999999999991, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999989]}]}, {'name': 'rightHandSide', 'components': [{'name': '0', 'values': [1.0, -0.16666666666666669, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': '-rhsNeumannBC', 'components': [{'name': '0', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], 'elementalDofs': [[0, 1, 2, 3], [1, 4, 3, 5], [2, 3, 6, 7], [3, 5, 7, 8]], 'timeStepNo': -1, 'currentTime': 0.0}"; std::string referenceOutput2 = "{\"meshType\": \"UnstructuredDeformable\", \"dimension\": 2, \"nElements\": 4, \"basisFunction\": \"Lagrange\", \"basisOrder\": 1, \"onlyNodalValues\": true, \"nRanks\": 1, \"ownRankNo\": 0, \"data\": [{\"name\": \"geometry\", \"components\": [{\"name\": \"x\", \"values\": [0.0, 1.0, 0.0, 1.0, 2.0, 2.0, 0.0, 1.0, 2.0]}, {\"name\": \"y\", \"values\": [0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 2.0, 2.0]}, {\"name\": \"z\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"solution\", \"components\": [{\"name\": \"0\", \"values\": [0.9999999999999998, 0.9999999999999991, 0.9999999999999991, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999988, 0.9999999999999989]}]}, {\"name\": \"rightHandSide\", \"components\": [{\"name\": \"0\", \"values\": [1.0, -0.16666666666666669, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"-rhsNeumannBC\", \"components\": [{\"name\": \"0\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], \"elementalDofs\": [[0, 1, 2, 3], [1, 4, 3, 5], [2, 3, 6, 7], [3, 5, 7, 8]], \"timeStepNo\": -1, \"currentTime\": 0.0}"; std::string referenceOutput3 = "{'meshType': 'UnstructuredDeformable', 'dimension': 2, 'nElements': 4, 'basisFunction': 'Lagrange', 'basisOrder': 1, 'onlyNodalValues': True, 'nRanks': 1, 'ownRankNo': 0, 'data': [{'name': 'geometry', 'components': [{'name': 'x', 'values': [0.0, 1.0, 0.0, 1.0, 2.0, 2.0, 0.0, 1.0, 2.0]}, {'name': 'y', 'values': [0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 2.0, 2.0]}, {'name': 'z', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': 'solution', 'components': [{'name': '0', 'values': [0.9999999999999998, 0.9999999999999987, 0.9999999999999988, 0.9999999999999987, 0.9999999999999987, 0.9999999999999989, 0.9999999999999987, 0.9999999999999986, 0.9999999999999986]}]}, {'name': 'rightHandSide', 'components': [{'name': '0', 'values': [1.0, -0.16666666666666669, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], 'elementalDofs': [[0, 1, 2, 3], [1, 4, 3, 5], [2, 3, 6, 7], [3, 5, 7, 8]], 'timeStepNo': -1, 'currentTime': 0.0}"; std::string referenceOutput4 = "{\"meshType\": \"UnstructuredDeformable\", \"dimension\": 2, \"nElements\": 4, \"basisFunction\": \"Lagrange\", \"basisOrder\": 1, \"onlyNodalValues\": true, \"nRanks\": 1, \"ownRankNo\": 0, \"data\": [{\"name\": \"geometry\", \"components\": [{\"name\": \"x\", \"values\": [0.0, 1.0, 0.0, 1.0, 2.0, 2.0, 0.0, 1.0, 2.0]}, {\"name\": \"y\", \"values\": [0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 2.0, 2.0]}, {\"name\": \"z\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"solution\", \"components\": [{\"name\": \"0\", \"values\": [0.9999999999999998, 0.9999999999999987, 0.9999999999999988, 0.9999999999999987, 0.9999999999999987, 0.9999999999999989, 0.9999999999999987, 0.9999999999999986, 0.9999999999999986]}]}, {\"name\": \"rightHandSide\", \"components\": [{\"name\": \"0\", \"values\": [1.0, -0.16666666666666669, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], \"elementalDofs\": [[0, 1, 2, 3], [1, 4, 3, 5], [2, 3, 6, 7], [3, 5, 7, 8]], \"timeStepNo\": -1, \"currentTime\": 0.0}"; //std::string referenceOutputSolution = "[1. 1. 1. 1. 1. 1. 1. 1. 1.]"; assertFileMatchesContent("result_callback", referenceOutput, referenceOutput3); assertFileMatchesContent("out_txt.py", referenceOutput2, referenceOutput4); //assertFileMatchesContent("result_binary", referenceOutputSolution); } TEST(OutputTest, StructuredDeformable) { std::string pythonConfig = R"( # Laplace 2D def callback(config): print("config=",config) with open("result_callback","w") as f: f.write(str(config[0])) #import numpy as np #a = np.load("out_binary_solution.npy") #print("binary=",a) #with open("result_binary","w") as f: # f.write(str(a)) config = { "disablePrinting": False, "disableMatrixPrinting": False, "FiniteElementMethod" : { "dirichletBoundaryConditions": {0:1.0}, "initialValues": [0], "relativeTolerance": 1e-15, "nElements": [2,2], "nodeDimension": 2, "nodePositions": [0,0, 1,0, 2,0, 0,1, 1,1, 2,1, 0,2, 1,2, 2,2], # 3x3 nodes, 4 elements "OutputWriter" : [ {"format": "PythonFile", "filename" : "out_binary", "binary" : True}, {"format": "PythonFile", "filename" : "out_txt", "binary" : False}, {"format": "PythonCallback", "callback": callback}, ] } } )"; DihuContext settings(argc, argv, pythonConfig); FiniteElementMethod< Mesh::StructuredDeformableOfDimension<2>, BasisFunction::LagrangeOfOrder<1>, Quadrature::Gauss<2>, Equation::Static::Laplace > equationDiscretized(settings); equationDiscretized.run(); std::string referenceOutput = "{'meshType': 'StructuredDeformable', 'dimension': 2, 'nElementsGlobal': [2, 2], 'nElementsLocal': [2, 2], 'beginNodeGlobalNatural': [0, 0], 'hasFullNumberOfNodes': [True, True], 'basisFunction': 'Lagrange', 'basisOrder': 1, 'onlyNodalValues': True, 'nRanks': 1, 'ownRankNo': 0, 'data': [{'name': 'geometry', 'components': [{'name': 'x', 'values': [0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0]}, {'name': 'y', 'values': [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0]}, {'name': 'z', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': 'solution', 'components': [{'name': '0', 'values': [1.0, 0.999999999999999, 0.9999999999999987, 0.9999999999999991, 0.9999999999999988, 0.9999999999999987, 0.9999999999999984, 0.9999999999999984, 0.9999999999999989]}]}, {'name': 'rightHandSide', 'components': [{'name': '0', 'values': [1.0, -0.16666666666666669, 0.0, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0]}]}, {'name': '-rhsNeumannBC', 'components': [{'name': '0', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], 'timeStepNo': -1, 'currentTime': 0.0}"; std::string referenceOutput2 = "{\"meshType\": \"StructuredDeformable\", \"dimension\": 2, \"nElementsGlobal\": [2, 2], \"nElementsLocal\": [2, 2], \"beginNodeGlobalNatural\": [0, 0], \"hasFullNumberOfNodes\": [true, true], \"basisFunction\": \"Lagrange\", \"basisOrder\": 1, \"onlyNodalValues\": true, \"nRanks\": 1, \"ownRankNo\": 0, \"data\": [{\"name\": \"geometry\", \"components\": [{\"name\": \"x\", \"values\": [0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0]}, {\"name\": \"y\", \"values\": [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0]}, {\"name\": \"z\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"solution\", \"components\": [{\"name\": \"0\", \"values\": [1.0, 0.999999999999999, 0.9999999999999987, 0.9999999999999991, 0.9999999999999988, 0.9999999999999987, 0.9999999999999984, 0.9999999999999984, 0.9999999999999989]}]}, {\"name\": \"rightHandSide\", \"components\": [{\"name\": \"0\", \"values\": [1.0, -0.16666666666666669, 0.0, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"-rhsNeumannBC\", \"components\": [{\"name\": \"0\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], \"timeStepNo\": -1, \"currentTime\": 0.0}"; assertFileMatchesContent("result_callback", referenceOutput); assertFileMatchesContent("out_txt.py", referenceOutput2); } TEST(OutputTest, StructuredDeformable2) { std::string pythonConfig = R"( # Laplace 2D def callback(config): print("config=",config) with open("result_callback","w") as f: f.write(str(config[0])) #import numpy as np #a = np.load("out_binary_solution.npy") #print("binary=",a) #with open("result_binary","w") as f: # f.write(str(a)) config = { "disablePrinting": False, "disableMatrixPrinting": False, "FiniteElementMethod" : { "dirichletBoundaryConditions": {0:1.0}, "initialValues": [0], "relativeTolerance": 1e-15, "nElements": [2,2], "nodeDimension": 2, "nodePositions": [[0,0], 1, [2], [0,1], [1,1,0], [2,1,0], [0,2], [1,2], [2,2]], # 3x3 nodes, 4 elements "OutputWriter" : [ {"format": "PythonFile", "filename" : "out_binary", "binary" : True}, {"format": "PythonFile", "filename" : "out_txt", "binary" : False}, {"format": "PythonCallback", "callback": callback}, ] } } )"; DihuContext settings(argc, argv, pythonConfig); FiniteElementMethod< Mesh::StructuredDeformableOfDimension<2>, BasisFunction::LagrangeOfOrder<1>, Quadrature::Gauss<2>, Equation::Static::Laplace > equationDiscretized(settings); equationDiscretized.run(); std::string referenceOutput = "{'meshType': 'StructuredDeformable', 'dimension': 2, 'nElementsGlobal': [2, 2], 'nElementsLocal': [2, 2], 'beginNodeGlobalNatural': [0, 0], 'hasFullNumberOfNodes': [True, True], 'basisFunction': 'Lagrange', 'basisOrder': 1, 'onlyNodalValues': True, 'nRanks': 1, 'ownRankNo': 0, 'data': [{'name': 'geometry', 'components': [{'name': 'x', 'values': [0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0]}, {'name': 'y', 'values': [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0]}, {'name': 'z', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': 'solution', 'components': [{'name': '0', 'values': [1.0, 0.999999999999999, 0.9999999999999987, 0.9999999999999991, 0.9999999999999988, 0.9999999999999987, 0.9999999999999984, 0.9999999999999984, 0.9999999999999989]}]}, {'name': 'rightHandSide', 'components': [{'name': '0', 'values': [1.0, -0.16666666666666669, 0.0, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0]}]}, {'name': '-rhsNeumannBC', 'components': [{'name': '0', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], 'timeStepNo': -1, 'currentTime': 0.0}"; std::string referenceOutput2 = "{\"meshType\": \"StructuredDeformable\", \"dimension\": 2, \"nElementsGlobal\": [2, 2], \"nElementsLocal\": [2, 2], \"beginNodeGlobalNatural\": [0, 0], \"hasFullNumberOfNodes\": [true, true], \"basisFunction\": \"Lagrange\", \"basisOrder\": 1, \"onlyNodalValues\": true, \"nRanks\": 1, \"ownRankNo\": 0, \"data\": [{\"name\": \"geometry\", \"components\": [{\"name\": \"x\", \"values\": [0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0]}, {\"name\": \"y\", \"values\": [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0]}, {\"name\": \"z\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"solution\", \"components\": [{\"name\": \"0\", \"values\": [1.0, 0.999999999999999, 0.9999999999999987, 0.9999999999999991, 0.9999999999999988, 0.9999999999999987, 0.9999999999999984, 0.9999999999999984, 0.9999999999999989]}]}, {\"name\": \"rightHandSide\", \"components\": [{\"name\": \"0\", \"values\": [1.0, -0.16666666666666669, 0.0, -0.16666666666666669, -0.33333333333333337, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"-rhsNeumannBC\", \"components\": [{\"name\": \"0\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], \"timeStepNo\": -1, \"currentTime\": 0.0}"; //std::string referenceOutputSolution = "[1. 1. 1. 1. 1. 1. 1. 1. 1.]"; assertFileMatchesContent("result_callback", referenceOutput); assertFileMatchesContent("out_txt.py", referenceOutput2); //assertFileMatchesContent("result_binary", referenceOutputSolution); } TEST(OutputTest, RegularFixed) { std::string pythonConfig = R"( # Laplace 2D def callback(config): print("config=",config) with open("result_callback","w") as f: f.write(str(config[0])) #import numpy as np #a = np.load("out_binary_solution.npy") #print("binary=",a) #with open("result_binary","w") as f: # f.write(str(a)) config = { "FiniteElementMethod" : { "nElements": [4, 4], "physicalExtent": [4.0, 4.0], "initialValues": [0], "dirichletBoundaryConditions": {0:1.0}, "relativeTolerance": 1e-15, "OutputWriter" : [ {"format": "PythonFile", "filename" : "out_binary", "binary" : True}, {"format": "PythonCallback", "callback": callback}, {"format": "PythonFile", "filename" : "out_txt", "binary" : False}, ] } } )"; DihuContext settings(argc, argv, pythonConfig); FiniteElementMethod< Mesh::StructuredRegularFixedOfDimension<2>, BasisFunction::LagrangeOfOrder<>, Quadrature::None, Equation::Static::Laplace > equationDiscretized(settings); equationDiscretized.run(); std::string referenceOutput = "{'meshType': 'StructuredRegularFixed', 'dimension': 2, 'nElementsGlobal': [4, 4], 'nElementsLocal': [4, 4], 'beginNodeGlobalNatural': [0, 0], 'hasFullNumberOfNodes': [True, True], 'basisFunction': 'Lagrange', 'basisOrder': 1, 'onlyNodalValues': True, 'nRanks': 1, 'ownRankNo': 0, 'data': [{'name': 'geometry', 'components': [{'name': 'x', 'values': [0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0]}, {'name': 'y', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0]}, {'name': 'z', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': 'solution', 'components': [{'name': '0', 'values': [1.0000000000000004, 1.0000000000000018, 1.0000000000000027, 1.0000000000000036, 1.0000000000000033, 1.0000000000000018, 1.0000000000000022, 1.0000000000000027, 1.0000000000000029, 1.000000000000003, 1.0000000000000027, 1.0000000000000027, 1.0000000000000036, 1.0000000000000033, 1.000000000000003, 1.0000000000000036, 1.000000000000003, 1.0000000000000033, 1.0000000000000027, 1.000000000000003, 1.0000000000000033, 1.0000000000000036, 1.0000000000000033, 1.000000000000003, 1.000000000000003]}]}, {'name': 'rightHandSide', 'components': [{'name': '0', 'values': [1.0, -0.16666666666666666, 0.0, 0.0, 0.0, -0.16666666666666666, -0.3333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {'name': '-rhsNeumannBC', 'components': [{'name': '0', 'values': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], 'timeStepNo': -1, 'currentTime': 0.0}"; std::string referenceOutput2 = "{\"meshType\": \"StructuredRegularFixed\", \"dimension\": 2, \"nElementsGlobal\": [4, 4], \"nElementsLocal\": [4, 4], \"beginNodeGlobalNatural\": [0, 0], \"hasFullNumberOfNodes\": [true, true], \"basisFunction\": \"Lagrange\", \"basisOrder\": 1, \"onlyNodalValues\": true, \"nRanks\": 1, \"ownRankNo\": 0, \"data\": [{\"name\": \"geometry\", \"components\": [{\"name\": \"x\", \"values\": [0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 1.0, 2.0, 3.0, 4.0]}, {\"name\": \"y\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0]}, {\"name\": \"z\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"solution\", \"components\": [{\"name\": \"0\", \"values\": [1.0000000000000004, 1.0000000000000018, 1.0000000000000027, 1.0000000000000036, 1.0000000000000033, 1.0000000000000018, 1.0000000000000022, 1.0000000000000027, 1.0000000000000029, 1.000000000000003, 1.0000000000000027, 1.0000000000000027, 1.0000000000000036, 1.0000000000000033, 1.000000000000003, 1.0000000000000036, 1.000000000000003, 1.0000000000000033, 1.0000000000000027, 1.000000000000003, 1.0000000000000033, 1.0000000000000036, 1.0000000000000033, 1.000000000000003, 1.000000000000003]}]}, {\"name\": \"rightHandSide\", \"components\": [{\"name\": \"0\", \"values\": [1.0, -0.16666666666666666, 0.0, 0.0, 0.0, -0.16666666666666666, -0.3333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}, {\"name\": \"-rhsNeumannBC\", \"components\": [{\"name\": \"0\", \"values\": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}]}], \"timeStepNo\": -1, \"currentTime\": 0.0}"; //std::string referenceOutputSolution = "[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.\n 1.]"; assertFileMatchesContent("result_callback", referenceOutput); assertFileMatchesContent("out_txt.py", referenceOutput2); //assertFileMatchesContent("result_binary", referenceOutputSolution); } } // namespace
493a83167ce92e60ca6bfea3b0267a9594a900bd
7f610e8792081df5955492c9b55755c72c79da17
/chewbaccaandnumber/main.cpp
a8478b1a4c393bbada77aedffaaa1e3bbf4eaed8
[]
no_license
Parikshit22/Data-Structures-Algorithms-Cpp
8da910d0c1ba745ccfc016e0d0865f108b30cb04
4515f41c8a41850bc2888d4c83b9ce5dc9b66d68
refs/heads/master
2022-12-09T09:54:42.240609
2020-09-02T03:48:43
2020-09-02T03:48:43
276,821,418
1
0
null
null
null
null
UTF-8
C++
false
false
270
cpp
main.cpp
#include <iostream> using namespace std; int main() { char a[100]; cin>>a; int i=0; if(a[0]=='9'){ i++; } for( ;a[i]!='\0';i++){ if((a[i]-'0')>=5){ a[i] = ('9'-a[i])+'0'; } } cout<<a; return 0; }
1a0ec1a0269412b8dfe77b7f270b888af4d18dce
b1ab959bd124b6158853f517e95bcbb50b8e2728
/addgundialog.h
70e6f5930f1ce745639f42ef8e656fb60b039afc
[]
no_license
DNDCpp/QT_army_project
0fb431db1fb6921cc2989fe587b6782560b787b0
12aa0b6329690141858294e2ee73b4caddb33fb3
refs/heads/master
2021-06-07T05:18:15.991016
2016-11-04T19:43:01
2016-11-04T19:43:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
544
h
addgundialog.h
#ifndef ADDGUNDIALOG_H #define ADDGUNDIALOG_H #include <QDialog> namespace Ui { class addGunDialog; } class addGunDialog : public QDialog { Q_OBJECT public: explicit addGunDialog(QWidget *parent = 0); ~addGunDialog(); QString gun(); double caliber(); int count(); void setGun(QString string); void setCaliber(double caliber); void setCount(int count); private slots: void on_buttonBox_accepted(); void on_buttonBox_rejected(); private: Ui::addGunDialog *ui; }; #endif // ADDGUNDIALOG_H
51a5ef77339f8ec78269e142a7a6df3264586e0d
b22a777d250fdd600fd1836d6d8269738999bbea
/main.hpp
69087d3d3b183eec8f1222471dc31e589579e170
[ "MIT" ]
permissive
anhnnpham/house-remodeling-system
35495e0bb93728ff3fea5bf1e4da00b395f64928
5ea7d58806075aca524195772d9dd301187494f4
refs/heads/master
2020-12-10T19:32:27.966508
2020-01-20T20:49:11
2020-01-20T20:49:11
233,688,862
0
0
null
null
null
null
UTF-8
C++
false
false
495
hpp
main.hpp
#pragma once #ifndef MAIN_HPP #include <iostream> #include <string> #include <sstream> #include <fstream> using namespace std; class userInfo; class userOrder; class userBill; //Cost of materials for the remodel const float PAINTCOST = .50; //per square foot const float WALLPAPERCOST = 2.00; //per square foot const float CARPETCOST = 4.00; //per square foot const float TILECOST = 5.50; //per square foot const float WOODCOST = 6.00; //per square foot #endif // MAIN_HPP
166eb88c4a27fa5d7eab837c0e0c027679f3b3f0
9d0ca5e92c40f4d016846f8d07639425fc88a4ba
/ioi-training-master/IOITC/2010/Coded/Mafia/Mafia.cpp
d9056185512ebadea16a4a3112f8af71b96e2d1b
[]
no_license
prajneya/IOI
01532de1b92509e62214fd5a8208bc66db82c429
c509fccd5b9ef2f0748ae834aaee759582481ad8
refs/heads/master
2020-06-14T09:42:58.889117
2016-12-16T02:42:45
2016-12-16T02:42:45
75,202,750
0
0
null
null
null
null
UTF-8
C++
false
false
830
cpp
Mafia.cpp
/* Created By: Malvika Joshi Problem: Mafia (IOITC-2010 Final-3) */ #include <cstdio> #include <algorithm> #include <vector> #include <cstdlib> #define MAXN 100010 using namespace std; int rem[MAXN]; vector<int> par[MAXN]; int N,M; int main(){ int i,k,p,set; scanf("%d%d",&N,&M); while(M--){ scanf("%d%d",&i,&k); --i,--k; par[k].push_back(i); } for(i = 0; i < N; ++i) sort(par[i].begin(),par[i].end()); for(i = 0; i < N; ++i){ if(par[i].empty()) continue; p = par[i].back(); for(k = 0; k+1 < par[i].size(); ++k){ if(binary_search(par[p].begin(),par[p].end(),par[i][k])) continue; printf("NO\n%d\n",i+1); exit(0); } } set = 0; for(i = N-1; i >= 0; --i){ if(rem[i]) continue; ++set; for(k = 0; k < par[i].size(); ++k) rem[par[i][k]] = 1; } printf("YES\n%d\n",set); return 0; }
4b0bb2d3a6a2fb48889a1624c53cc18dbf52425e
5d6e432783619902d1aa76e46e9596e2019f6c35
/MainGame/OwlBoss.h
60e60907f2607b27f406b0db2459106ce21a34cf
[]
no_license
abolshakov/Superposition
55c322e1e13d100547bcf6647f87e386f94e146b
687abf4e7a2ceb42518b7a5c63d633766353df9c
refs/heads/master
2021-01-12T01:09:00.893742
2019-11-16T15:20:34
2019-11-16T15:20:34
78,336,283
0
0
null
null
null
null
UTF-8
C++
false
false
1,111
h
OwlBoss.h
#ifndef OWLBOSS_H #define OWLBOSS_H #include "DynamicObject.h" #include "Helper.h" using namespace sf; class OwlBoss : public DynamicObject { private: float timeForNewSprite = 0; float jerkDistance = 0; int animationLength; int strikingSprite = 1; int flapsBeforeJerkCount = 4; bool wasHit = false; public: OwlBoss(std::string objectName, Vector2f centerPosition); ~OwlBoss(); Vector2i calculateTextureOffset() override; void prepareSpriteNames(long long elapsedTime, float scaleFactor) override; void behaviorWithDynamic(DynamicObject* target, float elapsedTime) override; void behaviorWithStatic(WorldObject* target, float elapsedTime) override; void behavior(float elapsedTime) override; Vector2f getBuildPosition(std::vector<WorldObject*> visibleItems, float scaleFactor, Vector2f cameraPosition) override; int getBuildType(Vector2f ounPos, Vector2f otherPos) override; void setTarget(DynamicObject& object) override; void jerk(float power, float deceleration, Vector2f destinationPoint) override; void fightLogic(float elapsedTime, DynamicObject* target = nullptr) override; }; #endif
b7f46c4fb5d9cb5fa54ca1c5710894cf20a15bba
738090558ba0d47a6851bd0411f16fc91252b35f
/01/ex02/ZombieEvent.hpp
42998d2bb3ae7e03348f6e462c661aa7c1fadcf1
[]
no_license
somethingthaticantdecide/CPP-Module
30d8bd4da4b8b162a3b2120281f66199487e2b6f
5446449dc35e5f1755f0e568d74c2e8a2e4e9dde
refs/heads/main
2023-05-13T19:52:24.677052
2021-05-29T22:53:53
2021-05-29T22:53:53
372,082,575
0
0
null
null
null
null
UTF-8
C++
false
false
319
hpp
ZombieEvent.hpp
#ifndef ZOMBIE_EVENT_HPP # define ZOMBIE_EVENT_HPP # include "Zombie.hpp" class ZombieEvent { private: std::string _type; std::string _getRandomName(); public: ZombieEvent(); ~ZombieEvent(); Zombie* newZombie(std::string zName); void setZombieType(std::string zType); void randomChump(); }; #endif
9e1c0bc02218c0f92b21c4ebe632dbb8d4bd0e3b
cbf87541424058749d476e39e778fdd049d064fc
/roguelike42/rogue42/MessageWindow.cpp
80da8acee955a2cd075e2eabb0c066336d58ebec
[]
no_license
zolphinus/Team42Workspace
44746289b713c2d108c4640f18eb2e5efcd58cb7
82a6c451678b1deb54086e2ba81e8ba083b248cf
refs/heads/master
2016-09-05T20:32:47.493263
2014-04-22T01:07:53
2014-04-22T01:07:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,536
cpp
MessageWindow.cpp
#include "MessageWindow.h" #include "curses.h" MessageWindow::MessageWindow() { for(int arrayInitializer = 0; arrayInitializer<8; arrayInitializer++) { MessageArray[arrayInitializer] = ""; } messageWindow = newwin(MESSAGE_WINDOW_HEIGHT,MESSAGE_WINDOW_WIDTH,17,0); } MessageWindow::~MessageWindow() { delwin(messageWindow); } void MessageWindow::AddMessage(string stringToAdd) { string messageMover = "", messageHolder=""; messageHolder = MessageArray[6]; for(int arrayCycler=7; arrayCycler>0; arrayCycler--) { messageMover = MessageArray[arrayCycler-1]; MessageArray[arrayCycler] = messageMover; } MessageArray[0]=stringToAdd; } void MessageWindow::PrintMessageWindow() { //Displays the window with all blank spaces so when we print messages, it cleans up the trash automatically werase(messageWindow); init_pair(2,COLOR_RED,COLOR_BLACK); wbkgd(messageWindow, COLOR_PAIR(2)); for(int rowCounter = 7, arrayPos = 0; rowCounter>0; rowCounter--,arrayPos++)//This dual variable for loop prints bottom to top { //and reads the array top to bottom wmove(messageWindow, rowCounter,0); waddstr(messageWindow, MessageArray[arrayPos].c_str()); } //wgetch(messageWindow); //shouldn't need this if we control the flow of our window properly wrefresh(messageWindow); } WINDOW* MessageWindow::getMessageWindow(){ return messageWindow; }
825db8f5abf88dd87f3b558ca90ece10bfe08964
1288b4c6add8cf0db94025bfccf3e80ffef8cbce
/AccountManager.h
21c7a326d99596304ea0d226f77c7aecc47ba05b
[]
no_license
FrancescoCorazzi/EsercizioLaboratorio
c06d3ba912df8821ec047ad49a1b1885ee7174b6
8018c59ec99960b55fd530329044a6a4e0978548
refs/heads/master
2020-06-12T10:56:14.512783
2019-09-16T10:18:59
2019-09-16T10:18:59
194,277,361
0
0
null
null
null
null
UTF-8
C++
false
false
1,421
h
AccountManager.h
// // Created by coraz on 28/06/19. // #ifndef ESLABORATORIO_ACCOUNTMANAGER_H #define ESLABORATORIO_ACCOUNTMANAGER_H #include <fstream> #include <vector> #include <experimental/filesystem> #include "BankAccount.h" using namespace std; // Singleton class AccountManager { public: static AccountManager* getInstance() { if(instance != nullptr) return instance; else return new AccountManager(); } shared_ptr<BankAccount> findAccount(int id); //trova il puntatore al conto con l'id specificato shared_ptr<BankAccount> addAccount(); //aggiunge conto con parametri di default shared_ptr<BankAccount> addAccount(float balance); //aggiunge conto con bilancio iniziale void addFromFolder(std::string path); //crea un conto per ogni file in ./accounts/ void saveToFile(std::string path); //salva ogni conto in un file contenente le transazioni void removeAccount(int id); //rimuove il conto con l'id specificato private: AccountManager() { instance = this; next_number = 0; } void updateNextNumber(); //ricerca l'ID minore disponibile void addAccount(ifstream& file, string name); //aggiunge conto a partire da file static AccountManager* instance; vector<shared_ptr<BankAccount>> accounts; int next_number; }; static AccountManager* instance = nullptr; #endif //ESLABORATORIO_ACCOUNTMANAGER_H
c17fdf66b8a1a2c28b916235eb7e770f3c053afe
1c4c1fc58e589aa3f5c2b43cc78d283d02681360
/tests/test_sat.cpp
6648534d99be1763b031d10279c5c61453d427fa
[ "BSD-2-Clause" ]
permissive
liq07lzucn/easy-IP
593412448b0393cdc433fede4d08aeec8e40ae3d
d57607333b9844a32723db5e1d748b9eeb4fb2a2
refs/heads/master
2021-09-22T10:06:18.036631
2018-09-07T17:18:00
2018-09-07T17:18:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,450
cpp
test_sat.cpp
// Petter Strandmark 2013–2014. #include <catch.hpp> #include <easy-ip.h> using namespace std; #define REQUIRE_NUM_SOLUTIONS(ip, num) \ REQUIRE(ip.solve()); \ int num_solutions = 0; \ do { \ num_solutions++; \ } while (ip.next_solution()); \ REQUIRE(num_solutions == num); auto create_soduku_IP(IP& ip, int n = 3) -> decltype(ip.add_boolean_cube(9, 9, 9)) { auto P = ip.add_boolean_cube(n*n, n*n, n*n); // Exactly one indicator equal to 1. for (int i = 0; i < n*n; ++i) { for (int j = 0; j < n*n; ++j) { Sum k_sum; for (int k = 0; k < n*n; ++k) { k_sum += P[i][j][k]; } ip.add_constraint(k_sum == 1); // Advanced tip: One can use std::move to avoid a copy // here: // ip.add_constraint(move(k_sum) == 1); } } // All rows have every number. for (int i = 0; i < n*n; ++i) { for (int k = 0; k < n*n; ++k) { Sum row_k_sum; for (int j = 0; j < n*n; ++j) { row_k_sum += P[i][j][k]; } ip.add_constraint(row_k_sum == 1); } } // All columns have every number. for (int j = 0; j < n*n; ++j) { for (int k = 0; k < n*n; ++k) { Sum col_k_sum; for (int i = 0; i < n*n; ++i) { col_k_sum += P[i][j][k]; } ip.add_constraint(col_k_sum == 1); } } // The n*n subsquares have every number. for (int i1 = 0; i1 < n; ++i1) { for (int j1 = 0; j1 < n; ++j1) { for (int k = 0; k < n*n; ++k) { Sum square_k_sum; for (int i2 = 0; i2 < n; ++i2) { for (int j2 = 0; j2 < n; ++j2) { square_k_sum += P[n*i1 + i2][n*j1 + j2][k]; } } ip.add_constraint(square_k_sum == 1); } } } return P; } TEST_CASE("minisat") { { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_constraint(x + y == 1); REQUIRE(ip.solve()); CHECK((x.value() + y.value() == 1)); auto z = ip.add_boolean(); ip.add_constraint(x + z == 1); ip.add_constraint(y + z == 1); CHECK( ! ip.solve()); ip.add_constraint(x + y + z == 1); CHECK( ! ip.solve()); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); ip.add_objective(-x); CHECK(ip.solve()); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_objective(2*x + y); ip.add_constraint(x + y <= 1); ip.allow_ignoring_cost_function(); CHECK(ip.solve()); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_constraint(x + y <= 1); CHECK(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 3); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); auto w = ip.add_boolean(); auto u = ip.add_boolean(); auto v = ip.add_boolean(); ip.add_constraint(x + y + z + w + u + v <= 5); ip.add_constraint(x + y + z + w + u + v >= 2); CHECK(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 56); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_constraint(x + y == 2); CHECK(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 1); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_constraint(x + 2*y == 1); CHECK(ip.solve()); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); ip.add_constraint(x - y == 1); CHECK(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 1); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); auto w = ip.add_boolean(); ip.add_constraint(x + y - z - w == 0); CHECK(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 6); } { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); ip.add_constraint(x + y + z == 1); REQUIRE(ip.solve()); int num_solutions = 0; do { num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 3); } { IP ip; int n = 3; auto P = create_soduku_IP(ip, n); ip.set_external_solver(IP::Minisat); REQUIRE(ip.solve()); vector<vector<int>> solution(n*n); cout << endl; for (int i = 0; i < n*n; ++i) { for (int j = 0; j < n*n; ++j) { solution[i].emplace_back(); for (int k = 0; k < n*n; ++k) { if (P[i][j][k].bool_value()) { solution[i][j] = k + 1; } } } } for (int i = 0; i < n*n; ++i) { int row_sum = 0; int col_sum = 0; for (int j = 0; j < n*n; ++j) { row_sum += solution[i][j]; col_sum += solution[j][i]; } CHECK(row_sum == 45); CHECK(col_sum == 45); } } } TEST_CASE("minisat-large") { IP ip; ip.set_external_solver(IP::Minisat); ip.allow_ignoring_cost_function(); Sum sum = 0; for (int i = 0; i < 100; ++i) { auto x = ip.add_boolean(1); sum += x; } ip.add_constraint(sum == 50); CHECK(ip.solve()); CHECK(sum.value() == 50); } TEST_CASE("sat-objective") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); auto w = ip.add_boolean(); ip.add_objective(4*x + y + 2*z + w); ip.add_constraint(x + y + z + w == 2); CHECK(ip.solve()); CHECK(!x.bool_value()); CHECK( y.bool_value()); CHECK(!z.bool_value()); CHECK( w.bool_value()); } TEST_CASE("sat-constraints_coefs_larger_than_1") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); ip.add_constraint(4*x - y - z >= 0); REQUIRE(ip.solve()); REQUIRE_NUM_SOLUTIONS(ip, 5); } TEST_CASE("sat-constraints_coefs_zero") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); ip.add_constraint(0*x >= 0); REQUIRE_NUM_SOLUTIONS(ip, 2); } TEST_CASE("sat-constraints_fractional_coeff") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); ip.add_constraint(0.5*x >= 0); CHECK_THROWS(ip.solve()); } TEST_CASE("sat-constraints_coefs_less_than_minus_1") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); ip.add_constraint(8*x - 2*y - 2*z >= 0); REQUIRE_NUM_SOLUTIONS(ip, 5); } TEST_CASE("sat-constraints_coefs_negative_multiple_times") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); ip.add_constraint(8*x - y - y - z - z >= 0); REQUIRE_NUM_SOLUTIONS(ip, 5); } TEST_CASE("sat-negative-objective") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); auto w = ip.add_boolean(); ip.add_objective(-4 * x - y - 2 * z - w); ip.add_constraint(x + y + z + w == 2); CHECK(ip.solve()); CHECK(x.bool_value()); CHECK(!y.bool_value()); CHECK(z.bool_value()); CHECK(!w.bool_value()); } TEST_CASE("sat-objective-next_solution") { IP ip; ip.set_external_solver(IP::Minisat); auto x = ip.add_boolean(); auto y = ip.add_boolean(); auto z = ip.add_boolean(); auto w = ip.add_boolean(); auto u = ip.add_boolean(); auto v = ip.add_boolean(); auto obj = 4*x + y + 2*z + w + u + v; ip.add_objective(obj); ip.add_constraint(x + y + z + w + u + v == 2); REQUIRE_NUM_SOLUTIONS(ip, 6); } TEST_CASE("add_min_consequtive_constraints-2-true") { IP ip; ip.set_external_solver(IP::Minisat); vector<Sum> x; Sum x_sum = 0; for (int i = 1; i <= 3; ++i) { x.emplace_back(ip.add_boolean()); x_sum += x.back(); } ip.add_constraint(x_sum == 2); ip.add_min_consequtive_constraints(2, x, true); // 1 1 0 // 0 1 1 // 1 0 1 REQUIRE_NUM_SOLUTIONS(ip, 3); } TEST_CASE("add_min_max_consequtive_constraints-4") { IP ip; ip.set_external_solver(IP::Minisat); vector<Sum> x; Sum x_sum = 0; for (int i = 1; i <= 12; ++i) { x.emplace_back(ip.add_boolean()); x_sum += x.back(); } ip.add_min_consequtive_constraints(4, x, false); ip.add_max_consequtive_constraints(4, x); int num_solutions = 0; REQUIRE(ip.solve(nullptr, true)); do { CHECK(x_sum.value() <= 8); int consequtive = 0; for (auto& xx : x) { if (xx.value() > 0.5) { consequtive++; } else { consequtive = 0; } CHECK(consequtive <= 4); } num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 20); } TEST_CASE("add_min_max_consequtive_constraints-5") { IP ip; ip.set_external_solver(IP::Minisat); vector<Sum> x; Sum x_sum = 0; for (int i = 1; i <= 12; ++i) { x.emplace_back(ip.add_boolean()); x_sum += x.back(); } ip.add_min_consequtive_constraints(5, x, false); ip.add_max_consequtive_constraints(5, x); int num_solutions = 0; REQUIRE(ip.solve(nullptr, true)); do { int consequtive = 0; for (auto& xx : x) { if (xx.value() > 0.5) { } else { consequtive = 0; } CHECK(consequtive <= 5); } num_solutions++; } while (ip.next_solution()); CHECK(num_solutions == 12); }
d246743b04fa9c11eaab1757690b6d573b74daea
3a2c5c8681765d81f30fd4e9ebe5508734b1ed5b
/DP最短路径多解法.cpp
436aee0f8b6e8244a5a859ff9d5bc55dffc1b2e5
[]
no_license
lvningyuan/pdlbox
c9949de50bb2d1cb8cb58316294fcc6031a999fb
cd7bfa317a1b5a43a1aa9a70e3b6c4f211dadffc
refs/heads/master
2020-09-30T22:59:24.776722
2020-06-20T15:22:25
2020-06-20T15:22:25
227,394,200
0
0
null
null
null
null
UTF-8
C++
false
false
1,977
cpp
DP最短路径多解法.cpp
class Solution { public: int minimumTotal(vector<vector<int>>& triangle) { /* vector<int> dp(triangle.size()+1,0);//初始化为0 //为什么需要多一个数组空间,因为每次取两个路径长度比较并提取其中最小的。 //自底向上 for(int i=triangle.size()-1; i>=0; i--) { for(int j=0; j<triangle[i].size(); j++) { //每求完一层,新一层数据一旦出来就可以覆盖掉 //原有数据了,(原数据用不上了) dp[j] = min(dp[j],dp[j+1]) + triangle[i][j]; } } return dp[0]; */ /* vector<vector <int> > s(triangle); s[0][0] = triangle[0][0]; for(int i=1; i<triangle.size(); ++i) { s[i][0] = s[i-1][0] + triangle[i][0]; s[i][i] = s[i-1][i-1] + triangle[i][i]; } //注意这里的范围 for(int i=2; i < triangle.size(); ++i) { //注意这里的范围 :列 不能到最后一列 for(int j=1; j < i; ++j) { s[i][j] = min(s[i-1][j-1], s[i-1][j]) + triangle[i][j]; } } int ret =s[triangle.size()-1][0]; for(int i = 0; i < triangle.size(); ++i) { if(ret > s[triangle.size()-1][i]) ret = s[triangle.size()-1][i]; } return ret; */ //自底向上:最快做法, 若想节省空间,一维数组也可以 /* vector<vector <int> > s(triangle); for(int i =triangle.size()-2; i >= 0; --i) { for(int j=0; j <= i; ++j) { s[i][j] = min(s[i+1][j], s[i+1][j+1])+triangle[i][j]; } } return s[0][0]; */ //自底向上一维数组; vector<int> s(triangle[triangle.size()-1]); for(int i=triangle.size()-2; i >=0; --i) { for(int j=0; j<=i; ++j) { s[j] = triangle[i][j] + min(s[j+1],s[j]); } } return s[0]; } };
6d7c83d49b312a0a866c3ecf597ab377a7109d64
203e602370f4673f65f3c3022355ff6634c268ac
/c/hdu/viewed/hdu1010深度优先搜索.cpp
6eb4e6af98f04b97496cb02db3deba3bb58839ae
[ "Apache-2.0" ]
permissive
WeAreChampion/notes
4942fbd5c238559eb318787adc27be72f848de44
6c0f726d1003e5083d9cf1b75ac6905dc1c19c07
refs/heads/master
2020-06-14T03:54:00.587873
2016-12-07T13:02:45
2016-12-07T13:02:45
75,520,188
2
0
null
null
null
null
GB18030
C++
false
false
2,527
cpp
hdu1010深度优先搜索.cpp
#include<iostream> using namespace std; int sx, sy; // the start pos int ex, ey; //the end pos int n, m; char map[10][10];//the map int flag, step;//the work step and the flag about worker can go through successfully. //the direction int d[4][2]={ 0, 1, 1, 0, 0, -1, -1, 0}; /* The dfs by pos including x and y @param t that means the surplus times. */ void dfs(int x, int y, int t) { if(flag == 1) { return ;//若找到所需解,则不用再找其余路径 } /* 剪枝。若剩余时间-当前点到终点的横纵坐标之和,为偶数 则,该路,可走。(若无障碍,差值为0,若有障碍则绕道 即差值-1+(n*2+3)为偶数 */ if(t < abs(ex - x) + abs(ey - y) || (t - abs(ex - x) + abs(ey - y)) % 2) { return ; } /* t代表剩余时间,每走一步t--,这里若t=0,则迷宫坍塌 */ else if(t == 0) { if(x == ex && y == ey) { flag = 1; return ; } //若此时,t=0且刚好到达终点,则标记找到所需解。 else { return ; } } else { //每次向4个方向探。 //save the current pos including nx and ny for(int i = 0; i < 4; i++) { int nx = x + d[i][0], ny = y + d[i][1]; //若该点不为墙,则为可走 if (nx > 0 && nx <= n && ny > 0 && ny <= m && (map[nx][ny] == '.'|| map[nx][ny] == 'D')) { map[nx][ny] = 'X'; //标记走过 dfs(nx, ny, t - 1) ; map[nx][ny] = '.'; //回溯 } } } return ; } int main() { char str[10]; int t; while (scanf("%d%d%d", &n, &m, &t) != EOF) { //has finished inputing data if(n == 0 && m == 0 && t== 0) { return 0; } for (int i = 1; i <= n; i++) { scanf("%s", str); /* To init the start pos including sx and sy */ for (int j = 1; j <= m; j++) { //init the map map[i][j] = str[j - 1]; //save the start pos if(map[i][j] == 'S'){ sx = i; sy = j; } //save the end pos else if(map[i][j] == 'D'){ ex = i; ey = j; } } } //To init the flag's value is 0. flag = 0; //DFS the map dfs(sx, sy, t); /* If the flag is 0 then output No. Else then output Yes. */ if(flag == 0) { printf("NO\n"); } else { printf("YES\n"); } } return 0; } /* Sample Input 4 4 5 S.X. ..X. ..XD .... 3 4 5 S.X. ..X. ...D 0 0 0 Sample Output NO YES */
12968ecbd5ac18795efdc8cb1a9670ca5cb61bf8
9f1f8aa587a2d43668a2dc18debf1e69bb56ec5e
/测试/warehouse.cpp
daddd900fa81b07d4300c92d99efbf97b2b66c71
[]
no_license
miku-web/secondgit
9b6becce22b226ea82587cc073732de70c00b66e
01a1aae7ae2699505f3e675064ab6924f8883be7
refs/heads/master
2023-02-10T06:54:36.071968
2021-01-05T01:50:21
2021-01-05T01:50:21
275,836,734
0
0
null
null
null
null
UTF-8
C++
false
false
12,949
cpp
warehouse.cpp
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdlib> #include<stdio.h> #include<cstring> #include<cmath> #include<stdlib.h> #define error 0 #define ok 1 #define Max_Size 100 using namespace std; typedef int Status; typedef struct Warehourse { char number[Max_Size];//货物编号 char name[Max_Size];//货物名称 char counter[Max_Size];//货物数量 }WAREHOUSE; typedef struct DuLNode { WAREHOUSE data; struct DuLNode* prior, * next; }DuLNode, * DuLinkList; int number = 0; //初始化链表 void InitLinkList(DuLinkList& L) { L = new DuLNode; L->next = NULL; L->prior = L->next; } //读取仓库文件 int read(DuLinkList& L) { FILE* fp; int i; DuLinkList p, ptemp;//WAREHOUSE char tag; p = L; ptemp = NULL; fp = fopen("warehouse.dat", "rb");//打开文件 //fp = fopen("warehouse.dat", "rb"); // cout << "打开文件失败!" tag = fgetc(fp); rewind(fp); //i = 0; if (tag != EOF) { for (i = 0; !feof(fp); i++) { ptemp = new DuLNode; fread(&ptemp->data, sizeof(WAREHOUSE), 1, fp); ptemp->next = p->next; p->next = ptemp; ptemp->prior = p; p = ptemp; } p->prior->next = NULL; delete ptemp; } number = i; fclose(fp); return ok; } //保存新的仓库文件 void save(DuLinkList& L) { DuLinkList ptemp; FILE* fp; ptemp = L->next; if (number == 0)cout << "目前仓库无数据,请重新添加数据!"<<endl; if ((fp = fopen("warehouse.dat", "wb+")) == NULL) { cout << "无法打开此文件" << endl; exit(0); } for (int i = 0; ptemp; i++) { fwrite(&ptemp->data, sizeof(WAREHOUSE), 1, fp); ptemp = ptemp->next; } fclose(fp); if(number>0) cout <<"\t\t\t"<< "本地保存成功" << endl; } //查询仓库储存情况 void find(DuLinkList& L) { DuLinkList ptemp; char Gnumber[20]; char Gname[20]; char tag;//标记是否要输入 int flag; int i; int record; ptemp = L->next; cout << "请问你想以什么形式查找?(1是按照货物编号查找,2是按照名称查找)"; cin >> flag; if (flag == 1) { cout << "请输入你所需要找的货物编号(在10位数字以下):"; getchar(); cin.getline(Gnumber, 20); while (strlen(Gnumber) > 10) { cout << "你输入的货物编号有误,请重新输入"; getchar(); cin.getline(Gnumber, 20); } while (ptemp != NULL) { record = 1; if (strcmp(ptemp->data.number, Gnumber) == 0) { cout << "位序:" << record << " " << "货物编号:" << ptemp->data.number << " " << "货物名称:" << ptemp->data.name << "货物数量:" << ptemp->data.counter << endl; break; } ptemp = ptemp->next; record++; } }//flag==1 else if (flag == 2) { cout << "请输入你所需要找的货物名称(在10位字母以下):"; getchar(); cin.getline(Gname, 20); while (strlen(Gname) > 10) { cout << "你输入的货物名称有误,请重新输入"; getchar(); cin.getline(Gname, 20); } while (ptemp != NULL) { record = 1; if (strcmp(ptemp->data.name, Gname) == 0) { cout << "位序:" << record << " " << "货物编号:" << ptemp->data.number << " " << "货物名称:" << ptemp->data.name << "货物数量:" << ptemp->data.counter << endl; break; } ptemp = ptemp->next; record++; } if (ptemp == NULL)cout << "该仓库没有该数据" << endl; } } //修改编号 void modify_number(WAREHOUSE& ptemp) { cout << "请输入新的货物编号:"; getchar(); cin.getline(ptemp.number, 20); while (strlen(ptemp.number) > 10) { cout << "请输入新的货物编号:"; getchar(); cin.getline(ptemp.number, 20); } cout << "修改成功" << endl; } //修改货物名称 void modify_name(WAREHOUSE& ptemp) { cout << "请输入新的货物名称:"; getchar(); cin.getline(ptemp.name, 20); while (strlen(ptemp.name) > 10) { cout << "请输入新的货物名称:"; getchar(); cin.getline(ptemp.number, 20); } cout << "修改成功" << endl; } //修改货物数量 void modify_counter(WAREHOUSE& ptemp) { cout << "请输入新的货物数量:"; getchar(); cin.getline(ptemp.counter, 20); cout << "修改成功" << endl; } //全部修改 void modify_all(WAREHOUSE& ptemp) { cout << "请输入新的货物编号:" << endl; getchar(); cin.getline(ptemp.number, 20); cout << "请输入新的货物名称:" << endl; getchar(); cin.getline(ptemp.name, 20); cout << "请输入新的货物数量:" << endl; getchar(); cin.getline(ptemp.counter, 20); while (strlen(ptemp.number) > 10) { cout << "请输入新的货物编号:"; getchar(); cin >> ptemp.number; } //名称 while (strlen(ptemp.name) > 10) { cout << "请输入新的货物名称:"; getchar(); cin >> ptemp.name; } cout << "修改成功" << endl; } //修改数据2 void modify_add_cin(WAREHOUSE& ptemp) { int tag; cout << "请问是想修改哪个数据,还是全部修改?(修改货物编号输入0,修改货物名称输入1,修改货物数量输入2,全部修改输入3):"; cin >> tag; switch (tag) { case 0:modify_number(ptemp); break; case 1:modify_name(ptemp); break; case 2:modify_counter(ptemp); break; case 3:modify_all(ptemp); break; } } //修改数据 void modify(DuLinkList& L) { char Gnumber[20]; char Gname[20]; char Gcounter[20]; DuLinkList ptemp; bool flag = 0; ptemp = L; cout << "请输入你想修改的货物编号:"; //cin >> Gnumber; getchar(); cin.getline(Gnumber, 20); while (strlen(Gnumber) > 10) { cout << "你输入的编号有误,请重新输入!" << endl; cout << "请输入你想修改的货物编号: "; getchar(); cin.getline(Gnumber, 20); } while (ptemp) { if (strcmp(Gnumber, ptemp->data.number) == 0) { flag = 1; modify_add_cin(ptemp->data); } ptemp = ptemp->next; } if (flag == 0)cout << "你输入的编号没有该数据!" << endl; } //添加数据 void add_cin(WAREHOUSE& ptemp) { /*cout << "请输入货物编号,货物名称,货物数量" << endl; cin >> ptemp.number >> ptemp.name >> ptemp.counter;*/ cout << "请输入新的货物编号:" << endl; getchar(); cin.getline(ptemp.number, 20); cout << "请输入新的货物名称:" << endl; cin.getline(ptemp.name, 20); cout << "请输入新的货物数量:" << endl; cin.getline(ptemp.counter, 20); while (strlen(ptemp.number) > 10) { cout << "请输入新的货物编号:" << endl; getchar(); cin.getline(ptemp.number, 20); cout << "请输入新的货物名称:" << endl; //getchar(); cin.getline(ptemp.name, 20); cout << "请输入新的货物数量:" << endl; //getchar(); cin.getline(ptemp.counter, 20); } while (strlen(ptemp.name) > 10) { cout << "请输入新的货物编号:" << endl; getchar(); cin.getline(ptemp.number, 20); cout << "请输入新的货物名称:" << endl; //getchar(); cin.getline(ptemp.name, 20); cout << "请输入新的货物数量:" << endl; //getchar(); cin.getline(ptemp.counter, 20); } } void add(DuLinkList& L) { DuLinkList ptemp; int count; //int record; cout << "请输入你想添加的货物条数:"; cin >> count; number = count; while (count != 0) { if (L->next == NULL) { ptemp = new DuLNode; ptemp->next = L->next; L->next = ptemp; ptemp->prior = L; cout << "请添加货物信息:" << endl; add_cin(ptemp->data); } else { ptemp = new DuLNode; ptemp->prior = L; ptemp->next = L->next; L->next->prior = ptemp; L->next = ptemp; cout << "请添加货物信息:" << endl; add_cin(ptemp->data); } count--; } if (number > 0) cout << "新的货物信息已添加成功!" << endl; else cout << "当前添加的货物信息为0!" << endl; } //删除货物信息 void del(DuLinkList& L) { char Gnumber[20]; char Gname[20]; char Gcounter[20]; DuLinkList ptemp; int tag;//根据什么来删除 int i; char ch;//是否删除 ptemp = L; cout << "请问你需要根据什么来删除?(输入1是根据编号删除,输入2是根据名称删除)" << endl; cout << "温馨提示:货物编号是唯一的,货物名称有可能重复哦!" << endl; cout << "请输入你的选择:"; cin >> tag; if (tag == 1) { cout << "请输入你想删除的货物编号:"; getchar(); cin.getline(Gnumber, 20); for (i = 0; ptemp; i++) { if (strcmp(Gnumber, ptemp->data.number) == 0) { cout << "是否确认删除该货物信息(y/n)"; cin >> ch; if (ch == 'y' || ch == 'Y') { cout << "已删除货物编号为 " <<" "<< Gnumber << "的所有信息!" << endl; //在末尾找到 if (ptemp->next == NULL) { ptemp->prior->next = ptemp->next; } //中间区域找到 if (ptemp->next != NULL) { ptemp->prior->next = ptemp->next; ptemp->next->prior = ptemp->prior; } free(ptemp); break; } else { break; } } ptemp = ptemp->next; } } else if(tag==2) { cout << "请输入你想删除的货物名称:"; getchar(); cin.getline(Gname, 20); for (i = 0; ptemp; i++) { if (strcmp(Gname, ptemp->data.name) == 0) { cout << "是否确认删除该货物信息(y/n)"; cin >> ch; if (ch == 'y' || ch == 'Y') { cout << "已删除货物名称为 " <<" "<< Gnumber << "的所有信息!" << endl; //在末尾找到 if (ptemp->next == NULL) { ptemp->prior->next = ptemp->next; } //中间区域找到 if (ptemp->next != NULL) { ptemp->prior->next = ptemp->next; ptemp->next->prior = ptemp->prior; } free(ptemp); break; } else { break; } } ptemp = ptemp->next; } } //找不到 if (ptemp == NULL || i == number) { cout << "未查找到该货物信息!" << endl; } } //重新建立文件 void new_file(DuLinkList& L) { FILE* fp; if ((fp = fopen("warehouse.dat", "w")) == NULL) { cout << "新建文件失败!"; getchar(); exit(0); fclose(fp); } else { cout <<"\t\t\t"<< "新建文件成功!" << endl; } } //浏览全部仓库信息 void list(DuLinkList& L) { DuLinkList ptemp; ptemp = L->next; if (ptemp == NULL)cout <<"\t\t\t"<< "该仓库没有数据可读" << endl; while (ptemp != NULL) { cout <<"\t\t\t"<< "货物编号:" << ptemp->data.number << " " << "货物编号:" << ptemp->data.name << " " << "货物数量:" << ptemp->data.counter << endl; ptemp = ptemp->next; } } //菜单栏 void menu() { //system("cls"); printf("\n\t\t\t该系统版权归19软件一班 涛哥 119583010135 没问侵权违法!\n"); printf("\t\t\t*********************************************************\n"); printf("\t\t\t************* 仓库管理系统 ******************************\n"); printf("\t\t\t* 1-----查询仓库信息 *****\n"); printf("\t\t\t* 2-----修改仓库信息 *******\n"); printf("\t\t\t* 3-----添加仓库信息 ********\n"); printf("\t\t\t* 4-----删除仓库信息 *********\n"); printf("\t\t\t* 5-----保存仓库信息 ***********\n"); printf("\t\t\t* 6-----新建仓库 ************\n"); printf("\t\t\t* 7-----浏览仓库信息 **************\n"); printf("\t\t\t* 8-----退出程序 **************\n"); printf("\t\t\t*********************************************************\n"); printf(" \t \t\t\t 请输入你想要进行的操作所对应的选项:(1-8):"); } //main int main() { int sele; int key = 0; DuLinkList L; char ch; menu(); InitLinkList(L); read(L); cin >> sele; while (sele < 1 || sele>8) { cout << "你输入的选项中必须在1-8之间,请检查过后重新输入!" << endl; cin >> sele; } while (sele != 8) { switch (sele) { case 1:find(L); break; case 2:modify(L); break; case 3:add(L); break; case 4:del(L); break; case 5:save(L); break; case 6: new_file(L); break; case 7:list(L); break; case 8: exit(0); break; } cout <<"\t\t\t"<< "是否返回主菜单(y/n):" <<endl; cout<<"\t\t\t输入其他字母默认继续!"<<endl; cout<<"\t\t\t请输入你的选择:"; cin >> ch; if (ch == 'y' || ch == 'Y') { menu(); cin >> sele; } } }
7f7ddc381ef78a539c6ebd6db9d398794e21d154
639a6c8ff4d098a625b5904f260eec19764a598f
/Sources/AddOn/AddOnMain.cpp
439b0ea5247f81883e4ba9dae8fffb9f863e06c5
[ "MIT" ]
permissive
Bishwanath-Dey-Nayan/ARCHICAD-ADD-ONS-Manager
27c8fa47d2367dca428e8e3bd80b34d0ee889ab2
8960a43ead0aa0977d675bd6155e6c9bdd43683b
refs/heads/master
2023-04-13T08:07:06.555025
2021-04-27T08:12:52
2021-04-27T08:12:52
355,536,448
0
0
null
null
null
null
UTF-8
C++
false
false
1,384
cpp
AddOnMain.cpp
#include "APIEnvir.h" #include "ACAPinc.h" #include "ResourceIds.hpp" #include "DGModule.hpp" #include "StringConversion.hpp" #include <iostream> #include "Controls.hpp" #include "TemplateDialog.hpp" using namespace std; static const GSResID AddOnInfoID = ID_ADDON_INFO; static const Int32 AddOnNameID = 1; static const Int32 AddOnDescriptionID = 2; static const short AddOnMenuID = ID_ADDON_MENU; static const Int32 AddOnCommandID = 1; static GSErrCode MenuCommandHandler(const API_MenuParams* menuParams) { switch (menuParams->menuItemRef.menuResID) { case AddOnMenuID: switch (menuParams->menuItemRef.itemIndex) { case AddOnCommandID: { Controls init(10, 20, 1); TemplateDialog dialog(init); dialog.Invoke(); } break; } break; } return NoError; } API_AddonType __ACDLL_CALL CheckEnvironment(API_EnvirParams* envir) { RSGetIndString(&envir->addOnInfo.name, AddOnInfoID, AddOnNameID, ACAPI_GetOwnResModule()); RSGetIndString(&envir->addOnInfo.description, AddOnInfoID, AddOnDescriptionID, ACAPI_GetOwnResModule()); return APIAddon_Normal; } GSErrCode __ACDLL_CALL RegisterInterface(void) { return ACAPI_Register_Menu(AddOnMenuID, 0, MenuCode_Tools, MenuFlag_Default); } GSErrCode __ACENV_CALL Initialize(void) { return ACAPI_Install_MenuHandler(AddOnMenuID, MenuCommandHandler); } GSErrCode __ACENV_CALL FreeData(void) { return NoError; }
74bf7130aef20f822497cae3183aba1a1125bf55
ff80072eacc2cc9dc849380b793cab0233d33439
/oarphkit/ok/SV/SVCommon.hpp
2b3647e9de88b3ee31a6ec9027cf95db04159ad8
[ "Apache-2.0" ]
permissive
pwais/oarphkit
3477d71420c274cb56e22bf7ff08450a050ae7b4
e799e7904d5b374cb6b58cd06a42d05506e83d94
refs/heads/master
2021-01-01T05:59:31.179043
2015-09-09T08:17:18
2015-09-09T08:17:18
39,921,203
1
0
null
null
null
null
UTF-8
C++
false
false
5,586
hpp
SVCommon.hpp
/* * Copyright 2015 Maintainers of OarphKit * * 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 OK_SV_SVCOMMON_HPP_ #define OK_SV_SVCOMMON_HPP_ #include "ok/Stringify.hpp" #include "ok/SV/SVCommon-inl.hpp" // =========================================================================== // Declare SVStruct or SVMap Entries // A base entry (with an unserializable, unstringifiable value) #define OK_DECLARE_SV_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::detail::NonStringifiable<ValueType>, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry whose value has an operator<<() defined // (or is otherwise ok::Stringify()able) #define OK_DECLARE_SV_DSTR_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::Stringify, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // Use ok::Stringify() but with not length limit *peligro* #define OK_DECLARE_SV_DSTRUL_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry with a user stringification method defined #define OK_DECLARE_SV_USTR_ENTRY(EntryName, ValueType, FunStringify) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ FunStringify, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) #if OK_ENABLE_PROTOBUF // An IPBSerializable entry with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_IPB_ENTRY(EntryName, ValueType, ExtensionName) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_IPBSERIALIZABLE(ExtensionName)) // An entry that can be serialized to DynData // with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_PBDYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_PBDYNDATA_SERIALIZABLE()) // An entry that can be serialized to DynData // with ok::Stringify() and standard length limit #define OK_DECLARE_SV_DSTR_PBDYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::Stringify, \ OK_SVMAP_PBDYNDATA_SERIALIZABLE()) // An entry that can be serialized to DynData (array) // with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_PBDYNARR_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_PBDYNARR_SERIALIZABLE()) // An entry that can be serialized to DynData (array) // with ok::Stringify() and standard length limit #define OK_DECLARE_SV_DSTR_PBDYNARR_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::Stringify, \ OK_SVMAP_PBDYNARR_SERIALIZABLE()) // An IPBSerializable<DynamicProto> entry (that can be serialized to // SVMap's DynData). Using ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_IPB_OF_DYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_IPB_OF_DYNDATA_SERIALIZABLE()) #else /* no protobuf */ // An IPBSerializable entry with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_IPB_ENTRY(EntryName, ValueType, ExtensionName) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry that can be serialized to DynData // with ok::Stringify() and standard length limit #define OK_DECLARE_SV_DSTR_PBDYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::Stringify, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry that can be serialized to DynData // with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_PBDYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry that can be serialized to DynData // with ok::Stringify() and standard length limit #define OK_DECLARE_SV_DSTR_PBDYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::Stringify, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An entry that can be serialized to DynData (array) // with ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_PBDYNARR_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) // An IPBSerializable<DynamicProto> entry (that can be serialized to // SVMap's DynData). Using ok::Stringify() and no length limit #define OK_DECLARE_SV_DSTRUL_IPB_OF_DYNDATA_ENTRY(EntryName, ValueType) \ OK_DECLARE_SV_ENTRY_IMPL( \ EntryName, \ ValueType, \ ::ok::StringifyNoLimit, \ OK_SVMAP_NOT_IPBSERIALIZABLE()) #endif /* OK_ENABLE_PROTOBUF */ #endif /* OK_SV_SVCOMMON_HPP_ */
6829645d979c6c2f92b64b5051cee4d244bbb12c
18b1350719a35f258eef481d2c2a538dfaed4811
/FCTRL.cpp
385f8f5d88cb5a6c46b637015dad60d321f7a16a
[]
no_license
harshitt07/cps
079d9d712a64747dd1d3635e79524e70e65f15f8
f034ebd952200ac08dbaf0bca45eeb8054003c10
refs/heads/master
2021-09-03T07:02:56.290382
2018-01-06T17:38:58
2018-01-06T17:38:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
205
cpp
FCTRL.cpp
#include<iostream> using namespace std; int main() { long int a; int t; cin>>t; for(int i=0;i<t;i++) { int z=0; cin>>a; while(a!=0) { z=z+a/5; a=a/5; } cout<<z<<"\n"; } }
7a785a21a59a5213c3767b8dfdfa9e63d166bf5e
80520164b924d31c74594aa0815bb9bdd487637a
/include/hypro/algorithms/reachability/handlers/resetHandlers/rectangularResetHandler.h
9588be95a8b6c917e981e5f326068acc248ab4ce
[ "MIT" ]
permissive
hypro/hypro
da4efececa3e8390c4c4e8d44e908cd781bf6704
9333eb4d9319f0462b33802c5de76f6ad6c0cbe2
refs/heads/master
2023-07-08T01:24:37.025069
2022-01-04T07:54:06
2022-01-04T07:54:06
69,588,580
28
13
NOASSERTION
2023-09-07T07:30:00
2016-09-29T16:58:10
C++
UTF-8
C++
false
false
1,051
h
rectangularResetHandler.h
#pragma once #include "../IHandler.h" namespace hypro { template <typename State> class rectangularResetHandler : public IResetHandler { using Number = typename State::NumberType; using TransitionStatesMap = typename std::map<Transition<Number>*, std::vector<State>>; using TransitionContainmentMap = std::map<const Transition<Number>*, CONTAINMENT>; protected: State* mState; // A state containing the first segment for each subspace std::vector<carl::Interval<Number>> mIntervalResets; TransitionStatesMap mResetSatisfyingStates; TransitionContainmentMap mResetContainment; size_t mIndex; public: void handle(); const char* handlerName() { return "rectangularResetHandler"; } void rectangularIntersectReset( const State& stateSet, const HybridAutomaton<Number>& automaton ); const TransitionStatesMap& getResetSatisfyingStateSets() const { return mResetSatisfyingStates; } const TransitionContainmentMap& getResetContainment() const { return mResetContainment; } }; } // namespace hypro #include "rectangularResetHandler.tpp"
7a13b89e8b50a304f3890442ed050302b47f6dd7
0da268a0db15337d31674426b25f8b80fd0a3235
/nginx/_include/ngx_cpp_log_message.h
efe226b780f22a573af4f3eadea6dd94fb3e84ad
[]
no_license
847212939/server
9b4d1e81198b00ff1e84a09d96d748b88b4be89e
40532bbff894d703b89047d12a71efa0a5a6cb0e
refs/heads/master
2020-05-04T17:27:29.328298
2019-05-22T02:58:35
2019-05-22T02:58:35
179,311,663
0
1
null
null
null
null
UTF-8
C++
false
false
1,180
h
ngx_cpp_log_message.h
#pragma once #include "ngx_cpp_global.h" class CNgx_cpp_log_message { public: void ngx_log_init(); void ngx_log_error_core(int level, int err, const char *fmt, ...); void ngx_log_stderr(int err, const char *fmt, ...); u_char * ngx_snprintf(u_char *buf, size_t max, const char *fmt, ...); public: CNgx_cpp_log_message():m_pid(0) { m_log.fd=-1; }; ~CNgx_cpp_log_message() { if(m_log.fd) close(m_log.fd); }; private: struct SNgx_log { int log_level; /*日志级别 或者日志类型,ngx_macro.h里分0-8共9个级别*/ int fd; /*日志文件描述符*/ }; static u_char err_levels[][20]; private: static u_char * ngx_log_errno(u_char *buf, u_char *last, int err); static u_char * ngx_vslprintf(u_char *buf, u_char *last,const char *fmt,va_list args); static u_char * ngx_sprintf_num(u_char *buf, u_char *last, uint64_t ui64, u_char zero, uintptr_t hexadecimal, uintptr_t width); static u_char * ngx_slprintf(u_char *buf, u_char *last, const char *fmt, ...); private: SNgx_log m_log; pid_t m_pid; };
c0ef4ec3041ecce4b962a0bd32558b09b8171134
cdfb5c3e3049aaf3f210e679364f34e38932d736
/Source/main.cpp
9ba60c9854491232c415f1ddbf587e37ad05d1ce
[]
no_license
adjsky/terraria_clone
37ea886abfe18df12f19c1caa4476f8efa180e49
9541726d2a4b429d9f8d8a37137e5999ecc51208
refs/heads/master
2023-03-22T12:45:40.760567
2021-03-24T05:20:27
2021-03-24T05:20:27
324,908,519
2
0
null
null
null
null
UTF-8
C++
false
false
134
cpp
main.cpp
#include "Core/Engine.h" #include "Game/Game.h" int main() { Engine::init(); Game game{ }; game.start(); return 0; }
7a23c5b31e62380a13d3a1a3d80bc40623061119
2a8df53e849bd9033400d748ade0c714ae575b71
/OOP/latihan 2.cpp
c93de22022fbca6f8f1da293c6955a7bde8c195c
[]
no_license
tarishahamzah/Tarisha-File
c682e29a91f2af1901b6730cea6441fbc85dedb6
ffcaffe2fc8dbaca2489f0921fdc3b955290c617
refs/heads/main
2022-12-29T09:43:33.091904
2020-10-19T08:02:06
2020-10-19T08:02:06
305,303,155
0
0
null
null
null
null
UTF-8
C++
false
false
2,199
cpp
latihan 2.cpp
#include <iostream> #include <conio.h> #include <string.h> using namespace std; class ActionCam { char Nama[25]; char Series[25]; char Sensor[25]; float focal; int harga; int ongkir; int Total; public : void setActionCam(char *Nama, char *Series, char *Sensor, float focal, int harga) { strcpy (this->Nama, Nama); strcpy (this->Series, Series); strcpy (this->Sensor, Sensor); this->focal = focal; this->harga = harga; } void showSetActionCam(){ cout << "ActionCam Nama =" << Nama << endl; cout << "ActionCam Series =" << Series << endl; cout << "ActionCam Sensor =" << Sensor << endl; cout << "ActionCam Focal =" << focal << endl; cout << "ActionCam Harga =" << harga << endl; } void DisplayActionCam(int ongkir ){ Total = (harga + ongkir)*1.1; cout << "Total Bayar Seluruh ActionCam = Rp." << Total << endl; } }; class DSLR { char Nama[25]; char Series[25]; char Sensor[25]; float focal; int lensa; int harga; int ongkir, Total; public : void setDSLR(char *Nama, char *Series, char *Sensor, float focal, int lensa, int harga){ strcpy (this->Nama, Nama); strcpy (this->Series, Series); strcpy (this->Sensor, Sensor); this->focal = focal; this->lensa = lensa; this->harga = harga; } void showDSLR(){ cout << "DSLR Nama =" << Nama << endl; cout << "DSLR Series =" << Series << endl; cout << "DSLR Sensor =" << Sensor << endl; cout << "DSLR Focal =" << focal << endl; cout << "DSLR Lensa =" << lensa << endl; cout << "DSLR Harga =" << harga << endl; } void DisplayDSLR(int ongkir){ Total = (harga + ongkir + lensa)* 1.1; cout << "Total Bayar Seluruh DSLR = Rp." << Total << endl; } }; int main (){ ActionCam Satu; Satu.setActionCam((char*) "Go Pro", (char*) "Pro 4", (char*) "CarlZeis", 1.4 , 5000000); Satu.showSetActionCam(); Satu.DisplayActionCam(100000); DSLR Dua; Dua.setDSLR((char*) "Canon", (char*) "5 D", (char*) "CarlZeis", 1.4 , 2400000, 5000000); Dua.showDSLR(); Dua.DisplayDSLR(150000); getche(); }
817244035407f1978c20ad598e1d0c1c4ec33c1d
2008b223bcaeffc72abadf605f0ce8ea8704e136
/assignments/assignment-01-albertotezza/shortest_string.cpp
803538705b206524debb5fda961c00a858c83eed
[]
no_license
albertotezza/embedded-systems-programming-aa-2019-20
0f74e17725f0b457db4510c8a2ec82da86ddc296
60f61e656313b9ee2b5416bc6e302092415f1ad6
refs/heads/master
2023-07-13T08:02:57.178879
2023-07-02T08:07:45
2023-07-02T08:07:45
211,164,650
0
0
null
null
null
null
UTF-8
C++
false
false
464
cpp
shortest_string.cpp
#include <iostream> #include <vector> #include <string> using std::cout; using std::endl; using std::vector; using std::string; #include "functions.h" string shortest_string(const vector<string>&v){ size_t dim{10}; string box_min; vector<string>::const_iterator pos; for(pos=v.begin(); pos!=v.end(); ++pos){ if((*pos).size()<dim){ dim=(*pos).size(); box_min=*pos; } } return box_min; } // funziona con iteratori
5665d003d8254cc1ea4f49e112d2db7056fe1859
f7006c9f2ae60e94b4ac2c5a13ce62329dd3db71
/partialmodel/pmvolumetric.cpp
515b46b9c0c1a7268c5bc3a72a12a881d98486c8
[ "BSD-3-Clause" ]
permissive
CHLMYR/vpl
9d61e310371346be29bbda95b6c5ad427db5570b
1a6e88353395ca0e43a0c4d0d6b38f7c7e2925f7
refs/heads/master
2023-03-15T16:24:58.187700
2018-08-17T14:26:14
2018-08-17T14:26:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,490
cpp
pmvolumetric.cpp
/* <one line to give the program's name and a brief idea of what it does.> Copyright (C) 2012 <copyright holder> <email> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "pmvolumetric.h" PMVolumetric::PMVolumetric(): PartialModelBase() { voxelResolution = 0.1; // default resolution 0.1 m freeSpace = false; minUnknown = 1; thereIsUnmarkVoxelsInNBV = true; stopCriteria = false; } PMVolumetric::~PMVolumetric() { //std::cout << "~PMVolumetric" << std::endl; } bool PMVolumetric::init() { PartialModelBase::init(); std::string config_file(configFolder); config_file.append("/"); config_file.append("partialModelConfig.ini"); //mrpt::utils::CConfigFile parser; //ASSERT_FILE_EXISTS_(config_file); //parser.setFileName(config_file); INIReader reader(config_file.c_str()); if (reader.ParseError() < 0) { std::cout << "Can't load " << config_file.c_str() << "\n"; return false; } voxelResolution = reader.GetReal("volumetric", "resolution", -1); weight = reader.GetReal("volumetric", "weight", 0.5); freeSpace = reader.GetBoolean("volumetric", "freeSpace", false); collisionGap = reader.GetReal("volumetric", "collisionGap", 0.1); minUnknown = reader.GetInteger("volumetric", "minUnknown", 100); minOverlap = reader.GetInteger("volumetric", "minOverlap", 1); if(freeSpace){ x_free_1 = reader.GetReal("freeSpaceCoord", "x1", -1); x_free_2 = reader.GetReal("freeSpaceCoord", "x2", -1); y_free_1 = reader.GetReal("freeSpaceCoord", "y1", -1); y_free_2 = reader.GetReal("freeSpaceCoord", "y2", -1); z_free_1 = reader.GetReal("freeSpaceCoord", "z1", -1); z_free_2 = reader.GetReal("freeSpaceCoord", "z2", -1); } maxRange = reader.GetReal( "volumetric", "maxRange", -1); std::cout << "---------- Volumetric configuration -------" << std::endl; std::cout << "Voxel reslution:" << voxelResolution << std::endl; std::cout << "Weight:" << weight << std::endl; std::cout << "Free space:" << freeSpace << std::endl; std::cout << "Collision gap:" << collisionGap << std::endl; std::cout << "Min unknown:" << minUnknown << std::endl; std::cout << "Min overlap:" << minOverlap << std::endl; std::cout << "max range:" << maxRange << std::endl; float x1, x2, y1, y2, z1, z2; x1 = reader.GetReal("objectCapsule", "x1", 0); x2 = reader.GetReal("objectCapsule", "x2", 0); y1 = reader.GetReal("objectCapsule", "y1", 0); y2 = reader.GetReal("objectCapsule", "y2", 0); z1 = reader.GetReal("objectCapsule", "z1", 0); z2 = reader.GetReal("objectCapsule", "z2", 0); point3d obj_min(x1,y1,z1); ObjectBBxMin = obj_min; point3d obj_max(x2,y2,z2); ObjectBBxMax = obj_max; x1 = reader.GetReal("sceneCapsule", "x1", 0); x2 = reader.GetReal("sceneCapsule", "x2", 0); y1 = reader.GetReal("sceneCapsule", "y1", 0); y2 = reader.GetReal("sceneCapsule", "y2", 0); z1 = reader.GetReal("sceneCapsule", "z1", 0); z2 = reader.GetReal("sceneCapsule", "z2", 0); point3d sce_min(x1,y1,z1); SceneBBxMin = sce_min; point3d sce_max(x2,y2,z2); SceneBBxMax = sce_max; return true; } bool PMVolumetric::collisionFree(float x, float y, float z) { std::cout << "to be implemented" << std::endl; return true; } //TODO void PMVolumetric::saveEvaluations() { // //PartialModelBase::saveEvaluations(); // //saveEvaluationResultVector(evaluations, evaluationsFile); // evals.saveVector(evaluationsFile); } // void PMVolumetric::setMinimunNumberOfUnmarkVoxels(int n) { minUnknown = n; } bool PMVolumetric::stopCriteriaReached() { return stopCriteria; } void PMVolumetric::getVoxelVertices(point3d_list& vertices, const point3d center, const double resolution) { //TEST vertices.clear(); double x, y, z; double offset = resolution/2; // ---- vertex 1 ---- x = center.x() - offset; y = center.y() - offset; z = center.z() - offset; point3d p1(x,y,z); vertices.push_back(p1); // ---- vertex 2 ---- x = center.x() + offset; y = center.y() - offset; z = center.z() - offset; point3d p2(x,y,z); vertices.push_back(p2); // ---- vertex 3 ---- x = center.x() + offset; y = center.y() - offset; z = center.z() + offset; point3d p3(x,y,z); vertices.push_back(p3); // ---- vertex 4 ---- x = center.x() - offset; y = center.y() - offset; z = center.z() + offset; point3d p4(x,y,z); vertices.push_back(p4); // ---- vertex 5 ---- x = center.x() - offset; y = center.y() + offset; z = center.z() - offset; point3d p5(x,y,z); vertices.push_back(p5); // ---- vertex 6 ---- x = center.x() + offset; y = center.y() + offset; z = center.z() - offset; point3d p6(x,y,z); vertices.push_back(p6); // ---- vertex 7 ---- x = center.x() + offset; y = center.y() + offset; z = center.z() + offset; point3d p7(x,y,z); vertices.push_back(p7); // ---- vertex 8 ---- x = center.x() - offset; y = center.y() + offset; z = center.z() + offset; point3d p8(x,y,z); vertices.push_back(p8); } void PMVolumetric::getTrianglesOfVoxel(vpTriangleList& tris, const point3d center, const double resolution) { vpVertex vertex; std::vector<vpVertex> vertices(8); double x, y, z; double offset = resolution/2; // ---- vertex 1 ---- x = center.x() - offset; y = center.y() - offset; z = center.z() - offset; vertex.setCoordinates(x,y,z); vertices[0] = vertex; // ---- vertex 2 ---- x = center.x() + offset; y = center.y() - offset; z = center.z() - offset; vertex.setCoordinates(x,y,z); vertices[1] = vertex; // ---- vertex 3 ---- x = center.x() + offset; y = center.y() - offset; z = center.z() + offset; vertex.setCoordinates(x,y,z); vertices[2] = vertex; // ---- vertex 4 ---- x = center.x() - offset; y = center.y() - offset; z = center.z() + offset; vertex.setCoordinates(x,y,z); vertices[3] = vertex; // ---- vertex 5 ---- x = center.x() - offset; y = center.y() + offset; z = center.z() - offset; vertex.setCoordinates(x,y,z); vertices[4] = vertex; // ---- vertex 6 ---- x = center.x() + offset; y = center.y() + offset; z = center.z() - offset; vertex.setCoordinates(x,y,z); vertices[5] = vertex; // ---- vertex 7 ---- x = center.x() + offset; y = center.y() + offset; z = center.z() + offset; vertex.setCoordinates(x,y,z); vertices[6] = vertex; // ---- vertex 8 ---- x = center.x() - offset; y = center.y() + offset; z = center.z() + offset; vertex.setCoordinates(x,y,z); vertices[7] = vertex; vpTriangle t; tris.clear(); t.a = vertices[0]; t.b = vertices[1]; t.c = vertices[2]; tris.push_back(t); t.a = vertices[0]; t.b = vertices[2]; t.c = vertices[3]; tris.push_back(t); t.a = vertices[0]; t.b = vertices[1]; t.c = vertices[4]; tris.push_back(t); t.a = vertices[1]; t.b = vertices[4]; t.c = vertices[5]; tris.push_back(t); t.a = vertices[4]; t.b = vertices[5]; t.c = vertices[6]; tris.push_back(t); t.a = vertices[4]; t.b = vertices[6]; t.c = vertices[7]; tris.push_back(t); t.a = vertices[0]; t.b = vertices[4]; t.c = vertices[7]; tris.push_back(t); t.a = vertices[0]; t.b = vertices[3]; t.c = vertices[7]; tris.push_back(t); t.a = vertices[2]; t.b = vertices[6]; t.c = vertices[7]; tris.push_back(t); t.a = vertices[2]; t.b = vertices[7]; t.c = vertices[3]; tris.push_back(t); t.a = vertices[1]; t.b = vertices[5]; t.c = vertices[6]; tris.push_back(t); t.a = vertices[1]; t.b = vertices[6]; t.c = vertices[2]; tris.push_back(t); }
8a6bb6ed83711aa4295b3d2b5ebe0a05e2aad752
f2d99456cab86e8e5ff4d7c42f2f03b4d2fb34d8
/src/reverse/RTTIHelper.cpp
6c4444463b2aaa4ff07beff1a03faf29cf57dd46
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MIT", "OFL-1.1" ]
permissive
WopsS/PerformanceOverhaulCyberpunk
7e97a38002d0bae5d7592139dc85f4f04a6518a0
8d1ceebbae13e7067d0a95abf1ec07d5dde6a65b
refs/heads/master
2023-04-27T15:58:32.883915
2023-04-17T05:07:26
2023-04-17T05:07:26
323,208,527
0
1
MIT
2023-04-20T18:04:51
2020-12-21T02:16:02
C
UTF-8
C++
false
false
34,801
cpp
RTTIHelper.cpp
#include <stdafx.h> #include "RTTIHelper.h" #include "ClassReference.h" #include "StrongReference.h" #include "WeakReference.h" #include <common/ScopeGuard.h> #include <scripting/Scripting.h> #include <Utils.h> namespace { constexpr bool s_cEnableOverloads = true; constexpr bool s_cLogAllOverloadVariants = true; constexpr bool s_cThrowLuaErrors = true; std::unique_ptr<RTTIHelper> s_pInstance{nullptr}; using TCallScriptFunction = bool (*)(RED4ext::IFunction* apFunction, RED4ext::IScriptable* apContext, RED4ext::CStackFrame* apFrame, void* apResult, void* apResultType); RED4ext::RelocFunc<TCallScriptFunction> CallScriptFunction(RED4ext::Addresses::CBaseFunction_InternalExecute); } // namespace void RTTIHelper::Initialize(const LockableState& acLua, LuaSandbox& apSandbox) { if (!s_pInstance) { s_pInstance.reset(new RTTIHelper(acLua, apSandbox)); } } void RTTIHelper::PostInitialize() { if (s_pInstance) { s_pInstance->InitializeRuntime(); } } void RTTIHelper::Shutdown() { // Since m_resolvedFunctions contains references to Lua state // it's important to call destructor while Lua state exists. // Otherwise sol will throw invalid reference exception. s_pInstance.reset(nullptr); } RTTIHelper& RTTIHelper::Get() { return *s_pInstance; } RTTIHelper::RTTIHelper(const LockableState& acpLua, LuaSandbox& apSandbox) : m_lua(acpLua) , m_sandbox(apSandbox) { InitializeRTTI(); ParseGlobalStatics(); } void RTTIHelper::InitializeRTTI() { m_pRtti = RED4ext::CRTTISystem::Get(); m_pGameInstanceType = m_pRtti->GetClass(RED4ext::FNV1a64("ScriptGameInstance")); } void RTTIHelper::InitializeRuntime() { const auto cpEngine = RED4ext::CGameEngine::Get(); const auto cpGameInstance = cpEngine->framework->gameInstance; const auto cpPlayerSystemType = m_pRtti->GetType(RED4ext::FNV1a64("cpPlayerSystem")); m_pGameInstance = static_cast<ScriptGameInstance*>(m_pGameInstanceType->CreateInstance()); m_pGameInstance->gameInstance = cpGameInstance; m_pPlayerSystem = cpGameInstance->GetSystem(cpPlayerSystemType); } void RTTIHelper::ParseGlobalStatics() { m_pRtti->funcs.for_each( [this](RED4ext::CName aOrigName, RED4ext::CGlobalFunction* apFunc) { const std::string cOrigName = aOrigName.ToString(); const auto cClassSep = cOrigName.find("::"); if (cClassSep != std::string::npos) { const auto cClassName = cOrigName.substr(0, cClassSep); const auto cFullName = cOrigName.substr(cClassSep + 2); const auto cClassHash = RED4ext::FNV1a64(cClassName.c_str()); const auto cFullHash = RED4ext::FNV1a64(cFullName.c_str()); if (!m_extendedFunctions.contains(cClassHash)) m_extendedFunctions.emplace(cClassHash, 0); m_extendedFunctions.at(cClassHash).emplace(cFullHash, apFunc); } }); } void RTTIHelper::AddFunctionAlias(const std::string&, const std::string& acOrigClassName, const std::string& acOrigFuncName) { auto* pClass = m_pRtti->GetClass(RED4ext::FNV1a64(acOrigClassName.c_str())); if (pClass) { auto* pFunc = FindFunction(pClass, RED4ext::FNV1a64(acOrigFuncName.c_str())); if (pFunc) { if (!m_extendedFunctions.contains(kGlobalHash)) m_extendedFunctions.emplace(kGlobalHash, 0); m_extendedFunctions.at(kGlobalHash).emplace(pFunc->fullName.hash, pFunc); } } } void RTTIHelper::AddFunctionAlias(const std::string& acAliasClassName, const std::string&, const std::string& acOrigClassName, const std::string& acOrigFuncName) { auto* pClass = m_pRtti->GetClass(RED4ext::FNV1a64(acOrigClassName.c_str())); if (pClass) { auto* pFunc = FindFunction(pClass, RED4ext::FNV1a64(acOrigFuncName.c_str())); if (pFunc) { const auto cClassHash = RED4ext::FNV1a64(acAliasClassName.c_str()); if (!m_extendedFunctions.contains(cClassHash)) m_extendedFunctions.emplace(cClassHash, 0); m_extendedFunctions.at(cClassHash).emplace(pFunc->fullName.hash, pFunc); } } } bool RTTIHelper::IsFunctionAlias(RED4ext::CBaseFunction* apFunc) { static constexpr auto s_cTweakDBInterfaceHash = RED4ext::FNV1a64("gamedataTweakDBInterface"); static constexpr auto s_cTDBIDHelperHash = RED4ext::FNV1a64("gamedataTDBIDHelper"); if (m_extendedFunctions.contains(kGlobalHash)) { const auto& extendedFuncs = m_extendedFunctions.at(kGlobalHash); if (extendedFuncs.contains(apFunc->fullName.hash)) return true; } if (apFunc->GetParent()) { const auto cClassHash = apFunc->GetParent()->name.hash; // TweakDBInterface and TDBID classes are special. // All of their methods are non-static, but they can only be used as static ones. if (cClassHash == s_cTweakDBInterfaceHash || cClassHash == s_cTDBIDHelperHash) return true; if (m_extendedFunctions.contains(cClassHash)) { const auto& extendedFuncs = m_extendedFunctions.at(cClassHash); if (extendedFuncs.contains(apFunc->fullName.hash)) return true; } } return false; } sol::function RTTIHelper::GetResolvedFunction(const uint64_t acFuncHash) const { return GetResolvedFunction(kGlobalHash, acFuncHash, false); } sol::function RTTIHelper::GetResolvedFunction(const uint64_t acClassHash, const uint64_t acFuncHash, bool aIsMember) const { const auto cScope = aIsMember ? kMemberScope : kStaticScope; if (m_resolvedFunctions[cScope].contains(acClassHash)) { auto& classFuncs = m_resolvedFunctions[cScope].at(acClassHash); if (classFuncs.contains(acFuncHash)) return classFuncs.at(acFuncHash); } return sol::nil; } // Add global function to resolved map void RTTIHelper::AddResolvedFunction(const uint64_t acFuncHash, sol::function& acFunc) { AddResolvedFunction(kGlobalHash, acFuncHash, acFunc, false); } // Add class function to resolved map void RTTIHelper::AddResolvedFunction(const uint64_t acClassHash, const uint64_t acFuncHash, sol::function& acFunc, bool aIsMember) { const auto cScope = aIsMember ? kMemberScope : kStaticScope; if (!m_resolvedFunctions[cScope].contains(acClassHash)) m_resolvedFunctions[cScope].emplace(acClassHash, 0); m_resolvedFunctions[cScope].at(acClassHash).emplace(acFuncHash, acFunc); } // Find global function matching full name RED4ext::CBaseFunction* RTTIHelper::FindFunction(const uint64_t acFullNameHash) const { RED4ext::CBaseFunction* pFunc = m_pRtti->GetFunction(acFullNameHash); if (!pFunc && m_extendedFunctions.contains(kGlobalHash)) { auto& extendedFuncs = m_extendedFunctions.at(kGlobalHash); if (extendedFuncs.contains(acFullNameHash)) pFunc = extendedFuncs.at(acFullNameHash); } return pFunc; } // Find class function matching full name RED4ext::CBaseFunction* RTTIHelper::FindFunction(RED4ext::CClass* apClass, const uint64_t acFullNameHash) const { while (apClass != nullptr) { if (m_extendedFunctions.contains(apClass->name.hash)) { auto& extendedFuncs = m_extendedFunctions.at(apClass->name.hash); if (extendedFuncs.contains(acFullNameHash)) return extendedFuncs.at(acFullNameHash); } for (uint32_t i = 0; i < apClass->funcs.size; ++i) { if (apClass->funcs.entries[i]->fullName.hash == acFullNameHash) return apClass->funcs.entries[i]; } for (uint32_t i = 0; i < apClass->staticFuncs.size; ++i) { if (apClass->staticFuncs.entries[i]->fullName.hash == acFullNameHash) return apClass->staticFuncs.entries[i]; } apClass = apClass->parent; } return nullptr; } // Find all global functions matching short name std::map<uint64_t, RED4ext::CBaseFunction*> RTTIHelper::FindFunctions(const uint64_t acShortNameHash) const { std::map<uint64_t, RED4ext::CBaseFunction*> results{}; m_pRtti->funcs.for_each( [&results, &acShortNameHash](RED4ext::CName aFullName, RED4ext::CGlobalFunction* apFunction) { if (apFunction->shortName.hash == acShortNameHash) results.emplace(aFullName.hash, apFunction); }); if (m_extendedFunctions.contains(kGlobalHash)) { auto& extendedFuncs = m_extendedFunctions.at(kGlobalHash); for (const auto& cEntry : extendedFuncs) { if (cEntry.second->shortName.hash == acShortNameHash) results.emplace(cEntry.first, cEntry.second); } } return results; } // Find all class functions matching short name std::map<uint64_t, RED4ext::CBaseFunction*> RTTIHelper::FindFunctions(RED4ext::CClass* apClass, const uint64_t acShortNameHash, bool aIsMember) const { std::map<uint64_t, RED4ext::CBaseFunction*> results{}; while (apClass != nullptr) { if (aIsMember) { for (uint32_t i = 0; i < apClass->funcs.size; ++i) { if (apClass->funcs.entries[i]->shortName.hash == acShortNameHash) results.emplace(apClass->funcs.entries[i]->fullName.hash, apClass->funcs.entries[i]); } } else { for (uint32_t i = 0; i < apClass->staticFuncs.size; ++i) { if (apClass->staticFuncs.entries[i]->shortName.hash == acShortNameHash) results.emplace(apClass->staticFuncs.entries[i]->fullName.hash, apClass->staticFuncs.entries[i]); } if (m_extendedFunctions.contains(apClass->name.hash)) { auto& extendedFuncs = m_extendedFunctions.at(apClass->name.hash); for (const auto& cEntry : extendedFuncs) { if (cEntry.second->shortName.hash == acShortNameHash) results.emplace(cEntry.first, cEntry.second); } } } apClass = apClass->parent; } return results; } // Resolve global function to Lua function sol::function RTTIHelper::ResolveFunction(const std::string& acFuncName) { if (!m_pRtti) return sol::nil; const auto cFuncHash = RED4ext::FNV1a64(acFuncName.c_str()); auto invokable = GetResolvedFunction(cFuncHash); if (invokable != sol::nil) return invokable; const auto cIsFullName = acFuncName.find(';') != std::string::npos; if (cIsFullName) { auto pFunc = FindFunction(cFuncHash); if (!pFunc) { pFunc = FindFunction(m_pGameInstanceType, cFuncHash); if (!pFunc) return sol::nil; } invokable = MakeInvokableFunction(pFunc); AddResolvedFunction(cFuncHash, invokable); } else { auto overloads = FindFunctions(cFuncHash); if (overloads.empty()) { overloads = FindFunctions(m_pGameInstanceType, cFuncHash, false); if (overloads.empty()) return sol::nil; } if (!s_cEnableOverloads || overloads.size() == 1) invokable = MakeInvokableFunction(overloads.begin()->second); else invokable = MakeInvokableOverload(overloads); AddResolvedFunction(cFuncHash, invokable); } return invokable; } // Resolve class function to Lua function sol::function RTTIHelper::ResolveFunction(RED4ext::CClass* apClass, const std::string& acFuncName, bool aIsMember) { if (!m_pRtti) return sol::nil; if (apClass == nullptr) return ResolveFunction(acFuncName); const auto cClassHash = RED4ext::FNV1a64(apClass->name.ToString()); const auto cFuncHash = RED4ext::FNV1a64(acFuncName.c_str()); auto invokable = GetResolvedFunction(cClassHash, cFuncHash, aIsMember); if (invokable != sol::nil) return invokable; const auto cIsFullName = acFuncName.find(';') != std::string::npos; if (cIsFullName) { const auto pFunc = FindFunction(apClass, cFuncHash); if (!pFunc) return sol::nil; invokable = MakeInvokableFunction(pFunc); AddResolvedFunction(cClassHash, cFuncHash, invokable, aIsMember); } else { auto overloads = FindFunctions(apClass, cFuncHash, aIsMember); if (overloads.empty()) { // Try different scope if nothing was found in the needed one // Allows static functions to be called from the instance overloads = FindFunctions(apClass, cFuncHash, !aIsMember); if (overloads.empty()) return sol::nil; } if (!s_cEnableOverloads || overloads.size() == 1) invokable = MakeInvokableFunction(overloads.begin()->second); else invokable = MakeInvokableOverload(overloads); AddResolvedFunction(cClassHash, cFuncHash, invokable, aIsMember); } return invokable; } sol::function RTTIHelper::MakeInvokableFunction(RED4ext::CBaseFunction* apFunc) { auto lockedState = m_lua.Lock(); auto& luaState = lockedState.Get(); const bool cAllowNull = IsFunctionAlias(apFunc); return MakeSolFunction( luaState, [this, apFunc, cAllowNull](sol::variadic_args aArgs, sol::this_state aState, sol::this_environment aEnv) -> sol::variadic_results { uint64_t argOffset = 0; const auto pHandle = ResolveHandle(apFunc, aArgs, argOffset); std::string errorMessage; auto result = ExecuteFunction(apFunc, pHandle, aArgs, argOffset, errorMessage, cAllowNull); if (!errorMessage.empty()) { if constexpr (s_cThrowLuaErrors) { luaL_error(aState, errorMessage.c_str()); } else { const sol::environment cEnv = aEnv; auto logger = cEnv["__logger"].get<std::shared_ptr<spdlog::logger>>(); logger->error("Error: {}", errorMessage); } } return result; }); } sol::function RTTIHelper::MakeInvokableOverload(std::map<uint64_t, RED4ext::CBaseFunction*> aOverloadedFuncs) const { auto lockedState = m_lua.Lock(); auto& luaState = lockedState.Get(); TiltedPhoques::Vector<Overload> variants; for (const auto& func : aOverloadedFuncs | std::views::values) variants.emplace_back(func); return MakeSolFunction( luaState, [this, variants](sol::variadic_args aArgs, sol::this_state aState, sol::this_environment aEnv) mutable -> sol::variadic_results { for (auto variant = variants.begin(); variant != variants.end(); ++variant) { variant->lastError.clear(); uint64_t argOffset = 0; const auto pHandle = ResolveHandle(variant->func, aArgs, argOffset); auto result = ExecuteFunction(variant->func, pHandle, aArgs, argOffset, variant->lastError); if (variant->lastError.empty()) { if (variant->totalCalls < kTrackedOverloadCalls) { ++variant->totalCalls; if (variant != variants.begin()) { const auto previous = variant - 1; if (variant->totalCalls > previous->totalCalls) std::iter_swap(previous, variant); } } return result; } } if constexpr (s_cLogAllOverloadVariants) { const sol::environment cEnv = aEnv; const auto logger = cEnv["__logger"].get<std::shared_ptr<spdlog::logger>>(); for (auto& variant : variants) logger->info("{}: {}", variant.func->fullName.ToString(), variant.lastError); logger->flush(); } std::string errorMessage = fmt::format("No matching overload of '{}' function.", variants.begin()->func->shortName.ToString()); if constexpr (s_cThrowLuaErrors) { luaL_error(aState, errorMessage.c_str()); } else { const sol::environment cEnv = aEnv; auto logger = cEnv["__logger"].get<std::shared_ptr<spdlog::logger>>(); logger->error("Error: {}", errorMessage); } return {}; }); } RED4ext::IScriptable* RTTIHelper::ResolveHandle(RED4ext::CBaseFunction* apFunc, sol::variadic_args& aArgs, uint64_t& aArgOffset) const { // Case 1: obj:Member() -- Skip the first arg and pass it as a handle // Case 2: obj:Static() -- Pass args as is, including the implicit self // Case 3: obj:Static(obj) -- Skip the first arg as it duplicates the second arg (for backward compatibility) // Case 4: Type.Static() -- Pass args as is // Case 5: Type.Member() -- Skip the first arg and pass it as a handle // Case 6: GetSingleton("Type"):Static() -- Skip the first arg as it's a dummy // Case 7: GetSingleton("Type"):Member() -- Skip the first arg as it's a dummy RED4ext::IScriptable* pHandle = nullptr; if (aArgs.size() > aArgOffset) { if (apFunc->flags.isStatic) { if (aArgs[aArgOffset].is<SingletonReference>()) { ++aArgOffset; } else if (aArgs[aArgOffset].is<ClassReference>() && aArgs.size() > aArgOffset + 1) { const auto& cFirst = aArgs[aArgOffset]; const auto& cSecond = aArgs[aArgOffset + 1]; if (cFirst.as<sol::object>() == cSecond.as<sol::object>()) ++aArgOffset; } } else { const auto& cArg = aArgs[aArgOffset]; if (cArg.is<Type>()) { pHandle = reinterpret_cast<RED4ext::IScriptable*>(cArg.as<Type*>()->GetHandle()); if (cArg.is<StrongReference>() || cArg.is<WeakReference>()) { ++aArgOffset; if (pHandle && !pHandle->GetType()->IsA(apFunc->GetParent())) pHandle = nullptr; } else if (cArg.is<SingletonReference>()) { ++aArgOffset; } } } } return pHandle; } sol::variadic_results RTTIHelper::ExecuteFunction( RED4ext::CBaseFunction* apFunc, RED4ext::IScriptable* apContext, sol::variadic_args aLuaArgs, uint64_t aLuaArgOffset, std::string& aErrorMessage, bool aAllowNull) const { static thread_local TiltedPhoques::ScratchAllocator s_scratchMemory(1 << 14); static thread_local uint32_t s_callDepth = 0u; if (!m_pRtti) return {}; const auto* cpEngine = RED4ext::CGameEngine::Get(); if (!cpEngine || !cpEngine->framework) return {}; // Out params // There are cases when out param must be passed to the function. // These functions cannot be used until more complex logic for input // args is implemented (should check if a compatible arg is actually // passed at the expected position + same for optionals). if (!apFunc->flags.isStatic && !apContext && !aAllowNull) { aErrorMessage = fmt::format("Function '{}' context must be '{}'.", apFunc->shortName.ToString(), apFunc->GetParent()->name.ToString()); return {}; } auto numArgs = aLuaArgs.size() - aLuaArgOffset; auto minArgs = 0u; auto maxArgs = 0u; for (auto i = 0u; i < apFunc->params.size; ++i) { const auto cpParam = apFunc->params[i]; if (!cpParam->flags.isOut && cpParam->type != m_pGameInstanceType) { maxArgs++; if (!cpParam->flags.isOptional) minArgs++; } } if (numArgs < minArgs || numArgs > maxArgs) { if (minArgs != maxArgs) aErrorMessage = fmt::format("Function '{}' requires from {} to {} parameter(s).", apFunc->shortName.ToString(), minArgs, maxArgs); else aErrorMessage = fmt::format("Function '{}' requires {} parameter(s).", apFunc->shortName.ToString(), minArgs); return {}; } // Allocator management ++s_callDepth; ScopeGuard allocatorGuard( [&] { --s_callDepth; if (s_callDepth == 0u) s_scratchMemory.Reset(); }); auto pAllocator = TiltedPhoques::Allocator::Get(); TiltedPhoques::Allocator::Set(&s_scratchMemory); TiltedPhoques::Vector<RED4ext::CStackType> callArgs(apFunc->params.size); TiltedPhoques::Vector<uint32_t> callArgToParam(apFunc->params.size); TiltedPhoques::Vector<bool> argNeedsFree(apFunc->params.size, false); TiltedPhoques::Allocator::Set(pAllocator); uint32_t callArgOffset = 0u; ScopeGuard argsGuard( [&] { for (auto j = 0u; j < callArgOffset; ++j) { const bool isNew = argNeedsFree[j]; FreeInstance(callArgs[j], !isNew, isNew, &s_scratchMemory); } }); for (auto i = 0u; i < apFunc->params.size; ++i) { const auto cpParam = apFunc->params[i]; if (cpParam->type == m_pGameInstanceType) { callArgs[callArgOffset].type = m_pGameInstanceType; callArgs[callArgOffset].value = m_pGameInstance; } else if (cpParam->flags.isOut) { // It looks like constructing value with ToRED for out params is not required, // and memory allocation is enough. callArgs[callArgOffset].type = cpParam->type; callArgs[callArgOffset].value = NewPlaceholder(cpParam->type, &s_scratchMemory); argNeedsFree[callArgOffset] = true; // But ToRED conversion is necessary for implementing required out params. // callArgs[callArgOffset] = Scripting::ToRED(sol::nil, cpParam->type, &s_scratchMemory); } else if (cpParam->flags.isOptional) { if (aLuaArgOffset < aLuaArgs.size()) { sol::object argValue = aLuaArgs[aLuaArgOffset]; callArgs[callArgOffset] = Scripting::ToRED(argValue, cpParam->type, &s_scratchMemory); } // Create a placeholder if value is incompatible or omitted if (!callArgs[callArgOffset].value) { callArgs[callArgOffset].type = cpParam->type; callArgs[callArgOffset].value = nullptr; } else { ++aLuaArgOffset; } } else if (aLuaArgOffset < aLuaArgs.size()) { sol::object argValue = aLuaArgs[aLuaArgOffset]; callArgs[callArgOffset] = Scripting::ToRED(argValue, cpParam->type, &s_scratchMemory); ++aLuaArgOffset; } if (!callArgs[callArgOffset].value && !cpParam->flags.isOptional) { const auto typeName = cpParam->type->GetName(); aErrorMessage = fmt::format("Function '{}' parameter {} must be {}.", apFunc->shortName.ToString(), i + 1, typeName.ToString()); return {}; } callArgToParam[callArgOffset] = i; ++callArgOffset; } const bool hasReturnType = apFunc->returnType != nullptr && apFunc->returnType->type != nullptr; uint8_t buffer[1000]{0}; RED4ext::CStackType result; if (hasReturnType) { result.value = &buffer; result.type = apFunc->returnType->type; } const auto success = ExecuteFunction(apFunc, apContext, callArgs, result); if (!success) { aErrorMessage = fmt::format("Function '{}' failed to execute.", apFunc->shortName.ToString()); return {}; } auto lockedState = m_lua.Lock(); sol::variadic_results results; if (hasReturnType) { // There is a special case when a non-native function returns a specific class or something that holds that // class, which leads to another memory leak. So far the only known class that is causing the issue is // gameTargetSearchFilter. When it returned by a non-native function it is wrapped in the Variant or similar // structure. To prevent the leak the underlying value must be unwrapped and the wrapper explicitly destroyed. // The workaround has been proven to work, but it seems too much for only one known case, so it is not included // for now. results.emplace_back(Scripting::ToLua(lockedState, result)); FreeInstance(result, false, false, &s_scratchMemory); } for (auto i = 0u; i < callArgOffset; ++i) { const auto cpParam = apFunc->params[callArgToParam[i]]; if (cpParam->flags.isOut) results.emplace_back(Scripting::ToLua(lockedState, callArgs[i])); } return results; } bool RTTIHelper::ExecuteFunction( RED4ext::CBaseFunction* apFunc, RED4ext::IScriptable* apContext, TiltedPhoques::Vector<RED4ext::CStackType>& aArgs, RED4ext::CStackType& aResult) const { constexpr auto NopOp = 0; constexpr auto ParamOp = 27; constexpr auto ParamEndOp = 38; constexpr auto MaxCodeSize = 264; constexpr auto PointerSize = sizeof(void*); char code[MaxCodeSize]; RED4ext::CStackFrame frame(nullptr, code); for (uint32_t i = 0; i < apFunc->params.size; ++i) { const auto& param = apFunc->params[i]; const auto& arg = aArgs[i]; if (param->flags.isOptional && !arg.value) { *frame.code = NopOp; ++frame.code; } else { *frame.code = ParamOp; ++frame.code; *reinterpret_cast<void**>(frame.code) = arg.type; frame.code += PointerSize; *reinterpret_cast<void**>(frame.code) = arg.value; frame.code += PointerSize; } } *frame.code = ParamEndOp; frame.code = code; // Rewind // This is not intended use, but a trick. // The frame we create is the parent of the current call, // but we set it to apFunc itself just to make sure it's not null, // because there are some functions that expect a non-empty call stack. frame.func = apFunc; return CallScriptFunction(apFunc, apContext ? apContext : m_pPlayerSystem, &frame, aResult.value, aResult.type); } RED4ext::ScriptInstance RTTIHelper::NewPlaceholder(RED4ext::CBaseRTTIType* apType, TiltedPhoques::Allocator* apAllocator) const { auto* pMemory = apAllocator->Allocate(apType->GetSize()); memset(pMemory, 0, apType->GetSize()); apType->Construct(pMemory); return pMemory; } RED4ext::ScriptInstance RTTIHelper::NewInstance(RED4ext::CBaseRTTIType* apType, sol::optional<sol::table> aProps, TiltedPhoques::Allocator* apAllocator) const { if (!m_pRtti) return nullptr; RED4ext::CClass* pClass = nullptr; if (apType->GetType() == RED4ext::ERTTIType::Class) { pClass = reinterpret_cast<RED4ext::CClass*>(apType); } else if (apType->GetType() == RED4ext::ERTTIType::Handle) { auto* pInnerType = reinterpret_cast<RED4ext::CRTTIHandleType*>(apType)->GetInnerType(); if (pInnerType->GetType() == RED4ext::ERTTIType::Class) pClass = reinterpret_cast<RED4ext::CClass*>(pInnerType); } if (!pClass || pClass->flags.isAbstract) return nullptr; // AllocInstance() seems to be the only function that initializes an instance. // Neither Init() nor InitCls() initializes properties. auto* pInstance = pClass->CreateInstance(); if (aProps.has_value()) SetProperties(pClass, pInstance, aProps.value()); return (apType->GetType() == RED4ext::ERTTIType::Handle) ? apAllocator->New<RED4ext::Handle<RED4ext::IScriptable>>(static_cast<RED4ext::IScriptable*>(pInstance)) : pInstance; } sol::object RTTIHelper::NewInstance(RED4ext::CBaseRTTIType* apType, sol::optional<sol::table> aProps) const { if (!m_pRtti) return sol::nil; TiltedPhoques::StackAllocator<1 << 10> allocator; RED4ext::CStackType result; result.type = apType; result.value = NewInstance(apType, sol::nullopt, &allocator); auto lockedState = m_lua.Lock(); auto instance = Scripting::ToLua(lockedState, result); FreeInstance(result, true, true, &allocator); if (aProps.has_value()) { const auto pInstance = instance.as<ClassType*>(); SetProperties(pInstance->GetClass(), pInstance->GetHandle(), aProps); } return instance; } // Create new instance and wrap it in Handle<> if possible sol::object RTTIHelper::NewHandle(RED4ext::CBaseRTTIType* apType, sol::optional<sol::table> aProps) const { // This method should be preferred over NewInstance() for creating objects in Lua userland. // The behavior is similar to what can be seen in scripts, where variables of IScriptable // types are declared with the ref<> modifier (which means Handle<>). if (!m_pRtti) return sol::nil; TiltedPhoques::StackAllocator<1 << 10> allocator; RED4ext::CStackType result; result.type = apType; result.value = NewInstance(apType, sol::nullopt, &allocator); // Wrap ISerializable descendants in Handle if (result.value && apType->GetType() == RED4ext::ERTTIType::Class) { static auto* s_pHandleType = m_pRtti->GetType(RED4ext::FNV1a64("handle:Activator")); static auto* s_pISerializableType = m_pRtti->GetType(RED4ext::FNV1a64("ISerializable")); const auto* pClass = reinterpret_cast<RED4ext::CClass*>(apType); if (pClass->IsA(s_pISerializableType)) { auto* pInstance = static_cast<RED4ext::ISerializable*>(result.value); auto* pHandle = allocator.New<RED4ext::Handle<RED4ext::ISerializable>>(pInstance); result.type = s_pHandleType; // To trick converter and deallocator result.value = pHandle; } } auto lockedState = m_lua.Lock(); auto instance = Scripting::ToLua(lockedState, result); FreeInstance(result, true, true, &allocator); if (aProps.has_value()) { const auto pInstance = instance.as<ClassType*>(); SetProperties(pInstance->GetClass(), pInstance->GetHandle(), aProps); } return instance; } sol::object RTTIHelper::GetProperty(RED4ext::CClass* apClass, RED4ext::ScriptInstance apHandle, const std::string& acPropName, bool& aSuccess) const { aSuccess = false; if (!m_pRtti) return sol::nil; const auto* pProp = apClass->GetProperty(acPropName.c_str()); if (!pProp) return sol::nil; auto lockedState = m_lua.Lock(); RED4ext::CStackType stackType(pProp->type, pProp->GetValue<uintptr_t*>(apHandle)); aSuccess = true; return Scripting::ToLua(lockedState, stackType); } void RTTIHelper::SetProperty(RED4ext::CClass* apClass, RED4ext::ScriptInstance apHandle, const std::string& acPropName, sol::object aPropValue, bool& aSuccess) const { aSuccess = false; if (!m_pRtti) return; const auto* pProp = apClass->GetProperty(acPropName.c_str()); if (!pProp) return; static thread_local TiltedPhoques::ScratchAllocator s_scratchMemory(1 << 14); struct ResetAllocator { ~ResetAllocator() { s_scratchMemory.Reset(); } }; ResetAllocator ___allocatorReset; RED4ext::CStackType stackType = Scripting::ToRED(aPropValue, pProp->type, &s_scratchMemory); if (stackType.value) { pProp->SetValue<RED4ext::ScriptInstance>(apHandle, stackType.value); FreeInstance(stackType, true, false, &s_scratchMemory); aSuccess = true; } } void RTTIHelper::SetProperties(RED4ext::CClass* apClass, RED4ext::ScriptInstance apHandle, sol::optional<sol::table> aProps) const { bool success; for (const auto& cProp : aProps.value()) SetProperty(apClass, apHandle, cProp.first.as<std::string>(), cProp.second, success); } // Check if type is implemented using ClassReference bool RTTIHelper::IsClassReferenceType(RED4ext::CClass* apClass) const { static constexpr auto s_cHashVector3 = RED4ext::FNV1a64("Vector3"); static constexpr auto s_cHashVector4 = RED4ext::FNV1a64("Vector4"); static constexpr auto s_cHashEulerAngles = RED4ext::FNV1a64("EulerAngles"); static constexpr auto s_cHashQuaternion = RED4ext::FNV1a64("Quaternion"); static constexpr auto s_cHashItemID = RED4ext::FNV1a64("gameItemID"); return apClass->name.hash != s_cHashVector3 && apClass->name.hash != s_cHashVector4 && apClass->name.hash != s_cHashEulerAngles && apClass->name.hash != s_cHashQuaternion && apClass->name.hash != s_cHashItemID; } void RTTIHelper::FreeInstance(RED4ext::CStackType& aStackType, bool aOwn, bool aNew, TiltedPhoques::Allocator* apAllocator) const { FreeInstance(aStackType.type, aStackType.value, aOwn, aNew, apAllocator); } void RTTIHelper::FreeInstance(RED4ext::CBaseRTTIType* apType, void* apValue, bool aOwn, bool aNew, TiltedPhoques::Allocator*) const { if (!apValue) return; if (aOwn) { if (apType->GetType() == RED4ext::ERTTIType::Class) { // Free instances created with AllocInstance() if (aNew) { auto* pClass = reinterpret_cast<RED4ext::CClass*>(apType); // Skip basic types if (IsClassReferenceType(pClass)) { pClass->DestructCls(apValue); pClass->GetAllocator()->Free(apValue); } } } else { apType->Destruct(apValue); } } else { if (aNew || apType->GetType() != RED4ext::ERTTIType::Class) apType->Destruct(apValue); } // Right now it's a workaround that doesn't cover all cases but most. // It also requires explicit calls to FreeInstance(). // Should probably be refactored into a custom allocator that // combines ScratchAllocator and managed logic for: // 1. Instances created with AllocInstance() // 2. DynArray // 3. Handle // 4. WeakHandle }
b9df95f06503e34d2005214054aecdd6d750e9fc
742182b23044c91df9a3d99652697152fc13f91d
/Div1/SRM522Div1/Easy.cpp
b005635fb6d53e97c21e216939d085720831c32d
[]
no_license
iseki-masaya/topcoder
15e052bff8043f60a15969acc723e2550eae262c
c85ba323476b03abbc22a758e5724f15796ee62b
refs/heads/master
2016-09-11T02:00:10.773000
2015-04-26T02:41:05
2015-04-26T02:41:05
9,335,477
0
0
null
null
null
null
UTF-8
C++
false
false
847
cpp
Easy.cpp
#include <vector> #include <string> #include <iostream> #include <fstream> #include <sstream> #include <list> #include <algorithm> #include <sstream> #include <set> #include <cmath> #include <map> #include <stack> #include <queue> #include <cstdio> #include <cstdlib> #include <cstring> #include <numeric> #include <bitset> const long long LINF = (1e11); const int INF = (1<<28); #define EPS 1e-6 const int MOD = 1000000007; using namespace std; class RowAndCoins { public: string getWinner(string cells) { int alice = 0 , bob = 0; int idx = 0; int N = (int)cells.size(); while (idx < N) { char current = cells[idx]; while (idx < N && current == cells[idx]) ++idx; current == 'A' ? ++alice : ++bob; } return alice >= bob ? "Alice" : "Bob"; } };
774318e6e24850bb3a80289efd849c7ddfb33820
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_2524.cpp
2c3cc7d366ab3063be97ca45291fccd84943d1f8
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
27
cpp
Kitware_CMake_repos_basic_block_block_2524.cpp
{ runaway[i] = '.'; }
059f573ec6b729dfe0b56dd47270be2aca42fbe4
1806eaae69f944683e308348714efc4c470bb95c
/kex2/turok/game/canvas.cpp
8d7bb3d1efe35ce35e88c3fba6cfe8f9a4dcab7f
[]
no_license
ayaz345/TurokEX
09b929f69918ffef9c45d6142fe7888e96d409d9
90589b4bd3c35e79ea42572e4c89dc335c5cfbfe
refs/heads/master
2023-07-10T20:56:47.643435
2014-06-20T01:59:44
2014-06-20T01:59:44
650,764,618
0
0
null
null
null
null
UTF-8
C++
false
false
22,673
cpp
canvas.cpp
// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // Copyright(C) 2013 Samuel Villarreal // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // //----------------------------------------------------------------------------- // // DESCRIPTION: Canvas system // //----------------------------------------------------------------------------- #include "common.h" #include "renderBackend.h" #include "renderMain.h" #include "memHeap.h" #include "canvas.h" #include "system.h" #include "scriptAPI/scriptSystem.h" // // kexCanvasComponent::kexCanvasComponent // kexCanvasComponent::kexCanvasComponent(void) { this->onUpdate = NULL; this->onInit = NULL; this->onHover = NULL; this->onExit = NULL; this->onDown = NULL; this->onRelease = NULL; } // // kexCanvasComponent::~kexCanvasComponent // kexCanvasComponent::~kexCanvasComponent(void) { } // // kexCanvasComponent::Init // void kexCanvasComponent::Init(void) { scriptManager.Engine()->RegisterInterface("CanvasComponent"); scriptManager.Engine()->RegisterInterfaceMethod("CanvasComponent", "void OnUpdate(void)"); scriptManager.Engine()->RegisterInterfaceMethod("CanvasComponent", "void OnInit(void)"); } // // kexCanvasComponent::Construct // void kexCanvasComponent::Construct(const char *className) { if(!Spawn(className)) { return; } CallConstructor((kexStr(className) + " @" + className + "(kCanvasScriptObject@)").c_str()); onUpdate = type->GetMethodByDecl("void OnUpdate(void)"); onInit = type->GetMethodByDecl("void OnInit(void)"); onHover = type->GetMethodByDecl("void OnHover(void)"); onExit = type->GetMethodByDecl("void OnExit(void)"); onDown = type->GetMethodByDecl("void OnDown(void)"); onRelease = type->GetMethodByDecl("void OnRelease(void)"); } //----------------------------------------------------------------------------- // // kexCanvasObject // //----------------------------------------------------------------------------- DECLARE_ABSTRACT_CLASS(kexCanvasObject, kexObject) int kexCanvasObject::objId = 0; // // kexCanvasObject::kexCanvasObject // kexCanvasObject::kexCanvasObject(void) { this->x = 0; this->y = 0; this->scaleX = 1; this->scaleY = 1; this->regX = 0; this->regY = 0; this->alpha = 1; this->bVisible = true; this->parent = NULL; this->scriptRef = 0; this->refCanvas = NULL; this->max[0] = -M_INFINITY; this->max[1] = -M_INFINITY; this->min[0] = M_INFINITY; this->min[1] = M_INFINITY; this->curId = kexCanvasObject::objId++; this->link.SetData(this); } // // kexCanvasObject::~kexCanvasObject // kexCanvasObject::~kexCanvasObject(void) { scriptRef = 0; this->link.Remove(); } // // kexCanvasObject::IncRef // int kexCanvasObject::IncRef(void) { return ++scriptRef; } // // kexCanvasObject::DecRef // int kexCanvasObject::DecRef(void) { return --scriptRef; } //----------------------------------------------------------------------------- // // kexCanvasImage // //----------------------------------------------------------------------------- DECLARE_CLASS(kexCanvasImage, kexCanvasObject) // // kexCanvasImage::kexCanvasImage // kexCanvasImage::kexCanvasImage(void) { this->width = 0; this->height = 0; } // // kexCanvasImage::~kexCanvasImage // kexCanvasImage::~kexCanvasImage(void) { } // // kexCanvasImage::SetRGB // void kexCanvasImage::SetRGB(const int index, const byte r, const byte g, const byte b) { if(index < 0 || index >= 4) { return; } rgba[index * 4 + 0] = r; rgba[index * 4 + 1] = g; rgba[index * 4 + 2] = b; } // // kexCanvasImage::Draw // void kexCanvasImage::Draw(kexMatrix &curMatrix, const float &curAlpha) { int i; float w; float h; byte a[4]; if(bVisible == false) { return; } kexMatrix mtx; renderBackend.SetState(GLSTATE_BLEND, true); renderBackend.SetState(GLSTATE_ALPHATEST, true); renderBackend.SetState(GLSTATE_TEXTURE0, true); renderBackend.SetState(GLSTATE_CULL, false); renderBackend.SetState(GLSTATE_DEPTHTEST, false); cpuVertList.BindDrawPointers(); texture->Bind(); w = ((width <= 0) ? (float)texture->Width() : (width * 2.0f)) * 0.5f; h = ((height <= 0) ? (float)texture->Height() : (height * 2.0f)) * 0.5f; for(i = 0; i < 4; i++) { a[i] = (byte)((float)rgba[i * 4 + 3] * alpha * curAlpha); kexMath::Clamp(a[i], 0, 255); } mtx.Scale(scaleX, scaleY, 1); mtx.SetTranslation(x, y, 0); matrix = mtx * curMatrix; min[0] = -regX * 0.5f; min[1] = -regY * 0.5f; max[0] = w - (regX * 0.5f); max[1] = h - (regY * 0.5f); cpuVertList.AddVertex( min[0], min[1], 0, 0, 0, rgba[0 * 4 + 0], rgba[0 * 4 + 1], rgba[0 * 4 + 2], a[0]); cpuVertList.AddVertex( max[0], min[1], 0, 1, 0, rgba[1 * 4 + 0], rgba[1 * 4 + 1], rgba[1 * 4 + 2], a[1]); cpuVertList.AddVertex( min[0], max[1], 0, 0, 1, rgba[2 * 4 + 0], rgba[2 * 4 + 1], rgba[2 * 4 + 2], a[2]); cpuVertList.AddVertex( max[0], max[1], 0, 1, 1, rgba[3 * 4 + 0], rgba[3 * 4 + 1], rgba[3 * 4 + 2], a[3]); dglPushMatrix(); dglMultMatrixf(matrix.ToFloatPtr()); cpuVertList.AddTriangle(0, 1, 2); cpuVertList.AddTriangle(2, 1, 3); cpuVertList.DrawElementsNoShader(); dglPopMatrix(); min *= matrix; max *= matrix; } //----------------------------------------------------------------------------- // // kexCanvasScriptObject // //----------------------------------------------------------------------------- DECLARE_CLASS(kexCanvasScriptObject, kexCanvasObject) // // kexCanvasScriptObject::kexCanvasScriptObject // kexCanvasScriptObject::kexCanvasScriptObject(void) { this->component.SetOwner(this); } // // kexCanvasScriptObject::~kexCanvasScriptObject // kexCanvasScriptObject::~kexCanvasScriptObject(void) { if(container) { container->Empty(); } if(component.ScriptObject() != NULL) { component.Release(); } } // // kexCanvasScriptObject::Draw // void kexCanvasScriptObject::Draw(kexMatrix &curMatrix, const float &curAlpha) { if(component.onUpdate) { component.CallFunction(component.onUpdate); } } // // kexCanvasScriptObject::SetProperty // void kexCanvasScriptObject::SetProperty(const char *name, const char *value) { bool ok = false; int state; kexStr decl; int type = -1; int intVal = 0; if(name == NULL || value == NULL) { return; } decl = "void Set_"; if(value[0] >= '0' && value[0] <= '9') { if(kexStr::IndexOf(value, ".") != -1) { decl = decl + name + "(const float)"; type = 0; } else { decl = decl + name + "(const int)"; type = 1; } } else if(value[0] == '#') { char *hex = (char*)(value+1); decl = decl + name + "(const int)"; type = 2; intVal = strtol(hex, &hex, 16); } else if(!kexStr::CompareCase(value, "false")) { decl = decl + name + "(const bool)"; type = 3; } else if(!kexStr::CompareCase(value, "true")) { decl = decl + name + "(const bool)"; type = 4; } else { decl = decl + name + "(const kStr &in)"; type = 5; } if(type == -1) { return; } state = component.PrepareFunction(decl.c_str()); if(state == -1) { return; } switch(type) { case 0: component.SetCallArgument(0, (float)atof(value)); break; case 1: component.SetCallArgument(0, atoi(value)); break; case 2: component.SetCallArgument(0, intVal); break; case 3: component.SetCallArgument(0, false); break; case 4: component.SetCallArgument(0, true); break; case 5: component.SetCallArgument(0, new kexStr(value)); break; default: return; } if(!component.ExecuteFunction(state)) { return; } component.FinishFunction(state, &ok); if(ok == false) { return; } } //----------------------------------------------------------------------------- // // kexCanvasText // //----------------------------------------------------------------------------- DECLARE_CLASS(kexCanvasText, kexCanvasObject) // // kexCanvasText::kexCanvasText // kexCanvasText::kexCanvasText(void) { this->bCentered = false; } // // kexCanvasText::~kexCanvasText // kexCanvasText::~kexCanvasText(void) { } // // kexCanvasText::SetRGB // void kexCanvasText::SetRGB(const int index, const byte r, const byte g, const byte b) { if(index < 0 || index >= 4) { return; } rgba[index * 4 + 0] = r; rgba[index * 4 + 1] = g; rgba[index * 4 + 2] = b; } // // kexCanvasText::Draw // void kexCanvasText::Draw(kexMatrix &curMatrix, const float &curAlpha) { byte color[32]; if(bVisible == false) { return; } kexMatrix mtx; for(int i = 0; i < 4; i++) { color[i * 4 + 0] = rgba[i * 4 + 0]; color[i * 4 + 1] = rgba[i * 4 + 1]; color[i * 4 + 2] = rgba[i * 4 + 2]; color[i * 4 + 3] = (byte)((float)rgba[i * 4 + 3] * alpha * curAlpha); kexMath::Clamp(color[i * 4 + 3], 0, 255); } mtx.Scale(scaleX, scaleY, 1); mtx.SetTranslation(x - (regX * 0.5f), y - (regY * 0.5f), 0); matrix = mtx * curMatrix; dglPushMatrix(); dglMultMatrixf(matrix.ToFloatPtr()); renderBackend.SetState(GLSTATE_BLEND, true); font->DrawString(text.c_str(), x, y, 0.5f, bCentered, (byte*)&color[0 * 4], (byte*)&color[2 * 4]); renderBackend.SetState(GLSTATE_BLEND, false); dglPopMatrix(); float w = font->StringWidth(text.c_str(), 0.5f, 0); float h = font->StringHeight(text.c_str(), 0.5f, 0); min[0] = 0; min[1] = 0; max[0] = w; max[1] = h; if(bCentered) { min[0] -= (w * 0.5f); max[0] -= (w * 0.5f); } min *= matrix; max *= matrix; } //----------------------------------------------------------------------------- // // kexContainer // //----------------------------------------------------------------------------- DECLARE_CLASS(kexContainer, kexCanvasObject) // // kexContainer::kexContainer // kexContainer::kexContainer(void) { } // // kexContainer::~kexContainer // kexContainer::~kexContainer(void) { Empty(); } // // kexContainer::Draw // void kexContainer::Draw(kexMatrix &curMatrix, const float &curAlpha) { if(bVisible == false) { return; } kexMatrix mtx; mtx.Scale(scaleX, scaleY, 1); mtx.SetTranslation(x, y, 0); matrix = mtx * curMatrix; float a = alpha * curAlpha; kexMath::Clamp(a, 0.0f, 1.0f); this->max[0] = -M_INFINITY; this->max[1] = -M_INFINITY; this->min[0] = M_INFINITY; this->min[1] = M_INFINITY; for(kexCanvasObject *obj = children.Next(); obj != NULL; obj = obj->link.Next()) { obj->Draw(matrix, a); if(obj->min[0] < min[0]) min[0] = obj->min[0]; if(obj->max[0] > max[0]) max[0] = obj->max[0]; if(obj->min[1] < min[1]) min[1] = obj->min[1]; if(obj->max[1] > max[1]) max[1] = obj->max[1]; } } // // kexContainer::AddChild // void kexContainer::AddChild(kexCanvasObject *object) { object->link.Add(children); object->parent = this; } // // kexContainer::RemoveChild // void kexContainer::RemoveChild(kexCanvasObject *object) { object->link.Remove(); object->parent = NULL; object->DecRef(); if(object->InstanceOf(&kexContainer::info)) { static_cast<kexContainer*>(object)->Empty(); } if(object->scriptRef <= 0) { delete object; } } // // kexContainer::Empty // void kexContainer::Empty(void) { kexCanvasObject *next; for(kexCanvasObject *obj = children.Next(); obj != NULL;) { next = obj->link.Next(); RemoveChild(obj); obj = next; } } // // kexContainer::operator[] // kexCanvasObject *kexContainer::operator[](int index) { int idx = 0; for(kexCanvasObject *obj = children.Next(); obj != NULL; obj = obj->link.Next()) { if(idx++ == index) { return obj; } } return NULL; } //----------------------------------------------------------------------------- // // kexCanvas // //----------------------------------------------------------------------------- // // kexCanvas::kexCanvas // kexCanvas::kexCanvas(void) { this->alpha = 1.0f; } // // kexCanvas::~kexCanvas // kexCanvas::~kexCanvas(void) { } // // kexCanvas::CreateImage // kexCanvasImage *kexCanvas::CreateImage(const char *texture) { kexCanvasImage *img = static_cast<kexCanvasImage*>(kexObject::Create("kexCanvasImage")); if(img == NULL) { return NULL; } img->texture = renderBackend.CacheTexture(texture, TC_CLAMP, TF_LINEAR); img->link.Clear(); img->mainLink.Clear(); img->mainLink.Add(objects); for(int i = 0; i < 4; i++) { img->rgba[i * 4 + 0] = 0xff; img->rgba[i * 4 + 1] = 0xff; img->rgba[i * 4 + 2] = 0xff; img->rgba[i * 4 + 3] = 0xff; } img->refCanvas = this; return img; } // // kexCanvas::CreateImage // kexCanvasImage *kexCanvas::CreateImage(const kexStr &texture) { return CreateImage(texture.c_str()); } // // kexCanvas::CreateContainer // kexContainer *kexCanvas::CreateContainer(void) { kexContainer *container = static_cast<kexContainer*>(kexObject::Create("kexContainer")); container->link.Clear(); container->mainLink.Clear(); container->mainLink.Add(objects); container->refCanvas = this; return container; } // // kexCanvas::CreateScriptObject // kexCanvasScriptObject *kexCanvas::CreateScriptObject(const char *className) { kexCanvasScriptObject *cso = static_cast<kexCanvasScriptObject*> (kexObject::Create("kexCanvasScriptObject")); cso->link.Clear(); cso->mainLink.Clear(); cso->mainLink.Add(objects); cso->component.Construct(className); if(cso->component.ScriptObject() == NULL) { delete cso; return NULL; } cso->refCanvas = this; return cso; } // // kexCanvas::CreateText // kexCanvasText *kexCanvas::CreateText(const char *font) { kexCanvasText *str = static_cast<kexCanvasText*>(kexObject::Create("kexCanvasText")); str->font = kexFont::manager.Load(font); str->link.Clear(); str->mainLink.Clear(); str->mainLink.Add(objects); for(int i = 0; i < 4; i++) { str->rgba[i * 4 + 0] = 0xff; str->rgba[i * 4 + 1] = 0xff; str->rgba[i * 4 + 2] = 0xff; str->rgba[i * 4 + 3] = 0xff; } str->refCanvas = this; return str; } // // kexCanvas::CreateText // kexCanvasText *kexCanvas::CreateText(const kexStr &font) { return CreateText(font.c_str()); } // // kexCanvas::AddChild // void kexCanvas::AddChild(kexCanvasObject *object) { object->link.Add(children); } // // kexCanvas::RemoveChild // void kexCanvas::RemoveChild(kexCanvasObject *object) { object->link.Remove(); object->DecRef(); if(object->scriptRef <= 0) { delete object; } } // // kexCanvas::Empty // void kexCanvas::Empty(void) { kexCanvasObject *next; for(kexCanvasObject *obj = children.Next(); obj != NULL;) { next = obj->link.Next(); RemoveChild(obj); obj = next; } } // // kexCanvas::operator[] // kexCanvasObject *kexCanvas::operator[](int index) { int idx = 0; for(kexCanvasObject *obj = children.Next(); obj != NULL; obj = obj->link.Next()) { if(idx++ == index) { return obj; } } return NULL; } // // kexCanvas::Draw // void kexCanvas::Draw(void) { kexMatrix matrix; float _alpha = this->alpha; dglPushMatrix(); matrix.SetOrtho(0, (float)FIXED_WIDTH, (float)FIXED_HEIGHT, 0, -1, 1); dglLoadMatrixf(matrix.ToFloatPtr()); matrix.Identity(); for(kexCanvasObject *obj = children.Next(); obj != NULL; obj = obj->link.Next()) { obj->Draw(matrix, _alpha); } dglPopMatrix(); } // // RegisterCanvasObjectProperties // template<class type> static void RegisterCanvasObject(const char *name) { kexScriptManager::RegisterRefObjectNoCount<type>(name); scriptManager.Engine()->RegisterObjectProperty(name, "float x", asOFFSET(type, x)); scriptManager.Engine()->RegisterObjectProperty(name, "float y", asOFFSET(type, y)); scriptManager.Engine()->RegisterObjectProperty(name, "float scaleX", asOFFSET(type, scaleX)); scriptManager.Engine()->RegisterObjectProperty(name, "float scaleY", asOFFSET(type, scaleY)); scriptManager.Engine()->RegisterObjectProperty(name, "float regX", asOFFSET(type, regX)); scriptManager.Engine()->RegisterObjectProperty(name, "float regY", asOFFSET(type, regY)); scriptManager.Engine()->RegisterObjectProperty(name, "float alpha", asOFFSET(type, alpha)); scriptManager.Engine()->RegisterObjectProperty(name, "bool bVisible", asOFFSET(type, bVisible)); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", kva("void AddChild(%s@)", name), asMETHODPR(kexCanvas, AddChild, (kexCanvasObject*), void), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", kva("void RemoveChild(%s@)", name), asMETHODPR(kexCanvas, RemoveChild, (kexCanvasObject*), void), asCALL_THISCALL); } // // RegisterContainerChildMethods // static void RegisterContainerChildMethods(const char *name) { scriptManager.Engine()->RegisterObjectMethod( "kCanvasContainer", kva("void AddChild(%s@)", name), asMETHODPR(kexContainer, AddChild, (kexCanvasObject*), void), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvasContainer", kva("void RemoveChild(%s@)", name), asMETHODPR(kexContainer, RemoveChild, (kexCanvasObject*), void), asCALL_THISCALL); } // // kexCanvas::InitObject // void kexCanvas::InitObject(void) { kexCanvasComponent::Init(); kexScriptManager::RegisterDataObject<kexCanvas>("kCanvas"); RegisterCanvasObject<kexCanvasImage>("kCanvasImage"); RegisterCanvasObject<kexCanvasText>("kCanvasText"); RegisterCanvasObject<kexContainer>("kCanvasContainer"); RegisterCanvasObject<kexCanvasScriptObject>("kCanvasScriptObject"); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", "kCanvasImage @CreateImage(const kStr &in)", asMETHODPR(kexCanvas, CreateImage, (const kexStr&), kexCanvasImage*), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", "kCanvasContainer @CreateContainer(void)", asMETHODPR(kexCanvas, CreateContainer, (void), kexContainer*), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", "kCanvasText @CreateText(const kStr &in)", asMETHODPR(kexCanvas, CreateText, (const kexStr&), kexCanvasText*), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvas", "kCanvasImage @opIndex(const int)", asMETHODPR(kexCanvas, operator[], (const int), kexCanvasObject*), asCALL_THISCALL); RegisterContainerChildMethods("kCanvasImage"); RegisterContainerChildMethods("kCanvasText"); RegisterContainerChildMethods("kCanvasContainer"); scriptManager.Engine()->RegisterObjectMethod( "kCanvasContainer", "kCanvasImage @opIndex(const int)", asMETHODPR(kexContainer, operator[], (const int), kexCanvasObject*), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvasImage", "void SetRGB(const int, const uint8, const uint8, const uint8)", asMETHODPR(kexCanvasImage, SetRGB, (const int, const byte, const byte, const byte), void), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectMethod( "kCanvasText", "void SetRGB(const int, const uint8, const uint8, const uint8)", asMETHODPR(kexCanvasText, SetRGB, (const int, const byte, const byte, const byte), void), asCALL_THISCALL); scriptManager.Engine()->RegisterObjectProperty( "kCanvasScriptObject", "ref @obj", asOFFSET(kexCanvasScriptObject, component.Handle())); scriptManager.Engine()->RegisterObjectProperty( "kCanvasScriptObject", "kCanvasContainer @container", asOFFSET(kexCanvasScriptObject, container)); scriptManager.Engine()->RegisterObjectProperty( "kCanvasImage", "float width", asOFFSET(kexCanvasImage, width)); scriptManager.Engine()->RegisterObjectProperty( "kCanvasImage", "float height", asOFFSET(kexCanvasImage, height)); scriptManager.Engine()->RegisterObjectProperty( "kCanvasText", "kStr text", asOFFSET(kexCanvasText, text)); scriptManager.Engine()->RegisterObjectProperty( "kCanvasText", "bool bCentered", asOFFSET(kexCanvasText, bCentered)); scriptManager.Engine()->RegisterGlobalProperty("kCanvas Canvas", &renderBackend.Canvas()); }
8da246edcd26bf74881d815b7ce18100183556f9
f0d4f6f5b66e3c911b6d0cd763f4e84ffd95a417
/Lab3(Battleship)/ConsolePlayer.cpp
0b8bfed739400d97cc2323a3fab2b660139a3da0
[]
no_license
Nikssssss/Labs_1
52fa061f7e15cbaad5ffb135a9ea39707bc3d50a
ec703efdc9f64916ee4286f5a3e925d073f45950
refs/heads/master
2021-07-23T08:10:10.558296
2020-08-17T16:31:32
2020-08-17T16:31:32
207,206,038
0
0
null
null
null
null
UTF-8
C++
false
false
8,411
cpp
ConsolePlayer.cpp
#include "pch.h" #include "ConsolePlayer.h" ConsolePlayer::ConsolePlayer() { } bool ConsolePlayer::getWinStatus() { return isWinner; } char** ConsolePlayer::getMyBoard() { return myBoard.getBoard(); } char** ConsolePlayer::getEnemyBoard() { return enemyBoard.getBoard(); } std::vector<Ship*> &ConsolePlayer::getShips() { return ships; } void ConsolePlayer::setShips() { printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "Enter the first coordinates and the direction of your ship (down(d), right(r))." << std::endl; std::cout << "For example: enter the first coordinates - A0, enter direction - d" << std::endl << std::endl; int numberOfShips = 1; char numberOfDecks = '4'; for (int i = 0; i < 4; i++) { for (int j = 0; j < numberOfShips; j++) { std::cout << "Please, set your " << numberOfDecks << "-deck ship!" << std::endl << std::endl; setDecks(numberOfDecks - '0'); } numberOfDecks--; numberOfShips++; } /*for (int i = 0; i < ships.size(); i++) { std::vector<std::pair<int, int>> vector = ships[i]->getShipCoords(); for (int i = 0; i < vector.size(); i++) { std::cout << vector.size(); std::cout << vector[i].first << ' ' << vector[i].second << std::endl; } std::cout << std::endl; }*/ } void ConsolePlayer::setDecks(int numberOfDecks) { std::string coordinates; std::string direction; bool setIsCorrect = false; while (!setIsCorrect) { std::cout << "Enter the first coordinates of your ship (first - letter, second - number, e.g.: A0):" << std::endl; std::getline(std::cin, coordinates); if (numberOfDecks != 1) { std::cout << "Enter the direction of your ship (d, r):" << std::endl; std::getline(std::cin, direction); } if (checkSetting(coordinates, direction, numberOfDecks) == -1) { system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "Enter the correct coordinates!" << std::endl << std::endl; coordinates.clear(); direction.clear(); } else setIsCorrect = true; } if (direction == "d" || direction == "D") { ships.emplace_back(new Ship); for (int i = coordinates[1] - '0'; i < coordinates[1] - '0' + numberOfDecks; i++) { myBoard.getBoard()[i][letterToNumber(coordinates)] = '+'; ships[ships.size() - 1]->getShipCoords().emplace_back(std::make_pair(i, letterToNumber(coordinates))); } } else if (direction == "r" || direction == "R") { ships.emplace_back(new Ship); for (int i = letterToNumber(coordinates); i < letterToNumber(coordinates) + numberOfDecks; i++) { myBoard.getBoard()[coordinates[1] - '0'][i] = '+'; ships[ships.size() - 1]->getShipCoords().emplace_back(std::make_pair(coordinates[1] - '0', i)); } } else { myBoard.getBoard()[coordinates[1] - '0'][letterToNumber(coordinates)] = '+'; ships.emplace_back(new Ship); ships[ships.size() - 1]->getShipCoords().emplace_back(std::make_pair(coordinates[1] - '0', letterToNumber(coordinates))); } system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); } char ConsolePlayer::letterToNumber(std::string coordinates) { char letter; coordinates[0] <= 'J' ? letter = coordinates[0] - 'A' : letter = coordinates[0] - 'a'; return letter; } int ConsolePlayer::checkSetting(std::string coordinates, std::string direction, int numberOfDecks) { if (direction.size() > 1) return -1; else if (checkCoordinates(coordinates) == -1) return -1; else if (numberOfDecks != 1 && direction[0] != 'd' && direction[0] != 'r' && direction[0] != 'D' && direction[0] != 'R') return -1; else if (checkAround(coordinates, direction, numberOfDecks) == -1) return -1; return 1; } int ConsolePlayer::checkCoordinates(std::string coordinates) { if (coordinates.size() > 2) return -1; else if ((coordinates[0] < 'A' || coordinates[0] > 'J') && (coordinates[0] < 'a' || coordinates[0] > 'j')) return -1; else if (coordinates[1] < '0' || coordinates[1] > '9') return -1; return 1; } int ConsolePlayer::checkAround(std::string coordinates, std::string direction, int numberOfDecks) { char letter = letterToNumber(coordinates); char number = coordinates[1] - '0'; char upperLast, rightLast, leftLast, downLast, downLength, rightLength; if (direction == "d" || direction == "D") { downLength = (number + numberOfDecks - 1); if (downLength > 9) return -1; if ((upperLast = number - 1) < 0) upperLast = 0; if ((leftLast = letter - 1) < 0) leftLast = 0; if ((rightLast = letter + 1) > 9) rightLast = 9; if ((downLast = number + numberOfDecks) > 9) downLast = 9; } else if (direction == "r" || direction == "R"){ rightLength = (letter + numberOfDecks - 1); if (rightLength > 9) return -1; if ((upperLast = number - 1) < 0) upperLast = 0; if ((leftLast = letter - 1) < 0) leftLast = 0; if ((rightLast = letter + numberOfDecks) > 9) rightLast = 9; if ((downLast = number + 1) > 9) downLast = 9; } else { if ((upperLast = number - 1) < 0) upperLast = 0; if ((leftLast = letter - 1) < 0) leftLast = 0; if ((rightLast = letter + 1) > 9) rightLast = 9; if ((downLast = number + 1) > 9) downLast = 9; } for (int i = upperLast; i <= downLast; i++) { for (int j = leftLast; j <= rightLast; j++) { if (myBoard.getBoard()[i][j] == '+') return -1; } } return 1; } void ConsolePlayer::attack(IPlayer *enemy) { bool isMissed = false; std::string coordinates; printBoards(myBoard.getBoard(), enemyBoard.getBoard()); while (!isMissed && !isWinner) { std::cout << "Enter the coordinates you want to attack:" << std::endl; std::getline(std::cin, coordinates); if (checkCoordinates(coordinates) == -1) { system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "Enter the correct coordinates!" << std::endl << std::endl; coordinates.clear(); } else if (checkHit(enemy->getMyBoard(), coordinates[1] - '0', letterToNumber(coordinates)) == 0) { system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "You've already hit this cell. Try again!" << std::endl << std::endl; coordinates.clear(); } else if (checkHit(enemy->getMyBoard(), coordinates[1] - '0', letterToNumber(coordinates)) == 1) { if (doIfHit(enemy, coordinates[1] - '0', letterToNumber(coordinates)) == 0) { isWinner = true; system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); } coordinates.clear(); } else { enemyBoard.getBoard()[coordinates[1] - '0'][letterToNumber(coordinates)] = 'O'; enemy->getMyBoard()[coordinates[1] - '0'][letterToNumber(coordinates)] = 'O'; std::cout << "Missed!" << std::endl << std::endl; isMissed = true; } } } int ConsolePlayer::doIfHit(IPlayer *enemy, int xCoord, int yCoord) { enemyBoard.getBoard()[xCoord][yCoord] = '+'; enemy->getMyBoard()[xCoord][yCoord] = 'X'; std::vector<Ship*> &enemyShips = enemy->getShips(); for (int i = 0; i < enemyShips.size(); i++) { std::vector<std::pair<int, int>> &coordsOfShips = enemyShips[i]->getShipCoords(); std::vector<std::pair<int, int>> &killedCoords = enemyShips[i]->getKilledCoords(); for (int j = 0; j < coordsOfShips.size(); j++) { if (coordsOfShips[j] == std::make_pair(xCoord, yCoord)) { coordsOfShips.erase(coordsOfShips.begin() + j); killedCoords.emplace_back(std::make_pair(xCoord, yCoord)); int checkKill = checkKilling(coordsOfShips, enemyShips, i); if (checkKill == 0) { for (int i = 0; i < killedCoords.size(); i++) enemyBoard.getBoard()[killedCoords[i].first][killedCoords[i].second] = 'X'; return 0; } else if (checkKill == -1) { system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "Hit!" << std::endl << std::endl; return 1; } else if (checkKill == 1) { for (int i = 0; i < killedCoords.size(); i++) enemyBoard.getBoard()[killedCoords[i].first][killedCoords[i].second] = 'X'; system("cls"); printBoards(myBoard.getBoard(), enemyBoard.getBoard()); std::cout << "Killed!" << std::endl << std::endl; return 1; } } } } } ConsolePlayer::~ConsolePlayer() { }
07202c5393950050c6ab26410243f899c828ba9d
8ddfcc042544c499474653e2938be16c32ba7a15
/BasicRenderEngine/include/GLProgramPipeline.h
9bce790f8f071184011d671640055689ffde27fe
[ "MIT" ]
permissive
chbaker0/gl-engine
b167bdeb53841e8fa26a9a029a0aa5e944fd6031
7721c90d6bb552b99f01a57d30bafa772937cdb7
refs/heads/master
2021-01-02T08:19:40.552718
2015-06-21T21:38:57
2015-06-21T21:38:57
31,871,619
3
0
null
null
null
null
UTF-8
C++
false
false
638
h
GLProgramPipeline.h
/* * GLProgramPipeline.h * * Created on: Mar 9, 2015 * Author: Collin */ #ifndef GL_PROGRAM_PIPELINE_INCLUDED #define GL_PROGRAM_PIPELINE_INCLUDED #include <GL/glew.h> #include "GLExecutable.h" #include "GLShaderProgram.h" class GLProgramPipeline : public GLExecutable { protected: GLuint handle; public: GLProgramPipeline(GLuint handle_in): handle(handle_in) {}; virtual ~GLProgramPipeline(); virtual void use() noexcept override; virtual void useProgramStages(GLbitfield stages, GLShaderProgram& prog) noexcept; virtual void clearStages(GLbitfield stages) noexcept; }; #endif /* GL_PROGRAM_PIPELINE_INCLUDED */
2435af8f6ef16673642c06289d4e1aeaf09e1539
d396697011aa127c517372383bb56675ef6b4318
/practiceCode/practiceCode/B467.cpp
3eb8f95aa45eb70034b9541f347e7b12559f937d
[]
no_license
Quach2502/hello-world
f7afa3edff1bfb5db5eb5dd66474f4ad5000f22b
9932368ac24e907b138d3f5e744a28dfc5874bd3
refs/heads/master
2021-01-09T20:47:02.399667
2017-08-30T07:42:26
2017-08-30T07:42:26
63,652,315
0
0
null
2016-07-19T02:21:41
2016-07-19T02:17:30
null
UTF-8
C++
false
false
1,038
cpp
B467.cpp
//#include <iostream> //#include <vector> //#include <algorithm> //#include <string> //std::vector<int> convert(int n, int type) //{ // std::vector<int> result; // while (n > 0) // { // result.push_back(n % 2); // n = n / 2; // } // for (int i = result.size(); i < type; i++) // { // result.push_back(0); // } // return result; //} //int check(std::vector<int> origin, std::vector<int> sample,int k,int type) //{ // int result(0); // for(int i = 0; i < type; i++) // { // if (origin[i] != sample[i]) // result++; // } // if (result <= k) // return 1; // else // return 0; //} //void main() //{ // int type(0),player(0),k(0); // int max = 1; // std::vector<int> input; // int output(0); // std::cin >> type>>player>>k; // bool flag = true; // for (int i = 0; i < player+1; i++) // { // int a; // std::cin >> a; // input.push_back(a); // } // std::vector<int> fedor = convert(input[player],type); // for (int i = 0; i < player; i++) // { // output += check(fedor, convert(input[i],type),k,type); // } // std::cout << output; //}
4eb21ae30b994efa23b3c5c18149e4cd1ce74e6b
bac3a059bff226b394d56aeb1c4c29fd1010eda9
/test-project-new/include/particle.h
c0a646f697864895c4b916dac926fb5d6ab1ccca
[]
no_license
tectronics/lddtc
a91ccb984b37900f50caa9f373053075381a3bf1
6ec598c870d768a1c245d4b151d0fa0cdddcc2f3
refs/heads/master
2018-01-11T15:01:37.337823
2013-04-22T23:56:22
2013-04-22T23:56:22
47,875,725
0
0
null
null
null
null
GB18030
C++
false
false
2,034
h
particle.h
#ifndef PARTICLE_H #define PARTICLE_H #include "CVector3d.h" class particle{ public: particle(); ~particle(); void particleInit(double, double, double, double, double, double, double, double, double, double, double, double, double, int iLossFlag=0); void setPosition(double, double, double); void setVelocity(double, double, double); void moveOneStep(); void setE(double, double, double); void setB(double, double, double); void setStep(double p){step=p; }; CVector3d getE( ) const { return E; }; CVector3d getB( ) const { return B; }; CVector3d getPosition() const { return position;}; CVector3d getVelocity() const { return velocity;}; double getStep() const { return step;}; double getT0() { return t0; } ; int getLossFlag() { return iLossFlag;}; void setPositionX(double _dx) { position.setX(_dx); }; void setPositionY(double _dy) { position.setY(_dy); }; void setPositionZ(double _dz) { position.setZ(_dz); }; void setVelocityX(double _dx) { velocity.setX(_dx); }; void setVelocityY(double _dy) { velocity.setY(_dy); }; void setVelocityZ(double _dz) { velocity.setZ(_dz); }; void setT0(double _t0) { t0=_t0;}; void setLossFlag(int _i=0) { iLossFlag=_i;} ; public: private: //这两个数的含义 void rk4(double y[], double dydx[], int &n, double &x, double &h, double yout[]); void derivs(double x, double y[], double dydx[] ); private: CVector3d position; CVector3d velocity; CVector3d E; CVector3d B; double step; double t0; int iLossFlag; }; #endif
d01f60120d2aa5bf6512716d80dac7cee356f3c2
1e021770363d689b932e03b50a67963ee5989d1b
/UrbanDictionary/DictionaryDirectory/Word.cpp
797a0a0d554a8ed32284d8e2961b075beb91fd21
[]
no_license
tmorriso/Computer_Science
722b27d98abd5b97de585fcc5f524b7a3bb992cc
83a211985b5134552c175ded7f5410e9828f9222
refs/heads/master
2021-01-19T04:32:56.083324
2016-07-14T04:33:08
2016-07-14T04:33:08
63,301,807
0
0
null
null
null
null
UTF-8
C++
false
false
834
cpp
Word.cpp
// Word.cpp // Thomas Morrison // November 29, 2015 // Project 2 //-------------------------------------- // Purpose: Word Class to keep track of // words, definitions, and // sentences. //-------------------------------------- #include <iostream> #include <string> #include "Word.h" using namespace std; Word::Word() { word = "Unknown"; definition = "Unknown"; } Word::Word(string wrd, string def) { word = wrd; definition = def; } string Word::getWord() { return word; } string Word::getDefinition() { return definition; } void Word::setWord(string wrd) { word = wrd; } void Word::setDefinition(string def) { definition = def; } string Word::wordToString() { return ", your word is " + word; } string Word::definitionToString() { return "The definition is: " + definition; }
58fcf618cb1123692e47b6f19e4e62a212f402ec
c9cd76e3f53916d7089bd177b5959d0bbbd23c4d
/Matrix.h
41b0426d6f7fd82283be5febae7dfbf3edf3d6d5
[]
no_license
Pikecillo/boiling-simulation
db66250026957ad5d971dfea7d76d98f01a7671a
2ab5e0af4d64a736f23d67d0d0f8c882f4727ddc
refs/heads/master
2023-07-06T14:21:05.759603
2023-06-23T22:10:07
2023-06-23T22:10:07
152,322,803
1
2
null
2023-06-23T22:10:09
2018-10-09T21:18:39
C++
UTF-8
C++
false
false
588
h
Matrix.h
#pragma once #include <vector> template <typename T> class Matrix { public: Matrix(size_t rows, size_t cols) : m_cols(cols), m_rows(rows), m_elements(rows * cols, static_cast<T>(0)) { } size_t cols() const { return m_cols; } size_t rows() const { return m_rows; } float at(size_t i, size_t j) const { return m_elements[i * m_cols + j]; } float &at(size_t i, size_t j) { return m_elements[i * m_cols + j]; } size_t size() const { return m_elements.size(); }; private: size_t m_cols, m_rows; std::vector<T> m_elements; }; using Matrixd = Matrix<float>;
20cf9daaae168208e9e2d45a1a6b1e0d004a4cd4
3585f4e76b655c603e230137cbc8c4290d916cd0
/src/ui/scene/Cell.cpp
9ca7c3d545f731a4180c9c9c0cfd1f7f2b748e57
[]
no_license
Firely-Pasha/LangtonsAnt
77db6ce105bba44aa42f24b87955c5260064f25f
bff4570c55012bb98dc136c885cdd6454922a98e
refs/heads/master
2020-04-09T05:16:12.796866
2018-12-07T13:51:19
2018-12-07T13:51:19
160,057,716
1
0
null
null
null
null
UTF-8
C++
false
false
1,106
cpp
Cell.cpp
#include <utility> // Created by firely-pasha on 04.12.18. #include <GL/gl.h> #include "Cell.h" #include "Scene.h" Cell::Cell(QPoint position, int typeIndex) : SceneObject(position) { Cell::typeIndex = typeIndex; Cell::color = Scene::cellTypes[typeIndex].getColor(); } void Cell::update() { } void Cell::render() { glPushMatrix(); glColor3ub(static_cast<GLubyte>(color[0]), static_cast<GLubyte>(color[1]), static_cast<GLubyte>(color[2])); glBegin(GL_TRIANGLE_STRIP); glVertex2f(position.x(), position.y() + 1); // Справа вверху glVertex2f(position.x(), position.y()); // Слева внизу glVertex2f(position.x() + 1, position.y() + 1); // Слева вверху glVertex2f(position.x() + 1, position.y()); // Справа внизу glEnd(); glPopMatrix(); } int Cell::getTypeIndex() const { return typeIndex; } void Cell::setTypeIndex(int typeIndex) { Cell::typeIndex = typeIndex; Cell::color = Scene::cellTypes[typeIndex].getColor(); }
a85785d966706fd2ddb108d08ce32d5aab2a8118
a5e00504919bb338910de4cc5c3c3c4afb71e8c6
/UVa/Code/12650 - Dangerous Dive.cpp
abbc0e9050fb416a0d9207bccb0c76737c370bf0
[]
no_license
samuel21119/Cpp
f55333a6e012e020dd45b54d8fff59a339d0f808
056a6570bd28dd795f66f31c82537c79eb57cc72
refs/heads/master
2023-01-05T15:14:55.357393
2020-10-20T23:32:20
2020-10-20T23:32:20
168,485,083
0
0
null
null
null
null
UTF-8
C++
false
false
796
cpp
12650 - Dangerous Dive.cpp
/************************************************************************* > File Name: 12650 - Dangerous Dive.cpp > Author: Samuel > Mail: enminghuang21119@gmail.com > Created Time: Sat Dec 30 19:37:23 2017 *************************************************************************/ #include <iostream> #include <cstdlib> #include <cstring> using namespace std; int main() { int a, b, t; bool in[10002]; while (cin >> a >> b) { memset(in, 1, sizeof(in)); for (int i = 0; i < b; i++) { cin >> t; in[t] = 0; } if (a == b) { cout <<"*\n"; continue; } for (int i = 1; i <= a; i++) if (in[i]) cout << i << ' '; cout << '\n'; } return 0; }
4dd9b777b2604ec0f9c929cf5ae20238b3cc5650
ab65075a93126360824f034a78da57e9dc64bad1
/deps/spiel/label.h
c7d7be1e5a698004abd77b0d8c71683ae7534c70
[ "MIT" ]
permissive
xmil9/towers
6d79ee433e1e177a6a095e16d2a4bdbd973d29fc
06c9c07c1ec6cb5f3493c1de0ffa8930b6add5f6
refs/heads/master
2023-03-12T06:09:43.456772
2021-02-25T01:03:41
2021-02-25T01:03:41
303,491,375
0
0
null
null
null
null
UTF-8
C++
false
false
986
h
label.h
// // Jan-2021, Michael Lindner // MIT license // #pragma once #include "color.h" #include "coords.h" #include <functional> #include <string> namespace sp { class Renderer2; } namespace sp { /////////////////// class Label { public: using GetTextFn = std::function<std::string()>; public: Label(float textScale, const Color& textColor); void setup(GetTextFn getTextFn, const PixPos& leftTop, const PixDim& dim); PixPos position() const { return m_leftTop; } void setPosition(const PixPos& leftTop) { m_leftTop = leftTop; } PixDim dim() const { return m_dim; } void setDim(const PixDim& dim) { m_dim = dim; } void render(Renderer2& renderer, const PixPos& offset); private: float m_textScale = 1.f; Color m_textColor{Black}; GetTextFn m_getTextFn; PixPos m_leftTop{0.f, 0.f}; PixDim m_dim{0.f, 0.f}; }; inline Label::Label(float textScale, const Color& textColor) : m_textScale{textScale}, m_textColor{textColor} { } } // namespace sp
14f10cf85fae707900e2212d58648315d28ce444
7ba1a08aca63357e47abc428756781d30dc8de24
/week 3/lab3_part2/600/k
a86b36a39050e1a8fea8e51d4ab10b1acd460891
[]
no_license
MrSecrets/Computational-Fluid-Dynamics
208b1d3dcd9018a819cc886b4601c661b19203a3
15fc7bea495a61a885511618bd493df21facd448
refs/heads/main
2023-01-07T20:29:44.212648
2020-11-12T09:33:18
2020-11-12T09:33:18
310,844,803
1
0
null
null
null
null
UTF-8
C++
false
false
62,252
k
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 8 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "600"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 7320 ( 6.07652 5.55942 5.24732 5.04165 4.8942 4.78178 4.69211 4.61825 4.55602 4.50265 4.45625 4.41545 4.37924 4.34686 4.31771 4.29132 4.26733 4.24542 4.22534 4.20689 4.18987 4.17415 4.15959 4.14608 4.13352 4.12184 4.11095 4.10079 4.0913 4.08244 4.07414 4.06638 4.05912 4.05231 4.04594 4.03997 4.03438 4.02914 4.02423 4.01964 4.01535 4.01134 4.00759 4.0041 4.00084 3.99782 3.995 3.9924 3.98999 3.98776 3.98571 3.98384 3.98212 3.98056 3.97915 3.97789 3.97675 3.97575 3.97488 3.97412 3.97348 3.97296 3.97253 3.97222 3.972 3.97187 3.97184 3.9719 3.97204 3.97226 3.97257 3.97295 3.97341 3.97393 3.97453 3.9752 3.97593 3.97672 3.97758 3.97849 3.97946 3.98049 3.98157 3.98271 3.98389 3.98513 3.98641 3.98774 3.98912 3.99054 3.992 3.9935 3.99505 3.99663 3.99824 3.9999 4.00159 4.00331 4.00506 4.00684 4.00865 4.01049 4.01235 4.01423 4.01614 4.01807 4.02001 4.02197 4.02394 4.02593 4.02792 4.02992 4.03192 4.03393 4.03593 4.03793 4.03993 4.04191 4.04388 4.04584 4.04773 4.04965 4.84215 5.67924 5.54001 5.36046 5.21715 5.10399 5.01225 4.93597 4.87129 4.81558 4.76697 4.72412 4.68601 4.65186 4.62109 4.59321 4.56782 4.54462 4.52335 4.50378 4.48573 4.46904 4.45358 4.43924 4.4259 4.41348 4.40191 4.39111 4.38103 4.3716 4.36278 4.35453 4.34681 4.33957 4.33279 4.32645 4.3205 4.31493 4.30972 4.30484 4.30028 4.29602 4.29204 4.28833 4.28488 4.28167 4.27869 4.27593 4.27337 4.27102 4.26886 4.26688 4.26508 4.26344 4.26196 4.26063 4.25945 4.25841 4.25751 4.25673 4.25608 4.25555 4.25514 4.25483 4.25463 4.25454 4.25454 4.25464 4.25483 4.25511 4.25547 4.25592 4.25645 4.25705 4.25773 4.25849 4.25932 4.26021 4.26117 4.2622 4.26328 4.26443 4.26564 4.2669 4.26822 4.2696 4.27102 4.2725 4.27403 4.2756 4.27722 4.27889 4.2806 4.28235 4.28414 4.28597 4.28784 4.28974 4.29168 4.29365 4.29565 4.29768 4.29974 4.30183 4.30394 4.30607 4.30821 4.31038 4.31256 4.31475 4.31696 4.31917 4.32138 4.3236 4.32581 4.32802 4.33022 4.33242 4.3346 4.33676 4.33887 4.34095 3.59581 5.0514 5.15997 5.06781 4.96411 4.87324 4.79598 4.72999 4.67307 4.62344 4.57977 4.541 4.50635 4.47517 4.44698 4.42135 4.39797 4.37656 4.35689 4.33877 4.32204 4.30655 4.29219 4.27885 4.26644 4.25488 4.2441 4.23404 4.22463 4.21584 4.20762 4.19993 4.19272 4.18597 4.17965 4.17373 4.16819 4.163 4.15814 4.1536 4.14935 4.14538 4.14169 4.13824 4.13504 4.13206 4.1293 4.12675 4.1244 4.12224 4.12026 4.11845 4.11681 4.11532 4.11399 4.11281 4.11176 4.11085 4.11007 4.10941 4.10887 4.10844 4.10813 4.10792 4.10782 4.10781 4.1079 4.10808 4.10835 4.1087 4.10914 4.10966 4.11025 4.11092 4.11167 4.11249 4.11337 4.11432 4.11534 4.11642 4.11756 4.11877 4.12002 4.12134 4.12271 4.12413 4.12561 4.12713 4.12871 4.13033 4.132 4.13371 4.13546 4.13726 4.1391 4.14097 4.14289 4.14484 4.14682 4.14884 4.15088 4.15296 4.15507 4.1572 4.15935 4.16153 4.16372 4.16593 4.16816 4.1704 4.17265 4.17491 4.17717 4.17943 4.18169 4.18394 4.18619 4.18843 4.19065 4.19286 4.19502 4.19712 2.74725 4.48339 4.83294 4.83938 4.78111 4.71517 4.65355 4.59832 4.54927 4.50567 4.46677 4.43188 4.40045 4.372 4.34614 4.32254 4.30093 4.28108 4.2628 4.24593 4.23032 4.21585 4.20241 4.18991 4.17828 4.16743 4.15731 4.14786 4.13902 4.13075 4.12302 4.11578 4.109 4.10265 4.0967 4.09113 4.08592 4.08104 4.07648 4.07221 4.06823 4.06451 4.06105 4.05782 4.05483 4.05206 4.04949 4.04713 4.04495 4.04296 4.04114 4.03948 4.03799 4.03665 4.03546 4.0344 4.03349 4.0327 4.03204 4.0315 4.03108 4.03077 4.03056 4.03046 4.03046 4.03056 4.03075 4.03103 4.0314 4.03185 4.03238 4.033 4.03369 4.03445 4.03529 4.03619 4.03717 4.03821 4.03932 4.04049 4.04172 4.04301 4.04436 4.04576 4.04722 4.04874 4.0503 4.05192 4.05358 4.0553 4.05706 4.05886 4.06071 4.0626 4.06454 4.06651 4.06852 4.07056 4.07265 4.07476 4.07691 4.07909 4.08129 4.08352 4.08578 4.08806 4.09036 4.09267 4.095 4.09734 4.0997 4.10205 4.10442 4.10678 4.10914 4.1115 4.11385 4.11619 4.11851 4.12082 4.12309 4.12525 2.10346 3.90602 4.48941 4.61127 4.60898 4.57387 4.53133 4.489 4.44924 4.41265 4.37922 4.34873 4.32092 4.29549 4.27219 4.2508 4.23111 4.21295 4.19616 4.18061 4.16619 4.15279 4.14032 4.12871 4.11788 4.10777 4.09833 4.08951 4.08125 4.07353 4.06629 4.05952 4.05318 4.04724 4.04168 4.03647 4.0316 4.02704 4.02278 4.0188 4.01509 4.01163 4.00841 4.00542 4.00265 4.00009 3.99772 3.99555 3.99356 3.99175 3.9901 3.98862 3.98729 3.9861 3.98506 3.98416 3.98339 3.98274 3.98222 3.98181 3.98152 3.98134 3.98126 3.98129 3.98141 3.98163 3.98195 3.98235 3.98283 3.9834 3.98405 3.98477 3.98558 3.98645 3.9874 3.98842 3.98951 3.99067 3.99189 3.99317 3.99452 3.99592 3.99738 3.9989 4.00048 4.00211 4.00379 4.00552 4.00731 4.00914 4.01102 4.01294 4.01492 4.01693 4.01898 4.02108 4.02322 4.02539 4.0276 4.02984 4.03212 4.03442 4.03676 4.03912 4.04151 4.04392 4.04635 4.0488 4.05126 4.05373 4.05622 4.05871 4.0612 4.0637 4.06619 4.06868 4.07115 4.07362 4.07607 4.07849 4.08089 4.08316 1.61624 3.30894 4.10161 4.35522 4.42201 4.42574 4.40724 4.38106 4.35281 4.32483 4.29808 4.27292 4.24944 4.22762 4.20738 4.18859 4.17115 4.15496 4.13991 4.1259 4.11285 4.10069 4.08934 4.07874 4.06884 4.05958 4.05091 4.0428 4.03521 4.0281 4.02144 4.0152 4.00935 4.00388 3.99875 3.99395 3.98946 3.98527 3.98135 3.9777 3.97429 3.97113 3.96819 3.96546 3.96295 3.96063 3.9585 3.95655 3.95477 3.95316 3.95172 3.95042 3.94928 3.94828 3.94741 3.94668 3.94608 3.94559 3.94523 3.94498 3.94484 3.94481 3.94488 3.94505 3.94532 3.94568 3.94614 3.94668 3.9473 3.948 3.94878 3.94965 3.95058 3.95159 3.95268 3.95383 3.95505 3.95634 3.95769 3.9591 3.96058 3.96212 3.96371 3.96537 3.96708 3.96884 3.97066 3.97253 3.97445 3.97642 3.97844 3.98051 3.98262 3.98477 3.98697 3.98921 3.99149 3.99381 3.99616 3.99855 4.00098 4.00343 4.00591 4.00843 4.01096 4.01352 4.0161 4.0187 4.02131 4.02393 4.02657 4.02921 4.03185 4.03449 4.03712 4.03975 4.04237 4.04498 4.04757 4.05013 4.05267 4.05505 1.26812 2.7064 3.65726 4.05358 4.20386 4.25636 4.26838 4.26267 4.24897 4.23181 4.21339 4.19484 4.17674 4.15936 4.14285 4.12725 4.11255 4.09875 4.0858 4.07365 4.06226 4.05158 4.04157 4.03219 4.02339 4.01514 4.0074 4.00014 3.99333 3.98695 3.98097 3.97536 3.9701 3.96518 3.96057 3.95625 3.95222 3.94846 3.94495 3.94168 3.93864 3.93582 3.93321 3.9308 3.92858 3.92655 3.92469 3.923 3.92148 3.92012 3.91891 3.91784 3.91691 3.91612 3.91547 3.91493 3.91452 3.91423 3.91406 3.91399 3.91403 3.91417 3.91442 3.91476 3.91519 3.91572 3.91633 3.91703 3.91781 3.91867 3.91961 3.92062 3.92171 3.92288 3.92411 3.92541 3.92678 3.92822 3.92972 3.93129 3.93291 3.9346 3.93635 3.93815 3.94001 3.94193 3.94389 3.94592 3.94799 3.95011 3.95229 3.95451 3.95677 3.95908 3.96144 3.96384 3.96627 3.96875 3.97126 3.97381 3.9764 3.97901 3.98166 3.98433 3.98702 3.98974 3.99248 3.99524 3.99801 4.0008 4.00359 4.00638 4.00918 4.01197 4.01476 4.01755 4.02031 4.02306 4.0258 4.0285 4.03118 4.03369 1.04443 2.13048 3.15609 3.69382 3.94125 4.05401 4.10457 4.12487 4.12967 4.12622 4.11833 4.10811 4.09673 4.0849 4.07304 4.06139 4.0501 4.03924 4.02888 4.01901 4.00966 4.0008 3.99243 3.98452 3.97707 3.97005 3.96343 3.95721 3.95136 3.94586 3.9407 3.93585 3.9313 3.92705 3.92306 3.91933 3.91585 3.91261 3.90959 3.90678 3.90418 3.90178 3.89956 3.89753 3.89567 3.89398 3.89246 3.89108 3.88987 3.88879 3.88786 3.88706 3.8864 3.88586 3.88545 3.88515 3.88497 3.8849 3.88494 3.88509 3.88534 3.88569 3.88613 3.88667 3.88729 3.88801 3.88881 3.88969 3.89065 3.89169 3.89281 3.894 3.89526 3.89659 3.898 3.89947 3.90101 3.90261 3.90428 3.90601 3.9078 3.90965 3.91157 3.91353 3.91556 3.91764 3.91977 3.92196 3.9242 3.92649 3.92883 3.93122 3.93365 3.93613 3.93865 3.94121 3.94382 3.94647 3.94915 3.95187 3.95462 3.9574 3.96022 3.96306 3.96592 3.96881 3.97172 3.97464 3.97758 3.98053 3.98348 3.98644 3.9894 3.99235 3.99529 3.99823 4.00115 4.00405 4.00692 4.00977 4.0126 4.01523 0.919762 1.62589 2.61278 3.26901 3.62244 3.80741 3.90596 3.95917 3.98746 4.00145 4.00694 4.00725 4.00438 3.99954 3.99352 3.98681 3.97977 3.97259 3.96544 3.95842 3.95158 3.94497 3.93862 3.93255 3.92675 3.92124 3.91601 3.91106 3.90638 3.90196 3.8978 3.89389 3.89022 3.88677 3.88354 3.88053 3.87772 3.87511 3.87269 3.87045 3.86838 3.86648 3.86475 3.86317 3.86175 3.86048 3.85935 3.85836 3.8575 3.85678 3.85618 3.85571 3.85535 3.85512 3.85499 3.85498 3.85507 3.85527 3.85557 3.85596 3.85645 3.85704 3.85771 3.85848 3.85933 3.86026 3.86127 3.86237 3.86354 3.86478 3.8661 3.86749 3.86894 3.87047 3.87206 3.87372 3.87545 3.87724 3.87909 3.88101 3.88298 3.88502 3.88711 3.88926 3.89146 3.89372 3.89603 3.8984 3.90082 3.90328 3.9058 3.90836 3.91098 3.91363 3.91633 3.91907 3.92186 3.92468 3.92754 3.93043 3.93336 3.93632 3.93931 3.94233 3.94536 3.94843 3.9515 3.9546 3.9577 3.96082 3.96394 3.96706 3.97018 3.97329 3.97639 3.97948 3.98255 3.9856 3.98862 3.9916 3.99457 3.99732 0.860369 1.23773 2.06198 2.78202 3.23846 3.50547 3.66218 3.75644 3.81442 3.85055 3.87304 3.88674 3.89464 3.89864 3.89999 3.89953 3.89781 3.89526 3.89213 3.88865 3.88496 3.88115 3.87732 3.87352 3.86978 3.86614 3.86263 3.85925 3.85601 3.85293 3.85001 3.84724 3.84464 3.84219 3.83991 3.83777 3.83578 3.83395 3.83226 3.8307 3.82929 3.82801 3.82687 3.82585 3.82496 3.82419 3.82354 3.82301 3.8226 3.82229 3.8221 3.82202 3.82204 3.82216 3.82238 3.8227 3.82312 3.82363 3.82423 3.82493 3.8257 3.82657 3.82751 3.82854 3.82965 3.83084 3.8321 3.83344 3.83485 3.83632 3.83787 3.83948 3.84116 3.84291 3.84471 3.84659 3.84852 3.85052 3.85258 3.85469 3.85687 3.8591 3.86139 3.86374 3.86614 3.86859 3.8711 3.87365 3.87626 3.87892 3.88163 3.88438 3.88718 3.89002 3.89291 3.89584 3.89881 3.90181 3.90486 3.90794 3.91105 3.91419 3.91735 3.92055 3.92377 3.927 3.93025 3.93352 3.9368 3.94008 3.94337 3.94665 3.94993 3.9532 3.95645 3.95969 3.96291 3.9661 3.96926 3.97238 3.97548 3.97836 0.836787 0.98815 1.55966 2.25312 2.7872 3.13869 3.36248 3.50657 3.60152 3.66555 3.70958 3.74028 3.76187 3.77709 3.78779 3.79521 3.80023 3.80349 3.80544 3.80641 3.80665 3.80636 3.80568 3.8047 3.80353 3.80223 3.80084 3.79942 3.79798 3.79655 3.79516 3.79382 3.79254 3.79133 3.7902 3.78914 3.78817 3.78729 3.7865 3.78579 3.78518 3.78466 3.78424 3.7839 3.78366 3.78351 3.78345 3.78348 3.7836 3.78381 3.78411 3.7845 3.78497 3.78553 3.78617 3.78689 3.7877 3.78858 3.78955 3.79059 3.79171 3.7929 3.79417 3.79551 3.79692 3.7984 3.79995 3.80157 3.80326 3.805 3.80681 3.80868 3.81062 3.81261 3.81466 3.81677 3.81894 3.82117 3.82346 3.8258 3.8282 3.83065 3.83316 3.83572 3.83833 3.841 3.84371 3.84648 3.84929 3.85216 3.85507 3.85802 3.86102 3.86406 3.86714 3.87027 3.87343 3.87663 3.87987 3.88313 3.88643 3.88976 3.89311 3.89649 3.89989 3.9033 3.90673 3.91017 3.91362 3.91707 3.92052 3.92397 3.9274 3.93083 3.93423 3.93762 3.94097 3.9443 3.94759 3.95084 3.95407 3.95707 0.830413 0.857509 1.16926 1.7285 2.28148 2.70333 2.99742 3.19899 3.33861 3.4372 3.50825 3.56042 3.59936 3.62883 3.65138 3.6688 3.68236 3.69298 3.70133 3.70792 3.71312 3.71725 3.72051 3.7231 3.72514 3.72675 3.72803 3.72904 3.72984 3.73048 3.731 3.73142 3.73179 3.73211 3.7324 3.73269 3.73298 3.73327 3.73359 3.73394 3.73431 3.73473 3.73519 3.73569 3.73625 3.73686 3.73752 3.73824 3.73901 3.73985 3.74075 3.74171 3.74273 3.74381 3.74496 3.74617 3.74744 3.74878 3.75018 3.75164 3.75317 3.75475 3.7564 3.75811 3.75988 3.76171 3.7636 3.76555 3.76755 3.76962 3.77173 3.7739 3.77613 3.77841 3.78074 3.78312 3.78556 3.78805 3.7906 3.79319 3.79584 3.79854 3.80129 3.80409 3.80694 3.80983 3.81278 3.81577 3.81881 3.82189 3.82502 3.82819 3.8314 3.83466 3.83795 3.84128 3.84465 3.84805 3.85149 3.85495 3.85845 3.86197 3.86551 3.86908 3.87266 3.87626 3.87986 3.88348 3.8871 3.89072 3.89433 3.89794 3.90153 3.9051 3.90866 3.91218 3.91568 3.91913 3.92255 3.92592 3.92926 3.93238 0.831632 0.801461 0.924682 1.27902 1.76057 2.20994 2.5635 2.82478 3.0153 3.15518 3.2594 3.33832 3.39906 3.44651 3.48408 3.51418 3.53856 3.5585 3.57496 3.58866 3.60014 3.60984 3.61808 3.62514 3.63123 3.63651 3.64113 3.64519 3.6488 3.65202 3.65492 3.65755 3.65997 3.6622 3.66427 3.66622 3.66807 3.66983 3.67153 3.67317 3.67477 3.67635 3.6779 3.67944 3.68098 3.68252 3.68408 3.68564 3.68722 3.68883 3.69046 3.69212 3.69381 3.69554 3.6973 3.69911 3.70095 3.70283 3.70476 3.70673 3.70874 3.7108 3.71291 3.71506 3.71726 3.7195 3.72179 3.72413 3.72652 3.72895 3.73143 3.73395 3.73651 3.73912 3.74178 3.74448 3.74723 3.75002 3.75286 3.75575 3.75868 3.76166 3.76468 3.76775 3.77086 3.77401 3.77721 3.78045 3.78374 3.78707 3.79043 3.79384 3.79728 3.80077 3.80429 3.80784 3.81143 3.81504 3.81869 3.82237 3.82607 3.82979 3.83353 3.83729 3.84106 3.84485 3.84864 3.85243 3.85622 3.86001 3.86379 3.86755 3.8713 3.87502 3.87872 3.88238 3.88601 3.88959 3.89312 3.89661 3.90005 3.90327 0.835915 0.782667 0.803403 0.968303 1.29566 1.69673 2.07275 2.38225 2.62383 2.80953 2.95259 3.06386 3.15146 3.22133 3.27774 3.32383 3.3619 3.39365 3.42038 3.44308 3.46251 3.47926 3.49381 3.50652 3.51771 3.52762 3.53645 3.54435 3.55148 3.55795 3.56384 3.56924 3.57422 3.57884 3.58314 3.58717 3.59096 3.59455 3.59796 3.60122 3.60435 3.60736 3.61028 3.61311 3.61586 3.61856 3.62121 3.62382 3.6264 3.62896 3.6315 3.63402 3.63654 3.63906 3.64158 3.64411 3.64665 3.6492 3.65177 3.65436 3.65697 3.6596 3.66226 3.66495 3.66766 3.6704 3.67318 3.67598 3.67882 3.6817 3.6846 3.68754 3.69051 3.69351 3.69655 3.69962 3.70273 3.70588 3.70906 3.71228 3.71554 3.71883 3.72217 3.72554 3.72895 3.7324 3.73589 3.73941 3.74298 3.74657 3.75021 3.75387 3.75758 3.76131 3.76508 3.76887 3.7727 3.77655 3.78042 3.78432 3.78824 3.79218 3.79613 3.8001 3.80407 3.80805 3.81203 3.816 3.81998 3.82394 3.82788 3.83181 3.83571 3.83958 3.84341 3.84721 3.85096 3.85466 3.85831 3.86189 3.86544 3.86876 0.841165 0.780282 0.755 0.801817 0.962762 1.23783 1.56799 1.88853 2.16639 2.39488 2.57903 2.72692 2.8462 2.94318 3.02278 3.08874 3.14394 3.19054 3.23023 3.26431 3.29379 3.31947 3.34199 3.36187 3.37951 3.39527 3.40942 3.42218 3.43376 3.44431 3.45397 3.46285 3.47106 3.47868 3.48577 3.49241 3.49864 3.50452 3.51008 3.51536 3.52039 3.52519 3.5298 3.53424 3.53852 3.54266 3.54668 3.55059 3.55441 3.55814 3.5618 3.5654 3.56894 3.57244 3.57589 3.57932 3.58272 3.58609 3.58945 3.5928 3.59614 3.59948 3.60281 3.60615 3.60949 3.61284 3.61621 3.61958 3.62297 3.62637 3.62979 3.63323 3.63668 3.64016 3.64365 3.64716 3.6507 3.65426 3.65785 3.66147 3.66511 3.66878 3.67248 3.67621 3.67997 3.68376 3.68758 3.69143 3.6953 3.69921 3.70315 3.70711 3.7111 3.71512 3.71916 3.72323 3.72731 3.73142 3.73555 3.7397 3.74386 3.74803 3.75221 3.75639 3.76058 3.76477 3.76895 3.77312 3.77728 3.78142 3.78554 3.78963 3.79368 3.7977 3.80168 3.80561 3.80948 3.8133 3.81705 3.82073 3.82436 3.82778 0.846372 0.784571 0.740866 0.731421 0.780818 0.913761 1.13036 1.39676 1.66969 1.92048 2.13792 2.32135 2.47447 2.60211 2.70889 2.79873 2.87484 2.93979 2.99561 3.04393 3.08604 3.12297 3.15556 3.18449 3.2103 3.23346 3.25433 3.27324 3.29044 3.30616 3.32058 3.33386 3.34615 3.35755 3.36816 3.37809 3.38739 3.39614 3.4044 3.41221 3.41963 3.42669 3.43343 3.43987 3.44605 3.452 3.45773 3.46326 3.46863 3.47383 3.47889 3.48382 3.48864 3.49336 3.49798 3.50252 3.50698 3.51138 3.51572 3.52001 3.52425 3.52846 3.53263 3.53677 3.54089 3.54498 3.54906 3.55313 3.55719 3.56124 3.56529 3.56933 3.57338 3.57742 3.58147 3.58552 3.58957 3.59364 3.59771 3.6018 3.6059 3.61002 3.61415 3.6183 3.62247 3.62666 3.63087 3.6351 3.63934 3.64361 3.6479 3.6522 3.65653 3.66087 3.66523 3.6696 3.67399 3.67839 3.68281 3.68723 3.69166 3.69609 3.70052 3.70495 3.70937 3.71379 3.71819 3.72257 3.72693 3.73127 3.73557 3.73983 3.74406 3.74823 3.75235 3.75642 3.76042 3.76435 3.7682 3.77198 3.77569 3.7792 0.851011 0.791143 0.741126 0.708367 0.70346 0.741579 0.838108 0.996907 1.20263 1.4285 1.65059 1.85477 2.03555 2.19259 2.3279 2.44426 2.54449 2.63115 2.70642 2.77214 2.82983 2.88074 2.9259 2.96617 3.00226 3.03473 3.0641 3.09077 3.11508 3.13733 3.15777 3.17661 3.19405 3.21023 3.2253 3.23937 3.25255 3.26493 3.27659 3.2876 3.29803 3.30792 3.31733 3.3263 3.33488 3.34309 3.35097 3.35855 3.36585 3.3729 3.37972 3.38632 3.39274 3.39898 3.40506 3.41099 3.41679 3.42246 3.42802 3.43349 3.43885 3.44414 3.44935 3.45449 3.45957 3.46459 3.46956 3.47449 3.47938 3.48423 3.48905 3.49384 3.49861 3.50335 3.50808 3.51278 3.51747 3.52215 3.52682 3.53148 3.53614 3.5408 3.54546 3.55011 3.55478 3.55945 3.56412 3.5688 3.57349 3.57818 3.58288 3.58759 3.59231 3.59704 3.60177 3.6065 3.61124 3.61598 3.62073 3.62547 3.6302 3.63494 3.63966 3.64437 3.64906 3.65373 3.65838 3.663 3.66759 3.67214 3.67664 3.6811 3.6855 3.68984 3.69412 3.69833 3.70246 3.70651 3.71047 3.71434 3.71814 3.72173 0.854799 0.797919 0.746862 0.705362 0.677885 0.670753 0.692779 0.753704 0.85933 1.00619 1.18133 1.368 1.55204 1.72458 1.88152 2.02185 2.14624 2.2561 2.35311 2.43889 2.51496 2.58264 2.64308 2.69726 2.74603 2.79009 2.83005 2.86643 2.89967 2.93014 2.95817 2.98403 3.00797 3.03019 3.05088 3.0702 3.08828 3.10525 3.12121 3.13626 3.15049 3.16396 3.17675 3.18891 3.20051 3.21158 3.22217 3.23232 3.24206 3.25144 3.26047 3.26919 3.27762 3.28577 3.29369 3.30137 3.30884 3.31612 3.32322 3.33015 3.33694 3.34358 3.35009 3.35648 3.36276 3.36894 3.37503 3.38103 3.38695 3.3928 3.39858 3.4043 3.40997 3.41558 3.42114 3.42666 3.43213 3.43757 3.44297 3.44834 3.45369 3.45901 3.46431 3.4696 3.47486 3.48012 3.48536 3.49059 3.49581 3.50103 3.50623 3.51143 3.51662 3.52181 3.52698 3.53215 3.53731 3.54245 3.54759 3.55271 3.55781 3.5629 3.56796 3.57299 3.578 3.58298 3.58791 3.59281 3.59766 3.60245 3.60719 3.61187 3.61648 3.62101 3.62546 3.62983 3.63411 3.63829 3.64237 3.64634 3.65023 3.65391 0.857613 0.803838 0.754023 0.710069 0.674015 0.648368 0.636594 0.64348 0.674826 0.73588 0.828724 0.950234 1.09243 1.24518 1.3992 1.54782 1.68713 1.81538 1.93217 2.03791 2.13338 2.21952 2.29731 2.36768 2.43146 2.48942 2.54224 2.59051 2.63474 2.67539 2.71286 2.74748 2.77957 2.80937 2.83713 2.86305 2.88731 2.91006 2.93145 2.95161 2.97064 2.98863 3.00569 3.02189 3.0373 3.05199 3.066 3.07941 3.09224 3.10456 3.11639 3.12777 3.13874 3.14932 3.15955 3.16945 3.17904 3.18834 3.19738 3.20617 3.21474 3.22309 3.23124 3.23921 3.24701 3.25464 3.26213 3.26948 3.2767 3.2838 3.29079 3.29768 3.30447 3.31117 3.31779 3.32432 3.33078 3.33716 3.34348 3.34974 3.35594 3.36209 3.36819 3.37425 3.38027 3.38625 3.39219 3.39811 3.40399 3.40984 3.41567 3.42147 3.42724 3.43299 3.43871 3.4444 3.45007 3.45571 3.46132 3.4669 3.47245 3.47796 3.48344 3.48887 3.49425 3.49959 3.50487 3.5101 3.51526 3.52035 3.52537 3.5303 3.53515 3.53991 3.54458 3.54913 3.55358 3.55792 3.56213 3.56622 3.57021 3.574 0.859482 0.808378 0.760626 0.716973 0.678334 0.645749 0.620512 0.604371 0.599722 0.609658 0.637654 0.686738 0.758296 0.851094 0.961178 1.08279 1.20982 1.33698 1.46042 1.57773 1.68766 1.78972 1.88396 1.9707 2.05043 2.12369 2.19105 2.25304 2.31019 2.36297 2.41179 2.45705 2.49909 2.53822 2.57472 2.60884 2.64079 2.67077 2.69896 2.72551 2.75057 2.77426 2.7967 2.81799 2.83821 2.85746 2.87581 2.89332 2.91007 2.9261 2.94147 2.95623 2.97041 2.98407 2.99723 3.00993 3.0222 3.03407 3.04557 3.05671 3.06754 3.07805 3.08829 3.09825 3.10797 3.11745 3.12671 3.13577 3.14464 3.15332 3.16184 3.1702 3.17841 3.18648 3.19442 3.20224 3.20993 3.21752 3.22499 3.23237 3.23965 3.24684 3.25395 3.26099 3.26795 3.27484 3.28167 3.28844 3.29515 3.3018 3.3084 3.31495 3.32145 3.3279 3.3343 3.34065 3.34695 3.3532 3.35941 3.36556 3.37165 3.37769 3.38368 3.38959 3.39545 3.40123 3.40694 3.41257 3.41811 3.42356 3.42892 3.43418 3.43933 3.44437 3.44929 3.45408 3.45874 3.46327 3.46765 3.47189 3.476 3.47992 0.860565 0.811411 0.765711 0.723439 0.684828 0.650242 0.620147 0.595142 0.57603 0.563904 0.56022 0.566795 0.585676 0.618805 0.66751 0.731993 0.81102 0.902008 1.00149 1.10577 1.21146 1.31586 1.41705 1.51381 1.60547 1.69173 1.77257 1.84814 1.91867 1.98447 2.04585 2.10314 2.15665 2.20669 2.25354 2.29746 2.33869 2.37746 2.41396 2.44838 2.48088 2.51163 2.54075 2.56838 2.59462 2.61958 2.64336 2.66604 2.6877 2.70841 2.72825 2.74726 2.76551 2.78305 2.79992 2.81617 2.83183 2.84696 2.86157 2.8757 2.88939 2.90266 2.91553 2.92803 2.94019 2.95201 2.96353 2.97476 2.98572 2.99641 3.00687 3.0171 3.02712 3.03693 3.04655 3.05599 3.06526 3.07436 3.08331 3.09211 3.10076 3.10928 3.11767 3.12594 3.1341 3.14215 3.1501 3.15795 3.1657 3.17337 3.18095 3.18845 3.19586 3.2032 3.21045 3.21763 3.22474 3.23176 3.23871 3.24558 3.25236 3.25907 3.26569 3.27222 3.27866 3.285 3.29125 3.29738 3.30341 3.30932 3.31511 3.32077 3.3263 3.33169 3.33693 3.34202 3.34695 3.35172 3.35633 3.36076 3.36504 3.36912 0.861099 0.813133 0.76901 0.728261 0.690673 0.656203 0.624916 0.596953 0.57254 0.551996 0.535764 0.524447 0.518835 0.519919 0.528854 0.546863 0.575059 0.614217 0.664541 0.725514 0.795886 0.873821 0.957145 1.04364 1.13129 1.21842 1.30375 1.3864 1.4658 1.54163 1.61374 1.68211 1.74682 1.80798 1.86575 1.92032 1.97186 2.02057 2.06662 2.11021 2.15149 2.19063 2.22777 2.26305 2.29661 2.32855 2.35899 2.38803 2.41577 2.44229 2.46768 2.492 2.51533 2.53773 2.55925 2.57996 2.5999 2.61912 2.63767 2.65558 2.67289 2.68964 2.70585 2.72157 2.73682 2.75162 2.766 2.77999 2.7936 2.80686 2.81979 2.8324 2.84471 2.85674 2.8685 2.88001 2.89128 2.90231 2.91313 2.92374 2.93415 2.94437 2.9544 2.96425 2.97394 2.98346 2.99284 3.00207 3.01117 3.02013 3.02896 3.03766 3.04624 3.05471 3.06306 3.07129 3.07941 3.08742 3.09532 3.1031 3.11077 3.11832 3.12575 3.13306 3.14025 3.14731 3.15423 3.16102 3.16766 3.17415 3.18049 3.18667 3.19269 3.19853 3.20419 3.20967 3.21496 3.22005 3.22494 3.22963 3.23415 3.23846 0.861317 0.813942 0.770775 0.731184 0.694718 0.661081 0.630095 0.601662 0.575754 0.552397 0.531673 0.513721 0.498751 0.487049 0.478999 0.475087 0.475905 0.482135 0.494504 0.513718 0.540366 0.574817 0.617121 0.666953 0.72361 0.786067 0.853079 0.923307 0.995441 1.06829 1.14087 1.21238 1.28223 1.35001 1.41546 1.47842 1.53881 1.59663 1.65191 1.7047 1.75509 1.80318 1.84906 1.89286 1.93467 1.9746 2.01277 2.04927 2.0842 2.11764 2.14969 2.18042 2.20991 2.23823 2.26546 2.29165 2.31687 2.34116 2.36459 2.3872 2.40903 2.43013 2.45054 2.47029 2.48943 2.50798 2.52598 2.54345 2.56042 2.57692 2.59298 2.60861 2.62384 2.63869 2.65317 2.66731 2.68112 2.69462 2.70782 2.72073 2.73338 2.74576 2.75789 2.76977 2.78141 2.79284 2.80405 2.81505 2.82586 2.83648 2.84691 2.85717 2.86725 2.87716 2.88691 2.8965 2.90593 2.9152 2.92431 2.93326 2.94206 2.95069 2.95917 2.96748 2.97562 2.9836 2.9914 2.99902 3.00645 3.0137 3.02075 3.0276 3.03424 3.04068 3.04689 3.05288 3.05864 3.06416 3.06945 3.07449 3.07933 3.08394 0.861389 0.814244 0.77153 0.732597 0.696917 0.664079 0.633769 0.605753 0.579862 0.555979 0.53403 0.513979 0.495828 0.479611 0.4654 0.453309 0.443493 0.436161 0.431574 0.430052 0.431968 0.437737 0.4478 0.462586 0.482477 0.507758 0.538578 0.574904 0.616512 0.66298 0.713718 0.768009 0.825062 0.88407 0.94426 1.00493 1.06548 1.12542 1.18435 1.242 1.29815 1.35267 1.40547 1.45651 1.50578 1.55328 1.59905 1.64312 1.68554 1.72636 1.76565 1.80347 1.83988 1.87494 1.90873 1.94129 1.97268 2.00297 2.03221 2.06044 2.08772 2.11409 2.13959 2.16428 2.18819 2.21135 2.23381 2.2556 2.27675 2.29729 2.31726 2.33667 2.35556 2.37394 2.39185 2.40931 2.42633 2.44293 2.45914 2.47497 2.49044 2.50556 2.52035 2.53481 2.54897 2.56282 2.57637 2.58965 2.60265 2.61539 2.62788 2.64013 2.65213 2.66391 2.67545 2.68678 2.69788 2.70877 2.71944 2.7299 2.74015 2.75018 2.75999 2.76959 2.77897 2.78812 2.79705 2.80574 2.8142 2.82242 2.83039 2.83811 2.84557 2.85277 2.8597 2.86636 2.87275 2.87885 2.88466 2.89019 2.89547 2.9005 0.861406 0.814329 0.771776 0.733121 0.697834 0.665476 0.635686 0.608168 0.582682 0.559037 0.53708 0.516692 0.497782 0.480288 0.464168 0.449403 0.435996 0.423969 0.413369 0.404262 0.396745 0.390937 0.38699 0.385084 0.385432 0.38827 0.393857 0.402461 0.414344 0.429749 0.448872 0.471851 0.498741 0.5295 0.563988 0.601962 0.643088 0.68696 0.73312 0.781085 0.830369 0.880509 0.931076 0.981694 1.03204 1.08185 1.13091 1.17907 1.2262 1.27222 1.31708 1.36073 1.40317 1.4444 1.48441 1.52322 1.56086 1.59735 1.63272 1.667 1.70022 1.73243 1.76366 1.79394 1.82332 1.85183 1.87949 1.90636 1.93246 1.95781 1.98246 2.00643 2.02975 2.05244 2.07454 2.09605 2.11702 2.13746 2.15739 2.17684 2.19581 2.21434 2.23244 2.25013 2.26741 2.28431 2.30083 2.31698 2.33277 2.34821 2.36331 2.37808 2.39254 2.40668 2.42051 2.43405 2.44729 2.46025 2.47291 2.48529 2.49739 2.5092 2.52072 2.53196 2.54292 2.55358 2.56395 2.57402 2.58379 2.59326 2.60241 2.61125 2.61977 2.62797 2.63583 2.64337 2.65057 2.65743 2.66395 2.67013 2.67601 2.68161 0.861407 0.814342 0.77183 0.73326 0.698113 0.665954 0.636417 0.609191 0.584014 0.560665 0.538959 0.518737 0.499869 0.482247 0.46578 0.450397 0.43604 0.422666 0.410246 0.398762 0.388209 0.378592 0.36993 0.362255 0.355609 0.350053 0.345657 0.342512 0.340722 0.340409 0.341709 0.344772 0.349759 0.356833 0.366159 0.377891 0.392166 0.409093 0.428747 0.451159 0.476312 0.504134 0.534503 0.567246 0.602145 0.638949 0.677381 0.717149 0.75796 0.799527 0.841579 0.883868 0.926172 0.9683 1.01009 1.0514 1.09214 1.13222 1.17157 1.21015 1.24793 1.28489 1.32102 1.35632 1.39077 1.4244 1.45721 1.48921 1.5204 1.55082 1.58048 1.60939 1.63757 1.66505 1.69184 1.71797 1.74345 1.76832 1.79258 1.81626 1.83938 1.86195 1.884 1.90553 1.92657 1.94714 1.96723 1.98687 2.00607 2.02483 2.04316 2.06106 2.07855 2.09563 2.11231 2.1286 2.14451 2.16004 2.17519 2.18997 2.20438 2.21842 2.2321 2.2454 2.25833 2.27089 2.28307 2.29487 2.30629 2.31733 2.32798 2.33824 2.3481 2.35757 2.36664 2.3753 2.38357 2.39143 2.39888 2.40594 2.41264 2.41902 0.861405 0.814337 0.771831 0.733277 0.698164 0.666062 0.636607 0.60949 0.584448 0.561253 0.53971 0.519653 0.500935 0.483431 0.467033 0.451647 0.437194 0.423603 0.410816 0.398785 0.387468 0.376832 0.366852 0.357508 0.348789 0.340687 0.333204 0.326348 0.32013 0.314572 0.309702 0.305553 0.30217 0.299604 0.297915 0.29717 0.297449 0.298836 0.301424 0.305311 0.3106 0.317392 0.325787 0.335882 0.34776 0.361492 0.377132 0.394713 0.414243 0.435703 0.459048 0.484206 0.511076 0.539538 0.569448 0.600647 0.632966 0.666227 0.700254 0.734872 0.769912 0.805217 0.840643 0.876059 0.911351 0.946421 0.981184 1.01557 1.04953 1.08301 1.11597 1.14841 1.18029 1.2116 1.24234 1.2725 1.30208 1.33108 1.3595 1.38735 1.41462 1.44134 1.46749 1.4931 1.51816 1.54268 1.56668 1.59015 1.61311 1.63557 1.65754 1.67901 1.7 1.72048 1.74048 1.76 1.77903 1.7976 1.81569 1.83332 1.85049 1.86719 1.88342 1.89919 1.9145 1.92934 1.94371 1.95762 1.97105 1.98401 1.9965 2.00851 2.02005 2.03111 2.0417 2.05181 2.06146 2.07063 2.07934 2.08758 2.09542 2.10289 0.861402 0.814329 0.77182 0.733266 0.698157 0.666065 0.636627 0.609537 0.584532 0.561385 0.539902 0.519913 0.50127 0.483846 0.467525 0.45221 0.437813 0.424257 0.411474 0.399403 0.387993 0.377196 0.366972 0.357284 0.348103 0.339402 0.331157 0.323351 0.315968 0.308997 0.302429 0.296259 0.290486 0.285112 0.280141 0.275581 0.271446 0.267749 0.264512 0.261758 0.259514 0.257813 0.256693 0.256195 0.256365 0.257255 0.258919 0.261417 0.264811 0.269163 0.274539 0.281001 0.288613 0.297431 0.307508 0.318889 0.33161 0.345696 0.361161 0.378004 0.396213 0.415758 0.436597 0.458674 0.48192 0.506254 0.531586 0.557818 0.584845 0.612561 0.640857 0.669623 0.698755 0.728152 0.757717 0.787361 0.817002 0.846568 0.875992 0.905217 0.934193 0.962878 0.991235 1.01923 1.04685 1.07407 1.10087 1.12723 1.15315 1.17863 1.20364 1.22819 1.25226 1.27587 1.299 1.32163 1.34375 1.36535 1.38643 1.40699 1.42702 1.44653 1.4655 1.48394 1.50184 1.51921 1.53604 1.55233 1.56807 1.58329 1.59796 1.6121 1.62571 1.63879 1.65134 1.66338 1.6749 1.68591 1.69642 1.70644 1.71601 1.72517 0.8614 0.814321 0.77181 0.733253 0.698143 0.66605 0.636614 0.609527 0.584528 0.561391 0.53992 0.519948 0.501326 0.483926 0.467634 0.45235 0.437986 0.424462 0.411709 0.399665 0.388273 0.377484 0.367254 0.35754 0.348309 0.339526 0.331164 0.323195 0.315596 0.308347 0.301429 0.294824 0.288519 0.282502 0.27676 0.271286 0.266072 0.261113 0.256403 0.251941 0.247725 0.243758 0.24004 0.236576 0.233372 0.230436 0.227778 0.225408 0.223341 0.221593 0.220181 0.219128 0.218455 0.218189 0.218357 0.218991 0.220124 0.221791 0.22403 0.226878 0.230377 0.234566 0.239486 0.245177 0.251678 0.259025 0.267251 0.276386 0.286455 0.297478 0.309468 0.322434 0.336373 0.351279 0.367137 0.383922 0.401604 0.420143 0.439496 0.459609 0.480425 0.501883 0.523916 0.546455 0.56943 0.59277 0.616403 0.64026 0.664271 0.688372 0.7125 0.736596 0.760606 0.78448 0.808172 0.831642 0.85486 0.877788 0.900387 0.922625 0.944477 0.965927 0.986957 1.00755 1.02771 1.04741 1.06665 1.08543 1.10374 1.12158 1.13895 1.15584 1.17226 1.1882 1.20367 1.21866 1.23318 1.24724 1.26082 1.27395 1.28663 1.29889 0.861399 0.814317 0.771804 0.733245 0.698133 0.666039 0.636602 0.609515 0.584516 0.561379 0.53991 0.51994 0.501322 0.483926 0.46764 0.452363 0.438006 0.424492 0.411749 0.399716 0.388335 0.377557 0.367336 0.357631 0.348405 0.339625 0.331258 0.323279 0.315662 0.308383 0.301421 0.294758 0.288376 0.282259 0.276392 0.270762 0.265357 0.260167 0.25518 0.250389 0.245786 0.241363 0.237113 0.233033 0.229117 0.225362 0.221765 0.218323 0.215035 0.211902 0.208922 0.206098 0.203431 0.200924 0.198581 0.196407 0.194407 0.192589 0.19096 0.18953 0.188308 0.187307 0.186538 0.186017 0.185758 0.185779 0.186099 0.186737 0.187716 0.189057 0.190785 0.192925 0.195505 0.19855 0.202089 0.206149 0.210759 0.215947 0.221739 0.228162 0.235239 0.242994 0.251446 0.260612 0.270506 0.281138 0.292513 0.304633 0.317495 0.331089 0.345404 0.36042 0.376115 0.392461 0.409426 0.426973 0.445065 0.463657 0.482708 0.502171 0.521995 0.542126 0.562509 0.583091 0.603816 0.624634 0.645491 0.666338 0.687128 0.707814 0.728355 0.748709 0.76884 0.788713 0.808295 0.827558 0.846476 0.865025 0.883184 0.900936 0.91827 0.935136 0.861399 0.814317 0.771804 0.733245 0.698133 0.666039 0.636602 0.609515 0.584516 0.561379 0.53991 0.51994 0.501322 0.483926 0.46764 0.452363 0.438006 0.424492 0.411749 0.399716 0.388335 0.377557 0.367336 0.357631 0.348405 0.339624 0.331258 0.323279 0.315662 0.308383 0.301421 0.294758 0.288376 0.282259 0.276392 0.270762 0.265358 0.260167 0.255181 0.25039 0.245786 0.241363 0.237114 0.233034 0.229119 0.225364 0.221767 0.218325 0.215038 0.211904 0.208925 0.206101 0.203435 0.200929 0.198586 0.196413 0.194414 0.192597 0.190969 0.18954 0.188319 0.187318 0.186551 0.18603 0.185773 0.185796 0.186118 0.186758 0.187738 0.189082 0.190812 0.192956 0.195538 0.198587 0.202129 0.206194 0.210809 0.216002 0.221801 0.22823 0.235315 0.243078 0.251539 0.260715 0.27062 0.281263 0.29265 0.304784 0.317659 0.331268 0.345598 0.36063 0.376342 0.392705 0.409688 0.427254 0.445364 0.463975 0.483046 0.50253 0.522373 0.542523 0.562925 0.583524 0.604266 0.6251 0.645973 0.666835 0.687639 0.70834 0.728893 0.74926 0.769403 0.789287 0.80888 0.828153 0.84708 0.865639 0.883807 0.901568 0.91891 0.935784 0.8614 0.814321 0.77181 0.733253 0.698143 0.66605 0.636614 0.609527 0.584528 0.561391 0.53992 0.519948 0.501326 0.483926 0.467634 0.45235 0.437985 0.424462 0.411709 0.399665 0.388273 0.377484 0.367253 0.35754 0.348309 0.339526 0.331164 0.323195 0.315596 0.308347 0.301429 0.294825 0.288521 0.282504 0.276763 0.27129 0.266077 0.261118 0.25641 0.251949 0.247736 0.24377 0.240055 0.236594 0.233393 0.230461 0.227806 0.225441 0.223379 0.221637 0.220232 0.219185 0.21852 0.218262 0.218441 0.219085 0.22023 0.22191 0.224162 0.227026 0.230541 0.234748 0.239688 0.245399 0.251922 0.259292 0.267542 0.276703 0.2868 0.297852 0.309872 0.322868 0.33684 0.35178 0.367671 0.384491 0.402208 0.420784 0.440173 0.460323 0.481176 0.502671 0.52474 0.547316 0.570328 0.593704 0.617372 0.641264 0.665309 0.689444 0.713605 0.737733 0.761774 0.785679 0.809402 0.832902 0.85615 0.879107 0.901731 0.923993 0.945869 0.967341 0.988394 1.00901 1.02919 1.04891 1.06818 1.08697 1.1053 1.12316 1.14055 1.15746 1.17389 1.18985 1.20534 1.22035 1.23489 1.24896 1.26257 1.27571 1.28841 1.30069 0.861402 0.814329 0.77182 0.733266 0.698157 0.666065 0.636627 0.609537 0.584532 0.561385 0.539902 0.519912 0.50127 0.483845 0.467524 0.452209 0.437812 0.424256 0.411472 0.399402 0.387991 0.377195 0.366971 0.357284 0.348103 0.339402 0.331159 0.323354 0.315973 0.309004 0.302438 0.296272 0.290503 0.285133 0.280167 0.275614 0.271485 0.267797 0.264569 0.261826 0.259595 0.257908 0.256804 0.256323 0.256514 0.257427 0.259117 0.261643 0.265067 0.269454 0.274866 0.281369 0.289024 0.297887 0.308013 0.319445 0.332219 0.34636 0.361881 0.378782 0.397048 0.416651 0.437547 0.459681 0.482982 0.50737 0.532753 0.559035 0.586109 0.61387 0.642206 0.671012 0.700179 0.729609 0.759203 0.788875 0.818541 0.848129 0.877573 0.906816 0.935808 0.964507 0.992878 1.02089 1.04852 1.07574 1.10255 1.12893 1.15486 1.18034 1.20536 1.22992 1.254 1.27762 1.30076 1.3234 1.34552 1.36713 1.38822 1.40879 1.42883 1.44835 1.46733 1.48578 1.5037 1.52108 1.53792 1.55422 1.56998 1.58521 1.5999 1.61406 1.62768 1.64078 1.65335 1.6654 1.67694 1.68797 1.6985 1.70854 1.71813 1.72732 0.861405 0.814337 0.771831 0.733277 0.698164 0.666062 0.636607 0.60949 0.584447 0.561251 0.539709 0.519651 0.500932 0.483428 0.467029 0.451643 0.437189 0.423599 0.410813 0.398782 0.387467 0.376833 0.366856 0.357515 0.3488 0.340705 0.333229 0.326381 0.320173 0.314628 0.309772 0.305641 0.302278 0.299735 0.298072 0.297359 0.297673 0.299101 0.301735 0.305674 0.31102 0.317875 0.32634 0.33651 0.348468 0.362285 0.378015 0.395688 0.415313 0.436868 0.460309 0.48556 0.512522 0.541071 0.571064 0.60234 0.63473 0.668056 0.702141 0.73681 0.771894 0.807237 0.842694 0.878136 0.913448 0.948533 0.983307 1.0177 1.05166 1.08514 1.11811 1.15054 1.18241 1.21372 1.24445 1.2746 1.30417 1.33316 1.36157 1.38941 1.41667 1.44338 1.46952 1.49512 1.52017 1.54468 1.56867 1.59213 1.61509 1.63754 1.6595 1.68097 1.70195 1.72243 1.74242 1.76193 1.78097 1.79953 1.81763 1.83526 1.85242 1.86912 1.88536 1.90114 1.91645 1.9313 1.94568 1.95959 1.97304 1.98601 1.99851 2.01053 2.02208 2.03316 2.04376 2.05389 2.06355 2.07274 2.08147 2.08974 2.09759 2.10508 0.861407 0.814342 0.77183 0.73326 0.698112 0.665953 0.636415 0.609187 0.584009 0.560659 0.538951 0.518729 0.49986 0.482238 0.465771 0.450389 0.436034 0.422664 0.410249 0.398772 0.388227 0.378622 0.369975 0.362317 0.355694 0.350164 0.3458 0.342693 0.340948 0.340687 0.342048 0.345182 0.350249 0.357415 0.366843 0.378687 0.393083 0.410141 0.429932 0.452487 0.477785 0.505753 0.536265 0.569146 0.604176 0.641101 0.679643 0.71951 0.760407 0.802047 0.84416 0.886498 0.92884 0.970995 1.0128 1.05413 1.09487 1.13494 1.17429 1.21286 1.25062 1.28757 1.32367 1.35895 1.39338 1.42698 1.45976 1.49173 1.5229 1.55329 1.58291 1.61179 1.63995 1.6674 1.69416 1.72026 1.74572 1.77056 1.7948 1.81845 1.84155 1.8641 1.88612 1.90764 1.92866 1.9492 1.96928 1.9889 2.00809 2.02684 2.04515 2.06303 2.08051 2.09758 2.11425 2.13053 2.14643 2.16196 2.1771 2.19188 2.20629 2.22033 2.234 2.2473 2.26024 2.2728 2.28499 2.2968 2.30823 2.31927 2.32993 2.3402 2.35008 2.35956 2.36865 2.37733 2.38561 2.39349 2.40096 2.40804 2.41476 2.42116 0.861405 0.814329 0.771776 0.733119 0.69783 0.66547 0.635677 0.608156 0.582668 0.559021 0.537062 0.516674 0.497766 0.480275 0.464162 0.449406 0.436013 0.424004 0.413427 0.40435 0.39687 0.391108 0.387218 0.385381 0.385811 0.388747 0.394449 0.403185 0.415218 0.430789 0.450096 0.47327 0.500364 0.531332 0.566028 0.604204 0.645522 0.689572 0.735891 0.783995 0.833398 0.883634 0.934277 0.984953 1.03534 1.08517 1.13425 1.18241 1.22953 1.27553 1.32037 1.364 1.4064 1.44759 1.48757 1.52634 1.56394 1.60038 1.6357 1.66994 1.70312 1.73528 1.76646 1.7967 1.82603 1.85449 1.88212 1.90894 1.93499 1.96031 1.98492 2.00885 2.03213 2.05478 2.07684 2.09832 2.11926 2.13966 2.15956 2.17898 2.19793 2.21643 2.23451 2.25217 2.26943 2.2863 2.3028 2.31893 2.3347 2.35012 2.3652 2.37996 2.3944 2.40852 2.42235 2.43587 2.44911 2.46205 2.47471 2.48708 2.49918 2.51098 2.52251 2.53375 2.54471 2.55537 2.56575 2.57582 2.5856 2.59507 2.60424 2.61309 2.62162 2.62983 2.63772 2.64527 2.65249 2.65937 2.66591 2.67211 2.67802 2.68364 0.861388 0.814243 0.771526 0.73259 0.696905 0.664061 0.633746 0.605726 0.579833 0.55595 0.534004 0.513962 0.495824 0.479627 0.465445 0.453393 0.443628 0.436361 0.431857 0.430439 0.432481 0.438405 0.448649 0.463646 0.483775 0.509319 0.540418 0.577033 0.618929 0.665675 0.716672 0.771196 0.828451 0.887626 0.947949 1.00872 1.06934 1.12932 1.18828 1.24593 1.30207 1.35657 1.40934 1.46034 1.50956 1.55701 1.60272 1.64674 1.68909 1.72986 1.76909 1.80684 1.84319 1.87819 1.91191 1.94441 1.97575 2.00598 2.03515 2.06332 2.09055 2.11686 2.14231 2.16694 2.1908 2.21391 2.23632 2.25806 2.27917 2.29967 2.31959 2.33896 2.3578 2.37615 2.39403 2.41144 2.42843 2.445 2.46118 2.47698 2.49241 2.50751 2.52227 2.53671 2.55084 2.56466 2.57819 2.59144 2.60442 2.61715 2.62962 2.64184 2.65384 2.66559 2.67713 2.68844 2.69953 2.71041 2.72108 2.73153 2.74177 2.7518 2.76161 2.77121 2.78059 2.78974 2.79868 2.80738 2.81584 2.82407 2.83205 2.83979 2.84726 2.85448 2.86143 2.86811 2.87451 2.88063 2.88647 2.89202 2.89732 2.90238 0.861316 0.813937 0.770764 0.731165 0.694689 0.661045 0.630052 0.601618 0.575716 0.552372 0.531671 0.513756 0.498837 0.487207 0.479253 0.475467 0.476448 0.482881 0.495498 0.515007 0.541992 0.576813 0.619504 0.669726 0.726758 0.789556 0.856864 0.927335 0.999657 1.07265 1.14531 1.21687 1.28674 1.35451 1.41993 1.48285 1.54319 1.60094 1.65615 1.70887 1.75918 1.80719 1.85299 1.8967 1.93843 1.97829 2.01638 2.0528 2.08765 2.12102 2.15299 2.18364 2.21306 2.24132 2.26848 2.2946 2.31975 2.34398 2.36735 2.38989 2.41167 2.43271 2.45306 2.47276 2.49185 2.51035 2.5283 2.54572 2.56265 2.57911 2.59512 2.61071 2.6259 2.64071 2.65516 2.66926 2.68304 2.6965 2.70967 2.72255 2.73516 2.74752 2.75962 2.77147 2.78309 2.79449 2.80568 2.81666 2.82744 2.83804 2.84846 2.85869 2.86876 2.87866 2.8884 2.89797 2.90739 2.91665 2.92575 2.9347 2.94349 2.95212 2.9606 2.96891 2.97705 2.98503 2.99284 3.00046 3.00791 3.01516 3.02223 3.02909 3.03575 3.0422 3.04843 3.05444 3.06022 3.06577 3.07108 3.07615 3.08101 3.08565 0.861096 0.813121 0.768984 0.72822 0.69062 0.656144 0.62486 0.596913 0.572531 0.55204 0.535888 0.524686 0.519235 0.520534 0.529752 0.548115 0.576736 0.616375 0.667214 0.728705 0.799565 0.877928 0.961604 1.04837 1.1362 1.22344 1.30883 1.39149 1.47086 1.54663 1.61866 1.68694 1.75155 1.81261 1.87027 1.92473 1.97617 2.02477 2.07072 2.11421 2.15539 2.19444 2.23148 2.26667 2.30014 2.33199 2.36235 2.39131 2.41897 2.44541 2.47072 2.49497 2.51823 2.54056 2.56202 2.58266 2.60254 2.6217 2.64018 2.65803 2.67529 2.69198 2.70814 2.72381 2.73901 2.75376 2.7681 2.78204 2.79561 2.80883 2.82171 2.83429 2.84656 2.85855 2.87028 2.88175 2.89299 2.90399 2.91478 2.92536 2.93574 2.94592 2.95592 2.96575 2.97541 2.98491 2.99427 3.00348 3.01255 3.02149 3.0303 3.03899 3.04756 3.05601 3.06434 3.07256 3.08067 3.08867 3.09656 3.10434 3.112 3.11955 3.12698 3.13429 3.14148 3.14854 3.15547 3.16226 3.16891 3.17542 3.18177 3.18796 3.19399 3.19985 3.20553 3.21103 3.21635 3.22146 3.22638 3.2311 3.23565 3.23998 0.860556 0.811383 0.765662 0.723372 0.684754 0.650177 0.620113 0.59517 0.576161 0.564196 0.560746 0.56765 0.586971 0.620647 0.66999 0.735154 0.814848 0.906433 1.0064 1.11104 1.21696 1.32148 1.42271 1.51944 1.61102 1.69718 1.7779 1.85333 1.92373 1.98938 2.05061 2.10776 2.16114 2.21105 2.25777 2.30157 2.34268 2.38134 2.41773 2.45205 2.48446 2.51511 2.54414 2.57167 2.59783 2.62271 2.6464 2.66901 2.69059 2.71123 2.731 2.74994 2.76812 2.78559 2.8024 2.81859 2.8342 2.84926 2.86382 2.8779 2.89154 2.90475 2.91758 2.93003 2.94214 2.95392 2.9654 2.97658 2.9875 2.99816 3.00858 3.01877 3.02875 3.03853 3.04811 3.05752 3.06676 3.07583 3.08475 3.09351 3.10214 3.11063 3.11899 3.12724 3.13537 3.1434 3.15132 3.15915 3.16688 3.17453 3.18209 3.18957 3.19697 3.20429 3.21153 3.2187 3.22579 3.23281 3.23975 3.24661 3.25339 3.2601 3.26671 3.27325 3.27969 3.28603 3.29228 3.29843 3.30446 3.31038 3.31619 3.32186 3.32741 3.33281 3.33808 3.34319 3.34814 3.35294 3.35757 3.36203 3.36634 3.37045 0.859464 0.80833 0.760551 0.716886 0.678261 0.645727 0.620595 0.604638 0.600284 0.610661 0.639266 0.689119 0.761548 0.855222 0.966084 1.08831 1.21574 1.34312 1.46664 1.58393 1.69375 1.79567 1.88974 1.9763 2.05583 2.1289 2.19607 2.25789 2.31487 2.36748 2.41615 2.46126 2.50316 2.54216 2.57854 2.61254 2.64438 2.67426 2.70235 2.72881 2.75378 2.77738 2.79973 2.82094 2.84108 2.86026 2.87853 2.89598 2.91265 2.92862 2.94392 2.95861 2.97274 2.98633 2.99944 3.01208 3.0243 3.03612 3.04756 3.05866 3.06944 3.07991 3.0901 3.10002 3.10969 3.11913 3.12835 3.13737 3.1462 3.15485 3.16333 3.17165 3.17983 3.18787 3.19578 3.20356 3.21123 3.21878 3.22623 3.23357 3.24082 3.24799 3.25508 3.26208 3.26902 3.27589 3.28269 3.28944 3.29613 3.30276 3.30934 3.31588 3.32236 3.32879 3.33518 3.34152 3.34781 3.35406 3.36025 3.3664 3.37249 3.37852 3.3845 3.39042 3.39628 3.40206 3.40778 3.41341 3.41897 3.42443 3.42981 3.43508 3.44024 3.4453 3.45024 3.45505 3.45974 3.46429 3.4687 3.47296 3.47711 3.48105 0.857582 0.803766 0.753927 0.709985 0.674001 0.648514 0.637038 0.644422 0.676518 0.738565 0.832541 0.955142 1.09823 1.25157 1.4059 1.55461 1.69386 1.82195 1.93853 2.04402 2.13923 2.22513 2.30268 2.37281 2.43637 2.49413 2.54676 2.59485 2.63892 2.67942 2.71674 2.75123 2.78318 2.81287 2.84052 2.86634 2.8905 2.91316 2.93446 2.95453 2.97348 2.9914 3.00838 3.02451 3.03985 3.05446 3.06842 3.08176 3.09453 3.10679 3.11856 3.12988 3.1408 3.15133 3.1615 3.17135 3.18089 3.19015 3.19914 3.20789 3.21641 3.22472 3.23283 3.24075 3.24851 3.25611 3.26356 3.27087 3.27806 3.28513 3.29208 3.29893 3.30569 3.31236 3.31895 3.32545 3.33188 3.33823 3.34452 3.35075 3.35692 3.36305 3.36912 3.37516 3.38115 3.38711 3.39303 3.39892 3.40479 3.41062 3.41643 3.42221 3.42797 3.4337 3.43941 3.44509 3.45075 3.45638 3.46199 3.46756 3.4731 3.47861 3.48408 3.48951 3.4949 3.50024 3.50553 3.51076 3.51593 3.52103 3.52606 3.53101 3.53588 3.54066 3.54534 3.54992 3.55439 3.55875 3.56299 3.56711 3.57113 3.57494 0.854751 0.797826 0.746765 0.70534 0.678073 0.671377 0.694174 0.756253 0.863298 1.01155 1.18777 1.37509 1.55938 1.7319 1.88865 2.0287 2.15276 2.2623 2.35898 2.44445 2.52023 2.58765 2.64784 2.7018 2.75036 2.79423 2.83402 2.87025 2.90334 2.93367 2.96157 2.98732 3.01115 3.03327 3.05387 3.07309 3.09109 3.10797 3.12386 3.13884 3.15299 3.1664 3.17912 3.19122 3.20275 3.21376 3.22429 3.23439 3.24408 3.2534 3.26238 3.27105 3.27942 3.28753 3.2954 3.30304 3.31047 3.3177 3.32476 3.33165 3.33839 3.345 3.35147 3.35782 3.36407 3.37021 3.37626 3.38223 3.38811 3.39393 3.39968 3.40537 3.41101 3.41659 3.42212 3.42761 3.43305 3.43846 3.44384 3.44918 3.4545 3.4598 3.46507 3.47033 3.47558 3.48081 3.48603 3.49124 3.49644 3.50164 3.50682 3.51201 3.51718 3.52235 3.52751 3.53267 3.53782 3.54296 3.54808 3.5532 3.5583 3.56338 3.56844 3.57348 3.57848 3.58346 3.5884 3.59331 3.59816 3.60297 3.60772 3.61241 3.61703 3.62159 3.62606 3.63045 3.63475 3.63895 3.64306 3.64705 3.65097 3.65468 0.850946 0.791039 0.741074 0.708546 0.704202 0.7434 0.841547 1.00216 1.20938 1.43613 1.65851 1.86259 2.04306 2.1997 2.33458 2.45052 2.55036 2.63665 2.71159 2.77702 2.83444 2.8851 2.93005 2.97012 3.00602 3.03834 3.06755 3.09408 3.11827 3.1404 3.16073 3.17948 3.19682 3.21292 3.2279 3.2419 3.25501 3.26732 3.27891 3.28986 3.30022 3.31006 3.31941 3.32833 3.33685 3.34501 3.35283 3.36036 3.36761 3.37462 3.38139 3.38795 3.39432 3.40052 3.40656 3.41245 3.4182 3.42384 3.42936 3.43479 3.44012 3.44537 3.45054 3.45565 3.46069 3.46568 3.47062 3.47552 3.48037 3.48519 3.48998 3.49475 3.49948 3.5042 3.50889 3.51357 3.51823 3.52288 3.52752 3.53216 3.53679 3.54143 3.54606 3.5507 3.55534 3.55999 3.56464 3.5693 3.57397 3.57864 3.58333 3.58802 3.59273 3.59744 3.60215 3.60688 3.61161 3.61634 3.62108 3.62581 3.63054 3.63527 3.63999 3.6447 3.6494 3.65407 3.65873 3.66335 3.66795 3.67251 3.67702 3.68149 3.68591 3.69027 3.69457 3.69879 3.70295 3.70702 3.711 3.7149 3.71872 3.72234 0.846292 0.784482 0.740966 0.732137 0.78289 0.917939 1.13673 1.40461 1.67813 1.92885 2.1459 2.3288 2.48137 2.6085 2.7148 2.80421 2.87994 2.94455 3.00007 3.04813 3.09 3.12673 3.15913 3.18789 3.21355 3.23657 3.25731 3.27611 3.2932 3.30882 3.32315 3.33635 3.34856 3.35989 3.37043 3.38029 3.38953 3.39823 3.40643 3.41419 3.42155 3.42856 3.43524 3.44164 3.44778 3.45367 3.45936 3.46485 3.47017 3.47533 3.48035 3.48525 3.49003 3.4947 3.49929 3.50379 3.50821 3.51258 3.51688 3.52114 3.52535 3.52952 3.53365 3.53776 3.54185 3.54592 3.54997 3.554 3.55803 3.56205 3.56607 3.57009 3.57411 3.57812 3.58214 3.58616 3.59019 3.59423 3.59828 3.60234 3.60642 3.61052 3.61463 3.61876 3.6229 3.62707 3.63126 3.63547 3.6397 3.64395 3.64822 3.65251 3.65682 3.66115 3.66549 3.66986 3.67424 3.67863 3.68304 3.68745 3.69187 3.6963 3.70073 3.70516 3.70959 3.71401 3.71841 3.7228 3.72717 3.73151 3.73583 3.7401 3.74434 3.74853 3.75267 3.75675 3.76077 3.76472 3.7686 3.7724 3.77614 3.77967 0.841078 0.780264 0.755504 0.803802 0.967329 1.24502 1.57667 1.89752 2.175 2.40285 2.5863 2.73353 2.85223 2.94869 3.02784 3.09342 3.14828 3.1946 3.23403 3.26789 3.29717 3.32267 3.34504 3.36478 3.3823 3.39794 3.41198 3.42465 3.43614 3.44661 3.45619 3.46501 3.47315 3.48071 3.48774 3.49433 3.50051 3.50634 3.51185 3.51708 3.52206 3.52683 3.53139 3.53579 3.54002 3.54412 3.5481 3.55198 3.55576 3.55945 3.56308 3.56664 3.57015 3.57361 3.57703 3.58042 3.58379 3.58713 3.59046 3.59377 3.59708 3.60039 3.60369 3.607 3.61032 3.61364 3.61697 3.62032 3.62368 3.62705 3.63045 3.63386 3.63728 3.64073 3.6442 3.64769 3.6512 3.65474 3.6583 3.6619 3.66552 3.66917 3.67285 3.67655 3.68029 3.68406 3.68786 3.69169 3.69555 3.69944 3.70336 3.70731 3.71129 3.7153 3.71933 3.72338 3.72746 3.73156 3.73568 3.73982 3.74398 3.74815 3.75232 3.75651 3.7607 3.76489 3.76907 3.77325 3.77742 3.78157 3.78569 3.7898 3.79387 3.7979 3.80189 3.80584 3.80973 3.81357 3.81734 3.82104 3.8247 3.82814 0.835835 0.782846 0.804872 0.972689 1.30328 1.70602 2.08215 2.39101 2.63171 2.81657 2.95888 3.0695 3.15657 3.22598 3.28202 3.32778 3.36557 3.39708 3.4236 3.44611 3.46538 3.48199 3.4964 3.509 3.52009 3.5299 3.53864 3.54647 3.55353 3.55993 3.56576 3.5711 3.57603 3.58059 3.58485 3.58883 3.59258 3.59613 3.5995 3.60272 3.60581 3.60878 3.61166 3.61445 3.61717 3.61984 3.62246 3.62503 3.62758 3.6301 3.63261 3.6351 3.63759 3.64007 3.64256 3.64506 3.64757 3.6501 3.65264 3.65519 3.65778 3.66038 3.66301 3.66567 3.66836 3.67107 3.67382 3.6766 3.67942 3.68226 3.68514 3.68806 3.691 3.69398 3.69699 3.70004 3.70313 3.70625 3.70941 3.71261 3.71585 3.71913 3.72244 3.7258 3.72919 3.73262 3.73609 3.7396 3.74315 3.74673 3.75035 3.754 3.75769 3.76141 3.76517 3.76896 3.77277 3.77662 3.78049 3.78438 3.7883 3.79223 3.79618 3.80015 3.80412 3.8081 3.81208 3.81607 3.82005 3.82401 3.82797 3.8319 3.83582 3.8397 3.84355 3.84736 3.85113 3.85485 3.85852 3.86212 3.86569 3.86903 0.831589 0.802127 0.9281 1.28649 1.77028 2.21974 2.57241 2.8326 3.02211 3.16116 3.26468 3.34305 3.40333 3.4504 3.48765 3.51748 3.54164 3.56139 3.57767 3.59122 3.60257 3.61215 3.62029 3.62725 3.63325 3.63846 3.64301 3.64701 3.65055 3.65372 3.65657 3.65915 3.66152 3.66371 3.66575 3.66766 3.66947 3.6712 3.67286 3.67447 3.67604 3.67758 3.6791 3.68061 3.68212 3.68363 3.68515 3.68669 3.68824 3.68982 3.69142 3.69306 3.69472 3.69642 3.69816 3.69993 3.70175 3.7036 3.70551 3.70745 3.70944 3.71147 3.71355 3.71568 3.71785 3.72007 3.72234 3.72465 3.72702 3.72942 3.73188 3.73438 3.73692 3.73951 3.74214 3.74482 3.74755 3.75032 3.75314 3.75601 3.75892 3.76188 3.76488 3.76793 3.77103 3.77417 3.77735 3.78058 3.78385 3.78716 3.79052 3.79391 3.79735 3.80082 3.80433 3.80788 3.81146 3.81507 3.81871 3.82238 3.82608 3.8298 3.83354 3.8373 3.84107 3.84486 3.84865 3.85245 3.85625 3.86004 3.86383 3.86761 3.87137 3.8751 3.87881 3.88249 3.88613 3.88973 3.89328 3.89678 3.90025 3.90349 0.83047 0.859252 1.17557 1.73833 2.29171 2.71247 3.00523 3.20563 3.34431 3.44216 3.51263 3.56434 3.6029 3.63205 3.65435 3.67155 3.68493 3.69539 3.7036 3.71007 3.71517 3.7192 3.72238 3.72488 3.72686 3.72841 3.72963 3.73058 3.73134 3.73193 3.73241 3.7328 3.73312 3.73341 3.73367 3.73393 3.73418 3.73445 3.73474 3.73506 3.73541 3.7358 3.73623 3.73671 3.73724 3.73782 3.73845 3.73915 3.7399 3.74071 3.74158 3.74252 3.74351 3.74457 3.7457 3.74688 3.74813 3.74944 3.75082 3.75226 3.75376 3.75533 3.75695 3.75864 3.76039 3.76219 3.76406 3.76599 3.76797 3.77001 3.77211 3.77426 3.77646 3.77872 3.78103 3.7834 3.78582 3.7883 3.79082 3.7934 3.79603 3.79872 3.80145 3.80423 3.80707 3.80995 3.81288 3.81586 3.81889 3.82196 3.82508 3.82824 3.83144 3.83469 3.83797 3.8413 3.84466 3.84805 3.85149 3.85495 3.85844 3.86196 3.8655 3.86907 3.87265 3.87625 3.87986 3.88348 3.88711 3.89074 3.89436 3.89797 3.90158 3.90516 3.90873 3.91227 3.91578 3.91925 3.92269 3.92608 3.92944 3.93257 0.837083 0.991886 1.56879 2.26379 2.79675 3.14662 3.36902 3.51204 3.60619 3.66961 3.71316 3.74348 3.76477 3.77975 3.79024 3.79749 3.80237 3.8055 3.80733 3.80821 3.80837 3.808 3.80724 3.80621 3.80498 3.80363 3.8022 3.80073 3.79925 3.79779 3.79637 3.79499 3.79368 3.79244 3.79128 3.7902 3.78921 3.7883 3.78748 3.78676 3.78612 3.78558 3.78513 3.78478 3.78451 3.78434 3.78426 3.78427 3.78437 3.78456 3.78483 3.7852 3.78565 3.78618 3.7868 3.78751 3.78829 3.78916 3.7901 3.79112 3.79222 3.79339 3.79464 3.79596 3.79735 3.79881 3.80035 3.80195 3.80361 3.80534 3.80713 3.80899 3.8109 3.81288 3.81491 3.81701 3.81916 3.82138 3.82365 3.82598 3.82836 3.8308 3.83329 3.83584 3.83844 3.84109 3.8438 3.84655 3.84936 3.85221 3.85511 3.85806 3.86105 3.86408 3.86716 3.87028 3.87344 3.87664 3.87987 3.88313 3.88643 3.88976 3.89311 3.89649 3.89989 3.90331 3.90674 3.91019 3.91364 3.9171 3.92056 3.92401 3.92746 3.9309 3.93432 3.93772 3.94109 3.94443 3.94774 3.95101 3.95425 3.95727 0.861181 1.2442 2.07273 2.79223 3.24675 3.51205 3.66751 3.76086 3.81819 3.85383 3.87594 3.88935 3.89701 3.90082 3.90201 3.9014 3.89958 3.89692 3.89371 3.89015 3.88639 3.88252 3.87863 3.87478 3.871 3.86732 3.86377 3.86035 3.85709 3.85398 3.85103 3.84824 3.84561 3.84314 3.84083 3.83867 3.83667 3.83481 3.8331 3.83153 3.8301 3.8288 3.82764 3.8266 3.82569 3.8249 3.82424 3.82369 3.82326 3.82293 3.82272 3.82262 3.82262 3.82273 3.82293 3.82324 3.82363 3.82413 3.82471 3.82538 3.82615 3.82699 3.82792 3.82893 3.83002 3.83119 3.83244 3.83376 3.83515 3.83662 3.83815 3.83974 3.84141 3.84314 3.84493 3.84679 3.84872 3.8507 3.85274 3.85485 3.85701 3.85924 3.86151 3.86385 3.86624 3.86868 3.87118 3.87373 3.87633 3.87898 3.88168 3.88443 3.88722 3.89006 3.89295 3.89587 3.89884 3.90184 3.90488 3.90796 3.91107 3.91421 3.91738 3.92058 3.9238 3.92704 3.9303 3.93357 3.93686 3.94015 3.94344 3.94674 3.95002 3.95331 3.95657 3.95983 3.96306 3.96626 3.96944 3.97257 3.97569 3.97859 0.921567 1.63494 2.62374 3.27799 3.62928 3.8127 3.91021 3.96269 3.99047 4.00408 4.00927 4.00936 4.0063 4.0013 3.99516 3.98835 3.98121 3.97396 3.96674 3.95965 3.95276 3.9461 3.93971 3.9336 3.92777 3.92222 3.91696 3.91199 3.90728 3.90284 3.89866 3.89473 3.89103 3.88757 3.88433 3.8813 3.87847 3.87584 3.8734 3.87115 3.86907 3.86715 3.86541 3.86382 3.86238 3.86109 3.85994 3.85894 3.85807 3.85733 3.85672 3.85623 3.85586 3.85561 3.85547 3.85544 3.85551 3.8557 3.85598 3.85636 3.85684 3.85741 3.85807 3.85882 3.85965 3.86057 3.86157 3.86265 3.86381 3.86504 3.86635 3.86772 3.86917 3.87068 3.87227 3.87392 3.87563 3.87741 3.87925 3.88116 3.88313 3.88515 3.88724 3.88938 3.89157 3.89383 3.89613 3.89849 3.90091 3.90337 3.90588 3.90844 3.91105 3.91371 3.9164 3.91914 3.92193 3.92475 3.92761 3.93051 3.93344 3.9364 3.93939 3.94241 3.94545 3.94852 3.95161 3.95471 3.95782 3.96094 3.96407 3.96721 3.97034 3.97346 3.97657 3.97968 3.98276 3.98582 3.98886 3.99186 3.99484 3.99762 1.04783 2.14113 3.16618 3.70126 3.94668 4.05816 4.10789 4.12764 4.13203 4.12829 4.12018 4.10978 4.09826 4.08632 4.07436 4.06263 4.05126 4.04035 4.02993 4.02002 4.01062 4.00173 3.99332 3.98539 3.97791 3.97086 3.96422 3.95798 3.95211 3.94659 3.94141 3.93654 3.93198 3.92771 3.92371 3.91997 3.91648 3.91322 3.91019 3.90737 3.90476 3.90234 3.90012 3.89807 3.8962 3.8945 3.89296 3.89158 3.89035 3.88926 3.88832 3.88751 3.88683 3.88628 3.88585 3.88555 3.88536 3.88528 3.8853 3.88544 3.88567 3.88601 3.88644 3.88697 3.88758 3.88829 3.88908 3.88995 3.8909 3.89193 3.89304 3.89422 3.89547 3.8968 3.89819 3.89966 3.90119 3.90278 3.90445 3.90617 3.90796 3.9098 3.91171 3.91368 3.9157 3.91777 3.9199 3.92209 3.92433 3.92661 3.92895 3.93134 3.93377 3.93625 3.93877 3.94134 3.94395 3.94659 3.94928 3.952 3.95476 3.95755 3.96036 3.96321 3.96608 3.96898 3.97189 3.97483 3.97777 3.98073 3.98369 3.98666 3.98963 3.9926 3.99556 3.99851 4.00144 4.00436 4.00725 4.01011 4.01296 4.0156 1.27351 2.71741 3.66587 4.05945 4.20804 4.25954 4.27093 4.26479 4.2508 4.23342 4.21483 4.19615 4.17794 4.16048 4.14389 4.12823 4.11348 4.09963 4.08664 4.07446 4.06303 4.05233 4.04229 4.03289 4.02406 4.01579 4.00804 4.00076 3.99394 3.98754 3.98155 3.97592 3.97066 3.96572 3.9611 3.95678 3.95274 3.94896 3.94544 3.94217 3.93912 3.93629 3.93367 3.93125 3.92902 3.92698 3.92512 3.92342 3.92189 3.92052 3.91929 3.91822 3.91728 3.91648 3.91582 3.91527 3.91486 3.91455 3.91437 3.91429 3.91432 3.91446 3.91469 3.91502 3.91545 3.91597 3.91658 3.91727 3.91804 3.9189 3.91983 3.92084 3.92192 3.92308 3.92431 3.9256 3.92697 3.9284 3.9299 3.93146 3.93309 3.93477 3.93652 3.93832 3.94018 3.94209 3.94406 3.94609 3.94816 3.95028 3.95246 3.95468 3.95695 3.95926 3.96162 3.96402 3.96646 3.96895 3.97146 3.97402 3.97661 3.97923 3.98188 3.98456 3.98727 3.99 3.99275 3.99552 3.9983 4.00109 4.0039 4.0067 4.00951 4.01232 4.01513 4.01792 4.02071 4.02347 4.02622 4.02894 4.03164 4.03416 1.62357 3.31924 4.10848 4.35964 4.4251 4.42809 4.40914 4.38265 4.35419 4.32605 4.29917 4.27392 4.25037 4.22848 4.20818 4.18935 4.17187 4.15565 4.14056 4.12653 4.11346 4.10127 4.08991 4.07929 4.06937 4.0601 4.05142 4.0433 4.03569 4.02857 4.0219 4.01565 4.00979 4.00431 3.99918 3.99437 3.98988 3.98568 3.98175 3.97809 3.97468 3.97151 3.96856 3.96583 3.96331 3.96098 3.95885 3.95689 3.95511 3.95349 3.95204 3.95074 3.94959 3.94858 3.94771 3.94697 3.94636 3.94587 3.9455 3.94524 3.9451 3.94506 3.94513 3.94529 3.94556 3.94591 3.94636 3.9469 3.94752 3.94822 3.949 3.94985 3.95079 3.9518 3.95288 3.95403 3.95525 3.95654 3.95789 3.9593 3.96078 3.96232 3.96392 3.96557 3.96728 3.96905 3.97087 3.97275 3.97467 3.97664 3.97867 3.98074 3.98286 3.98502 3.98722 3.98947 3.99175 3.99408 3.99644 3.99884 4.00127 4.00374 4.00623 4.00875 4.0113 4.01387 4.01646 4.01907 4.0217 4.02433 4.02698 4.02963 4.03229 4.03495 4.0376 4.04024 4.04288 4.0455 4.04811 4.05069 4.05324 4.05564 2.11223 3.91483 4.49453 4.61442 4.61117 4.57553 4.53268 4.49014 4.45023 4.41353 4.38001 4.34947 4.32159 4.29612 4.27279 4.25136 4.23164 4.21346 4.19665 4.18108 4.16664 4.15323 4.14075 4.12912 4.11828 4.10817 4.09871 4.08988 4.08162 4.07388 4.06664 4.05987 4.05352 4.04757 4.04201 4.03679 4.03192 4.02735 4.02309 4.0191 4.01539 4.01192 4.0087 4.00571 4.00293 4.00037 3.998 3.99582 3.99383 3.99201 3.99036 3.98887 3.98754 3.98635 3.9853 3.9844 3.98362 3.98297 3.98245 3.98204 3.98174 3.98156 3.98148 3.9815 3.98162 3.98184 3.98215 3.98255 3.98303 3.9836 3.98425 3.98498 3.98578 3.98666 3.98761 3.98863 3.98972 3.99088 3.9921 3.99339 3.99474 3.99615 3.99762 3.99914 4.00072 4.00236 4.00404 4.00578 4.00758 4.00941 4.0113 4.01324 4.01521 4.01724 4.0193 4.02141 4.02355 4.02574 4.02796 4.03021 4.0325 4.03482 4.03717 4.03954 4.04194 4.04437 4.04681 4.04927 4.05175 4.05424 4.05674 4.05925 4.06176 4.06427 4.06678 4.06928 4.07178 4.07426 4.07673 4.07917 4.08159 4.08388 2.75671 4.49025 4.83644 4.84145 4.78254 4.71626 4.65444 4.59908 4.54993 4.50626 4.4673 4.43237 4.40091 4.37243 4.34654 4.32292 4.30129 4.28143 4.26313 4.24625 4.23063 4.21615 4.2027 4.1902 4.17855 4.1677 4.15757 4.14811 4.13927 4.131 4.12326 4.11602 4.10923 4.10288 4.09693 4.09136 4.08614 4.08126 4.07669 4.07243 4.06844 4.06472 4.06126 4.05803 4.05504 4.05226 4.04969 4.04732 4.04515 4.04315 4.04133 4.03967 4.03818 4.03684 4.03564 4.03459 4.03367 4.03288 4.03222 4.03168 4.03126 4.03094 4.03074 4.03064 4.03064 4.03074 4.03094 4.03122 4.03159 4.03204 4.03257 4.03319 4.03388 4.03465 4.03549 4.0364 4.03738 4.03843 4.03955 4.04072 4.04196 4.04326 4.04461 4.04603 4.0475 4.04902 4.05059 4.05222 4.05389 4.05562 4.05739 4.0592 4.06107 4.06297 4.06491 4.0669 4.06892 4.07098 4.07308 4.07521 4.07737 4.07956 4.08178 4.08403 4.0863 4.08859 4.09091 4.09324 4.09559 4.09795 4.10032 4.1027 4.10508 4.10746 4.10984 4.11222 4.11459 4.11695 4.11929 4.12161 4.12391 4.12609 3.60496 5.05607 5.16201 5.06896 4.96489 4.87383 4.79645 4.7304 4.67342 4.62376 4.58005 4.54126 4.50659 4.4754 4.44719 4.42155 4.39816 4.37674 4.35706 4.33894 4.3222 4.3067 4.29233 4.27899 4.26658 4.25501 4.24423 4.23416 4.22476 4.21597 4.20774 4.20004 4.19284 4.18609 4.17976 4.17384 4.1683 4.16311 4.15825 4.1537 4.14946 4.14549 4.14179 4.13835 4.13514 4.13217 4.12941 4.12686 4.12451 4.12235 4.12036 4.11856 4.11691 4.11543 4.1141 4.11291 4.11187 4.11096 4.11018 4.10952 4.10898 4.10856 4.10825 4.10804 4.10794 4.10794 4.10803 4.10822 4.10849 4.10885 4.10929 4.10982 4.11042 4.1111 4.11185 4.11268 4.11357 4.11453 4.11556 4.11665 4.1178 4.11901 4.12028 4.12161 4.12299 4.12442 4.12591 4.12745 4.12904 4.13067 4.13235 4.13408 4.13585 4.13766 4.13951 4.1414 4.14333 4.1453 4.1473 4.14933 4.1514 4.15349 4.15562 4.15776 4.15994 4.16213 4.16435 4.16658 4.16883 4.17109 4.17335 4.17563 4.17791 4.18019 4.18248 4.18475 4.18702 4.18928 4.19153 4.19376 4.19594 4.19806 4.84955 5.68154 5.54072 5.36077 5.21733 5.1041 5.01232 4.93602 4.87132 4.8156 4.76698 4.72412 4.686 4.65185 4.62107 4.59318 4.5678 4.5446 4.52332 4.50375 4.48569 4.46901 4.45355 4.4392 4.42586 4.41344 4.40187 4.39107 4.38098 4.37155 4.36274 4.35449 4.34676 4.33952 4.33275 4.3264 4.32046 4.31489 4.30968 4.3048 4.30024 4.29598 4.292 4.28829 4.28484 4.28163 4.27865 4.27589 4.27334 4.27099 4.26883 4.26685 4.26505 4.26342 4.26194 4.26062 4.25944 4.2584 4.2575 4.25673 4.25609 4.25556 4.25515 4.25485 4.25466 4.25457 4.25458 4.25468 4.25488 4.25516 4.25554 4.25599 4.25653 4.25715 4.25784 4.2586 4.25944 4.26034 4.26132 4.26235 4.26345 4.26462 4.26584 4.26711 4.26845 4.26984 4.27128 4.27277 4.27431 4.2759 4.27754 4.27922 4.28095 4.28271 4.28452 4.28637 4.28826 4.29018 4.29214 4.29413 4.29615 4.2982 4.30028 4.30239 4.30451 4.30666 4.30883 4.31102 4.31322 4.31544 4.31766 4.3199 4.32213 4.32437 4.32661 4.32884 4.33107 4.33328 4.33548 4.33767 4.3398 4.3419 6.07794 5.55972 5.2474 5.04169 4.89423 4.78182 4.69214 4.61828 4.55605 4.50269 4.45629 4.41549 4.37928 4.3469 4.31775 4.29137 4.26737 4.24546 4.22539 4.20693 4.18991 4.17419 4.15963 4.14612 4.13357 4.12188 4.11099 4.10084 4.09135 4.08248 4.07419 4.06643 4.05917 4.05236 4.04599 4.04002 4.03443 4.02919 4.02429 4.0197 4.01541 4.0114 4.00765 4.00416 4.00091 3.99788 3.99507 3.99246 3.99006 3.98783 3.98579 3.98391 3.9822 3.98065 3.97924 3.97798 3.97685 3.97585 3.97498 3.97423 3.9736 3.97307 3.97266 3.97235 3.97213 3.97202 3.97199 3.97205 3.9722 3.97244 3.97275 3.97314 3.9736 3.97414 3.97475 3.97542 3.97617 3.97697 3.97784 3.97876 3.97975 3.98079 3.98188 3.98303 3.98423 3.98548 3.98678 3.98812 3.98951 3.99095 3.99242 3.99394 3.9955 3.9971 3.99873 4.0004 4.00211 4.00385 4.00561 4.00741 4.00924 4.0111 4.01298 4.01488 4.01681 4.01875 4.02072 4.0227 4.02469 4.02669 4.02871 4.03073 4.03275 4.03478 4.0368 4.03882 4.04083 4.04284 4.04483 4.04681 4.04872 4.05065 ) ; boundaryField { lowerWall { type kqRWallFunction; value nonuniform List<scalar> 122 ( 6.07652 5.55942 5.24732 5.04165 4.8942 4.78178 4.69211 4.61825 4.55602 4.50265 4.45625 4.41545 4.37924 4.34686 4.31771 4.29132 4.26733 4.24542 4.22534 4.20689 4.18987 4.17415 4.15959 4.14608 4.13352 4.12184 4.11095 4.10079 4.0913 4.08244 4.07414 4.06638 4.05912 4.05231 4.04594 4.03997 4.03438 4.02914 4.02423 4.01964 4.01535 4.01134 4.00759 4.0041 4.00084 3.99782 3.995 3.9924 3.98999 3.98776 3.98571 3.98384 3.98212 3.98056 3.97915 3.97789 3.97675 3.97575 3.97488 3.97412 3.97348 3.97296 3.97253 3.97222 3.972 3.97187 3.97184 3.9719 3.97204 3.97226 3.97257 3.97295 3.97341 3.97393 3.97453 3.9752 3.97593 3.97672 3.97758 3.97849 3.97946 3.98049 3.98157 3.98271 3.98389 3.98513 3.98641 3.98774 3.98912 3.99054 3.992 3.9935 3.99505 3.99663 3.99824 3.9999 4.00159 4.00331 4.00506 4.00684 4.00865 4.01049 4.01235 4.01423 4.01614 4.01807 4.02001 4.02197 4.02394 4.02593 4.02792 4.02992 4.03192 4.03393 4.03593 4.03793 4.03993 4.04191 4.04388 4.04584 4.04773 4.04965 ) ; } upperWall { type kqRWallFunction; value nonuniform List<scalar> 122 ( 6.07794 5.55972 5.2474 5.04169 4.89423 4.78182 4.69214 4.61828 4.55605 4.50269 4.45629 4.41549 4.37928 4.3469 4.31775 4.29137 4.26737 4.24546 4.22539 4.20693 4.18991 4.17419 4.15963 4.14612 4.13357 4.12188 4.11099 4.10084 4.09135 4.08248 4.07419 4.06643 4.05917 4.05236 4.04599 4.04002 4.03443 4.02919 4.02429 4.0197 4.01541 4.0114 4.00765 4.00416 4.00091 3.99788 3.99507 3.99246 3.99006 3.98783 3.98579 3.98391 3.9822 3.98065 3.97924 3.97798 3.97685 3.97585 3.97498 3.97423 3.9736 3.97307 3.97266 3.97235 3.97213 3.97202 3.97199 3.97205 3.9722 3.97244 3.97275 3.97314 3.9736 3.97414 3.97475 3.97542 3.97617 3.97697 3.97784 3.97876 3.97975 3.98079 3.98188 3.98303 3.98423 3.98548 3.98678 3.98812 3.98951 3.99095 3.99242 3.99394 3.9955 3.9971 3.99873 4.0004 4.00211 4.00385 4.00561 4.00741 4.00924 4.0111 4.01298 4.01488 4.01681 4.01875 4.02072 4.0227 4.02469 4.02669 4.02871 4.03073 4.03275 4.03478 4.0368 4.03882 4.04083 4.04284 4.04483 4.04681 4.04872 4.05065 ) ; } inlet { type turbulentIntensityKineticEnergyInlet; intensity 0.0223; value uniform 0.91377; } outlet { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
ea91f78c0bc671b93a0c02da519ede52acb7ac3c
4584c47495d5c8928a36dc70a2a23adbbcc16bf0
/LGP1337.cpp
76fbc30e58da62edee9141eb82c613f1fa0fd871
[ "MIT" ]
permissive
Origami404/OI_Code
d59108d4be8cf02e288992e56f1a502deb6d2b42
9638ec6fa409dc8e243eaef9aa287c20c332bbe5
refs/heads/master
2020-06-29T09:04:48.931194
2019-08-04T13:26:14
2019-08-04T13:26:14
200,494,467
0
0
null
null
null
null
UTF-8
C++
false
false
1,115
cpp
LGP1337.cpp
#include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #define MAXN 1007 using namespace std; int hx[MAXN], hy[MAXN], w[MAXN], n; double drand() { return (rand()*2 - RAND_MAX); } double stat(double x, double y) { double E = 0.0; for (int i = 1; i <= n; i++) { double dx = x - hx[i], dy = y - hy[i]; E += w[i] * sqrt(dx * dx + dy * dy); } return E; } double ax = 0, ay = 0; void sa() { for (int i = 1; i <= n; i++) (ax += hx[i]), (ay += hy[i]); (ax /= n), (ay /= n); double t = 1000; double nowE = stat(ax, ay), nextE; while (t > 1e-15) { double dx = drand() * t, dy = drand() * t; nextE = stat(ax + dx, ay + dy); if (nextE < nowE || exp((nowE-nextE)/t) * RAND_MAX > rand()) { (ax += dx), (ay += dy); nowE = nextE; } t *= 0.999; } } int main() { srand(time(NULL)); scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d %d %d", hx + i, hy + i, w + i); sa(); printf("%.3f %.3f", ax, ay); return 0; }
09652083693775c9b9990c159b51ef2733bb750b
6e3b59d15607630869f518aee24c762d5dd71d06
/CODES/D_Zero_Quantity_Maximization.cpp
99c6c5dc1c332cd022252b664d4bc2db261f3b9a
[]
no_license
Aman-droid/CP_Essentials
c74ffce2c4acc9fa6b0ebc409f9f6e9640f92c91
40758de037a4b380bd7d921cd3cd7c4f8fc86be1
refs/heads/master
2023-06-05T13:56:29.053495
2021-06-29T18:13:14
2021-06-29T18:13:14
381,141,371
1
0
null
null
null
null
UTF-8
C++
false
false
1,281
cpp
D_Zero_Quantity_Maximization.cpp
#include<bits/stdc++.h> #define ll long long #define endl '\n' #define vll vector< ll > #define rep(i,a,b) for(ll i=a;i<=b;i++) #define pii pair<ll,ll> #define SZ(x) ((ll)x.size()) #define FIO ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define watch(x) cout << (#x) << " is " << (x) << "\n" #define pb push_back #define pf push_front #define ff first #define ss second #define mod 1000000007 using namespace std; ll power(ll a, ll b){//a^b ll res=1; a=a%mod; while(b>0){ if(b&1){res=(res*a)%mod;b--;} a=(a*a)%mod; b>>=1; } return res; } ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);} //--------------------------------------------------------------------------------------------------------// const ll mxn = 3e5; map<pii, ll> mp; ll a[mxn],b[mxn]; ll n; void upt(pii & a) { if(a.ff<0){ a.ff *=-1; a.ss *=-1; } else if(a.ff==0 && a.ss<0) a.ss*=-1; ll tmp= gcd(abs(a.ff),abs(a.ss)); a.ff/=tmp; a.ss/=tmp; } int main() { FIO; cin>>n; rep(i,0,n-1)cin>>a[i]; rep(i,0,n-1)cin>>b[i]; ll ans = 0; ll cnt = 0; rep(i,0,n-1){ if(a[i] == 0){ if(b[i] == 0) cnt++; } else{ pii p ={-b[i], a[i]}; upt(p); mp[p]++; ans = max(ans, mp[p]); } } cout <<cnt+ans << endl; }
b42b6c66fd9bc303b327888487ae011516253938
7e4e6e1e6066cabb7aebf6a90ce35a443e23c3dc
/notepad/Notepad.cpp
3f2ce70468323707f3f3e4994d2bd438bdc8efa8
[]
no_license
mlisgood/Start
958e68b3c5efef6f1d197a756ed7779e127049bf
66189fdb60f7e3d1fce309e879d722c8d44362e5
refs/heads/master
2020-06-29T16:37:52.485329
2019-08-05T03:26:57
2019-08-05T03:26:57
199,648,866
0
0
null
null
null
null
GB18030
C++
false
false
69,612
cpp
Notepad.cpp
#include "define.h" namespace rem { //全局变量定义 extern int find_dialog_mutex = 1;//只允许创建1个查找窗口。注意使用全局变量时,不管是声明还是定义都不需要在头文件中,并且需要用extern。全局变量只能定义1次,也就是赋初值1次,但需要用到其的文件中均需声明。 //使用标准命名空间 using std::string; using std::ifstream; using std::ofstream; using std::fstream; using std::ios_base; //构造与析构函数 Notepad::Notepad(QWidget *parent) : QMainWindow(parent) { //常规初始化 //以下功能用到了常量,如要修改最好重写 randnumber = WINDOW_RANDOM_MIN_NUMBER + rand() % (WINDOW_RANDOM_MAX_NUMBER - WINDOW_RANDOM_MIN_NUMBER + 1);//产生指定随机数。仅在构造函数中使用一次,以保证不会出现隐藏并打开窗口后背景因为重新绘图发生变化的问题 setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);//去掉窗口标题栏并且窗口可以通过点击任务栏放大缩小 resize(WINDOW_SIZE_WIDTH_NUMBER, WINDOW_SIZE_HEIGHT_NUMBER);//将窗口强制改为此大小 setFixedSize(this->width(), this->height());//禁止改变窗口大小 setAttribute(Qt::WA_QuitOnClose, true);//该窗口为主窗口,关闭时直接退出程序 hex_status = WINDOW_TOOL_TOHEX_STATUS_NO_FLAG;//默认不是十六进制模式 if (randnumber >= 1 && randnumber <= 5)//决定人物图像以及相关文字颜色 { chara_randnumber = 1 + rand() % (5 - 1 + 1); font_randnumber = 1; } else if (randnumber >= 6 && randnumber <= 10) { chara_randnumber = 6 + rand() % (10 - 6 + 1); font_randnumber = 2; } else if (randnumber >= 11 && randnumber <= 15) { chara_randnumber = 11 + rand() % (15 - 11 + 1); font_randnumber = 3; } else if (randnumber >= 16 && randnumber <= 20) { chara_randnumber = 16 + rand() % (20 - 16 + 1); font_randnumber = 4; } else if (randnumber >= 21 && randnumber <= 25) { chara_randnumber = 21 + rand() % (25 - 21 + 1); font_randnumber = 5; } else { } //初始化计时器 chara_picture_timer = new QTimer(this);//创建一个定时器 chara_picture_timer->setTimerType(Qt::PreciseTimer);//修改精度 connect(chara_picture_timer, SIGNAL(timeout()), this, SLOT(timer_chara_picture_timeout()));//计时器到期处理 timer_interval_number = WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + rand() % (WINDOW_RANDOM_TIMER_CHARA_NORMAL_MAX_NUMBER - WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + 1);//初始化计时间隔,取值在之前选取的区间当中 timer_chara_status = WINDOW_CHARA_NORMAL_FLAG;//初始化状态为常规状态 timer_chara_status_address = &timer_chara_status;//设置计时器状态地址 chara_picture_timer->start(timer_interval_number);//初始化计时器 //初始化人物图像 //以下功能用到了常量,如要修改最好重写 chara_path_normal = WINDOW_CHARA_PICTURE_PATH_FRONT_STRING;//人物形象常规状态 chara_path_normal += QString::number(chara_randnumber, 10);//将随机数转化为路径中的一部分 chara_path_normal += WINDOW_CHARA_PICTURE_PATH_BREAK_STRING; chara_path_close_eye = chara_path_normal;//需要切换的图片(人物眼睛闭上的状态)前半部分路径和常规状态的一样 chara_path_normal += tr("01"); chara_path_close_eye += tr("02"); chara_path_normal += WINDOW_CHARA_PICTURE_PATH_BACK_STRING; chara_path_close_eye += WINDOW_CHARA_PICTURE_PATH_BACK_STRING; chara_picture_label = new QLabel(this);//人物形象必须比左侧边界先绘制,否则其会覆盖左侧边界 margin_picture_label = new QLabel(this); chara_picture_label->setGeometry(0, 0, WINDOW_SIZE_PICTURE_CHARA_WIDTH_NUMBER, WINDOW_SIZE_PICTURE_CHARA_HEIGHT_NUMBER);//设置label的边界 margin_picture_label->setGeometry(0, 0, WINDOW_SIZE_MARGIN_PICTURE_LEFT_WIDTH_NUMBER, WINDOW_SIZE_MARGIN_PICTURE_LEFT_HEIGHT_NUMBER); chara_picture.load(chara_path_normal);//加载人物图片,采用先加载,之后每次使用而不重新加载的方法以提高效率 chara_picture_extra.load(chara_path_close_eye);//加载人物特殊状态图片 if (timer_chara_status == WINDOW_CHARA_NORMAL_FLAG)//通过人物状态的判断来映射到指定图片上面 { chara_picture_label->setPixmap(chara_picture); } else if (timer_chara_status == WINDOW_CHARA_SPECIAL_FLAG) { chara_picture_label->setPixmap(chara_picture_extra); } else { chara_picture_label->setPixmap(chara_picture); } margin_picture.load((QString)WINDOW_MARGIN_PICTURE_LEFT_PATH_STRING); margin_picture_label->setPixmap(margin_picture);//左侧边界 //加载界面,必须放在最后以避免界面被之后的绘图覆盖 ui.setupUi(this); //去除文本框背景。鉴于直接设置会导致文字超过一页出现滚动条后,背景跟随滚动条滚动成为平铺样式,故去掉文本框背景和边界,改为绘制背景 ui.textEdit_main->setStyleSheet("background-color: rgb(255, 255, 255, 0);border:0px solid #e1e0e0;"); //功能实现 connect(ui.textEdit_main, SIGNAL(cursorPositionChanged()), this, SLOT(text_line_and_col()));//文本框鼠标行数和列数的获取 connect(ui.textEdit_main, SIGNAL(textChanged()), this, SLOT(set_not_save_status()));//设置未保存标记 connect(ui.pushButton_close_windows, SIGNAL(clicked()), this, SLOT(close_dialog()));//关闭窗口按钮 connect(ui.pushButton_tool_06, SIGNAL(clicked()), this, SLOT(textedit_copy()));//复制 connect(ui.pushButton_tool_07, SIGNAL(clicked()), this, SLOT(textedit_paste()));//粘贴 connect(ui.pushButton_tool_08, SIGNAL(clicked()), this, SLOT(textedit_cut()));//剪切 connect(ui.pushButton_tool_09, SIGNAL(clicked()), this, SLOT(textedit_undo()));//撤销 connect(ui.pushButton_tool_10, SIGNAL(clicked()), this, SLOT(textedit_redo()));//重做 connect(ui.pushButton_tool_13, SIGNAL(clicked()), this, SLOT(textedit_font()));//字体 connect(ui.pushButton_tool_14, SIGNAL(clicked()), this, SLOT(textedit_color()));//颜色 connect(ui.pushButton_tool_18, SIGNAL(clicked()), this, SLOT(textedit_help()));//程序信息 connect(ui.pushButton_tool_01, SIGNAL(clicked()), this, SLOT(textedit_new()));//新建 connect(ui.pushButton_tool_02, SIGNAL(clicked()), this, SLOT(textedit_open()));//打开 connect(ui.pushButton_tool_03, SIGNAL(clicked()), this, SLOT(textedit_save()));//保存 connect(ui.pushButton_tool_04, SIGNAL(clicked()), this, SLOT(textedit_saveas()));//另存为 connect(ui.pushButton_tool_11, SIGNAL(clicked()), this, SLOT(textedit_find()));//查找 connect(ui.pushButton_tool_12, SIGNAL(clicked()), this, SLOT(textedit_replace()));//替换 connect(ui.pushButton_tool_05, SIGNAL(clicked()), this, SLOT(textedit_tohex()));//十六进制转换 connect(ui.pushButton_tool_15, SIGNAL(clicked()), this, SLOT(textedit_code()));//编码转换 connect(ui.pushButton_tool_16, SIGNAL(clicked()), this, SLOT(textedit_print()));//打印 connect(ui.pushButton_tool_17, SIGNAL(clicked()), this, SLOT(textedit_setting()));//设置 //初始化显示 ui.label_filestatus->setText(tr("行:1 列:0"));//行列数显示 ui.label_filename->setText(tr("未命名"));//文件名显示 ui.label_savestatus->setText(tr("已保存"));//保存状态显示 QPalette label_palette; QPalette text_palette; if (randnumber >= 1 && randnumber <= 5)//决定人物图像以及相关文字颜色,label使用WindowText,其余的使用Text,文本编辑还需要使用Highlight { label_palette.setColor(QPalette::WindowText, QColor(255, 83, 185, 255)); label_palette.setColor(QPalette::HighlightedText, QColor(255, 83, 185, 255)); label_palette.setColor(QPalette::Highlight, QColor(255, 83, 185, 64)); ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #FF53B9;background-color: #00FFFFFF;text-align:center;color:#FF53B9;}QProgressBar::chunk{background-color:#FF53B9;}"); } else if (randnumber >= 6 && randnumber <= 10) { label_palette.setColor(QPalette::WindowText, QColor(133, 153, 212, 255)); label_palette.setColor(QPalette::HighlightedText, QColor(133, 153, 212, 255)); label_palette.setColor(QPalette::Highlight, QColor(133, 153, 212, 64)); ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #8599D4;background-color: #00FFFFFF;text-align:center;color:#8599D4;}QProgressBar::chunk{background-color:#8599D4;}"); } else if (randnumber >= 11 && randnumber <= 15) { label_palette.setColor(QPalette::WindowText, QColor(222, 63, 235, 255)); label_palette.setColor(QPalette::HighlightedText, QColor(222, 63, 235, 255)); label_palette.setColor(QPalette::Highlight, QColor(222, 63, 235, 64)); ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #DE3FEB;background-color: #00FFFFFF;text-align:center;color:#DE3FEB;}QProgressBar::chunk{background-color:#DE3FEB;}"); } else if (randnumber >= 16 && randnumber <= 20) { label_palette.setColor(QPalette::WindowText, QColor(242, 153, 93, 255)); label_palette.setColor(QPalette::HighlightedText, QColor(242, 153, 93, 255)); label_palette.setColor(QPalette::Highlight, QColor(242, 153, 93, 64)); ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #F2995D;background-color: #00FFFFFF;text-align:center;color:#F2995D;}QProgressBar::chunk{background-color:#F2995D;}"); } else if (randnumber >= 21 && randnumber <= 25) { label_palette.setColor(QPalette::WindowText, QColor(71, 185, 78, 255)); label_palette.setColor(QPalette::HighlightedText, QColor(71, 185, 78, 255)); label_palette.setColor(QPalette::Highlight, QColor(71, 185, 78, 64)); ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #47B94E;background-color: #00FFFFFF;text-align:center;color:#47B94E;}QProgressBar::chunk{background-color:#47B94E;}"); } else { } ui.label_filename->setPalette(label_palette); ui.label_filestatus->setPalette(label_palette); ui.label_code->setPalette(label_palette); ui.label_savestatus->setPalette(label_palette); ui.label_file_read_advance->setPalette(label_palette); //进度条初始化 ui.progressBar->setVisible(false);//进度条初始不可见 ui.label_file_read_advance->setText(tr("正在获取文件信息……"));//进度条初始文本 ui.label_file_read_advance->setVisible(false);//进度提示初始不可见 progress_bar_change_color = false;//进度条字体未切换颜色 //初始化配置文件信息 setting_file_read(); //禁用富文本 ui.textEdit_main->setAcceptRichText(false); //去掉关联性控件的右键菜单 ui.textEdit_main->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); ui.textEdit_main->horizontalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); //拖拽事件初始化 ui.textEdit_main->setAcceptDrops(false);//禁用textEdit控件默认的放下操作 setAcceptDrops(true);//启用全局的放下操作 //窗口启动动画效果。窗口显示类,要先显示才能看到动画;反之,窗口关闭类,要先显示才能关闭,否则看不到动画 QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity"); animation->setDuration(WINDOW_ANIMATION_TIME_NUMBER); animation->setStartValue(WINDOW_ANIMATION_TRANSPRENT_DISAPPEAR_NUMBER); animation->setEndValue(WINDOW_ANIMATION_TRANSPRENT_NORMAL_NUMBER); animation->start(QAbstractAnimation::DeleteWhenStopped);//结束时释放内存 } Notepad::~Notepad() { delete chara_picture_timer; delete chara_picture_label; delete margin_picture_label; } //初始设置 void Notepad::setting_file_read()//设置文件读取 { setting_file_font_read();//字体 ifstream setting_file_color;//颜色 QString file_color_input = FILE_COLOR_OUTPUT_FILE_PATH_FRONT_STRING; file_color_input += QString::number(font_randnumber, 10); file_color_input += FILE_COLOR_OUTPUT_FILE_PATH_BACK_STRING; string file_color_input_final = string((const char *)file_color_input.toLocal8Bit()); setting_file_color.open(file_color_input_final, ios_base::in);//打开文件 if (!setting_file_color.is_open())//打开文件失败 { QPalette text_palette;//字体着色 text_palette.setColor(QPalette::Text, QColor(0, 0, 0, 255)); text_palette.setColor(QPalette::HighlightedText, QColor(0, 0, 0, 255)); text_palette.setColor(QPalette::Highlight, QColor(0, 0, 0, 64)); ui.textEdit_main->setPalette(text_palette); } else { int setting_color[3];//初始化设置 string temp;//临时存储读入的字符串 setting_file_color >> temp;//红 setting_color[0] = atoi(temp.c_str()); setting_file_color >> temp;//绿 setting_color[1] = atoi(temp.c_str()); setting_file_color >> temp;//蓝 setting_color[2] = atoi(temp.c_str()); QPalette text_palette;//字体着色 text_palette.setColor(QPalette::Text, QColor(setting_color[0], setting_color[1], setting_color[2], 255)); text_palette.setColor(QPalette::HighlightedText, QColor(setting_color[0], setting_color[1], setting_color[2], 255)); text_palette.setColor(QPalette::Highlight, QColor(setting_color[0], setting_color[1], setting_color[2], 64)); ui.textEdit_main->setPalette(text_palette); setting_file_color.close(); } ifstream setting_file_code;//编码 setting_file_code.open(FILE_CODE_OUTPUT_FILE_PATH_STRING, ios_base::in);//打开文件 if (!setting_file_code.is_open())//打开文件失败 { code_undefine = tr("UTF-8");//这里不能使用临时变量,否则等到该函数运行完毕,临时变量会被释放,指针会指向空地址,从而出错 } else { string information_code_temp; setting_file_code >> information_code_temp;//读取文件内容 code_undefine = QString(QString::fromLocal8Bit(information_code_temp.c_str())); setting_file_code.close(); } text_code = &code_undefine; ui.label_code->setText(*text_code); ifstream setting_text_file;//其他设置,因为此函数在构造函数里面,比右键菜单打开处理的函数set_args_string运行时间要早,故在此处读取文件 ifstream setting_binary_file; setting_text_file.open(FILE_SETTING_TEXT_OUTPUT_FILE_PATH_STRING, ios_base::in);//打开文件 setting_binary_file.open(FILE_SETTING_BINARY_OUTPUT_FILE_PATH_STRING, ios_base::in); if (!setting_text_file.is_open())//打开文件失败 { setting_text << tr("txt") << tr("ini") << tr("inf") << tr("bat") << tr("reg");//默认值 setting_binary << tr("exe") << tr("dll"); } else { string temp_string;//临时字符串 for (int maxsize = 0; maxsize < 100; maxsize++) { setting_text_file >> temp_string; if (temp_string != ""&&temp_string != FILE_SETTING_TEXT_AND_BINARY_END_WRITE_STRING)//读取的字符串不为空或结尾标志 { setting_text << QString(QString::fromLocal8Bit(temp_string.c_str())); } else { break; } } for (int maxsize = 0; maxsize < 100; maxsize++) { setting_binary_file >> temp_string; if (temp_string != ""&&temp_string != FILE_SETTING_TEXT_AND_BINARY_END_WRITE_STRING)//读取的字符串不为空或结尾标志 { setting_binary << QString(QString::fromLocal8Bit(temp_string.c_str())); } else { break; } } setting_text_file.close();//关闭文件 setting_binary_file.close(); } setting_text_address = &setting_text;//获得地址 setting_binary_address = &setting_binary; QSettings *setting_other_file = new QSettings(FILE_SETTING_OTHER_PATH_STRING, QSettings::IniFormat);//读取ini文件中的信息 setting_default_open_method = (setting_other_file->value(FILE_SETTING_CATALOG_1_INNER_PATH_STRING)).toString(); if (setting_default_open_method != tr("文本方式") && setting_default_open_method != tr("二进制方式")) { setting_default_open_method = tr("文本方式"); } else { } setting_default_open_method_address = &setting_default_open_method; setting_size[0] = (setting_other_file->value(FILE_SETTING_CATALOG_2_1_INNER_PATH_STRING)).toInt(); setting_size[1] = (setting_other_file->value(FILE_SETTING_CATALOG_2_2_INNER_PATH_STRING)).toInt(); if (setting_size[0]<DIALOG_SETTING_MIN_TEXT_SIZE_NUMBER || setting_size[0]>DIALOG_SETTING_MAX_TEXT_SIZE_NUMBER)//spinbox超出范围设定,即读取失败 { setting_size[0] = DIALOG_SETTING_MIN_TEXT_SIZE_NUMBER; } else { } if (setting_size[1]<DIALOG_SETTING_MIN_BINARY_SIZE_NUMBER || setting_size[1]>DIALOG_SETTING_MAX_BINARY_SIZE_NUMBER) { setting_size[0] = DIALOG_SETTING_MIN_BINARY_SIZE_NUMBER; } else { } setting_size_address[0] = &setting_size[0]; setting_size_address[1] = &setting_size[1]; setting_bool_value[0] = (setting_other_file->value(FILE_SETTING_CATALOG_3_1_INNER_PATH_STRING)).toBool();//读取失败时,会根据初始值进行强制转换,不是0就是1,因此不需要另行处理 setting_bool_value[1] = (setting_other_file->value(FILE_SETTING_CATALOG_3_2_INNER_PATH_STRING)).toBool(); setting_bool_value[2] = (setting_other_file->value(FILE_SETTING_CATALOG_3_3_INNER_PATH_STRING)).toBool(); setting_bool_value_address[0] = &setting_bool_value[0]; setting_bool_value_address[1] = &setting_bool_value[1]; setting_bool_value_address[2] = &setting_bool_value[2]; if (*setting_bool_value_address[0] == true) { ui.textEdit_main->setLineWrapMode(QTextEdit::WidgetWidth);//允许在窗口部件的当前宽度自动换行 } else { ui.textEdit_main->setLineWrapMode(QTextEdit::NoWrap);//禁止自动换行 } delete setting_other_file; QSettings *regedit_settings_1 = new QSettings(REG_MENU_1, QSettings::NativeFormat);//写入注册表 QSettings *regedit_settings_2 = new QSettings(REG_MENU_2, QSettings::NativeFormat); if (*setting_bool_value_address[1] == true)//是否关联右键菜单。这里用到了大量常量,如需修改,请修改此处 { QString reg_path = "\"" + QApplication::applicationFilePath();//获得绝对路径,注意applicationDirPath只获取路径,applicationFilePath还会包括程序文件名 reg_path += "\" \"%1\""; regedit_settings_1->setValue(".", reg_path.replace("/", "\\"));//写入注册表项,注意注册表使用的路径分隔符和QT输出的相反。默认值用一个点表示 regedit_settings_2->setValue(".", REG_MENU_NAME_PATH_STRING); reg_path = QApplication::applicationDirPath() + REG_MENU_ICON_PATH_STRING; regedit_settings_2->setValue(tr("icon"), reg_path.replace("/", "\\")); delete regedit_settings_1; delete regedit_settings_2; } else { regedit_settings_1->clear();//清除注册表项 regedit_settings_2->clear(); delete regedit_settings_1; delete regedit_settings_2; } } void Notepad::setting_file_font_read()//字体设置文件读取,因为字体文件在之后也会用到,因此单独做成一个函数 { ifstream setting_file; QString file_font_input = FILE_FONT_OUTPUT_FILE_PATH_FRONT_STRING; file_font_input += QString::number(font_randnumber, 10); if (hex_status == WINDOW_TOOL_TOHEX_STATUS_YES_FLAG)//二进制模式下需要读取另外的字体文件 { file_font_input += FILE_FONT_OUTPUT_FILE_PATH_BINARY_EXTRA_STRING; } else { } file_font_input += FILE_FONT_OUTPUT_FILE_PATH_BACK_STRING; string file_font_input_final = string((const char *)file_font_input.toLocal8Bit()); setting_file.open(file_font_input_final, ios_base::in);//打开文件 if (!setting_file.is_open())//打开文件失败 { ui.textEdit_main->setFont(QFont(tr("宋体"), 9, QFont::Normal, false)); } else//输入配置信息 { string information_font;//字体 string information_type;//类型 string information_size;//尺寸 string information_throw;//弃去不用的字符串 setting_file >> information_throw;//读取文件内容,用文件在输出时自带的空格符和回车符筛选各个字符串,然后弃掉不需要的 setting_file >> information_throw; setting_file.get();//这种方法能在空格字符处停下,但无法删除空格字符,如果没有这一步,下面的字符串开头会包含一个空格 getline(setting_file, information_font, '\n'); setting_file >> information_throw; setting_file >> information_throw; setting_file.get(); getline(setting_file, information_type, '\n'); setting_file >> information_throw; setting_file >> information_throw; setting_file.get(); getline(setting_file, information_size, '\n'); setting_file.close(); bool information_size_receive;//转换是否成功的返回值 int size_digit = QString(QString::fromLocal8Bit(information_size.c_str())).toInt(&information_size_receive);//转换尺寸为数值 QString type_transform = QString(QString::fromLocal8Bit(information_type.c_str()));//转化字符串格式 if (information_size_receive == false)//限定数字选择范围 { size_digit = 1; } else { if (size_digit < 1) { size_digit = 1; } else if (size_digit > 200) { size_digit = 200; } else { } } if (type_transform == tr("常规"))//设置字体 { ui.textEdit_main->setFont(QFont(QString(QString::fromLocal8Bit(information_font.c_str())), size_digit, QFont::Normal, false)); } else if (type_transform == tr("粗体")) { ui.textEdit_main->setFont(QFont(QString(QString::fromLocal8Bit(information_font.c_str())), size_digit, QFont::Bold, false)); } else if (type_transform == tr("倾斜")) { ui.textEdit_main->setFont(QFont(QString(QString::fromLocal8Bit(information_font.c_str())), size_digit, QFont::Normal, true)); } else if (type_transform == tr("粗体倾斜")) { ui.textEdit_main->setFont(QFont(QString(QString::fromLocal8Bit(information_font.c_str())), size_digit, QFont::Bold, true)); } else { ui.textEdit_main->setFont(QFont(QString(QString::fromLocal8Bit(information_font.c_str())), size_digit, QFont::Normal, false)); } setting_file.close(); } } //成员变量设置 void Notepad::set_args_string(string object_string)//获取通过右键菜单等方式打开程序时传入的目标文件路径 { args_string = object_string; //解析命令行 QString args_string_result;//最终参数 args_string_result = QString(QString::fromLocal8Bit(args_string.c_str()));//string转qstring if (!args_string_result.isEmpty())//读取文件 { QFileInfo args_file_info(args_string_result);//提取文件后缀以便于指定打开方式 QString file_suffix = args_file_info.suffix(); if ((*setting_text_address).contains(file_suffix))//文本方式 { hex_status = WINDOW_TOOL_TOHEX_STATUS_NO_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_1.png);");//改变按钮样式 } else if ((*setting_binary_address).contains(file_suffix)) { hex_status = WINDOW_TOOL_TOHEX_STATUS_YES_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_2.png);");//改变按钮样式 } else { if (*setting_default_open_method_address == tr("文本方式")) { hex_status = WINDOW_TOOL_TOHEX_STATUS_NO_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_1.png);");//改变按钮样式 } else if (*setting_default_open_method_address == tr("二进制方式")) { hex_status = WINDOW_TOOL_TOHEX_STATUS_YES_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_2.png);");//改变按钮样式 } else { hex_status = WINDOW_TOOL_TOHEX_STATUS_NO_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_1.png);");//改变按钮样式 } } file_load(args_string_result); } else { } } void Notepad::set_current_path(QString object_string)//设置文件打开或保存窗口使用的路径 { file_dialog_file_name = object_string; } //键盘事件,用于响应快捷键 void Notepad::keyPressEvent(QKeyEvent *event) { //ctrl和字母键的组合,先按下字母键再按下ctrl则无效 if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_N))//新建 { textedit_new(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_O))//打开 { textedit_open(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_S))//保存 { textedit_save(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_D))//另存为 { textedit_saveas(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_P))//打印 { textedit_print(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_B))//文本模式/二进制模式切换 { textedit_tohex(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_F))//查找 { textedit_find(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_H))//替换 { textedit_replace(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_T))//字体设置 { textedit_font(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_R))//颜色设置 { textedit_color(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_E))//编码设置 { textedit_code(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_G))//其他设置 { textedit_setting(); } else if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_I))//程序信息 { textedit_help(); } else { } } //以下为鼠标事件,可以实现去掉标题栏后窗口的移动 void Notepad::mousePressEvent(QMouseEvent *event)//当鼠标左键被按下时,设置相应变量为true,并得到当前点坐标 { if (event->button() == Qt::LeftButton) { m_bPressed = true; m_point = event->pos(); } else { } } void Notepad::mouseMoveEvent(QMouseEvent *event)//若鼠标左键被按下,则移动窗体位置 { if (m_bPressed) { move(event->pos() - m_point + pos()); } else { } } void Notepad::mouseReleaseEvent(QMouseEvent *event)//鼠标未被按下,则相应变量为false { Q_UNUSED(event); m_bPressed = false; } //拖拽事件 void Notepad::dragEnterEvent(QDragEnterEvent *e) { if (e->mimeData()->hasUrls())//防止出现拖拽文本框中的文字造成Url识别出错,然后程序崩溃 { e->acceptProposedAction(); //可以在这个窗口部件上拖放对象 } else { } } void Notepad::dropEvent(QDropEvent *e)//释放时执行的操作 { QList<QUrl> urls = e->mimeData()->urls(); QString file_name = urls.first().toLocalFile();//获得文件名 file_dialog_file_name = file_name;//传入工作路径便于后续打开或保存文件窗口展开路径初始化 file_dialog_file_name_address = &file_dialog_file_name;//传入工作路径便于后续打开或保存文件窗口显示路径初始化。不能使用file_name,因为其为临时变量 file_name = (file_name).replace(tr("/"), tr("\\"));//替换路径中的指定字符 file_load(file_name);//加载文件 } void Notepad::paintEvent(QPaintEvent *)//绘制事件 { //绘制窗口背景。具体方法:首先指派5种背景风格。之后从5组随机数中选取一个,映射到其中一种风格上面。以下是对应的映射关系:[1,5]->ココア,[6,10]->チノ,[11,15]->リゼ,[16,20]->シャロ,[21,25]->千夜。此外,之后的其他图片也和构建背景使用的随机数有关。 QString backrandnumber;//决定背景图片的参数 //以下功能用到了常量,如要修改最好重写 if (randnumber >= 1 && randnumber <= 5) { backrandnumber = "1"; } else if (randnumber >= 6 && randnumber <= 10) { backrandnumber = "2"; } else if (randnumber >= 11 && randnumber <= 15) { backrandnumber = "3"; } else if (randnumber >= 16 && randnumber <= 20) { backrandnumber = "4"; } else if (randnumber >= 21 && randnumber <= 25) { backrandnumber = "5"; } else { } //绘制背景,文本框背景及右边边界 QString filepath;//背景图片路径 QString texteditbackground;//文本框背景图片路径 filepath = WINDOW_BACKGROUND_PICTURE_PATH_FRONT_STRING + backrandnumber; filepath += WINDOW_BACKGROUND_PICTURE_PATH_BACK_STRING; texteditbackground = WINDOW_TEXTEDIT_BACKGROUND_PICTURE_PATH_STRING + backrandnumber; texteditbackground += WINDOW_TEXTEDIT_BACKGROUND_PICTURE_PATH_BACK_STRING; QPainter background_painter(this); QPainter margin_right_painter(this); QPainter textedit_painter(this); QPixmap background_picture; QPixmap margin_right_picture; QPixmap textedit_picture; background_picture.load(filepath); margin_right_picture.load((QString)WINDOW_MARGIN_PICTURE_RIGHT_PATH_STRING); textedit_picture.load(texteditbackground); background_painter.drawPixmap(0, 0, WINDOW_SIZE_WIDTH_NUMBER, WINDOW_SIZE_HEIGHT_NUMBER, background_picture); margin_right_painter.drawPixmap(WINDOW_SIZE_MARGIN_PICTURE_LEFT_WIDTH_NUMBER, 0, WINDOW_SIZE_MARGIN_PICTURE_RIGHT_WIDTH_NUMBER, WINDOW_SIZE_MARGIN_PICTURE_LEFT_HEIGHT_NUMBER, margin_right_picture);//从左边图片边界末尾的位置画右边边界,因为需要使用UI控件,因此右边部分只能画一次,否则会造成控件失效 textedit_painter.drawPixmap(WINDOW_TEXTEDIT_X_OFFSET_NUMBER, WINDOW_TEXTEDIT_Y_OFFSET_NUMBER, WINDOW_TEXTEDIT_SIZE_WIDTH_NUMBER, WINDOW_TEXTEDIT_SIZE_HEIGHT_NUMBER, textedit_picture); } //定时器到期处理函数 void Notepad::timer_chara_picture_timeout() { chara_picture_timer->stop(); if (timer_chara_status == WINDOW_CHARA_NORMAL_FLAG) { timer_chara_status = WINDOW_CHARA_SPECIAL_FLAG; } else if (timer_chara_status == WINDOW_CHARA_SPECIAL_FLAG) { timer_chara_status = WINDOW_CHARA_NORMAL_FLAG; } //绘制人物图像和左侧边界 if (timer_chara_status == WINDOW_CHARA_NORMAL_FLAG)//通过人物状态的判断来映射到指定图片上面 { chara_picture_label->setPixmap(chara_picture); timer_interval_number = WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + rand() % (WINDOW_RANDOM_TIMER_CHARA_NORMAL_MAX_NUMBER - WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + 1);//长时间间隔,即人物眼睛睁开的时间 } else if (timer_chara_status == WINDOW_CHARA_SPECIAL_FLAG) { chara_picture_label->setPixmap(chara_picture_extra); timer_interval_number = WINDOW_RANDOM_TIMER_CHARA_SPECIAL_NUMBER;//短时间间隔,即人物形象眼睛闭上的时间 } else { chara_picture_label->setPixmap(chara_picture); timer_interval_number = WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + rand() % (WINDOW_RANDOM_TIMER_CHARA_NORMAL_MAX_NUMBER - WINDOW_RANDOM_TIMER_CHARA_NORMAL_MIN_NUMBER + 1); } margin_picture.load((QString)WINDOW_MARGIN_PICTURE_LEFT_PATH_STRING); margin_picture_label->setPixmap(margin_picture);//左侧边界 chara_picture_timer->setInterval(timer_interval_number); chara_picture_timer->start(); } //显示光标所在的行数与列数 void Notepad::text_line_and_col() { QTextCursor textCursor = ui.textEdit_main->textCursor();//鼠标光标对象 int linenumber = textCursor.blockNumber();//获取光标行数。这是以回车符判别,不是显示出来的行数 int colnumber = textCursor.columnNumber();//获得光标列数 ui.label_filestatus->setText(tr("行:%1 列:%2").arg(linenumber + 1).arg(colnumber));//行数从0开始,因此需要增加1 } //基本功能实现 void Notepad::textedit_copy()//复制 { ui.textEdit_main->copy(); } void Notepad::textedit_paste()//粘贴 { ui.textEdit_main->paste(); } void Notepad::textedit_cut()//剪切 { ui.textEdit_main->cut(); } void Notepad::textedit_undo()//撤销 { ui.textEdit_main->undo(); } void Notepad::textedit_redo()//重做 { ui.textEdit_main->redo(); } void Notepad::textedit_font()//字体 { Font dialog;//信息提示框 dialog.set_textedit(ui.textEdit_main);//传入文本框地址 dialog.set_resource_random_number(font_randnumber, hex_status);//设置资源文件使用的随机数和处理模式 dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } void Notepad::textedit_color()//颜色 { Color dialog;//信息提示框 dialog.set_textedit(ui.textEdit_main);//传入文本框地址 dialog.set_resource_random_number(font_randnumber);//设置资源文件使用的随机数 dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } void Notepad::textedit_help()//程序信息 { Help dialog;//信息提示框 dialog.setWindowTitle(tr("关于我")); dialog.set_dialog_information_path(DIALOG_INFORMATION_HELP_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } void Notepad::textedit_new()//新建 { if (save_status()) { ui.textEdit_main->clear(); set_file_name(""); ui.label_filename->setText(tr("未命名"));//文件名显示 QString dialog_title_name = (tr("未命名"));//窗口标题 dialog_title_name += WINDOW_DIALOG_TITLE_PATH_STRING; setWindowTitle(dialog_title_name); if (hex_status == WINDOW_TOOL_TOHEX_STATUS_YES_FLAG)//根据处理方式更新编码提示框内容 { ui.label_code->setText(tr("二进制数据"));//修改主界面编码信息显示 } else { ui.label_code->setText(*text_code);//修改主界面编码信息显示 } setting_file_font_read();//加载对应字体文件 } else { } } void Notepad::textedit_open()//打开 { if (save_status()) { File dialog;//信息提示框 dialog.setWindowTitle(tr("打开文件")); file_dialog_file_name = current_file_name; file_dialog_file_name_address = &file_dialog_file_name;//设置地址 file_dialog_status_address = &file_dialog_status; dialog.set_file_path_address(file_dialog_file_name_address);//传入存放文件路径的变量 dialog.set_file_dialog_status_address(file_dialog_status_address);//传入存放文件打开或保存窗口的状态的变量 dialog.set_button_save_or_open(0); dialog.set_current_path(file_dialog_file_name);//传入工作路径 dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 if (file_dialog_status == true) { if (!file_dialog_file_name.isEmpty()) { file_load(file_dialog_file_name); } else { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_READ_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } } else { } } else { } } bool Notepad::textedit_save()//保存 { if (current_file_name.isEmpty())//如果当前文件没有文件名 { return textedit_saveas(); } else { return file_save(current_file_name); } } bool Notepad::textedit_saveas()//另存为 { File dialog;//信息提示框 dialog.setWindowTitle(tr("保存文件")); file_dialog_file_name = current_file_name; file_dialog_file_name_address = &file_dialog_file_name;//设置地址 file_dialog_status_address = &file_dialog_status; dialog.set_file_path_address(file_dialog_file_name_address);//传入存放文件路径的变量 dialog.set_file_dialog_status_address(file_dialog_status_address);//传入存放文件打开或保存窗口的状态的变量 dialog.set_button_save_or_open(1); dialog.set_current_path(file_dialog_file_name);//传入工作路径 dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 if (file_dialog_status == true) { if (file_dialog_file_name.isEmpty()) { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_WRITE_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 return false; } else { return file_save(file_dialog_file_name); } } else { return false; } } void Notepad::textedit_find()//查找 { if (find_dialog_mutex == 1)//只有在没有查找对话框时才能创建 { Find *dialog = new Find;//信息提示框 dialog->set_dialog_information_path(DIALOG_INFORMATION_FIND_PICTURE_PATH_STRING); dialog->set_textedit(ui.textEdit_main); dialog->setModal(false); dialog->show();//改用非模态对话框,注意非模态窗口不能直接用对象创建,需要用new方法,否则会立即退出 } else { } } void Notepad::textedit_replace()//替换 { if (find_dialog_mutex == 1)//只有在没有查找对话框时才能创建 { Replace *dialog = new Replace;//信息提示框 dialog->set_dialog_information_path(DIALOG_INFORMATION_REPLACE_PICTURE_PATH_STRING); dialog->set_textedit(ui.textEdit_main); dialog->setModal(false); dialog->show();//改用非模态对话框,注意非模态窗口不能直接用对象创建,需要用new方法,否则会立即退出 } else { } } void Notepad::textedit_tohex()//十六进制转化 { if (hex_status == WINDOW_TOOL_TOHEX_STATUS_NO_FLAG) { hex_status = WINDOW_TOOL_TOHEX_STATUS_YES_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_2.png);");//改变按钮样式 } else { hex_status = WINDOW_TOOL_TOHEX_STATUS_NO_FLAG; ui.pushButton_tool_05->setStyleSheet("border-image:url(:/picture_notepad/toolicon/picture_notepad/icon/tool_05_1.png);");//改变按钮样式 } if (hex_status == WINDOW_TOOL_TOHEX_STATUS_YES_FLAG)//根据处理方式更新编码提示框内容 { ui.label_code->setText(tr("二进制数据"));//修改主界面编码信息显示 } else { ui.label_code->setText(*text_code);//修改主界面编码信息显示 } setting_file_font_read();//字体切换 } void Notepad::textedit_code()//编码转换 { Code dialog; dialog.set_code_information(text_code, ui.label_code, hex_status); dialog.exec(); } void Notepad::textedit_setting()//其他设置 { Setting dialog; dialog.set_textedit(ui.textEdit_main);//利用指针传递参数 dialog.set_setting_text_address(setting_text_address); dialog.set_setting_binary_address(setting_binary_address); dialog.set_setting_default_open_method_address(setting_default_open_method_address); dialog.set_setting_bool_value_address(setting_bool_value_address[0], 0); dialog.set_setting_bool_value_address(setting_bool_value_address[1], 1); dialog.set_setting_bool_value_address(setting_bool_value_address[2], 2); dialog.set_setting_size_address(setting_size_address[0], 0); dialog.set_setting_size_address(setting_size_address[1], 1); dialog.exec(); } void Notepad::textedit_print()//打印 { Print dialog; dialog.set_textedit(ui.textEdit_main);//传入主界面参数 dialog.set_timer(chara_picture_timer); dialog.set_label_chara(chara_picture_label); dialog.set_label_margin(margin_picture_label); dialog.set_chara_path(chara_path_normal); dialog.set_flag(timer_chara_status_address); dialog.exec(); } void Notepad::file_load(QString name)//加载文件。这里用到了大量常量,如要修改最好重写 { QFile file(name); if (hex_status == WINDOW_TOOL_TOHEX_STATUS_NO_FLAG)//不是十六进制模式 { if (!file.open(QFile::ReadOnly | QFile::Text)) { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_READ_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } else { set_file_name(name); ui.label_filename->setText(name);//文件名显示 QString dialog_title_name = name;//窗口标题 dialog_title_name += WINDOW_DIALOG_TITLE_PATH_STRING; setWindowTitle(dialog_title_name); file.close(); File_read_text_thread *thread = new File_read_text_thread();//启用子线程 connect(thread, &QThread::finished, thread, &QObject::deleteLater);//直接delete子线程极其容易出现各种问题,要想安全删除线程可以使用此方式 connect(this, SIGNAL(send_file_name(QString)), thread, SLOT(get_file_name(QString)));//信号连接函数不仅应该放在能同时获得两个对象的地方,还要保证这里的子线程能在启动前得到所有参数。此外,信号函数和槽函数里面的参数只写类型,不写变量名,并且必须使用指针对象 connect(this, SIGNAL(send_file_size(int)), thread, SLOT(get_file_size(int))); connect(this, SIGNAL(send_file_code(QString)), thread, SLOT(get_file_code(QString))); emit send_file_name(name);//发出信号,给子线程传递文件名 emit send_file_size(*setting_size_address[0]);//发出信号,给子线程传递一次处理文件块大小 emit send_file_code(*text_code);//发出信号,给子线程传递文件编码 ui.label_file_read_advance->setText(tr("正在获取文件信息……"));//显示预处理进度信息 ui.label_file_read_advance->setVisible(true);//显示进度提示 progress_bar_change_color = false;//文件打开时进度条字体颜色未切换 ui.textEdit_main->clear();//清除文本内容 connect(thread, SIGNAL(send_data(QString, bool)), this, SLOT(get_data_t_r(QString, bool)));//接受子线程返回的参数 connect(thread, SIGNAL(send_index(long long, long long)), this, SLOT(get_index_t_r(long long, long long))); connect(thread, SIGNAL(send_advance_final()), this, SLOT(get_advance_final_t_r())); connect(thread, SIGNAL(send_final()), this, SLOT(get_final_t_r())); thread->start();//开始子线程。一定放在前面3个connect函数后面,否则有概率比它们先执行完子线程,connect函数还没被读取子线程那里的信号就已经发出来了,然后接收不到,造成槽函数无法运行 } } else//是十六进制模式 { if (!file.open(QFile::ReadOnly)) { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_READ_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 } else { ui.label_code->setText("二进制数据"); set_file_name(name); ui.label_filename->setText(name);//文件名显示 QString dialog_title_name = name;//窗口标题 dialog_title_name += WINDOW_DIALOG_TITLE_PATH_STRING; setWindowTitle(dialog_title_name); file.close(); File_read_binary_thread *thread = new File_read_binary_thread();//启用子线程 connect(thread, &QThread::finished, thread, &QObject::deleteLater);//直接delete子线程极其容易出现各种问题,要想安全删除线程可以使用此方式 connect(this, SIGNAL(send_file_name(QString)), thread, SLOT(get_file_name(QString)));//信号连接函数不仅应该放在能同时获得两个对象的地方,还要保证这里的子线程能在启动前得到所有参数。此外,信号函数和槽函数里面的参数只写类型,不写变量名,并且必须使用指针对象 connect(this, SIGNAL(send_file_size(int)), thread, SLOT(get_file_size(int))); connect(this, SIGNAL(send_file_addspace(bool)), thread, SLOT(get_file_addspace(bool))); emit send_file_name(name);//发出信号,给子线程传递文件名 emit send_file_size(*setting_size_address[1]);//发出信号,给子线程传递一次处理文件块大小 emit send_file_addspace(*setting_bool_value_address[2]);//发出信号,给子线程传递决定是否添加空格字符的布尔值 ui.progressBar->setVisible(true);//显示进度条 ui.progressBar->setValue(0);//进度条初始值为0 progress_bar_change_color = false;//文件打开时进度条字体颜色未切换 if (randnumber >= 1 && randnumber <= 5)//进度条文字颜色初始化 { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #FF53B9;background-color: #00FFFFFF;text-align:center;color:#FF53B9;}QProgressBar::chunk{background-color:#FF53B9;}"); } else if (randnumber >= 6 && randnumber <= 10) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #8599D4;background-color: #00FFFFFF;text-align:center;color:#8599D4;}QProgressBar::chunk{background-color:#8599D4;}"); } else if (randnumber >= 11 && randnumber <= 15) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #DE3FEB;background-color: #00FFFFFF;text-align:center;color:#DE3FEB;}QProgressBar::chunk{background-color:#DE3FEB;}"); } else if (randnumber >= 16 && randnumber <= 20) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #F2995D;background-color: #00FFFFFF;text-align:center;color:#F2995D;}QProgressBar::chunk{background-color:#F2995D;}"); } else if (randnumber >= 21 && randnumber <= 25) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #47B94E;background-color: #00FFFFFF;text-align:center;color:#47B94E;}QProgressBar::chunk{background-color:#47B94E;}"); } else { } ui.textEdit_main->clear();//清除文本内容 connect(thread, SIGNAL(send_data(QString, bool)), this, SLOT(get_data_b_r(QString, bool)));//接受子线程返回的参数 connect(thread, SIGNAL(send_index(long long, long long)), this, SLOT(get_index_b_r(long long, long long))); connect(thread, SIGNAL(send_final()), this, SLOT(get_final_b_r())); thread->start();//开始子线程。一定放在前面3个connect函数后面,否则有概率比它们先执行完子线程,connect函数还没被读取子线程那里的信号就已经发出来了,然后接收不到,造成槽函数无法运行 } } setting_file_font_read();//加载对应字体文件 } bool Notepad::save_status()//判断是否需要保存 { if (ui.textEdit_main->document()->isModified())//判断文件是否被修改 { Save dialog;//相关提示框 dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_SAVE_PICTURE_PATH_STRING); dialog.set_return_number(DIALOG_INFORMATION_CANNOT_SAVE_NORMAL_RETURN_NUMBER);//预先还原返回值 dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 if (dialog.get_return_number() == DIALOG_INFORMATION_CANNOT_SAVE_NORMAL_RETURN_NUMBER)//取消 { return false; } else if (dialog.get_return_number() == DIALOG_INFORMATION_CANNOT_SAVE_SAVE_RETURN_NUMBER)//保存 { return textedit_save(); } else if (dialog.get_return_number() == DIALOG_INFORMATION_CANNOT_SAVE_DISCARD_RETURN_NUMBER)//忽略,即不保存 { return true; } else { return false; } } else { return true; } } bool Notepad::file_save(QString name)//实际保存功能。这里用到了大量常量,如要修改最好重写 { if (hex_status == WINDOW_TOOL_TOHEX_STATUS_NO_FLAG)//不是十六进制模式 { QFile file(name); if (!file.open(QFile::WriteOnly | QFile::Text)) { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_WRITE_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 return false; } else { set_file_name(name); ui.label_filename->setText(name);//文件名显示 QString dialog_title_name = name;//窗口标题 dialog_title_name += WINDOW_DIALOG_TITLE_PATH_STRING; setWindowTitle(dialog_title_name); file.close(); File_write_text_thread *thread = new File_write_text_thread();//启用子线程 connect(thread, &QThread::finished, thread, &QObject::deleteLater);//直接delete子线程极其容易出现各种问题,要想安全删除线程可以使用此方式 connect(this, SIGNAL(send_file_name(QString)), thread, SLOT(get_file_name(QString)));//信号连接函数不仅应该放在能同时获得两个对象的地方,还要保证这里的子线程能在启动前得到所有参数。此外,信号函数和槽函数里面的参数只写类型,不写变量名,并且必须使用指针对象 connect(this, SIGNAL(send_file_output(QString)), thread, SLOT(get_file_output(QString))); connect(this, SIGNAL(send_file_code(QString)), thread, SLOT(get_file_code(QString))); emit send_file_name(name);//发出信号,给子线程传递文件名 emit send_file_output(ui.textEdit_main->toPlainText());//发出信号,给子线程传递需要输出的文本 ui.label_file_read_advance->setText(tr("正在保存文件……"));//显示进度信息 ui.label_file_read_advance->setVisible(true);//显示进度提示 emit send_file_code(*text_code);//发出信号,给子线程传递文件编码 progress_bar_change_color = false;//文件打开时进度条字体颜色未切换 connect(thread, SIGNAL(send_final()), this, SLOT(get_final_t_w())); thread->start();//开始子线程。一定放在前面3个connect函数后面,否则有概率比它们先执行完子线程,connect函数还没被读取子线程那里的信号就已经发出来了,然后接收不到,造成槽函数无法运行 return true; } } else { QFile file(name); if (!file.open(QFile::WriteOnly)) { Help dialog;//信息提示框 dialog.setWindowTitle(tr("有错误哦……")); dialog.set_dialog_information_path(DIALOG_INFORMATION_CANNOT_WRITE_PICTURE_PATH_STRING); dialog.exec();//如果不加这一句,对话框在创建后会被立即析构 return false; } else { set_file_name(name); ui.label_filename->setText(name);//文件名显示 QString dialog_title_name = name;//窗口标题 dialog_title_name += WINDOW_DIALOG_TITLE_PATH_STRING; setWindowTitle(dialog_title_name); file.close(); File_write_binary_thread *thread = new File_write_binary_thread();//启用子线程 connect(thread, &QThread::finished, thread, &QObject::deleteLater);//直接delete子线程极其容易出现各种问题,要想安全删除线程可以使用此方式 connect(this, SIGNAL(send_file_name(QString)), thread, SLOT(get_file_name(QString)));//信号连接函数不仅应该放在能同时获得两个对象的地方,还要保证这里的子线程能在启动前得到所有参数。此外,信号函数和槽函数里面的参数只写类型,不写变量名,并且必须使用指针对象 connect(this, SIGNAL(send_file_output(QString)), thread, SLOT(get_file_output(QString))); emit send_file_name(name);//发出信号,给子线程传递文件名 emit send_file_output(ui.textEdit_main->toPlainText());//发出信号,给子线程传递需要输出的文本 ui.label_file_read_advance->setText(tr("正在保存文件……"));//显示进度信息 ui.label_file_read_advance->setVisible(true);//显示进度提示 progress_bar_change_color = false;//文件打开时进度条字体颜色未切换 connect(thread, SIGNAL(send_final()), this, SLOT(get_final_b_w())); thread->start();//开始子线程。一定放在前面3个connect函数后面,否则有概率比它们先执行完子线程,connect函数还没被读取子线程那里的信号就已经发出来了,然后接收不到,造成槽函数无法运行 return true; } } } void Notepad::set_file_name(QString name)//设置文件名并初始化文本框修改状态 { current_file_name = name; ui.textEdit_main->document()->setModified(false);//重置文本框修改状态为未修改 ui.label_savestatus->setText(tr("已保存")); this->setWindowModified(false); name.isEmpty() ? this->setWindowFilePath("new.txt") : this->setWindowFilePath(name); } void Notepad::close_dialog()//关闭窗口按钮 { if (save_status()) { close_window_include_animation();//关闭窗口并且退出程序 } else { } } void Notepad::set_not_save_status()//设置未保存标记 { if (ui.textEdit_main->document()->isModified())//加入该判断,防止出现利用撤销功能回到初始状态却显示未保存的状况 { ui.label_savestatus->setText(tr("未保存")); } else { ui.label_savestatus->setText(tr("已保存")); } } void Notepad::close_window_include_animation()//包含关闭窗口动画的关闭窗口方法 { //禁用所有按钮,否则动画播放完毕前再次点击按钮会重新触发动画 QList<QPushButton *> push_button = this->findChildren<QPushButton *>(); foreach(QPushButton *push_button_disable, push_button) { push_button_disable->setEnabled(false); } QPropertyAnimation *animation_close = new QPropertyAnimation(this, "windowOpacity"); animation_close->setDuration(WINDOW_ANIMATION_TIME_NUMBER);//窗口关闭动画效果 animation_close->setStartValue(WINDOW_ANIMATION_TRANSPRENT_NORMAL_NUMBER); animation_close->setEndValue(WINDOW_ANIMATION_TRANSPRENT_DISAPPEAR_NUMBER); animation_close->start(QAbstractAnimation::DeleteWhenStopped);//结束时释放内存 connect(animation_close, SIGNAL(finished()), this, SLOT(close())); } //File_read_text_thread类的子线程数据接收 void Notepad::get_data_t_r(QString data, bool status)//显示内容,status决定是否为最后一次 { char *transform_final;//QString转char*,获得编码名称 QByteArray transform = (*text_code).toLocal8Bit(); transform_final = transform.data(); ui.label_code->setText(*text_code); ui.textEdit_main->insertPlainText(data); if (status)//最后一次需要单独处理 { ui.textEdit_main->document()->setModified(false);//重置文本框修改状态为未修改 ui.label_savestatus->setText(tr("已保存")); } else { } } void Notepad::get_index_t_r(long long index, long long total_size)//进度条显示 { double progress_bar_value = (((double)index / (double)total_size)*100);//计算比例 if (progress_bar_value > 100) { progress_bar_value = 100; } else { } if (progress_bar_value > 50 && !progress_bar_change_color)//避免看不见数字 { if (randnumber >= 1 && randnumber <= 5) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #FF53B9;background-color: #00FFFFFF;text-align:center;color:#F8EBF4;}QProgressBar::chunk{background-color:#FF53B9;}"); } else if (randnumber >= 6 && randnumber <= 10) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #8599D4;background-color: #00FFFFFF;text-align:center;color:#EDECF7;}QProgressBar::chunk{background-color:#8599D4;}"); } else if (randnumber >= 11 && randnumber <= 15) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #DE3FEB;background-color: #00FFFFFF;text-align:center;color:#F0E5F7;}QProgressBar::chunk{background-color:#DE3FEB;}"); } else if (randnumber >= 16 && randnumber <= 20) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #F2995D;background-color: #00FFFFFF;text-align:center;color:#FBEDE4;}QProgressBar::chunk{background-color:#F2995D;}"); } else if (randnumber >= 21 && randnumber <= 25) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #47B94E;background-color: #00FFFFFF;text-align:center;color:#EEF2EB;}QProgressBar::chunk{background-color:#47B94E;}"); } else { } progress_bar_change_color = true;//保证只切换一次字体颜色 } else { } ui.progressBar->setValue((int)progress_bar_value);//进度条显示 } void Notepad::get_advance_final_t_r()//隐藏进度提示并显示进度条 { ui.label_file_read_advance->setVisible(false);//隐藏进度提示 ui.progressBar->setValue(0);//进度条数值初始化 if (randnumber >= 1 && randnumber <= 5)//进度条文字颜色初始化 { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #FF53B9;background-color: #00FFFFFF;text-align:center;color:#FF53B9;}QProgressBar::chunk{background-color:#FF53B9;}"); } else if (randnumber >= 6 && randnumber <= 10) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #8599D4;background-color: #00FFFFFF;text-align:center;color:#8599D4;}QProgressBar::chunk{background-color:#8599D4;}"); } else if (randnumber >= 11 && randnumber <= 15) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #DE3FEB;background-color: #00FFFFFF;text-align:center;color:#DE3FEB;}QProgressBar::chunk{background-color:#DE3FEB;}"); } else if (randnumber >= 16 && randnumber <= 20) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #F2995D;background-color: #00FFFFFF;text-align:center;color:#F2995D;}QProgressBar::chunk{background-color:#F2995D;}"); } else if (randnumber >= 21 && randnumber <= 25) { ui.progressBar->setStyleSheet("QProgressBar{border: 1px solid #47B94E;background-color: #00FFFFFF;text-align:center;color:#47B94E;}QProgressBar::chunk{background-color:#47B94E;}"); } else { } ui.progressBar->setVisible(true);//显示进度条 } void Notepad::get_final_t_r()//结束 { ui.progressBar->setValue((int)WINDOW_PROGRESSBAR_MAX_VALUE_NUMBER);//进度条显示最大值 ui.progressBar->setVisible(false);//隐藏进度条 } //File_write_text_thread类的子线程数据接收 void Notepad::get_final_t_w()//结束 { ui.label_file_read_advance->setVisible(false);//隐藏进度显示 } //File_read_binary_thread类的子线程数据接收 void Notepad::get_data_b_r(QString data, bool status)//显示内容,status决定是否为最后一次 { ui.textEdit_main->insertPlainText(data); if (status)//最后一次需要单独处理 { ui.textEdit_main->document()->setModified(false);//重置文本框修改状态为未修改 ui.label_savestatus->setText(tr("已保存")); } else { } } void Notepad::get_index_b_r(long long index, long long total_size)//进度条显示 { get_index_t_r(index, total_size);//和读取文本文件一样 } void Notepad::get_final_b_r()//结束 { get_final_t_r(); } void Notepad::get_final_b_w()//隐藏进度提示 { get_final_t_w(); } //子线程类函数 File_read_text_thread::File_read_text_thread()//构造函数 { } File_read_text_thread::~File_read_text_thread()//析构函数 { } void File_read_text_thread::get_file_name(QString file_name)//获取文件名 { this->file_name = file_name;//因为类的成员变量名和参数名相同,因此必须用this指代 } void File_read_text_thread::get_file_size(int file_size)//获取一次处理文件块大小 { this->file_size = file_size; } void File_read_text_thread::get_file_code(QString file_code)//获取一次处理文件块大小 { this->file_code = file_code; } void File_read_text_thread::run()//子线程主函数 { mutex.lock();//必须加锁 QFile sourcefile(file_name); if (!sourcefile.open(QFile::ReadOnly | QFile::Text))//第二次打开文件,如果无法打开就不给予提示,因为之前一次已经进行了提示 { } else { QTextStream sourcefile_textstream(&sourcefile); QTextStream *sourcefile_textstream_address = &sourcefile_textstream;//QTextStream不能直接按值传递,也不能使用引用传递,但是可以用指针传递 char* transform_final;//QString转char* QByteArray transform = (file_code).toLocal8Bit(); transform_final = transform.data(); sourcefile_textstream.setCodec(transform_final);//设置编码 long long total_time = 0;//之后读取文件总共需要循环的次数,这样计算比实际处理次数少一次 long long total_size = 0;//文件总大小 int once_size = 0;//在某一次读取时获得的块大小 for (total_time = 0;; total_time++)//先读取一次文件获得总字符数信息信息 { QString temp_string = sourcefile_textstream.read(file_size*FILE_BIT_TO_KBIT);//读取指send_advance_final定块大小的文件字节,然后计算实际字节数(因为最后一次大部分情况下读取的字符串不会达到相应的块大小),并同时对总的处理次数进行记录 once_size = temp_string.size(); total_size += once_size; if (once_size < file_size*FILE_BIT_TO_KBIT) { break; } else { } } emit send_advance_final();//文件获取总字符数目处理完毕,发出信号 sourcefile_textstream.seek(0);//指针重新定义到文件开头便于接下来的实际读取 typedef QString(*FUNCPROC)(QTextStream*, int);//宏定义函数指针类型,自定义名称为FUNCPROC HINSTANCE dll_name;//显式加载dll文件 dll_name = LoadLibrary(FILE_DLL_FILE_READ_PATH_STRING);//加载dll文件,常量为宽字符类型 if (dll_name != NULL) { FUNCPROC file_read_text_func = (FUNCPROC)GetProcAddress(dll_name, "file_read_text");//获得dll中函数名地址并用file_read_text_func替代其名字 if (file_read_text_func != NULL) { for (long long temp_time = 1; temp_time <= total_time; temp_time++)//使用循环读取文件内容,不包含最后一次 { QString return_string = file_read_text_func(sourcefile_textstream_address, file_size);//经过测试,直接将return_string右边部分全部写在emit里面会导致错误 Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_data(return_string, false); emit send_index(file_size*temp_time*FILE_BIT_TO_KBIT, total_size); } QString return_string;//最后一次因为信号的原因单独处理 return_string = file_read_text_func(sourcefile_textstream_address, file_size); Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_data(return_string, true); emit send_index(file_size*((total_time + 1)*FILE_BIT_TO_KBIT), total_size); emit send_final();//处理完毕 } else { } FreeLibrary(dll_name);//卸载dll文件,注意参数和加载dll文件不同 } else { } sourcefile.close(); } mutex.unlock();//解锁 this->quit();//退出子线程 } File_write_text_thread::File_write_text_thread()//构造函数 { } File_write_text_thread::~File_write_text_thread()//析构函数 { } void File_write_text_thread::get_file_output(QString file_output)//获得文件需要输出的内容 { this->file_output = file_output; } void File_write_text_thread::run() { mutex.lock();//必须加锁 QFile outputfile(file_name); QTextStream outputfile_textstream(&outputfile); QTextStream *outputfile_textstream_address = &outputfile_textstream;//QTextStream不能直接按值传递,也不能使用引用传递,但是可以用指针传递 char* transform_final;//QString转char* QByteArray transform = file_code.toLocal8Bit(); transform_final = transform.data(); outputfile_textstream.setCodec(transform_final);//设置编码 if (!outputfile.open(QFile::WriteOnly | QFile::Text))//第二次打开文件,如果无法打开就不给予提示,因为之前一次已经进行了提示 { } else { typedef void(*FUNCPROC)(QTextStream*, QString);//宏定义函数指针类型,自定义名称为FUNCPROC HINSTANCE dll_name;//显式加载dll文件 dll_name = LoadLibrary(FILE_DLL_FILE_READ_PATH_STRING);//加载dll文件,常量为宽字符类型 if (dll_name != NULL) { FUNCPROC file_write_text_func = (FUNCPROC)GetProcAddress(dll_name, "file_write_text");//获得dll中函数名地址并用file_read_text_func替代其名字 if (file_write_text_func != NULL) { file_write_text_func(outputfile_textstream_address, file_output); Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_final();//处理完毕 } else { } FreeLibrary(dll_name);//卸载dll文件,注意参数和加载dll文件不同 } else { } outputfile.close(); } mutex.unlock();//解锁 this->quit();//退出子线程 } File_read_binary_thread::File_read_binary_thread()//构造函数 { } File_read_binary_thread::~File_read_binary_thread()//析构函数 { } void File_read_binary_thread::get_file_addspace(bool file_addspace)//获取是否添加空格的布尔值 { this->file_addspace = file_addspace; } void File_read_binary_thread::run()//子线程主函数 { mutex.lock();//必须加锁 QFile sourcefile(file_name); if (!sourcefile.open(QFile::ReadOnly))//第二次打开文件,如果无法打开就不给予提示,因为之前一次已经进行了提示 { } else { QDataStream sourcefile_datastream(&sourcefile); QDataStream *sourcefile_datastream_address = &sourcefile_datastream;//QTextStream不能直接按值传递,也不能使用引用传递,但是可以用指针传递 long long total_size = sourcefile.size();//文件总大小 long long total_time = (long long)(sourcefile.size() / file_size/ FILE_BIT_TO_KBIT);//之后读取文件总共需要循环的次数,这样计算比实际处理次数少一次 typedef QString(*FUNCPROC)(QDataStream*, int, bool);//宏定义函数指针类型,自定义名称为FUNCPROC HINSTANCE dll_name;//显式加载dll文件 dll_name = LoadLibrary(FILE_DLL_FILE_READ_PATH_STRING);//加载dll文件,常量为宽字符类型 if (dll_name != NULL) { FUNCPROC file_read_binary_func = (FUNCPROC)GetProcAddress(dll_name, "file_read_binary");//获得dll中函数名地址并用file_read_text_func替代其名字 if (file_read_binary_func != NULL) { for (long long temp_time = 1; temp_time <= total_time; temp_time++)//使用循环读取文件内容,不包含最后一次 { QString return_string = file_read_binary_func(sourcefile_datastream_address, file_size*FILE_BIT_TO_KBIT, file_addspace);//经过测试,直接将return_string右边部分全部写在emit里面会导致错误。注意块大小的单位,dll文件函数没有乘以倍率,需要在这里处理 Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_data(return_string, false); emit send_index(file_size*temp_time*FILE_BIT_TO_KBIT, total_size); } QString return_string;//最后一次因为信号的原因单独处理 return_string = file_read_binary_func(sourcefile_datastream_address, total_size - file_size * total_time*FILE_BIT_TO_KBIT, file_addspace);//由于读取原始数据是存入char*的,但动态申请的char*数据会有初始垃圾数据,胡最后一次要控制好大小以免在文件末尾出现其他数据 Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_data(return_string, true); emit send_index(file_size*((total_time + 1)*FILE_BIT_TO_KBIT), total_size); emit send_final();//处理完毕 } else { } FreeLibrary(dll_name);//卸载dll文件,注意参数和加载dll文件不同 } else { } sourcefile.close(); } mutex.unlock();//解锁 this->quit();//退出子线程 } File_write_binary_thread::File_write_binary_thread()//构造函数 { } File_write_binary_thread::~File_write_binary_thread()//析构函数 { } void File_write_binary_thread::get_file_output(QString file_output)//获得文件需要输出的内容 { this->file_output = file_output; } void File_write_binary_thread::run() { mutex.lock();//必须加锁 QFile outputfile(file_name); QDataStream outputfile_datastream(&outputfile); QDataStream *outputfile_datastream_address = &outputfile_datastream;//QTextStream不能直接按值传递,也不能使用引用传递,但是可以用指针传递 if (!outputfile.open(QFile::WriteOnly))//第二次打开文件,如果无法打开就不给予提示,因为之前一次已经进行了提示 { } else { typedef void(*FUNCPROC)(QDataStream*, QString);//宏定义函数指针类型,自定义名称为FUNCPROC HINSTANCE dll_name;//显式加载dll文件 dll_name = LoadLibrary(FILE_DLL_FILE_READ_PATH_STRING);//加载dll文件,常量为宽字符类型 if (dll_name != NULL) { FUNCPROC file_write_binary_func = (FUNCPROC)GetProcAddress(dll_name, "file_write_binary");//获得dll中函数名地址并用file_read_text_func替代其名字 if (file_write_binary_func != NULL) { file_write_binary_func(outputfile_datastream_address, file_output); Sleep(WINDOW_THREAD_WAIT_TIME_NUMBER);//子线程休眠一段时间,否则运行过快导致主线程卡死 emit send_final();//处理完毕 } else { } FreeLibrary(dll_name);//卸载dll文件,注意参数和加载dll文件不同 } else { } outputfile.close(); } mutex.unlock();//解锁 this->quit();//退出子线程 } }
a6378231b91dd805c4ae559019267e5d6e3a6311
8e1022e1323c461d1a787d5df74082954dbf82ea
/provides/include/lax_v1/lazify.hpp
6f4670c4314c01b78d41d7ff878a68d2f1483251
[ "MIT" ]
permissive
per-framework/lax.cpp
e000f2dfc0b1c65fca29ef430f04b9813be6a87f
2acdb9adf19441fcd159238c63fba24865234ce1
refs/heads/v1
2021-07-01T04:49:27.930355
2020-10-08T12:32:42
2020-10-08T13:00:42
180,317,719
0
0
MIT
2019-04-22T20:06:57
2019-04-09T08:11:47
C++
UTF-8
C++
false
false
69
hpp
lazify.hpp
#pragma once #include "lax_v1/type.hpp" #include "lax_v1/value.hpp"
2a11b1fd92327387396cb04d27277a2db43b977a
5a6ccde5f37cc86b6fc0812b2bf40f42eab23906
/B-set/66B.Petya and Countryside.cpp
ecd5cc6cf13178e7677bd2dd8e3431f6a72f30a7
[]
no_license
Waqar-107/Codeforces
23f2b1edffb85f6f020107f03e09a455d3e6e792
f0d2f25aa6a09c06083b82c39cdf3288ec2eecba
refs/heads/master
2023-03-09T07:55:46.583363
2023-03-04T09:57:44
2023-03-04T09:57:44
82,915,896
196
138
null
2023-02-11T22:06:20
2017-02-23T10:29:34
C++
UTF-8
C++
false
false
898
cpp
66B.Petya and Countryside.cpp
/*****from dust i have come, dust i will be*****/ #include<bits/stdc++.h> typedef long long int ll; #define pp pair<ll,ll> #define dbg printf("in\n"); #define inf 1000000000000 #define fr(a) for(i=0;i<n;i++) #define mm 1000000007 using namespace std; int main() { //freopen("in.txt","r",stdin); int i,j,k; int n,r,l; cin>>n; int a[n]; for(i=0;i<n;i++) cin>>a[i]; int count,max=0; for(i=0;i<n;i++) { count=1; k=i; for(j=i-1;j>=0;j--) { if(a[j]<=a[k]) count++; else break; k--; } k=i; for(j=i+1;j<n;j++) { if(a[j]<=a[k]) count++; else break; k++; } if(max<count) max=count; } cout<<max; return 0; }
c0f4fa3840470333e70658265bede967f1433d6d
730d3b8067feb317c053f05d9d77780c8baa81e8
/src/tracklayer.hpp
85037cf9398540a507ad240946594978f63547f6
[ "MIT" ]
permissive
pekdon/florb
c5fea3fbe0ff64b9ae949bbb225c317a63d18db6
85d2be7d851f83db8a289fd2018832aec295d526
refs/heads/master
2022-12-22T12:09:32.027989
2019-07-16T16:54:55
2019-07-16T16:54:55
291,637,368
2
0
MIT
2020-08-31T06:48:11
2020-08-31T06:48:10
null
UTF-8
C++
false
false
3,354
hpp
tracklayer.hpp
#ifndef TRACKLAYER_HPP #define TRACKLAYER_HPP #include <string> #include <iostream> #include <tinyxml2.h> #include <vector> #include <ctime> #include <layer.hpp> #include "viewport.hpp" #include "point.hpp" namespace florb { class tracklayer : public florb::layer { public: tracklayer(const std::string &path); tracklayer(); ~tracklayer(); class event_notify; class waypoint; bool handle_evt_mouse(const florb::layer::event_mouse* evt); bool handle_evt_key(const florb::layer::event_key* evt); bool draw(const florb::viewport& vp, florb::canvas& os); void load_track(const std::string &path); void save_track(const std::string &path); void clear_track(); void add_trackpoint(const florb::point2d<double>& p); size_t selected(); void selection_get(std::vector<waypoint>& waypoints); void selection_set(const std::vector<waypoint>& waypoints); void selection_delete(); double trip(); void showwpmarkers(bool s); private: static const unsigned int wp_hotspot = 6; static const std::string trackname; struct gpx_trkpt { double lat; double lon; double ele; time_t time; }; struct selection { // Multiselect bool multiselect; // Dragging bool dragging; florb::point2d<double> dragorigin; florb::point2d<double> dragcurrent; std::vector< std::vector<florb::tracklayer::gpx_trkpt>::iterator > waypoints; }; void notify(); bool press(const florb::layer::event_mouse* evt); bool release(const florb::layer::event_mouse* evt); bool drag(const florb::layer::event_mouse* evt); bool key(const florb::layer::event_key* evt); void trip_update(); void trip_calcall(); void parsetree(tinyxml2::XMLNode *parent); std::vector<florb::tracklayer::gpx_trkpt> m_trkpts; selection m_selection; long double m_trip; bool m_showwpmarkers; }; class tracklayer::event_notify : public event_base { public: event_notify() {}; ~event_notify() {}; }; class tracklayer::waypoint { public: waypoint(double lon, double lat, double ele, time_t ti) : m_lon(lon), m_lat(lat), m_ele(ele), m_time(ti) {}; ~waypoint() {}; double lon() const { return m_lon; }; void lon(double l) { m_lon = l; }; double lat() const { return m_lat; }; void lat(double l) { m_lat = l; }; double elevation() const { return m_ele; }; void elevation(double ele) { m_ele = ele; }; time_t time() const { return m_time; }; void time(double t) { m_time = t; }; private: double m_lon; double m_lat; double m_ele; time_t m_time; }; }; #endif // TRACKLAYER_HPP
8a125bddde2066b652b6458a41ed4871f272728a
e1d613a4fcfcc3fa5b8704ae222d8c23b9a029c9
/codes/complete_binary_heap.cpp
b1c1413e9422880fcfbf35978524c35f5066b716
[]
no_license
greenpepper123/procon
5e7b616a0cf3b774b11522480a1b97884114dffd
084607c0a630f4e9791c2994446aa249dd4fa39e
refs/heads/master
2022-12-17T02:17:54.535943
2020-08-11T21:06:30
2020-08-11T21:06:30
279,042,818
0
0
null
null
null
null
UTF-8
C++
false
false
754
cpp
complete_binary_heap.cpp
#include <iostream> #include <cmath> #include <vector> #include <string> #include <algorithm> void print(int id, std::vector<int> tree) { std::cout << "node " << id << ": key = " << tree[id-1] << ", "; if (id/2 > 0) { std::cout << "parent key = " << tree[id/2-1] << ", "; } if (2*id <= tree.size()) { std::cout << "left key = " << tree[2*id-1] << ", "; } if (2*id+1 <= tree.size()) { std::cout << "right key = " << tree[2*id] << ", "; } std::cout << "\n"; } int main() { int n, h; std::cin >> n; std::vector<int> tree; for (int i=0; i<n; i++) { std::cin >> h; tree.push_back(h); } for (int i=1; i<=n; i++) { print(i, tree); } return 0; }
a1c86d72e901594f2fb0054199d227111794e0da
c1cfc72f3306067a63eceaeddd935c1032685c6d
/ServerClass.h
1e81ab1d76f3ec9c605d8027b6c863b3a6321c86
[]
no_license
Zephyrum-Alsend/Network_Chatroom
c4dfbfcdb90531600cb3efb336b0381f18144f4c
682bce8618245799c4d281909f0c02a387a3bf74
refs/heads/master
2021-05-06T19:43:18.998644
2017-10-31T00:52:09
2017-10-31T00:52:09
112,180,299
0
0
null
2017-11-27T10:11:01
2017-11-27T10:11:00
null
UTF-8
C++
false
false
1,665
h
ServerClass.h
#pragma once #include "stdafx.h" struct client; //maximum clients we will serve const int MAX_CLIENTS = 64; //class ServerClass //Handles all server functions, including password checking, etc. class ServerClass { public: //ServerClass(); //getter setter for whitelistpath std::string GetWhiteList(); void SetWhiteList(std::string NewPath); //for map version, builds whitelist from text file at ?server start? or have a function to UpdateWhiteList mid server void LoadWhiteList(); //when a new client connects, calls other functions to complete login procedure bool NewConnect(SOCKET s); //part of handshake process, checks if client has updated security code bool CheckSecurityCode(int code); //checks WhiteList for username + password combination returns true if found false if not bool CheckWhiteList(std::string UserName, std::string PassWord); protected: private: std::map<std::string, std::string> WhiteListMap; // path for where the WhiteList (assortment of usernames and passwords std::string m_WhiteList="WhiteList.txt"; //default val int keycode = 1312; //default val SOCKET ListeningSocket; //store our listening socket //connected client array //SOCKET SOC[MAX_CLIENTS]; std::vector<client> SOC; }; struct client { public: SOCKET s; //socket this client is on, identifying feature I guess? enum ClientStatus { Code, PassWord, LoggedIn }; //login status, code means they need to supply the code, password for loggin in process //logged in means they have fully logged in and are participating in the chat and recieving messages protected: private: };
2b90dc30994991e6503920e26b89f4fc74a36bb5
24b6c192d1b5f516717462d6bb16bfe6b3d05cdc
/plugin-test/plugins/Plugin2.cpp
c02cc6ed07c64e6bc12f3a797909071562b74551
[]
no_license
TrueJournals/cpp-experiments
512dc391669533782387361fc9df0a96674e8b75
d3250700f52f21cf12d541778f65e517e7782c4a
refs/heads/master
2021-01-22T01:05:45.815200
2015-10-03T19:07:28
2015-10-03T19:07:28
31,133,057
0
0
null
null
null
null
UTF-8
C++
false
false
433
cpp
Plugin2.cpp
#include "../interface.hpp" #include "../TestPlugin.hpp" class Plugin2 : public TestPlugin { public: using TestPlugin::TestPlugin; virtual ~Plugin2() = default; virtual std::string get_name() override { return "Plugin2"; } virtual unsigned int calc(unsigned int input) override { return input / 2; } }; extern "C" std::shared_ptr<TestPlugin> load(TestState* state) { return std::make_shared<Plugin2>(state); }
e071125e2d3b2f0530090a205d8d53b6083ebbb9
4baa62e54b5ad336d989cb0554ae422c591f73af
/1200/1293.cpp
1c3fe8a9e9cafeee719afce8500a850f9c59b8c1
[]
no_license
shikgom2/Codeup
219283fc487c2da781ba562bda4fcba40cfe7c46
111243633fbec7116e52e609b01415d6d2cbba99
refs/heads/master
2020-06-13T06:56:56.586964
2019-07-09T07:50:19
2019-07-09T07:50:19
194,578,627
7
3
null
null
null
null
UTF-8
C++
false
false
322
cpp
1293.cpp
#include <stdio.h> int main() { int n, i, a; int max, min; scanf("%d", &n); for(i=1; i<=n; i++){ scanf("%d", &a); if(i==1){ max=a; min=a; } if(a>=max) max=a; if(a<=min) min=a; } printf("%d %d", max, min); return 0; }
e1b4cbd4434c8b93e40d309f4a7ef3c0fe84715c
cb643d82dbc1c38a6dead34efb898d052a126716
/1302_DeepestLeavesSum.cpp
534b102dca603e236e80300845ffceb45ddffad9
[]
no_license
penthaapatel/LeetCodeSolutions
d72e3f44a7787bc5009a41b9f1814cf5c189995e
ceaee9d38f58c47dd489d175d9aa07a835667860
refs/heads/master
2021-06-27T02:14:48.075661
2021-04-04T08:30:56
2021-04-04T08:30:56
207,657,736
0
0
null
null
null
null
UTF-8
C++
false
false
1,098
cpp
1302_DeepestLeavesSum.cpp
// 1302. Deepest Leaves Sum - https://leetcode.com/problems/deepest-leaves-sum/ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { public: int deepestLeavesSum(TreeNode *root) { queue<TreeNode *> q; q.emplace(root); int levelsum = 0; while (!q.empty()) { levelsum = 0; int s = q.size(); for (int i = 0; i < s; i++) { TreeNode *current = q.front(); q.pop(); levelsum += current->val; if (current->left != nullptr) q.emplace(current->left); if (current->right != nullptr) q.emplace(current->right); } } return levelsum; } };
c76f6afd7b553c8f51efd28155e83c9a1f3eda3b
a85b9f1b1534c9658058d38ae4ef6451f66fda02
/Sets/Sets/main.cpp
32ce740e36a6eea4a3ff621e3ac2ba181e4c19b6
[]
no_license
erik1o6/Cplusplus
43e26b47ea1eaeab9c1b115fa47e8cb05e4ebc22
dbfbd2d954306665e2d0e1ef611502e9787d1c5a
refs/heads/master
2016-09-02T04:59:03.966350
2013-01-25T20:47:00
2013-01-25T20:47:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
140
cpp
main.cpp
//main.cpp //Written by: Erik Arfvidson #include"Set.h" using namespace std; void main() { insertStrings(); system("pause"); }
50284ac75233918ded165b976cbd7a0e7cce23d8
ac645d07f5540e59f9854c0c2dfefaeb313680bc
/src/Hummingbird Engine/Scene Manager/Attributes/Updateable/updateable.h
c93a653f48ec754b2dd9b6aedaff1f0767e0bb93
[]
no_license
brayanraya/HummingbirdEngine
a7785c3a5a642c43592a96f58cf2090c774b59e4
016e8b2c15fd27e88f2f665cc3d8e2df39b0a422
refs/heads/master
2020-03-17T09:16:49.341340
2018-05-15T05:55:21
2018-05-15T05:55:21
133,463,901
0
0
null
null
null
null
UTF-8
C++
false
false
3,220
h
updateable.h
#ifndef _updateable #define _updateable #include "../../Game Objects/gameObjects.h" #include "../Shared Enum/regestrationState.h" #include "../updateable/updateableManager.h" //------------------------------------ // Forward Declarations //------------------------------------ class updateableRegistratonCommand; class updateableDeregistratonCommand; //////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Allows inherited class to register and deregister for the engines update cylce. </summary> /// /// <remarks> Braya, 3/1/2017. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// class updateable : public virtual gameObjects { public: //------------------------------------ // Big 4. //------------------------------------ updateable(); ~updateable(); updateable(const updateable&) = delete; updateable& operator=(const updateable&) = delete; ///------------------------------------------------------------------------------------------------- /// <summary> Scene deregistraion. </summary> /// /// <remarks> Braya, 3/1/2017. </remarks> ///------------------------------------------------------------------------------------------------- void sceneDeregistraion(); ///------------------------------------------------------------------------------------------------- /// <summary> Scene registraion. </summary> /// /// <remarks> Braya, 3/1/2017. </remarks> ///------------------------------------------------------------------------------------------------- void sceneRegistraion(); ///------------------------------------------------------------------------------------------------- /// <summary> Submit updateable deregistration. </summary> /// /// <remarks> Braya, 3/1/2017. </remarks> ///------------------------------------------------------------------------------------------------- void submitUpdateableDeregistration(); ///------------------------------------------------------------------------------------------------- /// <summary> Submit updateable registration. </summary> /// /// <remarks> Braya, 3/1/2017. </remarks> ///------------------------------------------------------------------------------------------------- void submitUpdateableRegistration(); ///------------------------------------------------------------------------------------------------- /// <summary> Virtual Function: What is done during update. /// \code /// void userObject::sceneEntry() /// { /// alarmable::submitAlarmableRegistration(); /// } /// * // ... /// void userObject::update() /// { /// ///Things that change on a frame to frame basis /// } /// // ... /// \endcode /// </summary> ///------------------------------------------------------------------------------------------------- virtual void update() {}; updateableManager::updateableListRef myDeleteRef; private: //------------------------------------ //Private Variables //------------------------------------ registrationState currentState; updateableRegistratonCommand* pRegistrationCmd; updateableDeregistratonCommand* pDeregistrationCmd; }; #endif // !_updateable
f6cc6cb5c38fbdfe4187b59aa00bae0df05d0629
233a7040061c47bc4624c0bebe4b53d585a6db15
/src/EmpiricalDistribution.cxx
725adbf166af63ebd01c20958cbd8dad5677ebb0
[ "MIT" ]
permissive
chiumichael/EJD
97a12773a03098fbcdc69dc0a0bca51f5112e4d4
fa7e5f6854c56da0167e6d2935d8738121a0a22e
refs/heads/master
2021-06-24T11:28:06.413769
2020-10-14T19:25:08
2020-10-14T19:25:08
170,946,431
0
1
MIT
2020-01-09T22:59:42
2019-02-16T00:38:40
C++
UTF-8
C++
false
false
4,853
cxx
EmpiricalDistribution.cxx
/* This file is part of EJD. Copyright © 2020 Michael Chiu <chiu@cs.toronto.edu> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "EmpiricalDistribution.hpp" // std libs #include <algorithm> namespace ejd { ////////////////////////////////////////////////////////////////////////////// // // General Helper Functions // ////////////////////////////////////////////////////////////////////////////// void edit_sum_1(std::vector<double> * v_ptr) { std::vector<double> & v = * v_ptr; int v_size = v.size(); double sum_n_minus_1 = std::accumulate( v.begin(), v.begin() + v_size - 1, 0.0 ); v[v_size-1] = 1 - sum_n_minus_1; } bool valid_emp_distr(const std::vector<double>& p, double errtol) { double sum; std::for_each(p.begin(), p.end(), [&sum](double p_){ sum += p_; } ); if (sum - 1 < errtol) { return true; } return false; } ////////////////////////////////////////////////////////////////////////////// // // Empirical Distribution // ////////////////////////////////////////////////////////////////////////////// // TODO : finish me! bool EmpiricalDistribution::operator==(const EmpiricalDistribution &rhs) const { return std::equal(this->weights.begin(), this->weights.end(),rhs.weights.begin(), rhs.weights.end()) && std::equal(this->support.begin(), this->support.end(),rhs.support.begin(), rhs.support.end()); } double EmpiricalDistribution::mean() const { return discrete_empirical_mean(weights,support); } double EmpiricalDistribution::variance() const { return discrete_empirical_variance(weights,support); } double EmpiricalDistribution::total_prob() const { return std::accumulate( weights.begin(), weights.end(), 0.0 ); } double EmpiricalDistribution::entropy() const { double ent = 0; for (const auto & w : weights) { ent += w * std::log(w); } return -ent; } ////////////////////////////////////////////////////////////////////////////// // // Empirical Distribution Array // ////////////////////////////////////////////////////////////////////////////// bool EmpDistrArray::operator==(const EmpDistrArray& rhs) const { return std::equal(this->marginals.begin(), this->marginals.end(),rhs.marginals.begin(), rhs.marginals.end()); } std::vector<double> EmpDistrArray::means() const { std::vector<double> means(marginals.size(),0.); std::transform( marginals.begin(), marginals.end(), means.begin(), [](const EmpiricalDistribution & empdistr) { return empdistr.mean(); } ); return means; } std::vector<double> EmpDistrArray::variances() const { std::vector<double> variances(marginals.size(),0.); std::transform( marginals.begin(), marginals.end(), variances.begin(), [] (const EmpiricalDistribution & empdistr) { return empdistr.variance(); } ); return variances; } int EmpDistrArray::dimensions() const { return marginals.size(); } EmpDistrArray construct_EmpDistrArray(const std::vector<bm::poisson>& poisson_distrs) { std::vector<EmpiricalDistribution> emp_distr_data; // calculate the max length of uspport int max_upper_bound = 0; for (int i = 0; i < poisson_distrs.size(); ++i) { int this_ub = upper_bounds(poisson_distrs[i]); max_upper_bound = max_upper_bound < this_ub ? this_ub : max_upper_bound; } for (int i = 0; i < poisson_distrs.size(); ++i) { emp_distr_data.emplace_back( construct_discrete_EmpDistr(poisson_distrs[i], max_upper_bound) ); } return EmpDistrArray(emp_distr_data); } EmpDistrArray construct_Poisson_EmpDistrArray(const std::vector<double>& intensities) { std::vector<boost::math::poisson> poiss_distrs; poiss_distrs.reserve(intensities.size()); for (const auto & e : intensities) { poiss_distrs.emplace_back(boost::math::poisson(e)); } return construct_EmpDistrArray(poiss_distrs); } // namespace ejd }
18058aee33c7c2fc374b2b3f2b4cd136e17dc244
4045e2a8274c067f7b99fbe5a690cd7f7042aba1
/gctp/graphictest/graphictest.cpp
5f27e8027697de7159599789f8d5ae5265fd5cfe
[ "BSD-3-Clause" ]
permissive
Emulyator/gamecatapult
78b48efdae3e13e20eb3176c104e7432161362e0
d937e2a94d7156f040d34609e554991dc3a1cc47
refs/heads/master
2016-09-05T19:32:35.028735
2014-03-22T22:44:47
2014-03-22T22:44:47
41,599,252
1
0
null
null
null
null
SHIFT_JIS
C++
false
false
10,013
cpp
graphictest.cpp
/**@file * グラフィック機能のテスト * * @author SAM (T&GG, Org.)<sowwa_NO_SPAM_THANKS@water.sannet.ne.jp> * @date 2004/01/29 16:56:21 * Copyright (C) 2001,2002,2003,2004 SAM (T&GG, Org.). All rights reserved. */ #include "stdafx.h" #include <gctp/dbgout.hpp> #include <gctp/graphic.hpp> #include <gctp/graphic/dx/device.hpp> #include <gctp/inputbuffer.hpp> #include <gctp/graphic/spritebuffer.hpp> #include <gctp/graphic/texture.hpp> #include <gctp/font.hpp> #include <gctp/graphic/text.hpp> #include <gctp/graphic/fonttexture.hpp> #include <gctp/movie/player.hpp> #include <gctp/inputmethod.hpp> using namespace gctp; using namespace gctp::graphic; using namespace std; using namespace SmartWin; #define MOVIETEST //#define MOVIE_FOR_WINDOW class TestWindow : public WidgetFactory<WidgetWindow, TestWindow> { #ifndef GCTP_LITE TYPEDEF_DXCOMPTR(ID3DXMesh); #endif typedef TestWindow Self; public: TestWindow() {} void setUp(bool is_fs = false) { HRslt hr; if(is_fs) { size_t mode_no = graphic::dx::adapters()[0].modes.size()-1; for(size_t i = 0; i < graphic::dx::adapters()[0].modes.size(); i++) { const D3DDISPLAYMODE &mode = graphic::dx::adapters()[0].modes[i]; if(mode.Width >= 800 && mode.Width >= 600 && mode.Format < D3DFMT_A16B16G16R16) { mode_no = i; break; } } const D3DDISPLAYMODE &mode = graphic::dx::adapters()[0].modes[mode_no]; Seed seed = getDefaultSeed(); seed.location.pos.x = 0; seed.location.pos.y = 0; seed.location.size.x = mode.Width; seed.location.size.y = mode.Height; seed.style = 0; seed.exStyle = 0; seed.caption = _T("Hello GameCatapult"); // Title createWindow(seed); ime_.setUp(handle()); if(getParent()) hr = g_.open(handle(), getParent()->handle(), 0, (uint)mode_no); else hr = g_.open(handle(), 0, (uint)mode_no); maximize(); } else { Seed seed = getDefaultSeed(); seed.caption = _T("Hello GameCatapult"); // Title createWindow(seed); SmartWin::Rectangle location = getBounds(); location.size.x = 800; location.size.y = 600; ::RECT rc = location; ::AdjustWindowRectEx(&rc, seed.style, 0, seed.exStyle); setBounds(SmartWin::Rectangle::FromRECT(rc)); ime_.setUp(handle()); if(getParent()) hr = g_.open(handle(), getParent()->handle()); else hr = g_.open(handle()); } if(!hr) { GCTP_TRACE(hr); close(); return; } g_.setCurrent(); #ifndef GCTP_LITE //hr = D3DXCreateTeapot(device().impl().ptr(), &mesh_, NULL); //if(!hr) PRNN(hr); #endif #ifdef MOVIETEST # ifdef MOVIE_FOR_WINDOW hr = movie_.open(handle(), _T("movie.avi")); if(!hr) { hr = movie_.open(handle(), _T("movie.mpg")); if(!hr) { GCTP_TRACE(hr); close(); return; } } # else hr = movie_.openForTexture(_T("movie.avi")); if(!hr) { hr = movie_.openForTexture(_T("../../../media/movie.mpg")); if(!hr) { GCTP_TRACE(hr); close(); return; } } tex_ = movie_.getTexture().lock(); # endif movie_.play(0); #else tex_ = new Texture; tex_->setUp(_T("../../../media/gctp.jpg")); #endif font_ = new gctp::Font; font_->setUp(_T(",10,BOLD|FIXEDPITCH")); spr_ = new SpriteBuffer; spr_->setUp(); fonttex_ = new FontTexture; fonttex_->setUp(512, 512); theta_ = 0; scale_ = 0; count_ = 0; updateDisplay(); // handlers onSized( &Self::doOnResized ); onMouseMove( &Self::doOnMouseMove ); onChar( &Self::doOnChar ); onKeyPressed( &Self::doOnKeyPressed ); onRaw( &Self::doOnIMEChar, Message(WM_IME_CHAR) ); onRaw( &Self::doOnIMENotify, Message(WM_IME_NOTIFY) ); Command com( _T("Testing") ); createTimer(&Self::onTimer, 16, com); } void doOnResized(const WidgetSizedEventResult & sz) { GCTP_TRACE("onResized "<<sz.newSize.x<<","<<sz.newSize.y); } void onTimer(const CommandPtr &p) { updateDisplay(); #ifdef MOVIETEST movie_.checkStatus(); #endif Command com( _T("Testing") ); createTimer(&Self::onTimer, 16, com); } sw::Point mouse_pos_; void doOnMouseMove(const MouseEventResult &mouse) { mouse_pos_ = mouse.pos; } bool doOnKeyPressed(int key) { return ibuf_.inputKey(key); } bool doOnChar(int input_char) { ibuf_.input(input_char); return true; } HRESULT doOnIMEChar(LPARAM lParam, WPARAM wParam) { ibuf_.input(wParam); return 0; } HRESULT doOnIMENotify(LPARAM lParam, WPARAM wParam) { ime_.onNotify(wParam); return 0; } void updateDisplay() { #if !defined(MOVIETEST) || !defined(MOVIE_FOR_WINDOW) if(g_.isOpen()) { g_.setCurrent(); Matrix mat_world; mat_world.rotY(count_/360.0f); device().setWorld(mat_world); count_++; device().clear(); device().begin(); text_.reset(); text_.setFont(font_); SpriteDesc desc; #ifdef MOVIETEST desc = movie_.getDesc(); #else if(tex_) desc.setUp(*tex_); #endif if(tex_) spr_->begin(device().getViewPort().size(), *tex_).draw(desc).end(); text_.out() << desc.pos[0] << "," << desc.pos[1] << "," << desc.pos[2] << "," << desc.pos[3] << endl; #ifndef GCTP_LITE if(mesh_) { device().setView(Matrix().setLookAt(VectorC(0,3,5), VectorC(0,0,0), VectorC(0,1,0))); device().setProjection(Matrix().setFOV(g_pi/4, device().getViewPort().aspectRatio(), 1.0f, 100.0f)); mesh_->DrawSubset(0); } #endif spr_->begin(*fonttex_).draw(SpriteDesc().setUp(*fonttex_).addOffset(Point2fC(256, 8)).setColor(Color32(255,0,0))).end(); if(tex_) { spr_->begin(*tex_); spr_->draw(SpriteDesc(desc).mult(Point2fC(tex_->originalSize())/2, Matrix2C(true).scale(scale_*0.3f, scale_*0.3f)*Matrix2C(true).rot(theta_))); spr_->draw(SpriteDesc(desc).addOffset(Point2fC(scale_*100.0f, scale_*100.0f))); spr_->end(); } theta_ += 1/180.0f*g_pi; scale_ = fabsf(sinf(theta_))+0.5f; text_.setPos(10, g_.getScreenSize().y-20).out() << "Alt + F4 to exit"; text_.setPos(10, 20).setColor(Color32(255, 0, 127)).out() << _T("現在の角度:"); text_.setPos(90, 20).out() << theta_; text_.setPos(160, 20).out() << scale_; text_.setPos(10, 40).out() << "mouse (" << mouse_pos_.x << ", " << mouse_pos_.y << ")"; text_.setPos(10, 60).out() << ibuf_.get(); Point2f cursor_pos = text_.getPos(*fonttex_, (int)ibuf_.cursor()-(int)ibuf_.get().size()); if(ime_.isOpen()) { ime_.setPos(Point2C(cursor_pos)); LOGFONT logfont; font_->getLogFont(logfont); ime_.setFont(logfont); } #if 0 if(ime_.isOpen() && !ime_.str().empty()) { ime_.setPos(Point2C(cursor_pos)); uint i; for(i = 0; i < ime_.attrs().size(); i++) { if(ime_.attrs()[i] == ATTR_TARGET_CONVERTED || ime_.attrs()[i] == ATTR_TARGET_NOTCONVERTED) { text_.setColor(Color32(255, 255, 127), i); } else text_.setColor(Color32(255, 127, 255), i); } text_.setPos(cursor_pos.x, cursor_pos.y).out() << ime_.str(); text_.setColor(Color32(255, 127, 255)); cursor_pos = text_.getPos(*font_, (int)ime_.cursor()-(int)ime_.str().size()); text_.setPos(cursor_pos.x, cursor_pos.y+2).out() << (isleadbyte(ime_.str().c_str()[ime_.cursor()]) ? "_" : "_"); } else text_.setPos(cursor_pos.x, cursor_pos.y+2).out() << (isleadbyte(ibuf_.cursorChar()) ? "_" : "_"); #else # ifdef UNICODE text_.setPos(cursor_pos.x, cursor_pos.y+2).out() << "_"; # else text_.setPos(cursor_pos.x, cursor_pos.y+2).out() << (isleadbyte(ibuf_.cursorChar()) ? _T("_") : _T("_")); # endif #endif if(ime_.isOpen()) text_.setPos(10, 6).setColor(Color32(255, 127, 255)).out() << _T("変換"); text_.draw(*spr_, *fonttex_); HRslt hr = device().end(); if(!hr) GCTP_TRACE(hr); hr = device().present(); if(!hr) GCTP_TRACE(hr); } #endif } private: Device g_; #ifndef GCTP_LITE ID3DXMeshPtr mesh_; #endif #ifdef MOVIETEST movie::Player movie_; #endif Pointer<gctp::Font> font_; Pointer<SpriteBuffer> spr_; Pointer<Texture> tex_; Pointer<FontTexture> fonttex_; float theta_; float scale_; int count_; Text text_; InputBuffer ibuf_; InputMethod ime_; }; int SmartWinMain( Application & app ) { locale::global(locale(locale::classic(), locale(""), LC_CTYPE)); // Initialize COM CoInitialize(NULL); #ifdef MOVIETEST allowStrictMultiThreadSafe(true); // ムービーは別スレッドでテクスチャに触るので setIntervalTime(1); //setSwapMode(true); // もうこれデフォルトでよくね? #endif initialize(); WidgetMessageBoxFree msgbox; WidgetMessageBoxFree::RetVal retval = msgbox.show( _T("フルスクリーンで起動しますか?"), _T("モード選択"), WidgetMessageBoxFree::BOX_YESNO, WidgetMessageBoxFree::BOX_ICONINFORMATION); TestWindow *test_window = new TestWindow; test_window->setUp(retval == WidgetMessageBoxFree::RETBOX_YES); int ret = app.run(); CoUninitialize(); return ret; } #ifdef _UNICODE # ifdef _DEBUG # pragma comment(lib, "SmartWinDU.lib") # else # pragma comment(lib, "SmartWinU.lib") # endif #else # ifdef _DEBUG # pragma comment(lib, "SmartWinD.lib") # else # pragma comment(lib, "SmartWin.lib") # endif #endif #ifdef GCTP_LITE # pragma comment(lib, "DxErr8.lib") # pragma comment(lib, "d3d8.lib") # pragma comment(lib, "ddraw.lib") # pragma comment(lib, "dxguid.lib") #else # pragma comment(lib, "DxErr.lib") # pragma comment(lib, "d3d9.lib") # pragma comment(lib, "d3dxof.lib") # pragma comment(lib, "d2d1.lib") # pragma comment(lib, "dxguid.lib") # pragma comment(lib, "winmm.lib") # ifdef _DEBUG # pragma comment(lib, "d3dx9d.lib") # ifdef MOVIETEST # pragma comment(lib, "strmbasd.lib") # endif # else # pragma comment(lib, "d3dx9.lib") # ifdef MOVIETEST # pragma comment(lib, "strmbase.lib") # endif # endif #endif
3f1ce76ebe346a2ec56072cfa074ffac34ed57d3
7ebae5ec0378642a1d2c181184460e76c73debbd
/USACO/hopscotchb/hopscotchb/hopscotchb.cpp
3eb78f705dab35b6e60eafe80a4f0d85f304f755
[]
no_license
tonyli00000/Competition-Code
a4352b6b6835819a0f19f7f5cc67e46d2a200906
7f5767e3cb997fd15ae6f72145bcb8394f50975f
refs/heads/master
2020-06-17T23:04:10.367762
2019-12-28T22:08:25
2019-12-28T22:08:25
196,091,038
0
0
null
null
null
null
UTF-8
C++
false
false
791
cpp
hopscotchb.cpp
#include <iostream> #include <string> #include <sstream> #include <iomanip> #include <math.h> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #include <functional> #include <algorithm> using namespace std; int i, j, k; int main() { int m, n; cin >> m >> n; vector<vector<bool>>grid(m, vector<bool>(n)); vector<vector<long>>dp(m, vector<long>(n, 0)); for (i = 0; i < m; i++){ for (j = 0; j < n; j++){ char c; cin >> c; if (c == 'R')grid[i][j] = 0; else grid[i][j] = 1; } } dp[0][0] = 1; for (i = 0; i < m; i++){ for (j = 0; j < n; j++){ for (k = i + 1; k < m; k++){ for (int l = j + 1; l < n; l++){ if (grid[i][j] != grid[k][l])dp[k][l] += dp[i][j]; } } } } cout << dp[m - 1][n - 1] << "\n"; return 0; }
95191b830c363500f5371231f88b82e8940363e5
7d54d4cc22d94228cd32a3fcf488aa37740d4fdc
/ejemplos/monedas.cpp
46c4ee9881c043ec57829b3a073879e709a87974
[]
no_license
justomiguel/acm-problems
69c519aa2c6dbc6ca923ebea5b4a77a73e8b8487
b7e778d568ad6b9860ad9a5ffb00b3424ba7ea93
refs/heads/master
2020-05-18T10:40:26.256274
2013-11-25T00:55:09
2013-11-25T00:55:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
441
cpp
monedas.cpp
#include <stdio.h> #include <cmath> #include <stdlib.h> #include <algorithm> using namespace std; int m[5000]; int monedas[] = {1,5,10,25,50,100}; int calculoMin(int t){ if(m[t] != -1) return m[t]; m[t] = t; for(int i = 0;i < 6;++i){ if(t-monedas[i]>=0) m[t] = min(m[t],calculoMin(t-monedas[i])+1); } return m[t]; } int main(){ int q; scanf("%d",&q); for(int i = 0;i < 5000;++i) m[i] = -1; printf("%d\n",calculoMin(q)); }
b2c27bc31ef5c9f606dee60eac23a9942c2a759e
bb90a8863868804cffa567524abdbc79b5661f3f
/pion.h
bb164ef905f174e74b16ed683fd9ed4a0a461941
[]
no_license
karolinasea/jeu_dame_qt
7947d7fce7669f5a6dbb32b1e6ceeff0882ad066
d9f1e57831c3e365f58cab9f1f3de65b7eadc8c7
refs/heads/master
2020-05-21T15:47:26.986530
2019-06-05T18:11:12
2019-06-05T18:11:12
186,099,950
0
0
null
2019-05-11T07:08:38
2019-05-11T07:08:37
null
UTF-8
C++
false
false
1,051
h
pion.h
#ifndef PION_H #define PION_H #include <QGraphicsPixmapItem> #include <QGraphicsSceneMouseEvent> #include "enumCouleur.h" //#include "listecoups.h" #include "generateur.h" class generateur; class Boite; class Pion : public QGraphicsPixmapItem { public: Pion(Couleur team, QGraphicsItem *parent = nullptr); void moves(); void conversionDame(); void mousePressEvent(QGraphicsSceneMouseEvent *event); void setCurrentBoite(Boite *box); Boite *getCurrentBoite() ; QList <Boite *> boitePionEnnemi; QList <Boite *> location; Couleur getSide() ; void setSide( Couleur value); bool getIsPlaced() ; void setIsPlaced(bool value); QList <Boite *> getLocation(); QList <Boite *> getEnnemis(); void decolor(); bool boxSetting(Boite *box); generateur *gene; bool isDame; private: Boite *currentBox; Couleur side; bool isPlaced; //QList <Boite *> boitePionEnnemi; //QList <Boite *> location; }; #endif // PION_H
9e1380bfc5a6de2aa098fbf837418993d56a1411
e162bec7df809f1852949b64a4323bec6f83f663
/dynamic-programming/intermediate-problems/ways-to-arrange-balls-such-that-adjacent-balls-are-of-different-types.cpp
8200ad6d771212360b415257135626b30c61c51a
[]
no_license
tssavita/geeksforgeeks_topicwise_practice
be95383e0a9d41e702b255355fa193ed47d68928
ecf1fd638085c9af5d128d477d9a9617f00b7ca1
refs/heads/master
2021-04-27T06:13:24.280356
2018-05-01T18:47:11
2018-05-01T18:47:11
122,608,820
1
0
null
null
null
null
UTF-8
C++
false
false
834
cpp
ways-to-arrange-balls-such-that-adjacent-balls-are-of-different-types.cpp
#include <iostream> using namespace std; int count_util(int p, int q, int r, int last) { if (p < 0 || q < 0 || r < 0) return 0; if (p == 1 && q == 0 && r == 0 && last == 0) return 1; if (p == 0 && q == 1 && r == 0 && last == 1) return 1; if (p == 0 && q == 0 && r == 1 && last == 2) return 1; if (last == 0) return count_util(p-1, q, r, 1) + count_util(p-1, q, r, 2); if (last == 1) return count_util(p, q-1, r, 0) + count_util(p, q-1, r, 2); if (last == 2) return count_util(p, q, r-1, 0) + count_util(p, q, r-1, 1); } int count(int p, int q, int r) { return count_util(p, q, r, 0) + count_util(p, q, r, 1) + count_util(p, q, r, 2); } int main(int argc, char ** argv) { int p, q, r; cin>>p>>q>>r; cout << count(p, q, r); }
9af240a5ecc8f8da48c921bb5481ab0833898659
732fcfdfa15d41a906b7b7e90d85dce8cc834ffd
/src/Topic.cpp
c48cdee49b878aba906a2b0f14cfff1eb31ba225
[]
no_license
PhanDongQuang/Exercise
c5daa2d447c278688b5170184e3cf3533f269e2a
270136582b8fa93344a4a3a3cc46f9fba646913f
refs/heads/master
2021-03-17T04:14:10.280196
2020-03-13T00:40:24
2020-03-13T00:40:24
246,958,311
0
0
null
null
null
null
UTF-8
C++
false
false
1,363
cpp
Topic.cpp
/* * Topic.cpp * * Created on: May 7, 2019 * Author: puq81hc */ #include "Topic.h" //............. #include <iostream> Topic::Topic() { m_shutDown = false; } void Topic::registerClient(int clientFD) { std::list<int>::iterator findIter = std::find(clients.begin(), clients.end(), clientFD); if(findIter == clients.end()){ clients.push_back(clientFD); } } void Topic::notifyClient() { // Message mess(" "," "); while(true){ std::unique_lock<std::mutex> lock(m_mutex); m_cv.wait(lock, [this]{return !messageQueue.empty() || m_shutDown;}); if(m_shutDown){ break; } std::string message = messageQueue.front().first; int clientFD = messageQueue.front().second; messageQueue.pop_front(); lock.unlock(); for(auto m_clientFD : clients ){ if(m_clientFD != clientFD) { // send(m_clientFD, &message, sizeof(message),0); } } } } void Topic::addMessage(std::string message,int clientFD) { std::lock_guard<std::mutex> guard(m_mutex); messageQueue.push_back({message,clientFD}); m_cv.notify_one(); } Topic::~Topic() { shutDownTopic(); messageQueue.clear(); clients.clear(); } void Topic::shutDownTopic() { std::lock_guard<std::mutex> guard(m_mutex); m_shutDown = true; m_cv.notify_one(); }
6819a68eef760031190e69627155d0495483323f
da3f57c47bb64a84146e0c561be67d6c7244551f
/codechef/FebruaryChallenge16/two_lines.cpp
8d699562b27c4482ba1665e47cac2d7e24bad02c
[]
no_license
hieule22/contests
ccd09dcccc596401d86e61e7879f4d4f42f8a59f
ef3d33fffd031c6b56f11b29b884005ae23a7b21
refs/heads/master
2020-04-06T23:58:44.103522
2017-11-12T21:07:07
2017-11-12T21:07:07
54,355,631
1
0
null
null
null
null
UTF-8
C++
false
false
2,153
cpp
two_lines.cpp
#include <iostream> #include <vector> #include <unordered_map> #include <algorithm> using namespace std; class MySorter { public: bool operator() (const pair<int, int> lhs, const pair<int, int> rhs) { return lhs.second > rhs.second; } } sorter; int main() { ios_base::sync_with_stdio(false); int t, n, m; cin >> t; for (int tt = 0; tt < t; tt++) { cin >> n >> m; unordered_map<int, vector<pair<int, int> > > row_num; unordered_map<int, vector<pair<int, int> > > col_num; int a[n][m], num; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; num = a[i][j]; if (row_num.find(num) == row_num.end()) { row_num[num].push_back(make_pair(i, 1)); } else { auto & last = row_num[num].back(); if (last.first == i) last.second++; else row_num[num].push_back(make_pair(i, 1)); } } } for (int j = 0; j < m; j++) { for (int i = 0; i < n; i++) { num = a[i][j]; if (col_num.find(num) == col_num.end()) { col_num[num].push_back(make_pair(j, 1)); } else { auto & last = col_num[num].back(); if (last.first == j) last.second++; else col_num[num].push_back(make_pair(j, 1)); } } } for (auto & entry : row_num) sort(entry.second.begin(), entry.second.end(), sorter); for (auto & entry : col_num) sort(entry.second.begin(), entry.second.end(), sorter); int result = 0; for (auto & row : row_num) { int value = row.first; if (col_num.find(value) == col_num.end()) { result = max(result, row.second[0].second); continue; } int expected = row.second[0].second + col_num[value][0].second; bool overlap = true; for (auto & entry : row.second) { if (entry.second != row.second[0].second) break; for (auto & col : col_num[value]) { if (col.second != col_num[value][0].second) break; if (a[entry.first][col.first] != value) { overlap = false; break; } } if (!overlap) break; } if (overlap) result = max(result, expected - 1); else result = max(result, expected); } cout << result << endl; } }
bd8c964f0fd263d30d3f7f51d89569d54b52c18d
f1a89ead25b31c4ffacbabb02adfc9e64bfd7da9
/test/main.cpp
a1e33f3ae8de812fcfb7a20011240ddb594f62f3
[]
no_license
M3rs/ogle
a5aa09fbd2c548317f2f4ca446fa486e7ce0571d
4ebc42e68c2bb08eedcc8722a0353c3c95fe8085
refs/heads/master
2021-09-09T19:16:02.141478
2018-03-19T05:29:27
2018-03-19T05:29:27
104,819,836
0
0
null
null
null
null
UTF-8
C++
false
false
1,002
cpp
main.cpp
#include <iostream> #include <vector> #include <string> #include "sol.hpp" struct Vec { float x; float y; float z; Vec() : x(0.0f), y(0.0f), z(0.0f) {} Vec(float x, float y, float z) : x(x), y(y), z(z) {} }; template<class Value> std::vector<Value> get_vector(sol::table table) { std::vector<Value> items; for (auto& iter : table) { items.push_back(iter.second.as<Value>()); } return items; } int main() { sol::state lua; lua.open_libraries(sol::lib::base, sol::lib::package); lua.new_usertype<Vec>("vec3", sol::constructors<Vec(), Vec(float, float, float)>(), "x", &Vec::x, "y", &Vec::y, "z", &Vec::z); lua.script_file("test.lua"); //lua.script_file("other.lua"); lua.script("x()"); int x = 5; int w = lua["window"]["w"]; int h = lua["window"]["h"]; std::cout << w << ", " << h << std::endl; auto names = get_vector<std::string>(lua["items"]); auto items = get_vector<float>(lua["vertices"]); }
fc94a192e4563b01adbab1ae5a7d8675583c0814
dfc054679ffcdefa9da6170f6fe2d8f62ec91865
/Exams/03_VP.cpp
9d7f85c426bfc6e06d6e7f172ea3793f368f67a5
[]
no_license
truongtan29602/C-Introduction-To-Programing
0658b7975b8f29033d6784b64c1033964e87782c
2ed57a50be3c6c7331445d0fd64fcfb502f46584
refs/heads/main
2023-01-22T12:56:06.298094
2020-11-20T09:17:35
2020-11-20T09:17:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
283
cpp
03_VP.cpp
#include <iostream> using namespace std; int main () { int x; cout << "Nhap x: "; cin >> x; int count = 0; double thickness = 0.1; while (thickness < x*10) { thickness *= 2; count++; } cout << "So lan can gap doi la: " << count; return 0; }
7e3c4994aed4db30518d3c4ad8224a71bc44a53a
f65a120148b1e1ca72f900684598e1d95781e0ec
/source/MetaData/MetaDataModel.h
4ab5f4bc41bf703f6202015368a4fec61aa56af1
[]
no_license
mandlm/ESGRAF48
a5e194263f693b3a9aa52abe32437ac46f335603
c438d96668118b99ab8c06dad07bf1ffad7cddb6
refs/heads/master
2020-03-16T19:58:37.783473
2019-02-17T18:50:07
2019-02-17T18:50:07
132,940,863
0
0
null
2019-10-05T14:14:52
2018-05-10T18:41:17
C++
UTF-8
C++
false
false
950
h
MetaDataModel.h
#pragma once #include "PrintableModel.h" #include "Age.h" #include "MetaDataModel.pb.h" #include <QAbstractTableModel> #include <QString> #include <QDate> class MetaDataModel : public PrintableModel { Q_OBJECT private: QString m_participant; QString m_instructor; QDate m_dateOfBirth; QDate m_dateOfTest; QString m_remarks; public: MetaDataModel(QObject *parent); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; void read(const ESGRAF48::MetaDataModel &model); void write(ESGRAF48::MetaDataModel &model) const; void printTo(QPainter &painter) const override; Age getAge() const; };
048d30a4512ba053ad2eeeb2d10d2761649026ba
089c787f663a7e98f54cea93af60534276363934
/Online Judge problems solving/Categorized Problems Solving/Game Theory/LightOj 1247 - Matrix Game.cpp
b6acdf6e06f44a040c390950b0647dbae64ef091
[]
no_license
delower-hosen/Competitive-Programming
a723e6b4bccdb62b22be5794781b0c4319c86cc4
79869ffe451234f0feb00be10176b7de7fa3632f
refs/heads/master
2022-12-16T00:09:37.866203
2020-09-13T18:42:06
2020-09-13T18:42:06
295,212,924
0
0
null
null
null
null
UTF-8
C++
false
false
502
cpp
LightOj 1247 - Matrix Game.cpp
#include<bits/stdc++.h> using namespace std; int main() { int r,c,xorsum,sum,a,tc,cs=0; scanf("%d",&tc); while(tc--){ scanf("%d%d",&r,&c); for(int i=0;i<r;i++){ sum=0; for(int j=0;j<c;j++){ scanf("%d",&a); sum+=a; } if(i==0)xorsum=sum; else xorsum^=sum; } if(xorsum) printf("Case %d: Alice\n",++cs); else printf("Case %d: Bob\n",++cs); } return 0; }
e65c8816471d640eff2366a39b9bab632aab380f
963265958c4a407becd166dc5a252ad17b5cebf3
/playground/qmltube/vimeo.h
c8796d22fe77fb993cea2d99df2f922931b286da
[]
no_license
cuiboand1/ytd-meego
2c0f47f64d4face6258548fc2610b9fb912a5f43
1fde4b0fad4a25b9665defed7cf96f00dab1c37a
refs/heads/master
2016-09-06T19:36:32.010807
2011-08-29T00:26:56
2011-08-29T00:26:56
40,462,369
0
0
null
null
null
null
UTF-8
C++
false
false
3,025
h
vimeo.h
#ifndef VIMEO_H #define VIMEO_H #include <QObject> class QNetworkAccessManager; class QNetworkReply; class Vimeo : public QObject { Q_OBJECT Q_PROPERTY(QString currentUser READ getCurrentUser NOTIFY currentUserChanged) Q_PROPERTY(QString accessToken READ getAccessToken NOTIFY accessTokenChanged) Q_PROPERTY(QString tokenSecret READ getTokenSecret NOTIFY tokenSecretChanged) Q_PROPERTY(QString clientId READ getClientId NOTIFY clientIdChanged) Q_PROPERTY(QString clientSecret READ getClientSecret NOTIFY clientSecretChanged) public: explicit Vimeo(QObject *parent = 0); void setNetworkAccessManager(QNetworkAccessManager *manager); QString getCurrentUser() const { return currentUser; } QString getAccessToken() const { return accessToken; } QString getTokenSecret() const { return tokenSecret; } QString getClientId() const { return clientId; } QString getClientSecret() const { return clientSecret; } public slots: void setUserCredentials(const QString &user, const QString &token, const QString &secret); void getVideoUrl(const QString &id); void addToFavourites(const QString &url, const QString &header); void deleteFromFavourites(const QString &url, const QString &header); void addToPlaylist(const QString &url, const QString &header); void deleteFromPlaylist(const QString &url, const QString &header); void createNewPlaylist(const QString &url, const QString &header); void deletePlaylist(const QString &url, const QString &header); void subscribeToChannel(const QString &url, const QString &header); void unsubscribeToChannel(const QString &url, const QString &header); void addComment(const QString &url, const QString &header); private slots: void setCurrentUser(const QString &user); void setAccessToken(const QString &token); void setTokenSecret(const QString &secret); void postRequest(const QString &url, const QString &header); void deleteRequest(const QString &url, const QString &header); void postFinished(); void parseVideoPage(); void checkVideoUrl(); private: QNetworkAccessManager *nam; QString clientId; QString clientSecret; QString accessToken; QString tokenSecret; QString currentUser; signals: void gotVideoUrl(const QString &videoUrl); void videoUrlError(); void alert(const QString &message); void currentUserChanged(); void accessTokenChanged(); void tokenSecretChanged(); void clientIdChanged(); void clientSecretChanged(); void addedToFavourites(); void deletedFromFavourites(); void addedToPlaylist(); void deletedFromPlaylist(); void playlistCreated(); void playlistDeleted(); void subscribed(); void unsubscribed(); void commentAdded(); void postSuccessful(); void postFailed(); }; #endif // VIMEO_H
4d36ca86a2705f6a83a6c3c7ab5b34fce7b92387
56987a49f6f9a3d468672450cbc9422633ccc737
/BASIC_GL_ENGINE/FreeCamera.h
edd21d66880104a3ba9c27c0e5a04e0d59b67262
[]
no_license
JeanPhilippeKernel/BASIC_GL_ENGINE
52b8214361469aee1fc6ee7042bb0c2de60a2862
e983c643dfa35e9587916b9f907a0c8ef979103b
refs/heads/master
2020-07-22T11:52:45.432238
2019-11-25T17:29:06
2019-11-25T17:29:06
207,192,269
3
1
null
null
null
null
UTF-8
C++
false
false
183
h
FreeCamera.h
#pragma once #include "Camera.h" class FreeCamera : public Camera { public: FreeCamera(glm::vec3 position, glm::vec3 target, glm::vec3 up); virtual ~FreeCamera() = default; };
36650b647bc405db25d8f3a4bc908b8d732a86b9
0590c0321e026151f8939c64fc30dd5cc357b99b
/data structure/sparse-table.cpp
c75583ecca8f1fc4bb36ab46e7e18632256ce38d
[]
no_license
grsu-acm-icpc/acm-notebook
a6aca147c370c5d93764053674e4d6e5e6abc140
dbda4d7c2ab28532043010b538451275cd950a43
refs/heads/master
2020-09-05T23:04:25.636423
2016-08-27T13:16:24
2016-08-27T13:16:24
66,481,988
0
0
null
2016-08-27T13:16:24
2016-08-24T16:46:38
C++
UTF-8
C++
false
false
2,816
cpp
sparse-table.cpp
#include <bits/stdc++.h> #include <ctime> using namespace std; typedef long long ll; typedef double db; typedef long double ldb; typedef string str; typedef pair <int, int> pii; typedef vector <int> vi; typedef set <int> si; typedef map <int, int> mii; typedef pair <double, double> pdd; typedef pair <ll, ll> pll; #define fi first #define se second #define space ' ' #define enter endl #define forn(i, n) for(int i = 0; i < n; ++i) #define INF 1e+9 #define EPS 1e-9 #define PI 3.1415926535897932384626433832795 #define mp(a, b) make_pair(a, b) #define pb(a) push_back(a) #define X first #define Y second #define ms(x) memset(x, 0, sizeof(x)) #define ms1(x) memset(x, -1, sizeof(x)) #define sz(x) ( (int) x.size() ) #define len(x) ( (int) x.length() ) #define ALL(x) x.begin(), x.end() template <typename T> T gcd (T a, T b) { return b ? gcd(b, a % b) : a; } const int MAXN = 100500; char memory[MAXN * 300], *pointer = memory; void *operator new (size_t c) { void *ans = pointer; pointer += c; return ans; } void operator delete (void *p) { } struct sparse_table { vector<vector<int> > table; vector<int> pows; int getSize(int size) { int res = 0; while((1 << res) < size) res++; return res; } sparse_table(vector<int> &arr, int inf) { int n = sz(arr); int lg2 = getSize(sz(arr)); table = vector<vector<int> > (lg2 + 1, vector<int>(sz(arr), inf)); pows = vector<int> (1 << (lg2 + 1)); forn(i, sz(arr)) table[0][i] = arr[i]; for(int i = 0; i < lg2 - 1; ++i) { for(int j = 0; j < n; ++j) { int l = j, r = j + (1 << i); if (r >= n) r = l; table[i + 1][j] = max(table[i][l], table[i][r]); } } for(int i = 1; i < sz(pows); ++i) { pows[i] = pows[i - 1]; if ((1 << pows[i]) * 2 < i) pows[i]++; } } int query(int l, int r) { int lg2 = pows[r - l + 1]; return max(table[lg2][l], table[lg2][r - (1 << lg2) + 1]); } }; void solve () { int n; scanf("%d", &n); vector<int> arr(n); forn(iter, n) scanf("%d", &arr[iter]); sparse_table table = sparse_table(arr, 0); ll m, r, R; cin >> m >> r >> R; ll ans = 0; forn(iter, m) { ll H = table.query(r, R); ans += H; r = (r * H + H * H); if (r >= n) r %= n; if (r > R) swap(r, R); } cout << ans << endl; } int main() { #ifdef _DEBUG freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #else freopen("mushrooms.in", "r", stdin); freopen("mushrooms.out", "w", stdout); #endif solve(); #ifdef _DEBUG cout << fixed << setprecision(15) << clock() * 1. / CLOCKS_PER_SEC; #endif return 0; }
375abb8c37d3e2570b20f962e7a53a57104800df
9969fd8a7b4d1772f47ac744e47442bbb0499b5c
/src/scenario/pathloss/Pathloss.hpp
36c1e12bec6dcaf71c4ab1dc035fcd4946cb652e
[]
no_license
openwns/rise
d10822b4866d1c2ed05321727e95666dad9da531
72e07bbd0f6184ac3d8ddd7857550838ee7b0a0c
refs/heads/master
2021-01-20T12:41:49.675861
2013-12-06T11:35:24
2013-12-06T11:35:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,702
hpp
Pathloss.hpp
/******************************************************************************* * This file is part of openWNS (open Wireless Network Simulator) * _____________________________________________________________________________ * * Copyright (C) 2004-2007 * Chair of Communication Networks (ComNets) * Kopernikusstr. 5, D-52074 Aachen, Germany * phone: ++49-241-80-27910, * fax: ++49-241-80-22242 * email: info@openwns.org * www: http://www.openwns.org * _____________________________________________________________________________ * * openWNS is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License version 2 as published by the * Free Software Foundation; * * openWNS 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ #ifndef _RISE_SCENARIO_PATHLOSS_PATHLOSS_HPP #define _RISE_SCENARIO_PATHLOSS_PATHLOSS_HPP #include <RISE/antenna/Antenna.hpp> #include <RISE/scenario/PropagationModel.hpp> #include <WNS/PowerRatio.hpp> #include <WNS/Types.hpp> #include <WNS/Functor.hpp> namespace rise { namespace scenario { namespace pathloss { static const wns::Ratio OutOfRangePathloss = wns::Ratio::from_dB(500); /** * @brief Base class for all pathloss models. * * Pathloss models are expected to either derive from * DistanceDependent or DistanceIndependent. */ class Pathloss : public rise::scenario::PropagationModel { friend class RangeChecked; public: /** * @brief Interface for return value transformations. * * Classes deriving from pathloss must provide a return * value transformation. The value calculated by the * pathloss model can be further transformed. E.g. a minimal * pathloss can be guaranteed, but return value transformations * are of course not limited to such simple implementations. */ typedef wns::ArgumentFunctor<const wns::Ratio&, wns::Ratio> ReturnValueTransformation; /** * @brief Return the pathloss between source and target at frequency. */ wns::Ratio getPathloss(const antenna::Antenna& source, const antenna::Antenna& target, const wns::Frequency& frequency) const; virtual ~Pathloss(); virtual void onWorldCreated(){}; protected: Pathloss(const ReturnValueTransformation* rvt); /** * @brief Pathloss calculation function for models not dependent on the * distance of source and target. * * For models dependent on the distance DistanceDepedent will provide * an implementation of this method. */ virtual wns::Ratio calculatePathloss(const antenna::Antenna& source, const antenna::Antenna& target, const wns::Frequency& frequency) const = 0; /** * @brief Pathloss calculation function for models dependent on the * distance of source and target. * * For models not dependent on the distance DistanceIndependent will provide * an implementation of this method. */ virtual wns::Ratio calculatePathloss(const antenna::Antenna& source, const antenna::Antenna& target, const wns::Frequency& frequency, const wns::Distance& distance) const = 0; private: const ReturnValueTransformation* transform; }; }}} #endif // NOT defined _RISE_SCENARIO_PATHLOSS_PATHLOSS_HPP
d1fea2021d318ded2a86d3ce7816e05b4b16cfd3
b63b0d18e98e1ca0302aaaa37af21ac1a9b09afb
/src/nameserver/test/raft_test.cc
397cb68c0f20298922e7925116836520c57f8213
[ "BSD-3-Clause" ]
permissive
armsword/bfs
fd3340c4d94d35d86515e9517e1a536576890e9b
fe5d642c75e735b4e088454633dadc564a2fce55
refs/heads/master
2021-01-12T11:24:06.376585
2016-11-07T05:41:14
2016-11-07T05:41:14
72,910,889
2
0
null
2016-11-05T07:09:41
2016-11-05T07:09:40
null
UTF-8
C++
false
false
3,905
cc
raft_test.cc
// Copyright (c) 2016, Baidu.com, Inc. All Rights Reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // Author: yanshiguang02@baidu.com #include <stdio.h> #include <functional> #include <sofa/pbrpc/pbrpc.h> #include <gflags/gflags.h> #include <common/logging.h> #include <common/string_util.h> #include "nameserver/raft_node.h" DEFINE_string(raft_nodes, "127.0.0.1:8828,127.0.0.1:8829", "Nameserver cluster addresses"); DECLARE_string(flagfile); DECLARE_string(nameserver_nodes); DECLARE_int32(node_index); DECLARE_int32(nameserver_log_level); DECLARE_string(nameserver_logfile); DECLARE_string(nameserver_warninglog); DECLARE_string(bfs_log); DECLARE_int32(bfs_log_size); DECLARE_string(raftdb_path); namespace baidu { namespace bfs { class RaftTest { public: RaftTest(RaftNodeImpl* raft_node) : raft_node_(raft_node), applied_index_(0) { } void LogCallback(const std::string& log) { int t = 0; for (uint32_t i = 9; i < log.size(); i++) { t *= 10; t += log[i] - '0'; } LOG(INFO, "[LogCallback] %d %s", t, log.c_str()); applied_index_ = t; } void Run() { std::string leader; std::vector<std::string> nodes; common::SplitString(FLAGS_nameserver_nodes, ",", &nodes); if (static_cast<int64_t>(nodes.size()) < FLAGS_node_index) { LOG(WARNING, "Load nameserver nodes fail"); return; } std::string self = nodes[FLAGS_node_index]; raft_node_->Init(std::bind(&RaftTest::LogCallback, this, _1)); while (applied_index_ < 10000) { if (raft_node_->GetLeader(&leader) && leader == self) { applied_index_ ++; char buf[64]; snprintf(buf, sizeof(buf), "LogEntry-%05ld", applied_index_); bool ret = raft_node_->AppendLog(buf); LOG(INFO, "[RaftTest] Append log: \"%s\" return %d", buf, ret); } else { LOG(INFO, "[RaftTest] Leader is %s", leader.c_str()); } sleep(1); } } private: RaftNodeImpl* raft_node_; int64_t applied_index_; }; } } int main(int argc, char* argv[]) { FLAGS_flagfile = "./bfs.flag"; ::google::ParseCommandLineFlags(&argc, &argv, false); if (FLAGS_bfs_log != "") { baidu::common::SetLogFile(FLAGS_bfs_log.c_str()); baidu::common::SetLogSize(FLAGS_bfs_log_size); } ::baidu::common::SetLogLevel(FLAGS_nameserver_log_level); ::baidu::common::SetWarningFile(FLAGS_nameserver_warninglog.c_str()); LOG(baidu::common::INFO, "NameServer start ..."); // Service baidu::bfs::RaftNodeImpl* raft_service = new baidu::bfs::RaftNodeImpl(FLAGS_raft_nodes, FLAGS_node_index, FLAGS_raftdb_path); // rpc_server sofa::pbrpc::RpcServerOptions options; sofa::pbrpc::RpcServer rpc_server(options); // Register if (!rpc_server.RegisterService(raft_service)) { return EXIT_FAILURE; } // Start std::vector<std::string> nameserver_nodes; baidu::common::SplitString(FLAGS_nameserver_nodes, ",", &nameserver_nodes); if (static_cast<int>(nameserver_nodes.size()) <= FLAGS_node_index) { LOG(baidu::common::FATAL, "Bad nodes or index: %s, %d", FLAGS_nameserver_nodes.c_str(), FLAGS_node_index); return EXIT_FAILURE; } std::string server_addr = nameserver_nodes[FLAGS_node_index]; std::string listen_addr = std::string("0.0.0.0") + server_addr.substr(server_addr.rfind(':')); if (!rpc_server.Start(server_addr)) { return EXIT_FAILURE; } baidu::bfs::RaftTest test(raft_service); test.Run(); //delete webservice; LOG(baidu::common::WARNING, "Nameserver exit"); return EXIT_SUCCESS; } /* vim: set expandtab ts=4 sw=4 sts=4 tw=100: */
53e851b9c31c48efe7ab17583c08323e82021710
7e9576bf84010a115152564f9af6de5e597c016b
/emulatorbase/Logger.cpp
502377368fafad312f0b755b79cb1c44407c0687
[ "MIT" ]
permissive
hotkeysoft/pfe_8085basic
9b17fd5e664db1996de0be077ba2f74ef8ccd8c7
b8a669d3d3358250e292d13e78768e80dbfad7fd
refs/heads/master
2022-11-26T21:52:49.060411
2020-07-11T20:21:00
2020-07-11T20:21:00
275,280,990
3
0
null
null
null
null
UTF-8
C++
false
false
1,569
cpp
Logger.cpp
#include "Logger.h" #include <stdio.h> #include <string.h> #include <stdarg.h> #include <exception> void(*Logger::m_logCallbackFunc)(const char *str); char Logger::m_logBuffer[1024]; Logger::ModuleList Logger::m_moduleList; Logger::Logger(const char* moduleID) : m_moduleID(moduleID), m_enabled(true) { RegisterModuleID(moduleID); } Logger::~Logger() { } void Logger::RegisterModuleID(const char* moduleID) { if (moduleID == nullptr) { throw std::exception("Logger: ModuleID is null"); } if (m_moduleList.find(moduleID) != m_moduleList.end()) { throw std::exception("ModuleID already defined"); } m_moduleList[moduleID] = this; } void Logger::EnableLog(bool enable) { m_enabled = enable; } void Logger::RegisterLogCallback(void(*logCallbackFunc)(const char *)) { m_logCallbackFunc = logCallbackFunc; } void Logger::LogPrintf(SEVERITY sev, const char *msg, ...) { if (!m_enabled) return; va_list args; va_start(args, msg); m_logBuffer[0] = 0; char* pos = m_logBuffer + sprintf(m_logBuffer, "[%s]", m_moduleID.c_str()); switch (sev) { case LOG_INFO: pos = strcat(m_logBuffer, "[INFO]") + 6; break; case LOG_WARNING: pos = strcat(m_logBuffer, "[WARN]") + 6; break; case LOG_ERROR: pos = strcat(m_logBuffer, "[ERR]") + 5; break; } vsprintf(pos, msg, args); va_end(args); strcat(m_logBuffer, "\n"); if (m_logCallbackFunc) { m_logCallbackFunc(m_logBuffer); } if (sev == LOG_ERROR) { throw std::exception(m_logBuffer); } }
f55c5c475e4f71bf10bb5389947d90ab5399132c
cd45a5a20de51f9e2e829a027045e927e63e4c16
/apps/wrf2vdc/wrf2vdc.cpp
3e719f618c644914e551a1e00a010cac86076224
[]
no_license
StasJ/vapor-formatted
b98f55c6528827122bf191c72be5a2165253d1cc
9fad47d88714ef835b78f6c1dd855d66b6aa90da
refs/heads/master
2022-12-05T22:29:23.048696
2020-08-13T21:05:11
2020-08-13T21:05:11
287,616,510
0
0
null
null
null
null
UTF-8
C++
false
false
4,367
cpp
wrf2vdc.cpp
#include <fstream> #include <iostream> #include <sstream> #include <string.h> #include <vector> #include <vapor/CFuncs.h> #include <vapor/DCWRF.h> #include <vapor/FileUtils.h> #include <vapor/OptionParser.h> #include <vapor/VDCNetCDF.h> using namespace Wasp; using namespace VAPoR; struct opt_t { int nthreads; int numts; std::vector<string> vars; std::vector<string> xvars; OptionParser::Boolean_T help; } opt; OptionParser::OptDescRec_T set_opts[] = { {"nthreads", 1, "0", "Specify number of execution threads " "0 => use number of cores"}, {"numts", 1, "-1", "Number of timesteps to be included in the VDC. Default (-1) includes all timesteps."}, {"vars", 1, "", "Colon delimited list of variable names " "to be copied to the VDC"}, {"xvars", 1, "", "Colon delimited list of variable names " "to exclude from copying the VDC"}, {"help", 0, "", "Print this message and exit"}, {NULL}}; OptionParser::Option_T get_options[] = { {"nthreads", Wasp::CvtToInt, &opt.nthreads, sizeof(opt.nthreads)}, {"numts", Wasp::CvtToInt, &opt.numts, sizeof(opt.numts)}, {"vars", Wasp::CvtToStrVec, &opt.vars, sizeof(opt.vars)}, {"xvars", Wasp::CvtToStrVec, &opt.xvars, sizeof(opt.xvars)}, {"help", Wasp::CvtToBoolean, &opt.help, sizeof(opt.help)}, {NULL}}; // Return a new vector containing elements of v1 with any elements from // v2 removed // vector<string> remove_vector(vector<string> v1, vector<string> v2) { vector<string> newvec; for (auto it = v1.begin(); it != v1.end(); ++it) { if (find(v2.begin(), v2.end(), *it) == v2.end()) { newvec.push_back(*it); } } return (newvec); } string ProgName; int main(int argc, char **argv) { OptionParser op; MyBase::SetErrMsgFilePtr(stderr); // // Parse command line arguments // ProgName = FileUtils::LegacyBasename(argv[0]); if (op.AppendOptions(set_opts) < 0) { return (1); } if (op.ParseOptions(&argc, argv, get_options) < 0) { return (1); } if (argc < 3) { cerr << "Usage: " << ProgName << " wrffiles... master.vdc" << endl; op.PrintOptionHelp(stderr, 80, false); return (1); } if (opt.help) { cerr << "Usage: " << ProgName << " master.vdc" << endl; op.PrintOptionHelp(stderr, 80, false); return (0); } argc--; argv++; vector<string> wrffiles; for (int i = 0; i < argc - 1; i++) wrffiles.push_back(argv[i]); string master = argv[argc - 1]; VDCNetCDF vdc(opt.nthreads); size_t chunksize = 1024 * 1024 * 4; vector<size_t> bs; int rc = vdc.Initialize(master, vector<string>(), VDC::A, bs, chunksize); if (rc < 0) return (1); DCWRF dcwrf; rc = dcwrf.Initialize(wrffiles, vector<string>()); if (rc < 0) { return (1); } vector<string> varnames = dcwrf.GetCoordVarNames(); for (int i = 0; i < varnames.size(); i++) { int nts = dcwrf.GetNumTimeSteps(varnames[i]); nts = opt.numts != -1 && nts > opt.numts ? opt.numts : nts; VAssert(nts >= 0); cout << "Copying variable " << varnames[i] << endl; for (int ts = 0; ts < nts; ts++) { cout << " Time step " << ts << endl; int rc = vdc.CopyVar(dcwrf, ts, varnames[i], -1, -1); if (rc < 0) { MyBase::SetErrMsg("Failed to copy variable %s", varnames[i].c_str()); return (1); } } } if (opt.vars.size()) { varnames = opt.vars; } else { varnames = dcwrf.GetDataVarNames(); } varnames = remove_vector(varnames, opt.xvars); int estatus = 0; for (int i = 0; i < varnames.size(); i++) { int nts = dcwrf.GetNumTimeSteps(varnames[i]); nts = opt.numts != -1 && nts > opt.numts ? opt.numts : nts; VAssert(nts >= 0); cout << "Copying variable " << varnames[i] << endl; for (int ts = 0; ts < nts; ts++) { cout << " Time step " << ts << endl; int rc = vdc.CopyVar(dcwrf, ts, varnames[i], -1, -1); if (rc < 0) { MyBase::SetErrMsg("Failed to copy variable %s", varnames[i].c_str()); estatus = 1; } } } return estatus; }
38b0d69c0bdd5dfb0273f6100f22797b18f09a33
a3397257311767947ac482db871c14ddd27f1d4e
/ISLAND/Program/Program.cpp
9375454f9f0fcfec083b7e6c044b4a303172cb69
[]
no_license
jheun66/ISLAND
10813b414585e5abcbefe1cb452c34795a29039d
54109db38de0473a3a32f8d9298f5c36ab2f6340
refs/heads/main
2023-01-14T13:40:07.010515
2020-11-12T05:46:32
2020-11-12T05:46:32
305,555,595
1
0
null
null
null
null
UHC
C++
false
false
2,596
cpp
Program.cpp
#include "Framework.h" #include "Scene/CubeScene.h" #include "Scene/QuadScene.h" #include "Scene/TerrainScene.h" #include "Scene/QuadTreeTerrainScene.h" #include "Scene/ModelScene.h" Program::Program() { scene = new TerrainScene(); srand(time(NULL)); } Program::~Program() { delete scene; } void Program::Update() { scene->Update(); Environment::Get()->MainCamera()->Update(); Control::Get()->SetWheel(0.0f); } void Program::PreRender() { Environment::Get()->MainCamera()->VSSet(1); Environment::Get()->GetProjectionBuffer()->SetVSBuffer(2); Environment::Get()->GetLight()->SetPSBuffer(0); Environment::Get()->SetViewport(); scene->PreRender(); } void Program::Render() { // 주의) // PreRender에서 바궈 줬을 수 있으니.. 다시 세팅 Graphics::Get()->SetRenderTarget(); Environment::Get()->MainCamera()->VSSet(1); Environment::Get()->GetProjectionBuffer()->SetVSBuffer(2); Environment::Get()->GetLight()->SetPSBuffer(0); Environment::Get()->SetViewport(); scene->Render(); } void Program::PostRender() { Environment::Get()->PostRender(); scene->PostRender(); PrintInfo(); } void Program::PrintInfo() { Graphics::Get()->GUI(); ImGui::BeginMainMenuBar(); { if (ImGui::BeginMenu("Option")) { // 왼쪽에 체크박스 ImGui::Checkbox("FPS", &bFps); ImGui::Checkbox("MousePos", &bMouse); ImGui::EndMenu(); } } ImGui::EndMainMenuBar(); if (bFps) PrintFPS(); if (bMouse) PrintMousePos(); } void Program::PrintFPS() { static bool bOpen = true; //ImGui::SetNextWindowPos({ WIN_WIDTH - 100 ,15 }); ImGui::Begin("FPS" , &bOpen , ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove ); { string frame = "FPS : " + to_string((int)ImGui::GetIO().Framerate); ImGui::TextColored(ImVec4(1, 1, 1, 1), frame.c_str()); } ImGui::End(); } void Program::PrintMousePos() { static bool bOpen = true; ImGui::SetNextWindowPos({ WIN_WIDTH - 100 , 30 }); ImGui::SetNextWindowSize(ImVec2(200, 60)); ImGui::Begin("MousePos" , &bOpen , ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove ); { string x = "X : " + GameMath::to_string_with_precision(MOUSEPOS.x, 0); string y = "Y : " + GameMath::to_string_with_precision(MOUSEPOS.y, 0); ImGui::TextColored(ImVec4(1, 1, 1, 1), x.c_str()); ImGui::TextColored(ImVec4(1, 1, 1, 1), y.c_str()); } ImGui::End(); }
34461272902a82a7d7a3d20703ff902ab88e1f3e
8a1df632f92e85b910be747ec50028ac1ba1669c
/include/Exception.h
1dc68c3fd799beffa84b6de20b93ecbe4a1af843
[]
no_license
Elieu/GaussianShape
58dcd7d6425d9fff6537f852347e438a94c0fec3
f832896cbd25fdf6c76efc8225ddff53f9e36916
refs/heads/master
2020-05-03T05:12:59.941317
2012-03-06T02:15:14
2012-03-06T02:15:14
3,633,610
0
0
null
null
null
null
UTF-8
C++
false
false
4,747
h
Exception.h
/** * Exception Module * * Copyright(c) 2010 ECUST. * All Rights Reserved. * * @file Exception.h * @author Chaoqian Cai * @version v1.0 * @date 2011-02-23 */ #ifndef EXCEPTION_INCLUDE_H #define EXCEPTION_INCLUDE_H // #include <string> /** * Exception relationship map: * * CException * - CIoException * -- CBadFormatException * -- CFileOpenException * -- CIoErrorException * - CLogicException * - CRuntimeException * -- CBadCastException * -- CBufferOverflowException * -- CElementNotFoundException * -- CInvalidArgumentException * - CBusinessException */ // get direct string representation (without macro expansion) #define STR(x) #x // string conversion with macro expansion #define TO_STR(x) STR(x) // get string representation of current line number #define __LINE_STR__ TO_STR(__LINE__) // string of current location in source code #define __MY_LOCATION__ __FILE__ ": " __LINE_STR__ /* __MY_FUNCTION__ */ // for GCC #ifdef __GNUC__ // get current function name with full signature #define __MY_FUNCTION__ __PRETTY_FUNCTION__ #endif // for MS VC #ifdef _MSC_VER // get current function name with full signature #define __MY_FUNCTION__ __FUNCSIG__ #endif // for other compilers #ifndef __MY_FUNCTION__ // get current function name only #define __MY_FUNCTION__ __FUNCTION__ #endif // insert detailed location information into a stream #define LOCATION_STREAM_INSERTION __MY_LOCATION__ << ": " << __MY_FUNCTION__ << ": " /** * Description: Base class for all exceptions. */ class CException { /* data: */ public: private: // error message std::string _sErrorMessage; /* method: */ public: CException(); CException(const std::string& sErrorMessage); virtual ~CException(); const std::string& getErrorMessage() const; private: }; /** * Description: Logic error. */ class CLogicException : public CException { /* data: */ public: private: /* method: */ public: CLogicException(); CLogicException(const std::string& sErrorMessage); private: }; /** * Description: Runtime exception. */ class CRuntimeException : public CException { /* data: */ public: private: /* method: */ public: CRuntimeException(); CRuntimeException(const std::string& sErrorMessage); private: }; /** * Description: Bad cast exception. */ class CBadCastException : public CRuntimeException { /* data: */ public: private: /* method: */ public: CBadCastException(); CBadCastException(const std::string& sErrorMessage); private: }; /** * Description: Invalid argument exception. */ class CInvalidArgumentException : public CRuntimeException { /* data: */ public: private: /* method: */ public: CInvalidArgumentException(); CInvalidArgumentException(const std::string& sErrorMessage); private: }; /** * Description: Buffer overflow exception. */ class CBufferOverflowException : public CRuntimeException { /* data: */ public: private: /* method: */ public: CBufferOverflowException(); CBufferOverflowException(const std::string& sErrorMessage); private: }; class CElementNotFoundException : public CRuntimeException { /* data: */ public: private: /* method: */ public: CElementNotFoundException(); CElementNotFoundException(const std::string& sErrorMessage); private: }; /** * Description: IO exception. */ class CIoException : public CException { /* data: */ public: private: /* method: */ public: CIoException(); CIoException(const std::string& sErrorMessage); private: }; /** * Description: File open exception. */ class CFileOpenException : public CIoException { /* data: */ public: private: /* method: */ public: CFileOpenException(); CFileOpenException(const std::string& sErrorMessage); private: }; /** * Description: Bad format exception. */ class CBadFormatException : public CIoException { /* data: */ public: private: /* method: */ public: CBadFormatException(); CBadFormatException(const std::string& sErrorMessage); private: }; /** * Description: IO error exception. */ class CIoErrorException : public CIoException { /* data: */ public: private: /* method: */ public: CIoErrorException(); CIoErrorException(const std::string& sErrorMessage); private: }; /** * Description: Base class for all specific transaction related exceptions. */ class CBusinessException : public CException { /* data: */ public: private: /* method: */ public: CBusinessException(); CBusinessException(const std::string& sErrorMessage); }; // #endif
8f262fca8b8e7288d403f84da0ebfdac018b4c23
a648fcbc90606b5ac2ac3e9ee53c4a8fffcf14e4
/BattleTankOnline/BattleCity/BattleCity/Sprite.cpp
64ba64146b68f1ac464f1a4773fa30dddb6f140e
[]
no_license
vanhoaile95/OOAD-SVN
35e61569180367dbd9652e6e86a667f4bc6f174e
282fec76ce3a4baf46539e11e44343ea8b2d4036
refs/heads/master
2020-06-18T01:22:06.103481
2017-01-04T15:43:54
2017-01-04T15:43:54
74,960,984
2
0
null
null
null
null
UTF-8
C++
false
false
1,256
cpp
Sprite.cpp
#include "Sprite.h" CSprite* CSprite::Atlas1 = NULL; CSprite* CSprite::UI = NULL; CSprite::CSprite(MTexture Texture) { _Image = TextureManager::GetInstance()->Get(Texture); if (_Image == NULL) { int i = 0; i++; } } void CSprite::Draw(P pos) { if (_Image != NULL) { RECT srect; srect.left = 0; srect.top = 0; srect.right = (LONG)(srect.left + pos.X); srect.bottom = (LONG)(srect.top + pos.Y); Camera::GetInstance()->Draw(*_Image, srect,pos); } } void CSprite::FixedDraw(P pos) { if (_Image != NULL) { RECT srect; srect.left = 0; srect.top = 0; srect.right = (LONG)(srect.left + pos.X); srect.bottom = (LONG)(srect.top + pos.Y); Camera::GetInstance()->FixedDraw(*_Image, srect,pos); } } void CSprite::Draw(RECT srect, P pos) { Camera::GetInstance()->Draw(*_Image, srect, pos); } void CSprite::FixedDraw(RECT srect,P pos) { Camera::GetInstance()->FixedDraw(*_Image, srect, pos); } CSprite* CSprite::GetGlobalSpriteSheet() { if (Atlas1 == NULL) { Atlas1 = new CSprite(MTexture::TEXTURE_ATLAS_1); } else { } return Atlas1; } CSprite* CSprite::GetUISpriteSheet() { if (UI == NULL) { UI = new CSprite(MTexture::UI_TEXTURE); } return UI; }
0334a1b430fd7f60f69d1207786afeea9de884d5
b57ae0c52f025b9968736c005c09abfee92ab903
/src/X.h
6af436de642eb0b590ee0280bfccb0466e5ef238
[]
no_license
vladbataev/BigML
786b8431297cc4a4605f7f3e211ca6087b33d2b4
0ea8a34513db68cee825eb1b50cc91c7a0572612
refs/heads/master
2020-03-10T08:17:12.523791
2018-05-19T21:20:54
2018-05-19T21:20:54
129,281,720
0
0
null
2018-05-13T12:31:23
2018-04-12T16:36:56
Jupyter Notebook
UTF-8
C++
false
false
717
h
X.h
#pragma once #include "factor.h" #include <Eigen/Dense> #include <Eigen/Sparse> #include <set> #include <vector> class CachedWTransform { public: CachedWTransform(std::vector<int>); Eigen::SparseMatrix<double> operator()(size_t T, const Eigen::VectorXd& w) const; private: std::vector<std::tuple<int, int, int, int>> diffs_; std::vector<int> lags_; int m_; }; void OptimizeByX(const Eigen::MatrixXd& Y, const Eigen::MatrixXb& omega, const Eigen::MatrixXd& F, Eigen::MatrixXd& X, const CachedWTransform& transform, const Eigen::MatrixXd& W, double eta, double lambdaX, bool verify = false);
5e39d7446af91ff356d3ae87b4455ef22148304d
414d8df54ad3beef3c6af52fe31ea037aa4fc90c
/ITC Assignment 1/task 2.cpp
194501924fac8733b79e2def6a6bc6bc2c79dbf2
[]
no_license
musakhan18/ITC
4f5874cb36543c0e4e8bbc54275d5a8b3e64159e
16dbcb14b59ae3c466d85d153e0a4c58987a68c7
refs/heads/main
2023-04-04T10:29:34.303963
2021-03-30T13:31:44
2021-03-30T13:31:44
352,686,214
0
0
null
null
null
null
UTF-8
C++
false
false
347
cpp
task 2.cpp
#include<iostream> using namespace std; int main() { int a; cout << "enter a four digit number " << endl; cin >> a; if (a > 999 && a < 9999) { a = a + 8; a = a / 3; a = a % 5; a = a * 5; cout << "your result is = " << a << endl; } else { cout << "Your number not contain 4 digits" << endl; } return 0; }
3e6430f485667019b9dee2806ee0b03b4067c80f
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/wedata/src/v20210820/model/SourceFieldInfo.cpp
60c89b88c85fe53637e72fbc48a23cb7048bbd61
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp
9f5df8220eaaf72f7eaee07b2ede94f89313651f
42a76b812b81d1b52ec6a217fafc8faa135e06ca
refs/heads/master
2023-08-30T03:22:45.269556
2023-08-30T00:45:39
2023-08-30T00:45:39
188,991,963
55
37
Apache-2.0
2023-08-17T03:13:20
2019-05-28T08:56:08
C++
UTF-8
C++
false
false
5,020
cpp
SourceFieldInfo.cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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. */ #include <tencentcloud/wedata/v20210820/model/SourceFieldInfo.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Wedata::V20210820::Model; using namespace std; SourceFieldInfo::SourceFieldInfo() : m_fieldNameHasBeenSet(false), m_fieldTypeHasBeenSet(false), m_aliasHasBeenSet(false), m_commentHasBeenSet(false) { } CoreInternalOutcome SourceFieldInfo::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("FieldName") && !value["FieldName"].IsNull()) { if (!value["FieldName"].IsString()) { return CoreInternalOutcome(Core::Error("response `SourceFieldInfo.FieldName` IsString=false incorrectly").SetRequestId(requestId)); } m_fieldName = string(value["FieldName"].GetString()); m_fieldNameHasBeenSet = true; } if (value.HasMember("FieldType") && !value["FieldType"].IsNull()) { if (!value["FieldType"].IsString()) { return CoreInternalOutcome(Core::Error("response `SourceFieldInfo.FieldType` IsString=false incorrectly").SetRequestId(requestId)); } m_fieldType = string(value["FieldType"].GetString()); m_fieldTypeHasBeenSet = true; } if (value.HasMember("Alias") && !value["Alias"].IsNull()) { if (!value["Alias"].IsString()) { return CoreInternalOutcome(Core::Error("response `SourceFieldInfo.Alias` IsString=false incorrectly").SetRequestId(requestId)); } m_alias = string(value["Alias"].GetString()); m_aliasHasBeenSet = true; } if (value.HasMember("Comment") && !value["Comment"].IsNull()) { if (!value["Comment"].IsString()) { return CoreInternalOutcome(Core::Error("response `SourceFieldInfo.Comment` IsString=false incorrectly").SetRequestId(requestId)); } m_comment = string(value["Comment"].GetString()); m_commentHasBeenSet = true; } return CoreInternalOutcome(true); } void SourceFieldInfo::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_fieldNameHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "FieldName"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_fieldName.c_str(), allocator).Move(), allocator); } if (m_fieldTypeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "FieldType"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_fieldType.c_str(), allocator).Move(), allocator); } if (m_aliasHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Alias"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_alias.c_str(), allocator).Move(), allocator); } if (m_commentHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Comment"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_comment.c_str(), allocator).Move(), allocator); } } string SourceFieldInfo::GetFieldName() const { return m_fieldName; } void SourceFieldInfo::SetFieldName(const string& _fieldName) { m_fieldName = _fieldName; m_fieldNameHasBeenSet = true; } bool SourceFieldInfo::FieldNameHasBeenSet() const { return m_fieldNameHasBeenSet; } string SourceFieldInfo::GetFieldType() const { return m_fieldType; } void SourceFieldInfo::SetFieldType(const string& _fieldType) { m_fieldType = _fieldType; m_fieldTypeHasBeenSet = true; } bool SourceFieldInfo::FieldTypeHasBeenSet() const { return m_fieldTypeHasBeenSet; } string SourceFieldInfo::GetAlias() const { return m_alias; } void SourceFieldInfo::SetAlias(const string& _alias) { m_alias = _alias; m_aliasHasBeenSet = true; } bool SourceFieldInfo::AliasHasBeenSet() const { return m_aliasHasBeenSet; } string SourceFieldInfo::GetComment() const { return m_comment; } void SourceFieldInfo::SetComment(const string& _comment) { m_comment = _comment; m_commentHasBeenSet = true; } bool SourceFieldInfo::CommentHasBeenSet() const { return m_commentHasBeenSet; }
d253e03462834582459fa1600572ef8f4f2f5cfd
d9ebc929c59ac57962e184da8e31febe78a06691
/src/hlct/InfoScreen.cpp
873feaf52b2f6edcd3cd24420444c5cd657e2115
[]
no_license
serkansokmen/hlct
d3ae30a3aab8f09f9ea85219611e89bfea3937c1
b88032745b9cd2bdadbc582fb244623b6fde1df7
refs/heads/master
2021-01-10T04:56:42.699518
2016-03-14T15:38:13
2016-03-14T15:38:13
53,314,755
0
0
null
null
null
null
UTF-8
C++
false
false
2,124
cpp
InfoScreen.cpp
#include "InfoScreen.h" hlct::InfoScreen::InfoScreen(){ timer = shared_ptr<ofxAnimatableFloat>(new ofxAnimatableFloat); timer->setup(); timer->setRepeatType(LOOP_BACK_AND_FORTH); timer->setCurve(LINEAR); this->msgIndex = -1; } void hlct::InfoScreen::setup(const ofRectangle& stageRect, const float& messageDuration, const ofPixels& pixels, vector<string> messages){ this->stageRect.set(stageRect); this->image.setFromPixels(pixels); for (auto msg : messages){ ofxTextBlock t; // shared_ptr<ofxSmartFont> font = ofxSmartFont::get(HLCT_INFO_SCREEN_FONT_NAME); t.init(HLCT_INFO_SCREEN_FONT_PATH, HLCT_INFO_SCREEN_FONT_SIZE); t.setText(msg); t.setColor(255, 255, 255, 255); t.wrapTextX(stageRect.getWidth()*0.65); this->texts.push_back(t); } timer->setDuration(messageDuration); timer->animateTo(messages.size()); } void hlct::InfoScreen::update(const ofRectangle& stageRect){ this->stageRect.set(stageRect); timer->update(HLCT_ANIM_UPDATE_CYCLE); int idx = (int)timer->getCurrentValue(); if (idx == texts.size() && idx != 0) { idx--; } this->msgIndex = idx; auto t = texts[msgIndex]; float imgW = image.getWidth(); float imgH = image.getHeight(); float rw = stageRect.getWidth(); float rh = stageRect.getHeight(); float tx = (rw - t.getWidth())/2; float ty = rectImage.getTop() + rectImage.getHeight(); this->rectImage.set(stageRect.getX() + (rw-imgW)/2, stageRect.getY() + (rh-imgH)/2 - 200, imgW, imgH); this->rectParagraph.set(stageRect.getX() + tx, stageRect.getY() + ty, t.getWidth(), t.getHeight()); // this->drawRect.set(tx, rectImage.getTop(), t.getWidth(), imgH + rectImage.getHeight()); } void hlct::InfoScreen::draw(){ if (this->msgIndex != -1){ image.draw(rectImage); auto t = texts[msgIndex]; t.drawCenter(rectParagraph.getCenter().x, rectImage.getBottom()); } }
7782d2114a33f5cb1c0daa70259e48ced1507ec7
3ded37602d6d303e61bff401b2682f5c2b52928c
/ml/1063/Classes/sl_layer/layer/SL_EatLayer.h
eb166f541b04f6297b0ea9c71ed280a278e8660b
[ "MIT" ]
permissive
CristinaBaby/Demo_CC
8ce532dcf016f21b442d8b05173a7d20c03d337e
6f6a7ff132e93271b8952b8da6884c3634f5cb59
refs/heads/master
2021-05-02T14:58:52.900119
2018-02-09T11:48:02
2018-02-09T11:48:02
120,727,659
0
0
null
null
null
null
UTF-8
C++
false
false
2,990
h
SL_EatLayer.h
// // SL_EatLayer.h // OreoMaker // // Created by wusonglin1// on 14-11-10. // // #ifndef __OreoMaker__SL_EatLayer__ #define __OreoMaker__SL_EatLayer__ #include <iostream> #include "cocos2d.h" #include "BaseLayer.h" #include "Global.h" #include "SL_ScribbleTouchNode.h" #include "ToolSprite.h" #include "ShadeSprite.h" #include "FileUtility.h" USING_NS_CC; using namespace std; class SL_EatLayer:public BaseLayer,public ToolSpriteDelegate,public SL_ScribbleTouchDelegate{ private: SL_EatLayer(); ~SL_EatLayer(); public: virtual bool init(); CREATE_FUNC(SL_EatLayer); public: virtual void onEnter(); virtual void onEnterTransitionDidFinish(); virtual void onExit(); public: void initUI(); void initMenu(); void onBtnCallBack(Ref* sender); virtual void showTip(); void _showTip(); void touchEvent(Ref *obj , Widget::TouchEventType type); void setRenderTexture(RenderTexture* rt){m_pRenderTexture = rt; m_pRenderTexture->setPosition(Vec2(m_pRenderTexture->getSprite()->getContentSize().width*0.5, m_pRenderTexture->getSprite()->getContentSize().height*0.5)); addChild(m_pRenderTexture);}; // virtual void onExit(); virtual void onNegativeClick(void* type); virtual void onPositiveClick(void* type); void getScribbleCallback(float ft); void _getScribbleCallback(float ft); void saveToPhoto(float ft); void _saveToPhoto(float ft); void savePic(float ft); virtual void onTouchDown(ToolSprite* toolSprite,Touch *pTouch); void addFavoriteCallback(bool isSuc); void _addFavoriteCallback(bool isSuc); void onKeyReleasedCallBack(EventKeyboard::KeyCode keyCode,Event* event); void initCup(); void ProgressTimerFunc(float dt); void DrinkMove(float dt); // void eatOver(Ref*); void eatAgain(); void onScribbleTouchOver(); void onScribbleTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); void showPhotoBg(); void hidePhotoBg(); void startTimeAction(float f); void readyAction(); void goAction(); void timeAction(); void showNomorTip(); void showTips(bool isGood); void drinkWater(float f); private: Sprite* m_pBackGround; //Sprite* m_pFavor; Sprite* m_pPlate; Sprite* m_pSpriteTip; Sprite* m_pCup1; Sprite* _cup; Sprite* _cupSprite; ToolSprite* m_pCup2; Sprite* m_pDrink; Menu* m_pUIMenu; MenuItemSprite *m_pHomeItemSprite; MenuItemSprite *m_pBackItemSprite; MenuItemSprite *m_pFavItemSprite; RenderTexture* m_pRenderTexture; RenderTexture* m_pFavoriteTexture; RenderTexture* _m_pFavoriteTexture; SL_ScribbleTouchNode* node; SL_ScribbleTouchNode* nodeBom; ProgressTimer* m_pdrink; ToolSprite* m_pEatAgain; bool m_bTouchOver; bool m_bIsTouch; string m_sPath; }; #endif /* defined(__OreoMaker__SL_EatLayer__) */
91f59696bd0c9831253356581bddf9258773b313
6ddbc5941d969596d8c06cc2bc08827db175a3a7
/parameter.h
d1ad37b72143db6f548252e85e6738452f36b4ea
[]
no_license
Emzapp/proj2
99080d14703e99bfbd0d267e3d810dc89eb49603
2d5b4638fd21d51576ec4f9fa2acc5d9f932b3f7
refs/heads/master
2023-08-17T14:01:32.240809
2021-10-02T23:36:58
2021-10-02T23:36:58
412,933,414
0
0
null
null
null
null
UTF-8
C++
false
false
201
h
parameter.h
#pragma once #include "string" using namespace std; class Parameter { public: void SetParam(string param); string ToString(); private: string theParameter; };
962affdc26a95dac7acf4a441a9a3b8fbbae91b2
e36e9d2945e51497206304e048c6f2635b575f4a
/simoh/src/Object.hpp
6094c6e4aeefda75f4d58f219a4515919b25b3fe
[ "BSD-3-Clause" ]
permissive
sirikata/sirikata
593709a8ed477d11649a2447a113f559f1cfd11a
3a0d54a8c4778ad6e25ef031d461b2bc3e264860
refs/heads/master
2023-03-07T10:06:09.815675
2015-12-13T23:07:45
2015-12-13T23:07:45
109,733
54
19
null
null
null
null
UTF-8
C++
false
false
7,508
hpp
Object.hpp
/* Sirikata * Object.hpp * * Copyright (c) 2009, Ewen Cheslack-Postava * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Sirikata nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _SIRIKATA_OBJECT_HPP_ #define _SIRIKATA_OBJECT_HPP_ #include <sirikata/core/util/Platform.hpp> #include <sirikata/core/util/SpaceID.hpp> #include <sirikata/core/network/ObjectMessage.hpp> #include <sirikata/core/util/MotionPath.hpp> #include <sirikata/core/util/SimpleExtrapolator.hpp> #include <sirikata/core/service/Service.hpp> #include <sirikata/core/network/IOTimer.hpp> #include <sirikata/core/odp/DelegateService.hpp> #include <sirikata/core/odp/SSTDecls.hpp> #include <boost/thread/shared_mutex.hpp> #include <sirikata/oh/DisconnectCodes.hpp> namespace Sirikata { /** A property shared between multiple threads. Guarantees thread safety * with a multi-reader, single writer lock. */ template<typename T> class SharedProperty { public: SharedProperty() { mutex = new boost::shared_mutex; } SharedProperty(const T& t) : data(t) { mutex = new boost::shared_mutex; } ~SharedProperty() { delete mutex; } T read() const { boost::shared_lock<boost::shared_mutex> lck(*mutex); return data; } void set(const T& t) { boost::unique_lock<boost::shared_mutex> lck(*mutex); data = t; } void operator=(const T& t) { set(t); } private: T data; boost::shared_mutex* mutex; }; // class SharedPropery typedef std::set<UUID> ObjectSet; class ObjectHostContext; class ObjectFactory; struct MaxDistUpdatePredicate { static float64 maxDist; bool operator()(const MotionVector3f& lhs, const MotionVector3f& rhs) const { return (lhs.position() - rhs.position()).length() > maxDist; } }; class Object : public Service { public: /** Standard constructor. */ Object(ObjectFactory* obj_factory, const UUID& id, MotionPath* motion, const BoundingSphere3f& bnds, bool regQuery, SolidAngle queryAngle, ObjectHostContext* ctx); ~Object(); const UUID& uuid() const { return mID; } const TimedMotionVector3f location() const; const BoundingSphere3f bounds() const; void receiveMessage(const Sirikata::Protocol::Object::ObjectMessage* msg); virtual void start(); virtual void stop(); ServerID connectedTo()const { return mConnectedTo; } bool connected(); bool send(ObjectMessagePort src_port, UUID dest, ObjectMessagePort dest_port, std::string payload); private: typedef ODPSST::Endpoint EndPointType; typedef ODPSST::BaseDatagramLayerPtr BaseDatagramLayerPtr; typedef ODPSST::StreamPtr SSTStreamPtr; typedef ODPSST::ConnectionPtr SSTConnectionPtr; // Initiate a connection void connect(); // Disconnects from the space if a connection has been established void disconnect(); void scheduleNextLocUpdate(); void handleNextLocUpdate(const TimedMotionVector3f& up); // Handlers for substreams for space-managed updates void handleLocationSubstream(int err, SSTStreamPtr s); void handleProximitySubstream(int err, SSTStreamPtr s); // Handlers for substream read events for space-managed updates void handleLocationSubstreamRead(SSTStreamPtr s, std::stringstream* prevdata, uint8* buffer, int length); void handleProximitySubstreamRead(SSTStreamPtr s, std::stringstream* prevdata, uint8* buffer, int length); bool locationMessage(const std::string& payload); bool proximityMessage(const std::string& payload); // Handle a new connection to a space -- initiate session void handleSpaceConnection(const SpaceID& space, const ObjectReference&, ServerID sid); // We need to manually wrap this for the main strand because IOStrand // doesn't support > 5 arguments, which the original callback has void handleSpaceConnectionIndirect(const SpaceID& space, const ObjectReference&, ServerID sid); // Handle a migration to a new space server void handleSpaceMigration(const SpaceID& space, const ObjectReference&, ServerID sid); void handleSpaceStreamCreated(); // Handle a disconnection from the space void handleSpaceDisconnection(const SpaceObjectReference& spaceobj, Disconnect::Code); void sendNoReturn(ObjectMessagePort src_port, UUID dest, ObjectMessagePort dest_port, std::string payload); // ODP::Service Interface virtual ODP::Port* bindODPPort(const SpaceID& space, const ObjectReference& objref, ODP::PortID port); virtual ODP::Port* bindODPPort(const SpaceObjectReference& sor, ODP::PortID port); virtual ODP::Port* bindODPPort(const SpaceID& space, const ObjectReference& objref); virtual ODP::Port* bindODPPort(const SpaceObjectReference& sor); virtual void registerDefaultODPHandler(const ODP::Service::MessageHandler& cb); ODP::DelegatePort* createDelegateODPPort(ODP::DelegateService* parentService, const SpaceObjectReference& spaceobj, ODP::PortID port); bool delegateODPPortSend(const ODP::Endpoint& source_ep, const ODP::Endpoint& dest_ep, MemoryReference payload); // THREAD SAFE: // These are thread safe (they don't change after initialization) const UUID mID; ObjectHostContext* mContext; ObjectFactory* const mObjectFactory; // LOCK PROTECTED: // These need to be accessed by multiple threads, protected by locks SharedProperty<BoundingSphere3f> mBounds; // FIXME Should probably be variable SharedProperty<TimedMotionVector3f> mLocation; // OBJECT THREAD: // Only accessed by object simulation operations MotionPath* mMotion; SimpleExtrapolator<MotionVector3f, MaxDistUpdatePredicate> mLocationExtrapolator; bool mRegisterQuery; SolidAngle mQueryAngle; ServerID mConnectedTo; bool mMigrating; bool mQuitting; Network::IOTimerPtr mLocUpdateTimer; ODP::DelegateService* mDelegateODPService; BaseDatagramLayerPtr mSSTDatagramLayer; }; // class Object } // namespace Sirikata #endif //_SIRIKATA_OBJECT_HPP_
cb1ac7f1e5a723b79e3ee9bbdcc42307c1e56a5c
f7b5329c6ddc4353e724d8b2119748ae2458d768
/VideoCodec/encoder_x264.h
17a6fd92af85f219dbb429c59c0cac9f147af362
[]
no_license
hotkidfamily/MediaVideoProject
ac9471bd8fd6131e6cc0dc3a93365b25ca7d26b6
2c4e27d4f3345b4d33f61da9c48deb49ee985b8c
refs/heads/master
2021-01-12T04:21:39.661941
2020-11-13T09:36:58
2020-11-13T09:36:58
77,592,422
4
0
null
null
null
null
UTF-8
C++
false
false
1,268
h
encoder_x264.h
#pragma once #include "PackageManager.h" #include "IVideoCodec.h" extern "C" { #include "x264.h" } class CLibx264 : public ICodec { public: CLibx264(); ~CLibx264(); /* step 2 */ bool open(); /* step 4 */ void close(); /* step 1 */ bool setConfig(const ENCODECCFG &config); /* step 3.x */ bool reset(const ENCODECCFG &config); /* step 3.x */ bool addFrame(const CSampleBuffer &inputFrame); /* step 3.x */ bool getPackage(CPackageBuffer *&outputPackage); bool releasePackage(CPackageBuffer *&outputPackage); /* step all */ uint32_t getLastError() { return mLastError; } const char* getCodecDescriptor() { return "libx264"; }; CodecID getCodecId() { return VCODEC_H264; }; protected: void setLastError(uint32_t v){ mLastError = v; }; bool parseConfigString(); void flushEncodeCache(); bool assemblePackage(int outputNALsDataSizeInBytes, const x264_nal_t *outputNalus, int outputNaluCnt, const x264_picture_t *outputPic); bool encodeFrame(x264_picture_t *inpic); private: x264_param_t mCodecParams; x264_t *mCodecHandle; uint32_t mLastError; x264_picture_t mInPic; CPackageBufferManager mPackages; ENCODECCFG mWorkConfig; BOOL mbNeedVpp; IVPPPARAMETER vppParams; IVPPFactory *mVppFactory; IVPP * mVpp; };
934b60607dfd79ac05afb8f329a0add4a1809eea
6f0257fcee235791496d13ecc1c848c19017f06e
/main.cpp
e71f9794bacced39b600f373083e30f5f0134200
[]
no_license
LemosDanilo/TP2-Conteneurs-et-fichiers
391ffb345ca3e19507c0456128b2bb511051579d
6feb7c5c389a6f500e5ec97d917c1c35c071cfce
refs/heads/master
2022-12-12T09:52:47.096805
2020-09-08T00:36:55
2020-09-08T00:36:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
242
cpp
main.cpp
#include <fstream> #include <iostream> using namespace std; int main() { ifstream lecteur("hiscore.txt"); string line; while(!lecteur.eof()) { lecteur >> line; if(!lecteur.eof()) { cout << line << endl; } } lecteur.close(); }
0e7a8faa5b1ad05c6096a005c8123cf51961a517
50431019976e12f4fb87b985f8829650240c235c
/LineEquations.cpp
75e242fec667a123973cbc0f63fef322f35697a9
[]
no_license
Charlieranderson/GraphicsFinalProject
80117ed1870525eacb09c23d8c49986c8962dcf3
0969bf1c5114a52cc99bfce687a99caee876a6f3
refs/heads/main
2023-01-18T23:47:20.859023
2020-12-01T00:08:43
2020-12-01T00:08:43
309,230,737
0
0
null
null
null
null
UTF-8
C++
false
false
3,783
cpp
LineEquations.cpp
#include "StdAfx.h" #include "LineEquations.h" #include "MatrixEquations.h" #include <iostream> //Orders Vertices for LEE calculations in Object Order void LineEquations::OrderVerts(GzCoord* ptr, GzCoord* normalPtr, GzTextureIndex* uvList) { //GzCoord temp; float* currentPtr, *nextVal; bool topBottomRelationship = false; float topBottomVal; float otherValue = 0; //Order verts by Y for (int i = 0; i < 2; i++) { for (int j = i + 1; j < 3; j++) { currentPtr = (float*)ptr[i]; currentPtr++; //set to Y val nextVal = (float*)ptr[j]; nextVal++; //Set to yval //If current is larger than nextval, swap if (*currentPtr > *nextVal) { std::swap(ptr[i], ptr[j]); std::swap(normalPtr[i], normalPtr[j]); std::swap(uvList[i], uvList[j]); } else if (*currentPtr == *nextVal) { topBottomRelationship = true; topBottomVal = *currentPtr; float* findVal = (float*)ptr[0]; findVal++; for (int h = 0; h < 3; h++) { if (*findVal != *currentPtr) { otherValue = *findVal; findVal += 3; } } } } } if (topBottomRelationship) { if (otherValue > topBottomVal) { currentPtr = (float*)ptr[0]; nextVal = (float*)ptr[1]; if (*nextVal > *currentPtr) { std::swap(ptr[0], ptr[1]); std::swap(normalPtr[0], normalPtr[1]); std::swap(uvList[0], uvList[1]); } } else { currentPtr = (float*)ptr[1]; nextVal = (float*)ptr[2]; if (*nextVal < *currentPtr) { std::swap(ptr[1], ptr[2]); std::swap(normalPtr[1], normalPtr[2]); std::swap(uvList[1], uvList[2]); } } } else { //Check LR relationship currentPtr = (float*)ptr[1]; currentPtr++; //Set to yVal float y = *currentPtr; //Retain middle vert Y value currentPtr--; //Set to xVal float coefficients[3]; GetLineCoefficients(ptr[0], ptr[2], coefficients); float xVal = -1 * (coefficients[1] * y + coefficients[2]) / coefficients[0]; if (xVal > *currentPtr) { std::swap(ptr[0], ptr[1]); std::swap(normalPtr[0], normalPtr[1]); std::swap(uvList[0], uvList[1]); } } } //returns line coefficients void LineEquations::GetLineCoefficients(float* tailVert, float* headVert, float* returnArray) { returnArray[0] = headVert[1] - tailVert[1]; //A = dY returnArray[1] = tailVert[0] - headVert[0]; //B = -(dX) returnArray[2] = (headVert[0] - tailVert[0]) * tailVert[1] - returnArray[0] * tailVert[0]; //C = (dX * Y) - (dY * X) } //LEE, if negative its 'inside' the line, need three evals for a triangle bool LineEquations::EvaluatePointByLine(float* lineCoefficients, int x, int y) { float val = lineCoefficients[0] * x + lineCoefficients[1] * y + lineCoefficients[2]; if (val <= 0) return true; //need to do 0 check here. else { return false; } } inline float CalculateD(float* otherCoefficients, float* vert) { return -1 * (otherCoefficients[0] * vert[0] + otherCoefficients[1] * vert[1] + otherCoefficients[2] * vert[2]); } void LineEquations::GetPlaneCoefficients(float* coordOne, float* coordTwo, float* coordThree, float* returnVal) { GzCoord vecOne = { coordTwo[0] - coordOne[0], coordTwo[1] - coordOne[1], coordTwo[2] - coordOne[2] }; GzCoord vecTwo = { coordThree[0] - coordTwo[0], coordThree[1] - coordTwo[1], coordThree[2] - coordTwo[2] }; MatrixEquations::CrossProduct((float*)vecOne, (float*)vecTwo, returnVal); returnVal[3] = CalculateD(returnVal, coordOne); } float LineEquations::InterpolateZ(float* coefficients, int x, int y) { return (-1 * (coefficients[0] * x + coefficients[1] * y + coefficients[3]) / coefficients[2]); } float LineEquations::InterpolateZFloat(float* coefficients, float x, float y) { if (coefficients[2] == 0) { return 1; } return (-1 * (coefficients[0] * x + coefficients[1] * y + coefficients[3]) / coefficients[2]); }
4ca411c26cb859be12c2d8d8027908c11cef717a
8f50c262f89d3dc4f15f2f67eb76e686b8f808f5
/Trigger/TrigEvent/TrigNavTools/src/getLabel.cxx
11480ae3c9523bcf3307433868a9e56a02b93934
[ "Apache-2.0" ]
permissive
strigazi/athena
2d099e6aab4a94ab8b636ae681736da4e13ac5c9
354f92551294f7be678aebcd7b9d67d2c4448176
refs/heads/master
2022-12-09T02:05:30.632208
2020-09-03T14:03:18
2020-09-03T14:03:18
292,587,480
0
1
null
null
null
null
UTF-8
C++
false
false
815
cxx
getLabel.cxx
/* * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration. */ /** * @file TrigNavTools/src/getLabel.cxx * @author scott snyder <snyder@bnl.gov> * @date May, 2020 * @brief Helper function to get a label for a feature. * * Broken out from the old TrigNavigationSlimmingTool (B. Smith / T. Bold). */ #include "getLabel.h" #include "TrigNavigation/Navigation.h" namespace HLT { namespace TrigNavTools { std::string SlimmingHelper::getLabel(const HLT::NavigationCore& navigation, const HLT::TriggerElement::FeatureAccessHelper& fah) { CLID clid = fah.getCLID(); std::string label; HLTNavDetails::IHolder *h = navigation.getHolder(clid, fah.getIndex().subTypeIndex()); if(h) label = h->label(); return label; } }} // namespace HLT::TrigNavTools
0d6c72ff5dbf227ee348020f6d2fa64bd3c7b2eb
b5d6bef867559a53ac6cd82b65624458dd20214f
/baekjoon/14890.cpp
06c0759f8acba3d1ba36150dbf0fc73fddce6225
[]
no_license
jingnee/algorithm
cfb33ab5c5243c2d7752746aadfa9d3017f63072
3c99db64c3840a3696bd188b5fbb6b54990303c4
refs/heads/master
2022-06-22T22:15:36.838947
2022-06-09T09:22:04
2022-06-09T09:22:04
231,215,092
4
0
null
null
null
null
UTF-8
C++
false
false
2,274
cpp
14890.cpp
//경사로 #include <iostream> #include <cmath> using namespace std; int N, L, ans; int map[101][101]; int main() { cin >> N >> L; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cin >> map[i][j]; } } //가로 확인 for (int i = 0; i < N; i++) { bool flag = true; int prev = 1; for (int j = 1; j < N; j++) { //차이가 1초과이면 안됨 if (abs(map[i][j - 1] - map[i][j]) > 1) { flag = false; break; } //이전과 같은 위치면 prev ++ else if (map[i][j - 1] == map[i][j])prev++; //이전과 다른위치인데 하나차이 else { //뒤에있는게 큰애이면 prev갯수 세기 if (map[i][j - 1] < map[i][j]) { if (prev < L) { flag = false; break; } prev = 1; } //앞에 있는게 더 큰애면 블록 세울만큼 뒤에 있는지 확인하고 없거나 같은수 아니면 탈락 else if (map[i][j - 1] > map[i][j]) { if (j + L - 1 >= N) { flag = false; break; } int num = map[i][j]; for (int k = j+1; k < j + L; k++) { if (num != map[i][k]) { flag = false; break; } } j = j + L-1; prev = 0; if (!flag)break; } } } if (flag)ans++; } //세로 확인 for (int j = 0; j < N; j++) { bool flag = true; int prev = 1; for (int i = 1; i < N; i++) { //차이가 1초과이면 안됨 if (abs(map[i-1][j] - map[i][j]) > 1) { flag = false; break; } //이전과 같은 위치면 prev ++ else if (map[i-1][j] == map[i][j])prev++; //이전과 다른위치인데 하나차이 else { //뒤에있는게 큰애이면 prev갯수 세기 if (map[i-1][j] < map[i][j]) { if (prev < L) { flag = false; break; } prev = 1; } //앞에 있는게 더 큰애면 블록 세울만큼 뒤에 있는지 확인하고 없거나 같은수 아니면 탈락 else if (map[i-1][j] > map[i][j]) { if (i + L - 1 >= N) { flag = false; break; } int num = map[i][j]; for (int k = i + 1; k < i + L; k++) { if (num != map[k][j]) { flag = false; break; } } i = i + L-1; prev = 0; if (!flag)break; } } } if (flag)ans++; } cout << ans; }
bb78a6d681c0227f9e866474ae9c45f8acac3b78
0d05c22e94372d2c9f32763aeeca82347eb3cb0f
/CS32/Homework1/SalaryMap.cpp
913c27a418215c27a82866ddcf87d03990bf15a1
[]
no_license
rlchung/UCLA-Undergraduate-Coursework
cc4c1f1a25f3d6bdf5fc84a9cd77a76db697f137
7f366ae96d921b8cf045efc3fcbdd2fff99636c9
refs/heads/master
2021-01-23T07:15:38.308311
2017-01-31T08:14:46
2017-01-31T08:14:46
80,494,057
0
0
null
null
null
null
UTF-8
C++
false
false
2,097
cpp
SalaryMap.cpp
#include "SalaryMap.h" #include <iostream> SalaryMap::SalaryMap() { //create an empty salary map }; // If an employee with the given name is not currently in the map, // there is room in the map, and the salary is not negative, add an // entry for that employee and salary and return true. Otherwise // make no change to the map and return false. bool SalaryMap::add(std::string name, double salary) { if (!s_map.contains(name) && s_map.size() < DEFAULT_MAX_ITEMS && salary >= 0) { s_map.insert(name, salary); return true; } else return false; }; // If no employee with the given name is in the map or if pct is less // than -100, make no change to the map and return false. Otherwise, // change the salary of the indicated employee by the given // percentage and return true. For example, if pct is 10, the // employee gets a 10% raise; if it's -5, the salary is reduced by 5%. bool SalaryMap::raise(std::string name, double pct) { if (!s_map.contains(name) || pct < -100) return false; else { double old_salary; double new_salary; double pct_raise = pct * (.01); if (s_map.get(name, old_salary)) { new_salary = old_salary + (old_salary * pct_raise); s_map.update(name, new_salary); } return true; } }; // If an employee with the given name is in the map, return that // employee's salary; otherwise, return -1. double SalaryMap::salary(std::string name) const { double retrieved_sal; if (s_map.get(name, retrieved_sal)) return retrieved_sal; else return -1; }; // Return the number of employees in the SalaryMap. int SalaryMap::size() const { return s_map.size(); }; // Write to cout one line for every employee in the map. Each line // has the employee's name, followed by one space, followed by that // employee's salary. void SalaryMap::print() const { std::string e_name; double retrieved_sal = 0; for (int x = 0; x < s_map.size(); x++) { if (s_map.get(x, e_name, retrieved_sal)) { cout << e_name << " " << retrieved_sal << endl; } } };
b8cd50d5ce39c09a1bdce13290982180f212ae06
95c415af4e44198214566ca25451bb2950670f99
/include/extend_parser.h
17a5415703311f73f529e2a5a5f39346e48ff4cc
[]
no_license
pabloufrn/bares
a1b66992d40c82f088f06773ca0badd45353a7ae
072fc0a682e80a34e7a580af4220694b86e15406
refs/heads/master
2020-03-15T07:41:23.444306
2018-05-13T23:05:29
2018-05-13T23:05:29
132,034,328
1
0
null
null
null
null
UTF-8
C++
false
false
4,870
h
extend_parser.h
/// Imprimir qual o erro que foi gerado durante a execução do programa. /// \param struct do erro. /// \return erro gerado. std::string print_error_msg( const Parser::ResultType & result ) { switch ( result.type ) { case Parser::ResultType::INTEGER_OUT_OF_RANGE: std::cout << "Integer constant out of range beginning at column ("<< result.at_col << ")!\n"; return "Integer constant out of range beginning at column (" + std::to_string(result.at_col) + ")!\n"; case Parser::ResultType::MISSING_TERM: std::cout << "Missing <term> at column (" << result.at_col << ")!\n"; return "Missing <term> at column (" + std::to_string(result.at_col) + ")!\n"; case Parser::ResultType::EXTRANEOUS_SYMBOL: std::cout << "Extraneous symbol after valid expression found at column (" << result.at_col << ")!\n"; return "Extraneous symbol after valid expression found at column (" + std::to_string(result.at_col) + ")!\n"; case Parser::ResultType::ILL_FORMED_INTEGER: std::cout << "Ill formed integer at column (" << result.at_col << ")!\n"; return "Ill formed integer at column (" + std::to_string(result.at_col) + ")!\n"; case Parser::ResultType::MISSING_CLOSE: std::cout << "Missing closing ”)”at column (" << result.at_col << ")!\n"; return "Missing closing ”)”at column (" + std::to_string(result.at_col) + ")!\n"; case Parser::ResultType::UNEXPECTED_END_OF_EXPRESSION: std::cout << "Unexpected end of input at column (" << result.at_col << ")!\n"; return "Unexpected end of input at column (" + std::to_string(result.at_col) + ")!\n"; default: std::cout << "Unhandled error found!\n"; return "Unhandled error found!\n"; } } /// Verificar se a expressão está bem formada. /// \param vetor de expressões. void parser_driver( sc::vector<std::string> & conjunto ){ Parser type_parser; // Instancia um parser. // Tentar analisar cada expressão da lista. for( const auto & express : conjunto ) { // Fazer o parsing desta expressão. auto result = type_parser.parse( express ); // Preparar cabeçalho da saida. //std::cout << std::setfill('=') << std::setw(80) << "\n"; //std::cout << std::setfill(' ') << ">>> Parsing \"" << express << "\"\n"; // Se deu errado, imprimir a mensagem adequada. if ( result.type != Parser::ResultType::OK ){ print_error_msg( result ); } else{ // Recuperar a lista de tokens. auto lista = type_parser.get_tokens(); try { value_type result = resolucao( lista ); std::cout << result << std::endl; } catch(std::runtime_error e) { std::cout << e.what() << std::endl; } } } } /// Verificar se a expressão está bem formada e com saída para arquivo específico. /// \param vetor de expressões. void parser_driver_out( sc::vector<std::string> & conjunto , std::string ofFile_name ){ /// Criação do tipo de arquivo de saída arq_saida oFile; /// Gerar o arquivo de saída. oFile.open(ofFile_name); /// Verificar se ocorreu algum erro ao gerar o arquivo de saida. if( oFile.fail()){ std::cout << "Error! It wasn't possible to create the output file.\n"; exit(1); } Parser type_parser; // Instancia um parser. // Tentar analisar cada expressão da lista. for( const auto & express : conjunto ) { // Fazer o parsing desta expressão. auto result = type_parser.parse( express ); /// Imprimir mensagem de erro caso tenha dado algo errado. if ( result.type != Parser::ResultType::OK ){ std::string error_name = print_error_msg( result ); oFile << error_name; } else{ // Recuperar a lista de tokens. sc::vector<Token> lista = type_parser.get_tokens(); /// Verificar se deu algo errado durante a resolução da expressão. try { /// Realizar a operação. value_type result = resolucao( lista ); /// Imprimir resultado no arquivo. oFile << result << std::endl; /// Imprimir o resultado no terminal para o usuário. std::cout << result << std::endl; } catch(std::runtime_error e) { //!< Verificar se ocorreu algum erro durante a expressão. std::cout << e.what() << std::endl; oFile << e.what() << std::endl; } } } /// Fechar o arquivo. oFile.close(); }
070525578be55ee6f112ada6ad98783805c2febc
3821202739fa08cbb373351d387c810bbf4a934a
/structural/src/facade/expression_node.cc
8523dcec3baee794f947830850aaed00574bd53d
[ "MIT" ]
permissive
wqx081/DesignPatterns
464a4a3dc69bdb9b9ca73529d76357dbc0f21ccc
0645544706c915a69e1ca64addba5cc14453f64c
refs/heads/master
2021-01-17T10:42:21.357680
2015-11-06T00:43:58
2015-11-06T00:43:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
983
cc
expression_node.cc
// Based on "Design Patterns: Elements of Reusable Object-Oriented Software" // book by Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm // // Created by Bartosz Rachwal. The National Institute of Advanced Industrial Science and Technology, Japan. #include "expression_node.h" #include "../../../operational/src/iterator/list_iterator.h" namespace structural { namespace facade { ExpressionNode::ExpressionNode() { children_ = new operational::iterator::List<ProgramNodeInterface*>(10); } void ExpressionNode::GetSourcePosition(int& line, int& index) { } void ExpressionNode::Add(ProgramNodeInterface* node) { children_->Append(node); } void ExpressionNode::Remove(ProgramNodeInterface* node) { children_->Remove(node); } void ExpressionNode::Traverse(CodeGeneratorInterface& cg) { cg.Visit(this); operational::iterator::ListIterator<ProgramNodeInterface*> i(children_); for (i.First(); !i.IsDone(); i.Next()) { i.CurrentItem()->Traverse(cg); } } } }