text
stringlengths
8
6.88M
#include <Model/thanos.h> bool EmailSender::sendEmail(string name, string toName, string to, string subject, string body){ }
vector < Rect> vRegionSearchRect; Rect regionSearchRect = targetRegion; regionSearchRect.x = targetRegion.x -patchSize; regionSearchRect.y = targetRegion.y -patchSize; for (; regionSearchRect.y < targetRegion.y+patchSize ; regionSearchRect.y += 4) //.y < vpatches[i].r.y + vpatches[i].r.height; patchSearch...
#include <RcppGSL.h> using namespace Rcpp; // [[Rcpp::depends(RcppGSL)]] // [[Rcpp::export]] NumericMatrix RcppGibbs(int N, int thn) { int i,j; NumericMatrix mat(N, 2); RNGScope scope; // Initialize Random number generator // The rest of the code follows the R version double x=0, y=0; for (i=0; i<...
#include "common/Compiler.h" #include "common/FastRand.h" #include <benchmark/benchmark.h> #include <memory> #include <sstream> #include <system_error> namespace PayloadErrorCode { class GlobPattern { public: GlobPattern() noexcept { ErrorCodeGt10 = fastrand() % 10 + 100; } ATTRIBUTE_NOINLINE static std...
/* 4.9.2 向上类型转换及问题 cpp1data004i2a 4.9.2.1 问题抛出 对象可以作为自己的类或者作为它的基类的对象来使用。还能通过基类的地址来操作它。取一个对象的地址(指针或引用),并将其作为基类的地址来处理,这种称为向上类型转换。 也就是说:父类引用或指针可以指向子类对象,通过父类指针或引用来操作子类对象。 早绑定(early binding) * */ #include <iostream> using namespace std; class Animal { public: void speak() { cout << "Animal speak" <<...
/* Q4: Two dates are given in a 8 node single linked list form,where each node has one digit only, dates 01-31, months 01-12, year 0000-9999. Find the number of days in between those two dates .[Exclusive] Ex : Date1: 0->1->0->1->2->0->0->4 . Date2 : 0->5->0->1->2->0->0->4 should return 3 . As there are 3 days ...
#ifndef OBJECTDATA_H #define OBJECTDATA_H #include <string> #include <vector> #include <map> #include "cinder/Vector.h" namespace cilender { class ObjectData { public: ObjectData(); std::string name; std::string data; ci::Vec3f location; ci::Vec3f rotation; ci::Vec3f scale; std::vector< ...
// -*- C++ -*- // // Copyright (C) 1998, 1999, 2000, 2002 Los Alamos National Laboratory, // Copyright (C) 1998, 1999, 2000, 2002 CodeSourcery, LLC // // This file is part of FreePOOMA. // // FreePOOMA is free software; you can redistribute it and/or modify it // under the terms of the Expat license. // // This progr...
#include <cstdio> #include <cstring> int main() { int n1, n2, len, tmp; char str[90]; scanf("%s", str); for(len = 0; str[len] != '\0'; len++) ; // get n1=n3 and n2 for(n1 = 1; n1 <= n2; n1++) { tmp = len + 2 - 2 * n1; // ATTENTION: 这里与前一题B1027一样, 需要后悔 if(n1 > tmp) break; n2 = tmp; ...
//--------------------------------------------------------------------------- #ifndef UtilForVectH #define UtilForVectH //--------------------------------------------------------------------------- #include <vector> using namespace std; void VectDoubleWriteFile(vector<double> &vect,int handle); void VectDouble...
#ifndef BASE_GRAPH_CREATE #define BASE_GRAPH_CREATE #include <MultiGraphCreate.h> #include <GraphAccess.h> #include <assert.h> typedef MultiGraphElemTemplate<void*> BaseGraphNode; typedef MultiGraphElemTemplate<void*> BaseGraphEdge; class BaseGraphCreate : public MultiGraphCreate, public Gra...
// // MrCrash - crash info reporting tool // Copyright (C) 2005-2014 Michael Fink // /// \file AppOptions.hpp Application options // #pragma once /// start mode enum T_enStartMode { smStartProcess, ///< starts process smAttachProcess, ///< attaches to running process smInteractive, ///< interactive mode...
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 100000, y = 500, min_x = 100000, min_y = 500, max_x = 0; cin>>n; for(int i=0; i<n; i++) { int tx, ty; cin>>tx>>ty; min_x = min(min_x, tx); max_x = max(max_x, tx); min_y = min(min_y, ty); } cout<<max(min_x*y, max(min_y*x, (x-max_x)*y...
/*************************************************************************** Copyright (c) 2020 Philip Fortier 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...
#include "mutation_detector.h" using namespace std; vector<string> find_mutations(ParseTreeNode *program_node) { auto assignments = find_assignments(program_node, std::string()); vector<string> mutations; for (auto assn : assignments) if (assn.second > 1) mutations.push_back(assn.first...
#include "stdafx.h" #include "window.h" #include "TVView.h" #include "TVCreator.h" #include "utilites/serl/Archive.h" Window::Window(HWND h, int id, rect r) : hwnd_(h), id_(id), r_(r), contents_(0) { } Window::Window(const Window &win) : id_(win.id_), r_(win.r_), hwnd_(win.hwnd_), contents_(0) { } Window::...
/* * Author : BurningTiles */ #include <iostream> using namespace std; int main(){ int B, N, temp; cin >> B >> N; while(N-- && cin >> temp) B -= ++temp/2; if(cin.fail()) cout << "Invalid Input"; else (B>0)? cout << "YES" : cout << "NO"; return 0; } ...
/*********************************************************************** created: Mon Jul 4 2005 author: Paul D Turner <paul@cegui.org.uk> *************************************************************************/ /*************************************************************************** * Copyright...
#include "PurchaseList.h" #pragma region Merge Sort Code // The following code was adapted from // https://www.tutorialspoint.com/cplusplus-program-to-implement-merge-sort-algorithm-on-linked-list Purchase* PurchaseList::mergeList(Purchase* list1, Purchase* list2) { Purchase* newHead = NULL; if (list1 == NULL) { ...
#pragma once enum BStates { BS_DEFAULT, BS_ALPHA, BS_ADDITIVE, BS_COUNT }; class BlendStateManager { public: BlendStateManager(void); ~BlendStateManager(void); bool ApplyState(BStates eState); ID3D11BlendState* GetState(BStates eState) { if (eState < BS_COUNT) return m_pBlendStates[eState]; ...
#define _CRT_SECURE_NO_WARNINGS #include <Windows.h> #include <iostream> #include <vector> #include <array> #include <random> #include <thread> #include <atomic> #include <glm/glm.hpp> #include <glm/ext/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale #define TINYOBJLOADER_IMPLEMENTATION #include <t...
#include "PointLight.h" int PointLight::idIndex = 0; PointLight::PointLight() : _ambient(glm::vec3(0.05f)), _diffuse(glm::vec3(1.0f)), _specular(glm::vec3(1.0f)) { id = idIndex++; } void PointLight::RenderMe(AbstractRenderer* renderer) { std::string pointLightId = "pointLights[" + std::to_string(id) + "]"...
// C++ for the Windows Runtime vv1.0.170303.6 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "Windows.Media.DialProtocol.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_cdb5efb3_5788_509d_9be1_71ccb8a3362a #define WINRT_GENERIC...
/// /// \file C3DReader.h /// \brief /// \author PISUPATI Phanindra /// \date 03.04.2014 /// /// #ifndef APPLICATION_H #define APPLICATION_H #include "Settings.h" #include "Subject.h" #include "Targets.h" #include "PlotInterface.h" #include <vector> #include <string> #include <memory> /// /// \class Application /// ...
// // Created by sinimawath on 18.05.18. // #ifndef GRAPH_CLISTGRAPH_H #define GRAPH_CLISTGRAPH_H #include <memory> #include "igraph.h" #include "list" class CListGraph : public IGraph{ public: explicit CListGraph(int n) : adjacencyList( n ) {} explicit CListGraph(const std::shared_ptr<IGraph>& igraph); ...
#include <bits/stdc++.h> using namespace std; string trim(string s) { string ans = ""; for (char c : s) if (c != ' ') ans += c; return ans; } string reverseWords(string s) { vector<string> words; s += ' '; string temp = ""; for (int i = 0; i < s.length(); i++) { ...
#include <iostream> #include <iomanip> #include <string> #include <list> #include "LoadBalancer.h" using namespace std; /** * Story: * Assign a server 10 times using load balancer (LoadBalancer) **/ void testSingleton() { cout << endl << "<<Test Singleton>>" << endl; LoadBalancer* loadBalancer; loadBalancer = ...
/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */ bool compare(Interval a,Interval b){ return a.start < b.start; } vector<Interval> Solution::merge(vector<Interval> &A) {...
/************************************************* * Publicly released by Rhoban System, August 2012 * www.rhoban-system.fr * * Freely usable for non-commercial purposes * * Licence Creative Commons *CC BY-NC-SA * http://creativecommons.org/licenses/by-nc-sa/3.0 *************************************...
#include <iostream> #include "matchit/core.h" #include "matchit/patterns.h" #include "matchit/utility.h" using namespace matchit; template <typename T> auto square(T const* t) { Id<T> id; return match(t)( pattern(some(id)) = [&id] { return *id * *id; }, pattern(none) = [] { return 0; }); } int...
// // Copyright Jason Rice 2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // #include <nbdl/ui_helper/params_concat.hpp> #include <nbdl/ui_spec.hpp> #include <boost/hana/equal.hpp> #include <boost/hana/in...
#include "Menu.hpp" Menu::Menu(RenderWindow* window) { Window=window; IpIsSet = false; AmIClient = false; AmIServer = false; CreateServer = false; csiga_b.LoadFromFile("contents/csiguszbody.png"); //csiga_b.LoadFromFile("contents/xmas_csiguszbody.png"); Csiga_b.SetImage(csiga_...
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; * transform function the set of left child of root(x) is the set of root(y < x) * transform function the set of right child of...
#include "reqcompile.h" using std::string; ReqCompile::ReqCompile(const string& name) :nm(name) { } const std::string& ReqCompile::name() const { return nm; } const char* ReqCompile::snippet_prefix = "rust_import_";
// -*- C++ -*- // // Copyright (C) 1998, 1999, 2000, 2002 Los Alamos National Laboratory, // Copyright (C) 1998, 1999, 2000, 2002 CodeSourcery, LLC // // This file is part of FreePOOMA. // // FreePOOMA is free software; you can redistribute it and/or modify it // under the terms of the Expat license. // // This progr...
#include<iostream> using namespace std; int main() { int n,i; cin>>n; for(int no=2;no<=n;no++) { for(i=2;i<no;i++) { if(no%i==0) { break; } } if(i==no) { cout<<no<<" "; } } cout<<endl; return 0; }
#include<iostream> #include<string.h> #include<stdlib.h> using namespace std; struct node{ int end; node *child[26]; }*root; node *cnn() { node *ptr=new node; ptr->end=0; for(int i=0;i<26;i++) ptr->child[i]=NULL; return ptr; } void insert(string str,int l) { int i,j,k; node *nptr,*p...
#ifndef _PARATABLE_H_ #define _PARATABLE_H_ #include "ParaMore.h" namespace GUI { class MainWindow; } namespace DataProperty { class ParameterBase; class ParameterTable; } namespace SelfDefObj { class SELFDEFINEOBJAPI ParaTable : public ParaMore { Q_OBJECT public: ParaTable(GUI::MainWindow* m, DataPropert...
// // Created by 梁栋 on 2019-05-06. // #include <vector> #include <iostream> #include <string> #include <cstring> using namespace std; class Solution { public: bool wordBreakBase(string s, vector<string>& wordDict, int idx, bool& res){ if(s == wordDict[idx]){ res = true; return true; ...
#include <iostream> #include <vector> #include <string> using namespace::std; void RadixSort(vector<string> &A, vector<string> &B, int d); void CountingSort(vector<string> &A, vector<string> &B, int k, int d); int main() { vector<string> A{"329", "457", "657", "839", "436", "720", "355"}; vector<string> B(A.size()...
#pragma once #include <chrono> #include <iostream> class FPS { public: void Update(){ ++_frame_counter; if (_last_time + std::chrono::seconds(1) < _timer.now()) { _last_time = _timer.now(); _fps = _frame_counter; _frame_counter = 0; std::cout << "FPS:" << _fps << std::endl; } }; pr...
#include<iostream> #include<cstdio> using namespace std; int a[1001]; int c[1001]; void dfs(int node) { if (c[node]) return; c[node] = true; dfs(a[node]); } int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; c[i] = false; } ...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define mp make_pair #define PI pair<ll,ll> #define poly vector<ll> #define mem(a) memset((a),0,sizeof(a)) #define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++) #define Rep(i,r,l) for(int i=(int)(...
/* Copyright (c) 2005-2023, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms...
#include <regex> #include <cstdio> #include <regex> #include <algorithm> #include <vector> #include <cstring> using namespace std; const regex EMAIL_FILTER("@gmail\\.com$"); struct Person { char name[21]; char email[51]; }; bool filterFunction(Person* p); bool compareFunction(Person* p1, Person* p2); int m...
#include "stdafx.h" #include "Monster.h" Monster::Monster() { } Monster::~Monster() { } void Monster::removeHealth(int value) { health -= value; } void Monster::addHealth(int value) { health += value; } void Monster::getMonsterStats() { cout << "[[ " << monsterName << " - level: " << getLevel() << " || " << "Hea...
/*************************************************************************** * Filename : OpenGLMesh.h * Name : Ori Lazar * Date : 30/10/2019 * Description : A declaration for a mesh object for OpenGL, currently * used to auto generate primitives. .---. .'_:___". |__ --==| [ ] ...
#include <iostream> #include <unordered_map> #include <string> using namespace std; int Q; int key, val; struct node { int val,idx; }; unordered_map<int, node> hTab(200000); int nodeCnt; int main() { freopen("input.txt", "r", stdin); cin >> Q; nodeCnt = 0; for (; Q; Q--) { cin >> key >> val; node tmp; au...
#include <iostream> #include <fstream> using namespace std; ifstream fin("ssm.in"); ofstream fout("ssm.out"); int main() { long long int n, i, mx_val, mx_index, s = 0; fin >> n; long long int arr[n + 1], prev_val; for (i = 0; i < n; i++) fin >> arr[i]; prev_val = arr[0]; mx_val = prev_v...
#include "DeviceVk.hpp" #include "Logger.hpp" #include "Utility.hpp" #include "CommandBufferVk.hpp" #include "SwapchainVk.hpp" #include <sstream> #include <vector> #include <cstring> namespace engine { Bool DeviceVk::Initialize() { if (!CreateInstance()) { return false; }...
/*************************************************************************** Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. 2010-2020 DADI ORISTAR TECHNOLOGY DEVELOPMENT(BEIJING)CO.,LTD FileName: RTSPSessionInterface.cpp Description: Presents an API for session-wide resources for modules...
#include <ros/ros.h> #include <actionlib/client/simple_action_client.h> #include <move_base_msgs/MoveBaseAction.h> /* This node receives a single goal position and produces a global trajectory * using the global planner from the move_base node. */ typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction>...
#include<iostream> #include<bits/stdc++.h> using namespace std; int main() { stack <int> s; s.push(2); s.push(3); s.push(1); int val = s.size(); // cout<<s.top()+2; cout<<min(s.top(),s.top()+val); }
#include "Board.h" Board::Board() { } Board::~Board() { } void Board::renderGrid(sf::RenderWindow *window, int width, int height) { sf::VertexArray grid(sf::Lines); for (int x = 0; x < height; x += (GameManager::get().gridHeight)) { grid.append(sf::Vector2f(0 + x, 0)); // start grid....
#include<iostream> using namespace std; //封装一个函数,利用冒泡排序,实现对整形数组的升序排序 void bubbleSort(int * arr,int len)//参数分别是数组的首地址和数组长度 { for(int i = 0;i < len-1;i++) { for(int j = 0;j<len - i - 1;j++) { if(arr[j] > arr[j+1]) { int temp = arr[j]; arr[j] ...
/* ID: hjl11841 TASK: frac1 LANG: C++ */ #include<bits/stdc++.h> using namespace std; vector<int> fengzi; vector<int> fengmu; int gcd(int x,int y){ int s; while(x){ s=y%x; y=x; x=s; } return y; } int main(){ freopen("frac1.in","r",stdin); freopen("frac1.out","w",stdout); int n; cin>>n; fengzi.push_back...
#include "seal/seal.h" #include "helper.hpp" #include <iostream> #include <vector> using namespace std; using namespace seal; SEALContext SetupCKKS() { EncryptionParameters parms(scheme_type::ckks); size_t poly_modulus_degree = 16384; parms.set_poly_modulus_degree(poly_modulus_degree); try { ...
#include "dialogquerypasswd.h" #include "ui_dialogquerypasswd.h" #include <QTextCodec> DialogQueryPasswd::DialogQueryPasswd(QWidget *parent) : QDialog(parent), ui(new Ui::DialogQueryPasswd) { QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec); ui->setupUi(th...
int pm[n],sm[n]; pm[0]=0; sm[n-1]=0; for(int i=1;i<n;i++) { pm[i]=max(pm[i-1],arr[i-1]); } for(int i=n-2;i>=0;i--) { sm[i]=max(sm[i+1],arr[i+1]); } // for(int i=1;i<n-1;i++) // { // cout<<arr[i]<<" "<<pm[...
#include "yaml-cpp/yaml.h" #include "info.h" #include <iostream> #include <stdlib.h> #include <stdio.h> #include <string> void get_config(Global_Info& my_info) { YAML::Node config = YAML::LoadFile("query_input.yaml"); YAML::Node queries = config["queries"]; YAML::Node cred = config["twitter-api"]; my...
#ifndef _GALES_SCATTER_HPP_ #define _GALES_SCATTER_HPP_ #include <vector> namespace GALES { /** This class scatters the element level computations into global matrix and vector. */ template<typename dofs_ic_bc_type> class scatter { public: explicit scatter(dofs_ic_bc_type& dofs...
#include "Adafruit_NeoPixel.h" extern "C" { extern void render_pixel(uint16_t, uint8_t, uint8_t, uint8_t); extern void initialize_pixels(uint16_t); extern void show_pixels(); } SoftPixel::SoftPixel(uint16_t count, uint8_t pin, uint8_t mode) { pixels = new uint32_t[count]; pixel_count = count; //printf("[?] ...
// // ART.cpp // PianoPlayer // // Created by Ben Smith on 10/10/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <dispatch/dispatch.h> #include "ART.h" ART::ART(double _choice, double _learnRate, double _Vigilance) : mDimensions(19), residual(0), choices(0x00), inputCount(0), maxRecency(0...
// --------------------------------------------------------------------------- // Example NewPing library sketch that does a ping about 20 times per second. // --------------------------------------------------------------------------- #include <NewPing.h> #include <Time.h> #include <SimpleTimer.h> #include <string.h>...
#pragma once #include <vector> #include <iostream> #include <utility> #include <list> #include <bitset> class Board { public: typedef std::pair<int, int> mov; typedef std::list<Board> positions; friend class Game; Board(); positions generate() const; mov get_last() const { return last_move; } void set_last(mov n...
#include "GALogger.h" #include <iostream> #include "GADevice.h" #if USE_UWP #include "GAUtilities.h" #include <collection.h> #include <ppltasks.h> #elif USE_TIZEN #include <dlog.h> #else #include "GAUtilities.h" #include <vector> #include <spdlog/sinks/ostream_sink.h> #endif #if USE_UWP #define GALOGGER_PREFIX ...
#ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> #include<QLabel> #include<QLineEdit> #include<QPushButton> #include<QProgressBar> #include<QSlider> class MainWidget : public QWidget { Q_OBJECT public: MainWidget(QWidget *parent = nullptr); ~MainWidget(); protected: QPushButton *pushButt...
// github.com/andy489 #include <iostream> #include <vector> #include <queue> using namespace std; #define INF 100000 struct Edge{ int u, v, w; }; void bel(const vector<Edge>& adj, int n, int s){ vector<int> paths(adj.size(), INF); paths[s] = 0; bool updated = false;; int i, j; for (i = 0; i < n; ++i) { upd...
/** * @file multiplier754.ccp * @author Luigi Capogrosso * @date 11 Dec 2019 * @copyright 2019 Luigi Capogrosso * @brief <brief> */ #ifndef MULTIPLIER754_RTL_HH #define MULTIPLIER754_RTL_HH #include <systemc.h> //============================================================================== #define SIZE 32 #de...
#include "KoopmanCharacter.h" #include "Player.h" std::shared_ptr<Character> KoopmanCharacter::Create(const std::string name, int order) { std::shared_ptr<Character> character(new KoopmanCharacter(name, order)); return std::move(character); } int KoopmanCharacter::CollectCash() { if (ownedBy) { actionPreformed =...
#include<stdlib.h> #include<pthread.h> #include<jni.h> #include<android/log.h> #include "com_example_ndktest_CallbackTest.h" #define LOG_TAG "jni" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) jmethodID mid; jclass objclass; jobject mobj; pthread_t thread; JavaVM *m_v...
#pragma once #include "AObject.h" #include "TDataTypes.h" class RAnimationSequence: public AObject { DECLARE_CLASS(RAnimationSequence,) public: class RBoneSequence { public: RBoneSequence(RAnimationSequence* Seq) { AnimSequenceRef = Seq; } TString BoneName; struct POSKEY { ...
#ifndef VIEWER_WINDOW_H #define VIEWER_WINDOW_H #include <QMainWindow> #include <QList> #include <QFileDialog> #include <QMessageBox> #include <QtAlgorithms> #include <QPushButton> #include <QString> #include <QVBoxLayout> #include <QHBoxLayout> #include <QLabel> #include <QTextStream> #include <QLineEdit> #include <QI...
/* * Copyright (C) 2007-2015 Frank Mertens. * * Use of this source is governed by a BSD-style license that can be * found in the LICENSE file. * */ #ifndef FLUXNODE_CONNECTIONMANAGER_H #define FLUXNODE_CONNECTIONMANAGER_H #include <flux/types> #include <flux/List> #include <flux/Map> #include "ServiceWorker.h" ...
#include<iostream> using namespace std; int evenoddnumbers(int j , int k) { if (j>k) { return 1; } else { cout <<j<< endl; j+=2; evenoddnumbers(j ,k); } } int main () { int j ,k; cout <<"what are the number between which u want numbers to print? "; cin>> j >>k; if(j%2==0) { j=j; } else { j+=1; } c...
// main.c // // Created: 17 OCT 2010 // Author : Daniel M. Klein // #include <stdlib.h> #include <stdio.h> #include <string.h> extern "C" { #include "common.h" #include "named_tag.h" #include "callbacks.h" #include "tag_list.h" #include "tag_byte_array.h" #include "main.h" } #include <QtGui/QApplication> #include "ch...
#include <iostream> using namespace std; bool isPowerOfThree(int n) { int val = 3; while (true) { val *= 3; if (val == n) return true; else if (val > n) return false; } } int main() { int n = 27; cout << isPowerOfThree(n) << endl; return 0; }
#include <cstdlib> #include <cstdio> double EPS = 1e-10; // gosa double add(double a, double b){ if (abs(a+b) < EPS * (abs(a) + abs(b))) return 0; return a+b; } //2 dimensions vector struct P { double x, y; P(){}; P(double x, double y) : x(x), y(y) { } P operator + (P p) { return P(add(x, p.x), add...
// // Copyright (C) 2017 Ruslan Manaev (manavrion@yandex.com) // This file is part of the Modern Expert System // #include "pch.h" #include "OneResultPage.xaml.h" #include "ProgramController.h" using namespace mes_base; using namespace modern_expert_system; using namespace concurrency; using namespace Platform; usi...
#include <math.h> #include <conio.h> #include <stdio.h> #include <locale.h> #include <stdlib.h> #include <string.h> typedef struct tipo_no no; struct tipo_no { int info; struct tipo_no *prox; }; void insereInicio (int n, no **inicio); int main () { setlocale (LC_ALL, "Portuguese"); no *lista = NULL; in...
#include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h" //stuff to run the motors #include <PS2X_lib.h> //backend stuff to detect the controller, can be downloaded fram this site: http://www.billporter.info/2010/06/05/playstation-2-controller-arduino-library-v1-0/ PS2X ps2...
#include "Box.h" Box::Box():_center(0.0f,0.0f,0.0f),_extent(1.0f,1.0f,1.0f),_scale(1.0f,1.0f,1.0f) { _vertexs.resize(8); }
#include<bits/stdc++.h> #include<limits.h> using namespace std; #define mod 1000000007 #define si(x) scanf("%d", &x) #define sll(x) scanf("%lld", &x) #define pi(x) printf("%d\n", x) #define pll(x) printf("%lld\n", x) #define ii pair<int, int> #define vi vector<int> #define vii vector<pair<int, int> > #define adjList v...
/** * @file multiplier754.ccp * @author Luigi Capogrosso * @date 11 Dec 2019 * @copyright 2019 Luigi Capogrosso * @brief <brief> */ //============================================================================== void multiplier754_cpp(float op1, float op2, float * res) { *res = op1 * op2; } //==============...
// // Created by zanbo on 2020/3/6. // class Solution { public: vector<int> topKFrequent(vector<int>& nums, int k) { unordered_map<int,int> myMap; vector<int> res; for(int x:nums) { myMap[x]++; } // 优先队列 最小堆 priority_queue< pair<int,int>,vector...
// // Copyright (c) 2017-2019 Native Instruments GmbH, Berlin // // 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, cop...
#include<stdio.h> #include<string.h> int main() { int a = 10, b = 5, c = 5; int e; e = a == (b + c); printf("%d", e); }
#include "raw_resource.h" namespace GLPlay { void RawResource::SetData(std::vector<unsigned char> & data) { data_ = std::move(data); } const std::vector<unsigned char> & RawResource::GetData() const { return data_; } }
#include "StringUtils.h" #include "Log.h" #include "Testing.h" #include "Crypt.h" #include "FileSystem.h" #include "Threading.h" #include "UcsTables_Include.h" uint _str::length() { return (uint) s.length(); } bool _str::empty() { return s.empty(); } bool _str::compareIgnoreCase( const stri...
#pragma once #include "Pet.h" #include "Purchase.h" #include <chrono> using namespace std; class PurchaseList { private: int size = 0; int id = 0; Purchase* mergeList(Purchase* list1, Purchase* list2); void splitList(Purchase* start, Purchase** list1, Purchase** list2); void mergeSort(Purchase** start); public: ...
// ***************************************************************************** // Module..: Leddar // /// \file LdConnectionFactory.cpp /// /// \brief Factory to create connection /// /// \author Patrick Boulay /// /// \since February 2016 // // Copyright (c) 2016 LeddarTech Inc. All rights reserved. // *****...
#include "bullet.h" #include <iostream> bullet::bullet(vector pos, vector vel, float s){ position = pos; velocity = vel; size = s; } void bullet::update(float eTime, vector grav){ position = position + velocity * eTime + grav * 0.5 * eTime * eTime; velocity = velocity + grav * eTime; } void bullet::drawBull...
// generating a random sequence of distinct elements #include <bits/stdc++.h> using namespace std; int rand(int a, int b) { return a + rand() % (b - a + 1); } int main(int argc, char *argv[]) { int t; cin >> t; srand(t); // atoi(s) converts an array of chars to int int n = rand(2, 10); printf("%d\n", n); ...
/************************************************************* * > File Name : P1328.cpp * > Author : Tony * > Created Time : 2019/05/21 13:14:14 **************************************************************/ #include <bits/stdc++.h> using namespace std; const int maxn = 200 + 10; int n, n...
#ifndef TRANSLATOR_ANTLR_ERROR_LISTENER_HPP #define TRANSLATOR_ANTLR_ERROR_LISTENER_HPP #include <antlr4-runtime.h> class AntlrErrorListener : public antlr4::BaseErrorListener { void syntaxError(antlr4::Recognizer* recognizer, antlr4::Token* offendingSymbol, size_t line, ...
class Solution { public: int twoSumLessThanK(vector<int>& A, int K) { int res = -1, left = 0, right = A.size() - 1; sort(A.begin(), A.end()); while (left < right) { int cursum = A[left] + A[right]; if (cursum >= K) --right; else { res = max...
// MyCompression.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "MyCompression.h" #define PI 3.14159265358979323846 #define MAX_VAL 65536 #define IMAGE_WIDTH 352 #define IMAGE_HEIGHT 288 #define MAX_LOADSTRING 100 // Global Variables: MyImage inImage, outImage; // image ob...
// C++IOFile.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #define MAX 1024 typedef int(*Fun)(char* s,FILE *file); int chooseAction(Fun fun, char* name) { FILE *file = fopen("D:\\MyProject\\c++\\FILE\\bookname.txt", "a+"); fun(name,file); return 0; } int addFile(char *pName, FILE *file) { char bo...
#include <iostream> #include <string> #include "GameLogic.h" using namespace std; string player1Name; char player1Piece; string player2Name; char player2Piece; int main() { cout << "Please Enter Player 1's Name: "; cin >> player1Name; cout << "Player 1s Name Is " << player1Name << endl; cout << "Please Enter Play...
#include<stdio.h> int func(int n) { static int a = 0; a++; printf("n=%d, a=%d\n", n, a); return 0; } int main() { //static 변수를 사용하는 이유는? int n = 5; func(n); func(n); return 0; }