text stringlengths 8 6.88M |
|---|
#include "precompiled.h"
#include "registeredfunctions.h"
namespace registeredfunctions
{
typedef multiset<StartupFunction> startup_list_t;
typedef multiset<ShutdownFunction> shutdown_list_t;
typedef multiset<ScriptFunction> script_list_t;
startup_list_t& getStartupList();
shutdown_list_t& getShutdownL... |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// Author: Tatparya Shankar
void getSumOfFibonacci()
{
long long int sum = 0;
long long int fib1 = 0;
long long int fib2 = 1;
long long int fibNext = fib1 + fib2;
long long int number;
int scan;
... |
// Created on: 1993-06-15
// Created by: Jean Yves LEBEY
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GN... |
#ifndef TRAJECTORYVIEW_H
#define TRAJECTORYVIEW_H
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QGraphicsView>
#include <QMouseEvent>
#include <QScrollBar>
#include <QTimeLine>
#include <QTextStream>
#include <QToolTip>
#include <QWheelEvent>
#include <QDebug>
#include "Editor.h"
#include "MainWin... |
#include <stdint.h>
#include <stdlib.h>
/**
* @brief 进行转发时所需的 IP 头的更新:
* 你需要先检查 IP 头校验和的正确性,如果不正确,直接返回 false ;
* 如果正确,请更新 TTL 和 IP 头校验和,并返回 true 。
* 你可以从 checksum 题中复制代码到这里使用。
* @param packet 收到的 IP 包,既是输入也是输出,原地更改
* @param len 即 packet 的长度,单位为字节
* @return 校验和无误则返回 true ,有误则返回 false
*/
boo... |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b,c,ans,count;
ans = 0;
cin>>n;
for (int i = 0; i < n; i++)
{
count = 0;
cin>>a>>b>>c;
if(a==1){
count += 1;
}
if(b==1){
count += 1;
}
... |
/* BEGIN LICENSE */
/*****************************************************************************
* SKFind : the SK search engine
* Copyright (C) 1995-2005 IDM <skcontact @at@ idm .dot. fr>
* $Id: filters.cpp,v 1.13.2.3 2005/02/21 14:22:46 krys Exp $
*
* Authors: Mathieu Poumeyrol <poumeyrol @at@ idm .dot. fr>
*... |
#ifndef DOCTOR_H
#define DOCTOR_H
#pragma once
#include<iostream>
#include"person.h"
#include<iomanip>
class doctor :public Person
{
private:
std::string Expertise;
public:
static int count;
doctor() {}
doctor(std::string Name, std::string Family, std::string Phone, std::string Code, std::string ... |
#include <iostream>
#include <iomanip>
using namespace std;
//method declarations
long long int factorial(int N);
int main(){
int numberInput;
long long int factorialAns;
//ask the user for a number
cout << "Enter a number to use to compute a factorial... or enter a negative number to quit: " << endl;
cin ... |
//
// getParameters.cpp
// PlaneMap
//
// Created by Yimeng Zhang on 5/25/14.
// Copyright (c) 2014 Yimeng Zhang. All rights reserved.
//
#include "getParameters.h"
#include <cstdlib>
#include <cstdio>
#include <stdint.h>
#include <fstream>
#include <sstream>
#include <glm/gtc/matrix_transform.hpp>
void getParame... |
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
... |
#include "Object.h"
#include "ObjectStatus.h"
#include "Calculater.h"
#include "Define.h"
#include <math.h>
#include <QFile>
#include <QIODevice>
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
Object::Object(const char* fileName) :
velocity(Vector()),... |
#ifndef SET_H
#define SET_H
template<typename T>
class Set
{
public:
virtual void add(T) = 0;
virtual bool contains(T&) = 0;
};
#endif
|
#ifndef TEXTURE_LOADER_H
#define TEXTURE_LOADER_H
#include <GL\glew.h>
#include <string>
typedef unsigned int U32;
typedef unsigned char U8;
class TextureLoader
{
public:
enum TextureType
{
NONE,
PNG,
JPG,
};
TextureLoader();
TextureLoader(const char* fileName, const char* extension);
~TextureLoader();
... |
#pragma once
#include"Product.h"
class ConcreteProductA:public Product{
public:
ConcreteProductA();
virtual ~ConcreteProductA();
virtual void Use();
};
|
#include "consumer.h"
#include <string>
#include "bnlogif.h"
#include "algo/aes_algo.h"
//begin cipher by liulijin 20170606 add
#include "config.h"
//end cipher by liulijin 20170606 add
static int POS_TYPE = 4;
static string PRIX_BSDR_PRODUCER = "/yl/broadcast/bsdr/producer";
static string TYPE_GET_DATA = "getdata"... |
/*
* 思路:利用无序哈希表存储值到索引的映射
*/
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> ret;
if(nums.empty()){
return ret;
}
unordered_map<int,int> M;
for(int i=0; i<nums.size(); ++i){
M[nums[i]] = i;
}
f... |
#include "projectionlight.h"
ProjectionLight::ProjectionLight(const Transform &t,
const std::shared_ptr<QImage> &projectionMap,
const Point3f &pLight,const Color3f &I,
Float fov
):Light(t... |
#pragma once
#include "ipc_medium.h"
#include "message.h"
#include <queue>
#include <memory>
namespace Petunia {
class IPCInternalMedium;
class IPCMediumDefault: public IPCMedium
{
public:
IPCMediumDefault(std::string &channel, ConnectionRole connection_role = ConnectionRole::Auto);
~IPCMediumDefault(... |
#include<iostream>
#include<clocale>
using namespace std;
int** PereChislenie(int key);
void Watch(int **M, int mM);
void KonZap();
void menu();
int** InOne(int **A, int **B, int mA, int mB); // Объединение графиков
int** Peresek(int **A, int **B, int mA, int mB); // Пересечение графиков
int** Pa3HocTb(int **U, in... |
#pragma once
#include "utils.hpp"
#include "utils/ptts.hpp"
#include "proto/config_rank.pb.h"
using namespace std;
namespace pc = proto::config;
namespace nora {
namespace config {
using rank_reward_ptts = ptts<pc::rank_reward>;
rank_reward_ptts& rank_reward_ptts_instance();
... |
#ifndef DATABASE_H
#define DATABASE_H
#include <QString>
class DataBase
{
public:
DataBase();
void initDataBase(); //初始化数据库
int dealLand(QString id,QString password);
};
#endif // DATABASE_H
|
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <iomanip>
#include <set>
#include <complex>
#include <cstring>
#include <cstdio>
using namespace std;
#define endl '\n'
typedef pair<int, int> pii;
typedef long double ld;
typedef long long... |
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <queue>
#include <vector>
using namespace cv;
using namespace std;
Vec3b empty(182,189,186);
Vec3b hover(198,206,202);
Vec3b full(220,222,222);
Vec3b black(0,0,0);
vector<int> search(Mat_<Vec3b> &img, int rows, int... |
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; c-file-style:"stroustrup" -*-
*
* Copyright (C) 1995-2011 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser.
* It may not be distributed under any circumstances.
*
* Author: Petter Nilsen
*/
#include "c... |
#include "../include/basic.h"
User::User()
{
;
}
std::list<User *> User::getAll()
{
std::string delimiter = DELIMITER;
std::ifstream file("users.txt");
std::string line;
std::string properties[NUMBER_USER_PROPERTIES];
std::list<User *> users;
while (std::getline(file, line))
{
... |
#include "OPENGL_Include.h"
#include "OpenGLDrvPrivate.h"
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include "OpenGLES31.h"
static void printGLString(const char *name, GLenum s) {
const char *v = (const char *)glGetString(s);
#ifdef ANDROID
LOGI("%s", v);
#else
cout <<endl<<name... |
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
using namespace std;
int a[1100];
int main()
{
int t,turn = 0;
scanf("%d",&t);
while (tu... |
// -*- LSST-C++ -*-
/*
* LSST Data Management System
* Copyright 2014-2015 AURA/LSST.
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as publ... |
#include "TilesetWidget.hpp"
#include "ui_TilesetWidget.h"
#include "TileDefinitionDialog.hpp"
#include <Tileset.hpp>
using namespace Maint;
TilesetWidget::TilesetWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TilesetWidget),
_levelManager(NULL),
_textureManager(NULL)
{
ui->setupUi(this);
... |
#include "file.h"
file::file(/* args */)
{
}
file::~file()
{
}
|
/****************************************************************************
* *
* Author : lukasz.iwaszkiewicz@gmail.com *
* ~~~~~~~~ *
* Lice... |
VehicleDocuments[] = {
{Loot_MAGAZINE, 1, ItemORP},
{Loot_MAGAZINE, 1, ItemAVE},
{Loot_MAGAZINE, 1, ItemLRK},
{Loot_MAGAZINE, 1, ItemTNK},
{Loot_MAGAZINE, 1, ItemARM},
{Loot_MAGAZINE, 1, ItemTruckORP},
{Loot_MAGAZINE, 1, ItemTruckAVE},
{Loot_MAGAZINE, 1, ItemTruckLRK},
{Loot_MAGAZINE, 1, Item... |
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
/// Some documentation
struct s{
std::string i;
};
int main(int argc, char *argv[]){
int b = 1;
b++;
void* p;
int* c = new int(2);
char dir[1024];
std::strcpy(dir, argv[1]);
std::sprintf(dir, argv[1]);
}
|
// **********************************************************************
// This file was generated by a TAF parser!
// TAF version 2.1.5.0 by WSRD Tencent.
// Generated from `GMOnline.jce'
// **********************************************************************
#include "GMOnline.h"
#include "jce/wup.h"
#include "s... |
#pragma once
#include "../../Toolbox/Toolbox.h"
#include "Texture2D.h"
#include "../../Maths/Primitives/TRect.h"
namespace ae
{
class Image;
class ImageHDR;
/// \ingroup graphics
/// <summary>
/// 2D image that can be link to a shader to be rendered.
/// </summary>
/// <seealso cref="Image"/>
class AERO_CORE... |
#pragma once
#include "ofMain.h"
#include "grotesParticle.h"
struct lastParticle {
ofPoint pos;
float speed;
float radius;
};
class lastParticles {
public:
void setup();
void update();
void draw();
void toggleGo();
void clear();
vector <lastParticle> particles;
void fadeOut()... |
class Path{
public:
int start_x;
int start_y;
int dist;
Path(int a, int b, int c): start_x(a), start_y(b), dist(c){}
bool operator < (const Path& p) const{return dist > p.dist;}
};
class Solution {
private:
vector<int> delta = {0,1,0,-1,0};
public:
int shortestDistance(vector<vector<int>>& m... |
#pragma once
#include "Core/Core.h"
#include "Common/GeomMath.h"
#include "Scene/SceneCamera.h"
#include "Render/DrawBasic/Texture.h"
#include <string>
namespace Rocket
{
struct TagComponent
{
std::string Tag;
TagComponent() = default;
TagComponent(const TagComponent&) = default;
TagComponent(const std::... |
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int h,m;
float hour,mins,ans;
string input;
while(1)
{
input.clear();
cin>>input;
if(input=="0:00")
break;
if(input[2]==':')
{
h=(input.at(0)-'0')*10+(input.at(1)-'0');
m=(input.at(3)-'0')*10+(input.at(4)-'0');... |
#pragma once
#include "Vector3.h"
class Bullet
{
public:
Bullet();
~Bullet();
void Update(double dt);
void SetPosition(Vector3 pos,Vector3 dist);
void SetTarget(Vector3 pos);
Vector3 GetPosition();
Vector3 gravity;
Vector3 pos;
Vector3 vel;
Vector3 target;
private:
float positiontill;
Vector3 direction;
... |
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
brush = new QBrush;
palette = new QPalette;
brush->setTextureImage(QImage(":/textures/BackgroundMenu.jpg"));
palette->setBrush(QPalet... |
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDirModel>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//setup tree file view and bind to data model
model = new QFileSystemModel();
model... |
/*
* @lc app=leetcode.cn id=5 lang=cpp
*
* [5] 最长回文子串
*/
// @lc code=start
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
string palindrome(string& s, int l, int r){
while(l>=0 && r<s.size() && s[l]==s[r]){
l--;
... |
#include<bits/stdc++.h>
using namespace std;
/*
BFS-Breadth first search
-> You start with a given/source node and then you will reach to its neighbours
-> Its similar to level order traversal in trees
NOTE: Distance travelled by the level order is the shortest distance.
(if the graph is the unwaited graph that m... |
#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 <stdio.h>
#include <string.h>
#include <time.h>
#include <numeric>
using namesp... |
/* -*- Mode: c++; tab-width: 4; c-basic-offset: 4; c-file-style:"stroustrup" -*-
*
* Copyright (C) 1995-2012 Opera Software ASA. All rights reserved.
*
* This file is part of the Opera web browser.
* It may not be distributed under any circumstances.
*/
#include "core/pch.h"
#ifdef M2_SUPPORT
# include "adjun... |
#ifndef ADDONS_DOMAINS_MATRIX_SEMELEM_FIXTURES_HPP
#define ADDONS_DOMAINS_MATRIX_SEMELEM_FIXTURES_HPP
#include "wali/ShortestPathSemiring.hpp"
namespace testing
{
namespace semelem_matrix
{
using namespace boost::numeric::ublas;
using namespace wali::domains;
using wali::ShortestPathSemiring;
const int inf = 1000;
... |
#include "TestGTE.h"
#include <iostream>
#include <iomanip>
int main(int argc, char **argv)
{
using namespace test;
gte device;
GTEtestbench tester(&device);
tester.constructInstruction(0, DCPL);
tester.storeData(gte::RGB, 0x0000000C); // red = 12
tester.storeData(gte::IR0, 0x0... |
#include <locale>
#include <cppunit/extensions/HelperMacros.h>
#include "cppunit/BetterAssert.h"
#include "l10n/LocaleImpl.h"
using namespace std;
using namespace Poco;
namespace BeeeOn {
class SystemLocaleImplTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SystemLocaleImplTest);
CPPUNIT_TEST(testLanguage... |
#include<iostream>
//#include<cstdio>
#include<ctime>
#include <windows.h>
#include<time.h>
#include<stdio.h>
#define MAX 10001
#define MAX_RANGE 10001
#define MIN(a,b) a<b?a:b
#define good 8
using namespace std;
typedef int typee;
typee a[MAX],b[MAX];
double random(double start,double end){
return star... |
#pragma once
class CD3DFont;
namespace ui
{
class Console
{
public:
Console();
~Console();
void render();
void chooseFont();
void addMessage(const char* message);
void addMessage(const string& message);
void charpressed(const eXistenZ::KeyEventArgs& args);
void keypressed(const eXistenZ::KeyEventA... |
#ifndef VNASTANDARDMODEL_H
#define VNASTANDARDMODEL_H
// Rsa
//
// Qt
#include <QMetaType>
namespace RsaToolbox {
class VnaStandardModel
{
public:
enum /*class*/ Type {
Open,
Short,
Match,
R,
Thru
};
VnaStandardModel();
VnaStandardModel(const VnaStandardMode... |
#define _CRT_SECURE_NO_WARNINGS
//#define LOCAL_TEST
#include <iostream>
#include "parser.hpp"
#include "bookingSystem.h"
ticketBookingSystem S;
string getToken(const string &str, int t) {
int l = str.length(), cnt = 0, st = 0;
for(int i=0;i<l;i++)
if (str[i] == ' ') {
cnt++;
if (cnt == t) return str.subst... |
#include <iostream>
#include "Controller.hpp"
#include "Briscola.hpp"
#include "View.hpp"
int main(){
// TEST Briscola
Briscola* model = new Briscola();
Controller<Briscola>* cont = new Controller<Briscola>( model , new View<Briscola>() );
// REMPLACER LA LIGNE 32 PAR CELLES-CI POUR TESTER PLUS VITE (SANS E... |
#include "TestCPU.h"
#include <iostream>
int main(int argc, char** argv)
{
using namespace test;
memoryInterface *mem = new RAMImpl(10);
cpu device(mem);
CPUtestbench tester(&device);
mem->writeWord(0x110, 0xFEDCBA09);
tester.storeReg(1, 0x55);
tester.storeReg(2, 0x77);
... |
#include <NTL/GF2X.h>
#include <stdint.h>
#include <UnitTest++.h>
#include <tr1/random>
#include <sstream>
#include "xsadd.h"
#include "xsadd.c" // to check static functions
using namespace NTL;
using namespace std;
void touz(uz *r, ZZ& x)
{
ZZ work = x;
uz_clear(r);
for (int i = 0; i < UZ_ARRAY_SIZE; i++... |
// Sharna Hossain
// CSC 111
// Lab 8 | grades_switch2.cpp
#include <iostream>
using namespace std;
int main()
{
int grade;
char letter_grade;
cout << "Enter a grade (0-100): ";
cin >> grade;
if (grade >= 0 && grade <= 100)
{
// This solution works because grade is an int being d... |
#include <bits/stdc++.h>
using namespace std;
#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define MAXN 20000000
#define INF 0x3f3f3f3f
#define DEVIATION 0.00000005
typedef long long LL;
bool sieve[MAXN+10];
vector <int> Prime;
vector <pair<int,int>> TwinPrime;
void build(){
memset(sieve, 0, size... |
// Created on: 1994-10-13
// Created by: Jean Yves LEBEY
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GN... |
//
// main.cpp
// PlaneMapBatch
//
// Created by Yimeng Zhang on 5/25/14.
// Copyright (c) 2014 Yimeng Zhang. All rights reserved.
//
// Include standard headers
#include <iostream>
#include <cstdio>
#include <cstdlib>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <GLFW/glfw3.h>
// Include GLM
#inc... |
#include "udpclient.h"
// liste des commandes
char scmd[] = "b<ps>nxi m-+v";
UdpClient::UdpClient( QObject *parent ) : QObject( parent )
{
hostIp.setAddress( QString( LAROCOLA_IP ));
#ifdef DEBUG
if( udpSocket.bind( SERVER_PORT ))
qDebug() << "Ready to read";
else
qDeb... |
#include<iostream>
#include<cmath>
using namespace std;
int n;
char gr;
void putout(string s)
{
int space=s.find(' '),lth=s.length();
int n1=0,n2=0,n3;
for(int i=0;i<space;i++) n1=n1*10+s[i]-'0';
for(int i=space+1;i<lth;i++) n2=n2*10+s[i]-'0';
if(gr=='a')
{
n3=n1+n2;
while(n3) n3/=10,lth... |
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2009 Opera Software ASA. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*/
#ifndef DOM_JILUTILS_H
#define DOM_JILUTILS_H
#ifdef DOM_JIL_A... |
#pragma once
#include "WeaponInfo.h"
class MeshBuilder;
class Pistol :
public CWeaponInfo
{
public:
Pistol(GenericEntity::OBJECT_TYPE _bulletType);
virtual ~Pistol();
// Initialise this instance to default values
void Init(void);
//render weapon
void Render();
//Reolad gun
void Reload();
// Discharge this ... |
#ifndef _PLAYER_H
#define _PLAYER_H
#include <string>
using namespace std;
class PLAYER
{
private:
//private data members
unsigned short p_Level;
unsigned int p_Xp;
int p_HpMax;
int p_Hp;
short p_Armour;
short p_Attack;
string p_EquipedWeapon;
string p_EquipedHeadArmour;
string p_EquipedChestArm... |
#ifndef CALLER_H
#define CALLER_H
// These classes were made to provide a unified way of using
// pointers to functions as well as pointers to member functions
// KEEP IN MIND THAT THE MEMBER FUNCTION POINTERS 'GO BAD' once
// the object they point to is deleted!
template<typename retType, typename... paramType>
clas... |
// This program converts a set of images to a lmdb/leveldb by storing them
// as Datum proto buffers.
// Usage:
// convert_imageset [FLAGS] ROOTFOLDER/ LISTFILE DB_NAME
//
// where ROOTFOLDER is the root folder that holds all the images, and LISTFILE
// should be a list of files as well as their labels, in the format... |
// Lingor hangars
class land_ibr_hangar : House {
model = "\ibr\ibr_hangars\ibr_hangar";
scope = 2;
vehicleClass = "ibr_hangars";
transportFuel = 0;
transportRepair = 0;
icon = "\ibr\ibr_hangars\icons\icon5.paa";
mapSize = 40;
displayName = "House";
destrType = "DestructBuilding";
armor = 1200;
}; |
#include <string>
#include <iostream>
#include <map>
#include <math.h>
#include <stdexcept> // std::invalid_argument
#include <string>
#include <sstream>
#define SSTR( x ) dynamic_cast< std::ostringstream & >( \
(std::ostringstream() << std::dec << x)).str()
std::pair<int,int> * ParElem(std::stri... |
#include<bits/stdc++.h>
using namespace std;
int cnt1[10];
int cnt2[10];
int cnt[10];
int main() {
memset(cnt1,0,sizeof(cnt1));
memset(cnt2,0,sizeof(cnt2));
memset(cnt,0,sizeof(cnt));
int n;
cin>>n;
for(int i=0; i<n; i++) {
int x;
cin>>x;
cnt1[x]++;
... |
/* Copyright 2018 The TensorFlow Authors. 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 a... |
#include <functional>
#include <mutex>
using namespace std;
/*
本题固定有5个哲学家,多个线程共享一个实例对象,会抢着调用同一个实例对象的wantsToEat方法
大部分C++/Java解法都是使用Semaphore API,类似Mutex
我注意到Rust的Semaphore Deprecated since 1.7.0: easily confused with system sempahores and not used enough to pull its weight
而且Rust官方教程中的哲学家问题就是通过将Mutex去解决哲学家进餐问题的,所以... |
#include <algorithm>
#include <cstring>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <sstream>
#include <unordered_map>
#include "../utils/VectorUtils.hpp"
#include "../utils/PrintUtils.hpp"
// ... |
//
// Created by manout on 18-4-9.
//
static int x, y;
static unsigned long int dfs(int x_, int y_, int k)
{
if (x_ == x and y_ == y)
return 1;
if (x_ < 0 or x_ > 8 or y_ < 0 or y_ > 8 or k == 0)
return 0;
unsigned long int ans = 0;
ans += dfs(x_ + 1, y_ + 2, k - 1);
ans += dfs(x_ ... |
#pragma once
#include <vector>
#include <string>
#include <iostream> // tmp
#include <llog/severity_type.hpp>
#include <llog/argument.hpp>
namespace llog
{
class Context
{
public:
protected:
Context * parent_;
typedef std::vector<Context*> ChildListType;
ChildListType childs_;
std::string name_;
std::s... |
// Created on: 2000-02-05
// Created by: data exchange team
// Copyright (c) 2000-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2... |
/******************************************************************************
* *
* Copyright 2018 Jan Henrik Weinstock *
* *
... |
#include <string>
#include <vector>
#include <filesystem>
#include <boost/process.hpp>
#include <deco/all.h> |
#include <iostream>
#include <iterator>
#include "PuzzleArea.h"
#include "Item.h"
#include "SDLobsluga.h"
#include <string>
Item::Item(){
}
void Item::ChangeImage(int id,bool OnOff) {
switch (id) {
case 1:
SDL_RenderSetViewport(Obraz, &Slot1);
break;
case 2:
SDL_RenderSetViewport(Obraz, &Slot2);
break;
ca... |
// https://www.codechef.com/viewsolution/23658836
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
using namespace std;
bool comp(vector<pair<ll,ll>> a,vector<pair<ll,ll>> b)
{
if(a.size()>b.size())
return 1;... |
#include <iostream>
using namespace std;
int req[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int getSticks(int x)
{
int sticks = 0, rem;
while (x)
{
rem = x % 10;
x = x / 10;
sticks += req[rem];
}
return sticks;
}
int main()
{
int a, b, t;
cin >> t;
while (t--)
{
... |
/**
\file Kick.hpp
\author UnBeatables
\date LARC2018
\name Kick
*/
#pragma once
/*
* Kick inherited from BehaviorBase.
*/
#include <BehaviorBase.hpp>
/**
\brief This class is responsable for robot`s kick behavior.
*/
class Kick : public BehaviorBase
{
private:
static Kick *instance;
... |
// Created on: 2006-05-26
// Created by: Alexander GRIGORIEV
// Copyright (c) 2006-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version ... |
#ifndef __GAME_WORLDSPAWN_H__
#define __GAME_WORLDSPAWN_H__
/*
===============================================================================
World entity.
===============================================================================
*/
class idWorldspawn : public idEntity {
public:
CLASS_PROTOTYPE( idWorlds... |
/********************************************************************************
** Form generated from reading UI file 'networkaccessviewer.ui'
**
** Created: Tue Mar 8 09:41:16 2011
** by: Qt User Interface Compiler version 4.7.1
**
** WARNING! All changes made in this file will be lost when recompiling UI file... |
// Created on: 1995-03-06
// Created by: Laurent PAINNOT
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GN... |
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GeneticAI.h"
#include "Components/ActorComponent.h"
#include "NeuralInputComponent.generated.h"
class ANeuralNetworkManager;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class GENETICAI_API UNeu... |
/*
ID: washirv1
PROG: PROGRAM
LANG: C++
*/
#include <iostream>
#include <fstream>
using namespace std;
#define INFILE "PROGRAM.in"
#define OUTFILE "PROGRAM.out"
int main()
{
ifstream fin(INFILE);
fin.close();
ofstream fout(OUTFILE);
fout.close();
return 0;
}
|
/*
* File: main.cpp
* Author: Daniel Canales
*
* Created on July 27, 2014, 11:09 AM
*/
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
/*
*
*/
const int SIZE = 10;
const int SIZE2 = 12;
const int SIZE3 = 5;
const int ROW = 3;
const int COL ... |
#include "SceneHandler.hpp"
SceneHandler::SceneHandler()
{
}
SceneHandler::~SceneHandler()
{
}
Scene * SceneHandler::addScene(Scene * scene) {
m_scenes[scene->getName()] = scene;
return scene;
}
void SceneHandler::setScene(std::string name) {
Scene* s = m_scenes[name];
if (s != NULL) {... |
#include "implicitconstant.h"
namespace anl
{
CImplicitConstant::CImplicitConstant() : m_constant(0){}
CImplicitConstant::CImplicitConstant(double c) : m_constant(c){}
CImplicitConstant::~CImplicitConstant(){}
void CImplicitConstant::setConstant(double c){m_constant=c;}
double CImplicitConsta... |
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
**
** Copyright (C) 1995-2006 Opera Software ASA. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
**
*/
#ifndef SVG_DOM_ANGLE_IMPL_H
#define SVG_DOM_ANGLE_IMPL_H
#in... |
/*! \file */ //Copyright 2011-2016 Tyler Gilbert; All Rights Reserved
#ifndef THREAD_HPP_
#define THREAD_HPP_
#ifndef __link
#include <pthread.h>
#include "Sched.hpp"
namespace sys {
/*! \brief Thread Class
* \details This class creates and manages new threads using POSIX calls.
*
*/
class Thread {
public:
en... |
#pragma once
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <fstream>
#include <cstring>
#include <exception>
struct BadParse : public std::exception
{
const char * what() const throw ()
{
return "json parser Error!";
}
};
enum JsonTyp... |
#include <string>
namespace ariel{std::string snowman(int x);}; |
// Sharna Hossain
// CSC 111
// Lab 22 | exercise_2.cpp
// Ask user to enter the size of the array and then ask him to enter
// values for this array. Then by using pointer calculate the average
// of all these numbers.
// Hint: array name is the address of the first element of an array.
// so by knowing the address ... |
#pragma once
#include <cassert>
#include <functional>
namespace breakout
{
class Allocator
{
public:
Allocator(const size_t size);
virtual ~Allocator() = 0;
virtual void* allocate(const size_t size) = 0;
virtual void deallocate(void* p) = 0;
protected:
size_t m_memorySize = 0;
size_t m_allocatedMe... |
#include <iostream>
#include <deque>
using namespace std;
deque<int> q;
deque<int>::iterator it;
int csize;
void implement(int x)
{
if (q.size() == csize)
{
if (std::find(q.begin(), q.end(), x) != q.end())
{
for (it = q.begin(); it != q.end(); it++)
{
i... |
//
// Main menu for Blackjack
// Project: A2BlackJack
// Created by: Ryan Purse
// Date: 23/11/2020
//
#include <iostream>
#include "../public/blackjack.h"
#include "../public/input.h"
#include "../public/settings.h"
#include "../public/tutorial.h"
void menuInfo() {
system("CLS");
std::cout << "-_-_-_-_-_-_-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.