text stringlengths 8 6.88M |
|---|
#include "Bag.h"
#include "BagIterator.h"
#include "ShortTest.h"
#include "ExtendedTest.h"
#include <iostream>
#include<vector>
#include <assert.h>
using namespace std;
int main() {
testAll();
cout << "Short tests over" << endl;
testAllExtended();
return 0;
} |
/***************************************************************************
* Filename : OpenGLContext.cpp
* Name : Ori Lazar
* Date : 29/10/2019
* Description : Implements the OpenGL Context handling interface.
.---.
.'_:___".
|__ --==|
[ ] :[|
|__| I=[|
/ / ____|
|-/.____.'
/___\ /_... |
// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.
#include "MeshBuffer.h"
#include "MeshBufferResource.h"
#include "Buffer.h"
#include "Renderer.h"
#include "core/Engine.h"
namespace ouzel
{
namespace graphics
{
MeshBuffer::MeshBuffer()
{
resource = s... |
#include "../../Dependencies/glew/glew.h"
#include "../../Dependencies/freeglut/freeglut.h"
#include "Shader_Loader/Shader_Loader.hpp"
#include "Game_Models/Game_Models.hpp"
#include <iostream>
using namespace Core;
GLuint program;
Models::GameModels* gameModels;
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BI... |
#include<iostream>
using namespace std;
int sumOfN(int n){
if (n==0)
{
return 0;
}
else
{
return sumOfN(n-1)+n;
}
}
int main(int argc, char const *argv[])
{
cout<<sumOfN(5);
return 0;
}
|
#ifndef MESA_H
#define MESA_H
#include <graphics.h>
#include <sstream>
#include <string>
#include <iostream>
#include <graphics.h>
#include "Pieza.h"
using namespace std;
class Mesa
{
private:
int x1, x2, y1, y2; //Coordenadas necesarias para graficar un bar3d.
Pieza * ficha; //Si se encuentra la ficha dentro de... |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t , arr[t];
cin>>t;
for(int i = 0; i<t ; i++)
{
cin>>arr[i];
}
vector<int> v;
stack<int> s;
for(int i = t - 1; i>=0; i--)
... |
//---------------------------------------------------------------------------
#include <vcl.h>
#include "MainForm.h"
#pragma hdrstop
#include "OverallSettingsForm.h"
#include "S9Utils.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
T... |
#include <iostream>
using namespace std;
int f(int);
int g(int);
int main()
{
while(true)
{
int n;
cin>>n;
if(n==-1) return 0;
cout<<f(n)<<endl;
}
return 0;
}
int f(int n)
{
if(n==0) return 0;
else if(n==1) return 0;
else if(n==2) return 3;
return f(n-2) + (g(n-1) * 2);
}
int g(int n)
{
if(n==1) r... |
#include "file.h"
namespace File
{
String readEntireFile(String filename, Error* error) {
zeroMemory(error, sizeof(File::Error));
FILE* f = fopen(filename.data, "rb");
if (f == 0)
{
print("readEntireFile:: Invalid file. File = %s\n", &filename);
if (error) {
error->errorCode = FILE_CANT_OPEN;
}
... |
#include "base/pch.hpp"
#include "base/zenlang.hpp"
#include "gui/Mainframe.hpp"
#include "WindowImpl.hpp"
z::MainFrame::Create::_Out z::MainFrame::Create::run(const z::MainFrame::Definition& def) {
#if defined(WIN32)
z::widget::impl& impl = WindowImpl::createMainFrame(def, WS_OVERLAPPEDWINDOW, WS_EX_WINDOWEDGE);
... |
/*
Longest Common Subsequence (LCS). The following are some instances£º
a) X: xzyzzyx Y: zxyyzxz
b) X: ALLAAQANKESSSESFISRLLAIVAD
Y: KLQKKLAETEKRCTLLAAQANKENSNESFISRLLAIVAG
*/
#include<stdio.h>
#include<stdlib.h>
#define RESULTLEN 100
int getLCS(char[],int,char[],int ,char[][RESULTLEN]);
int getLen(char[]);
void sho... |
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
#include "vectors.h"
TEST_CASE("Verify Test Configuration", "verification") {
REQUIRE(true == true);
}
TEST_CASE("Test function is_prime") {
REQUIRE(is_prime(2) == true);
REQUIRE(is_prime(4) == f... |
/***************************************************************************
# Copyright (c) 2020, NVIDIA CORPORATION. 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... |
/*
* Metric.h
*
* Created on: May 25, 2011
* Author: marchi
*/
#ifndef METRIC_H_
#define METRIC_H_
#include <cmath>
#include "Ftypedefs.h"
#include "MyVec.h"
#include <vector>
using std::vector;
class Metric {
matrix co, oc;
static const matrix Idtity;
void invertCO();
int count;
double AA(){return n... |
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl ... |
#include <cstdint>
#include <iostream>
#include "packet.h"
namespace comms {
std::ostream& operator<<(std::ostream &o, Packet &p) {
o << "ID: " << (int) p.ID << " Index: " << p.index << " Data: ";
if (p.ID == ID_MSG1) {
for (int i = 0; i < 16; i++)
o << (char) p.data[i];
} else {
for (int i = 0; i < ... |
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (long long int i = (a); i < (b); i++)
#define FORR(i, a, b) for(long long int i = (a); i >=(b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=10... |
/***********************************************************************
created: Sun Jan 11 2009
author: Paul D Turner
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2009 Pa... |
// This question is special, instead of using DP solution, we kind of use the markov chain.
class Solution {
public:
int maxProfit(vector<int>& prices) {
if(prices.empty()) return 0;
int n = prices.size();
vector<int> s0(n), s1(n), s2(n);
s0[0] = 0;
s1[0] = -prices[0];
... |
#include "../common/tcp_socket.h"
#include "protocol6.hpp"
#include <iostream>
using namespace std;
/*定义MAX_SEQ 保证为 2^n-1*/
const seq_nr MAX_SEQ = 7;
const seq_nr NR_BUFS = ((MAX_SEQ + 1) / 2);
bool no_nak = true;
//static const char* NetworkProcName = "./protocol6_network_s";
//static const char* Da... |
//TODO: this class actually ignores overflows of long's.
class Tone
{
private:
unsigned long frequency;
unsigned long delayTime;
unsigned long lastTime;
bool isHigh;
int pin;
public:
Tone(int p);
void setTone(unsigned int freq);
void play();
void stop();
enum note{c1=131, d1=14... |
#ifndef CONSULTOR_H
#define CONSULTOR_H
#include "Funcionario.h"
#include <iostream>
class Consultor: public Funcionario{
private:
float percentual;
public:
void setPercentual(float p);
float getPercentual();
float getSalario(float percentual);
virtual float getSalario(... |
//*******************************************************************************
// VMA209 - Pot meter + PWM example
// The VMA209 contains a blue potmeter (trimmer) which is connected to Analog 0
// In this example we show You how to measure the voltage between 0 and 5V,how to visualise it by the serial monitor, a... |
/* 3DMeshMetric is a visualization tool used to measures and display
* surface-to-surface distance between two triangle meshes.
*
* 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 vers... |
#ifndef _BALL
#define _BALL
#include "ofMain.h"
class Ball
{
public:
Ball();
~Ball();
void setup();
void update();
void draw();
// variables
float x;
float y;
float speedX;
float speedY;
int dim;
ofColor color;
private:
};
#endif |
// -*- 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... |
// Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.
#include "core/CompileConfig.h"
#if OUZEL_SUPPORTS_DIRECT3D11
#include "BufferResourceD3D11.h"
#include "RendererD3D11.h"
#include "core/Engine.h"
#include "utils/Log.h"
namespace ouzel
{
namespace graphics
{
BufferReso... |
#include <list>
#include <unordered_map>
using namespace std;
class LRUCache{
public:
LRUCache(int capacity):capa(capacity) {
}
int get(int key) {
unordered_map<int, __Val>::iterator wh = cache.find(key);
if(wh != cache.end()){
lru.splice(lru.begin(), lru, wh->s... |
#include "AStar.h"
//当前游戏的状态 0表示路,1表示起点,2表示障碍,3表示终点
AStar::AStar(int **newmap,int x1,int y1,int x2,int y2) {
for (int i = 0; i < 28; i++) {
for (int j = 0; j < 38; j++) {
map[i][j] = newmap[i][j];
}
}
//for (int i = 0; i < 28; i++) {
// for (int j = 0; j < 38; j++) {
// log("%d",map[i][j]);
// }
//}
ASt... |
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word, sentence;
while (cin >> word)
sentence = sentence + word;
cout << sentence << endl;
return 0;
}
|
#include<iostream>
#include<climits>
#define ll long long int
using namespace std;
int main()
{
ll n;
cin>>n;
ll b[n];
ll max=0,n_max=0,min=LONG_MAX,n_min=0;
for(int i=0; i < n; i++)
{
cin>>b[i];
if(b[i]>max)
{
max = b[i];
n_max = 1;
}
else if(b[i]==max)
n_max++;
... |
/* ---------------------------------------------------------------------
* Numenta Platform for Intelligent Computing (NuPIC)
* Copyright (C) 2013-2015, Numenta, Inc. Unless you have an agreement
* with Numenta, Inc., for a separate license for this software code, the
* following terms and conditions apply:
*
* ... |
#include <iostream>
using namespace std;
int main()
{
int a[3], b[3], s = 0, l = 0;
for (int i = 0; i < 3; i++) cin >> a[i];
for (int i = 0; i < 3; i++) cin >> b[i];
for (int i = 0; i < 3; i++)
if (a[i] == b[i])
s += 1;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (a[i] == b[j]) l += 1... |
#include<iostream>
using namespace std;
int dp[30001];
int missile[20];
int n;
int main()
{
for(int i=0;i<=30001;i++)
{
dp[i]=0;
}
n=0;
while(!cin.eof())
{
cin >>missile[n];
dp[missile[n++]]=1;
}
for(int i=0;i<20;i++)
{
for(int j=
{
}
}
}
|
//
// main.cpp
// BFBDetectGraph
//
// Created by Tidesun on 21/3/2019.
// Copyright © 2019 Oliver. All rights reserved.
//
#include <iostream>
#include <chrono>
#include <ctime>
#include "file_reader.hpp"
#include "bfb_calculator.hpp"
using namespace std;
int main(int argc, char *argv[]) {
double costThreshol... |
#include<iostream>
#include<cmath>
using namespace std;
int dfs(int n,char a,char b,char c)
{
if(n==1)
{
cout<<a<<"-->"<<c<<endl;
}
else
{
dfs(n-1,a,c,b);
cout<<a<<"-->"<<c<<endl;
dfs(n-1,b,a,c);
}
}
int main()
{
int n;
cin >>n;
dfs(n,'A','B','C');
return 0;
}
|
#include "CUFLU.h"
#ifdef __CUDACC__
#include "CUAPI.h"
#include "CUFLU_Shared_FluUtility.cu"
#endif
#if ( MODEL == HYDRO && defined SRHD )
/********************************************************
1. Approximately relativistic ideal gas EoS (Taub-Mathews EoS)
2. This file is shared by both CPU and GPU
GPU_EoS_... |
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
void calc_Histo(const Mat& image, Mat& hist, Vec3i bins, Vec3f range_max, int _dims);
vector<Mat> load_histo(Vec3i bins, Vec3f ranges, int nImages);
Mat draw_histo(Mat hist);
Mat query_img();
Mat make_img(Mat img1, Mat img2);
Mat calc_similarity(Ma... |
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
bool compare(pair<int,int> &a,pair<int,int> &b){
return a.second>b.second;
}
int main(){
int n;
while(scanf("%d",&n)){
vector< pair<int,int> > buffer,result;
pair<int,int> temp;
for(int i=0;i<n;i++){
... |
#include <vector>
#include <string>
class Deck {
vector<Card*> base;
public:
// shuffle deck, randomize order of cards
vector<Card*> shuffle(vector<Card*> cards);
// drawCard from deck, return pointer to card drawn
Card* drawCard();
// whether deck contains any cards or not
bool isEmpty()... |
#include <opencv2/opencv.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include<math.h>
#define PI 3.1415926535
#define E 2.718281828
using namespace cv;
using namespace std;
struct feature
{
int sigma;
int x;
int y;
int octave;
double m;
double ori;
double theta;
double de... |
// lisp-aqtplotter.h -- Declarations for AquaTerm Graphics under Lisp
//
// DM/MCFA 02/99
// AquaTerm mods 06/04 DM
// ---------------------------------------------------------
#ifndef __GRAPHICS_H__
#define __GRAPHICS_H__
#define DEFAULT_WIN_ID 0
#define DEFAULT_X_POS 50
#define DEFAULT_Y_POS 50
#d... |
#include<iostream>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<strings.h>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
string h,k;
cin>>h>>k;
if(h.equal(k))
cout<<"r";
/* vector<string>l1;
int i,n,t;
char s[100];
cin>>t;
while(t--)
{
... |
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM9DS1.h>
#include <Adafruit_Simple_AHRS.h>
// Create LSM9DS0 board instance.
Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1();
// Create simple AHRS algorithm using the LSM9DS0 instance's accelerometer and magnetometer.
Adafruit_Simple_AHRS ahrs(&lsm.getAcce... |
#include "FrameBuffer.h"
#include "Globals.h"
#include "glad.h"
namespace
{
constexpr std::array<glm::vec2, 6> QUAD
{
glm::vec2(-1.0f, -1.0f),
glm::vec2(1.0f, -1.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(-1.0f, 1.0f),
glm::vec2(-1.0f, -1.0f)
};
constexpr std::array<glm::vec2, 6> TEX... |
//
// Created by 邓岩 on 2019/5/20.
//
/*
* 连号区间数
问题描述
小明这些天一直在思考这样一个奇怪而有趣的问题:
在1~N的某个全排列中有多少个连号区间呢?这里所说的连号区间的定义是:
如果区间[L, R] 里的所有元素(即此排列的第L个到第R个元素)递增排序后能得到一个长度为R-L+1的“连续”数列,则称这个区间连号区间。
当N很小的时候,小明可以很快地算出答案,但是当N变大的时候,问题就不是那么简单了,现在小明需要你的帮助。
输入格式
第一行是一个正整数N (1 <= N <= 50000), 表示全排列的规模。
第二行是N个不同的数字Pi(1 <= Pi <= N), 表示... |
#include "TreeDecompositionPACE.h"
RawInstructiveTreeDecomposition::RawInstructiveTreeDecomposition() {
// constructor
}
void RawInstructiveTreeDecomposition::print(unsigned &k, unsigned parentno) {
k++;
std::cout << k << " " << type << "(" << parentno << ") ";
bag.print();
for (auto it = color_to_vertex_map.begi... |
#include "CDrawing.h"
CDrawing::CDrawing(const SDrawingInfo& s)
{
V_PSM = CShaderManager::getInstance();
V_Array = V_PSM->M_GetPolygon(s.PolygonName);
V_Color = s.Global_Color;
V_Program = s.Program;
V_DrawMode = s.DrawMode;
V_LineColor = s.Line_Color;
}
void CDrawing::M_Draw(const glm::mat4& mat, T4Double colo... |
//
// SpriteFilterInkwell.h
// iPet
//
// Created by KimSteve on 2017. 5. 25..
// Copyright © 2017년 KimSteve. All rights reserved.
//
#ifndef SpriteFilterInkwell_h
#define SpriteFilterInkwell_h
#include <2d/CCSprite.h>
class SpriteFilterInkwell : public cocos2d::Sprite
{
public:
static SpriteFilterInkwell * ... |
#include "SplashScene.h"
#include "cocos2d.h"
#include "MenuScene.h"
#include "SoundControl.h"
USING_NS_CC;
Scene* SplashScene::createScene(){
auto scene = Scene::create();
auto layer = SplashScene::create();
scene->addChild(layer);
return scene;
}
bool SplashScene::init(){
if(!Layer::init()){
... |
#include <VirtualWire.h>
#include <Timer.h>
//Alive timer: once per 700 ms, the program checks for connection
Timer t;
boolean isAlive = true;
int dyingTimer;
//Pins for motor shield
int motor11;
int motor12;
int motor21;
int motor22;
void setup()
{
//Pins for motor shield
pinMode(motor11,OUTPUT);
p... |
#ifndef CONTAINER_H
#define CONTAINER_H
/**
* A common wrapper interface for container-like data structures.
*
* @tparam U is the type of element in this container
*/
template<class U>
class Container {
public:
/**
* @return the pre-allocated capacity of this data structure if relevant, otherwise 0
*... |
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main(){
int t;
cin >> t;
while(t--){
int n,x;
cin >> n;
v.clear();
for(int i=0;i<n;i++){
cin >> x;
v.push_back(x);
}
sort(v.begin(),v.end());
long long ans=0;
for(int i=0;i<(n/2);i++)
ans+=(v[n-i-1]-v[i]);
cout << ans << ... |
#include<iostream>
using namespace std;
int main()
{
int i,j,k,l,m;
string n;
cin>>n;
l=n.length();
if(n[0]!='-')
{
cout<<n<<endl;
}
else
{
if(n[l-1]-'0' >= n[l-2]-'0') { n.erase(n.begin()+(l-1)); if(n=="-0") cout<<n[1]<<endl; else cout<<n<<endl;}
else {n.erase(n... |
class Solution {
public:
int findNumbers(vector<int>& nums) {
int res = 0;
for (auto elem : nums) {
if (ndigits(elem) % 2 == 0) ++res;
}
return res;
}
int ndigits(int ival) {
int res = 0;
while (ival) {
ival /= 10;
++res;
}
return res;
}
};
|
#include<iostream>
using namespace std;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
void func() {
int a, b;
while (cin >> a >> b) {
int max = gcd(a, b);
int res = a / max * b;
cout << res << endl;
}
}
int main() {
func();
return 0;
}
|
#ifndef LSEDES_H
#define LSEDES_H
#include <iostream>
#include "sede.h"
using namespace std;
class Lsedes
{
private:
string lista_sedes[50];
int lista_tiempo[50];
int tamanio;
public:
Lsedes(Sede *sede[], int lenght);
void getListaSedes();
~Lsedes();
};
#endi... |
/* Copyright 2017-2018 All Rights Reserved.
* Gyeonghwan Hong (redcarrottt@gmail.com)
*
* [Contact]
* Gyeonghwan Hong (redcarrottt@gmail.com)
*
* 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 Lic... |
//Switch statements
//Author: Dalton Hook
//Date:4/19/2018
#include <iostream>
#include <string>
int main()
{
int bookScanID = 0;
std::string bookOwner;
std::cout << "Book ID Number pleae enter here" <<
std::endl;
std::cin >> bookScanID;
switch (bookScanID)
{
case 1:
level1();
break;
bookOwner = "Dalto... |
/*Tile Class
Contains data and logic for an individual tile*/
#ifndef TILE_H
#define TILE_H
#include "rectangle.h"
#include "globals.h"
struct SDL_Texture;
class Graphics;
class Tile {
public:
Tile();
Tile(SDL_Texture* tileset, Vector2 size, Vector2 tilesetPosition, Vector2 position);
void update(int elapsedTime)... |
// ControlDemo.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "windows.h"
#include "commdlg.h"
#include "DUILib.h"
#include "DUIPopupWindow.h"
#include "DUIDebug.h"
#include "DUIControls.h"
#include "DUIResLoader.h"
#include "DUISkinMgr.h"
#include "DUIDibProcess.h"
#include "Python.... |
class IProgess
{
public:
virtual void DoProgress(float value) = 0;
~IProgess();
};
class FileSplitter
{
public:
FileSplitter(const string& filePath,int fileNumber):m_filePath(filePath),m_fileNumber(fileNumber)
{
}
~FileSplitter();
void addIProgress(IProgess* iprogress) //订阅者自主决定是否订阅此通知
... |
#pragma once
#include"Shader.hpp"
#include "texture_2d.hpp"
#include "sprite.hpp"
#include "../GameEngine/game.hpp"
#include "billboard.hpp"
#include "mouse_effect.hpp"
#include "text.hpp"
#include<vector>
#include<glm/gtc/matrix_transform.hpp>
#include<glm/gtc/type_ptr.hpp>
#include<SFML/System/Vector2.... |
#include "music.h"
music::music(void)
{
Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096);
}
music::~music(void)
{
}
void music::Play()
{
melody = Mix_LoadMUS( "music.flac" ); //muzika
Mix_PlayMusic(melody, -1);
}
void music::SFX()
{
hit = Mix_LoadWAV("hit.flac"); //atsimusimo garsas
Mix_PlayChannel( -1,... |
#pragma once
#include "app.h"
class misc_data {
public:
misc_data(u8* memory_pointer);
~misc_data();
private:
}; |
//
// GA-SDK-CPP
// Copyright 2018 GameAnalytics C++ SDK. All rights reserved.
//
#pragma once
#if !USE_UWP && !USE_TIZEN
#include <exception>
#include <string>
#include <signal.h>
namespace gameanalytics
{
namespace errorreporter
{
class GAUncaughtExceptionHandler
{
public:
... |
#include <iostream>
using namespace std;
int substr(char arr[],char str[]){
int si=0, ai=0;
bool found;
while(arr[ai] != '\0'){
//cout << "-------";
if(str[si] == arr[ai] && arr[ai-1]== ' '){
found=true;
int index=ai;
while(str[si] != '\0'){
if(str[si] != arr[ai]){found=false; ai++;break;}
else{... |
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
template <class T>
void quick_sort(T b, T e)
{
if (b == e)
return;
auto l = b, r = e - 1;
cout << "!:" << *l << " " << *r << endl;
while (l < r)
{
cout << *l << " " << *r << endl;
while (*r > *b)
r--;
while (*l <= *b && l < ... |
#include <cstdio>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
long long int status[1000000];
void siv()
{
long long int N=1000000,i,j;
long long int sq=sqrt(N);
for(i=4; i<=N; i+=2) status[i]=1;
for(i=3; i<=sq; i+=2)
{
if(status[i]==0)
{
... |
// https://www.acwing.com/problem/content/102/
// acwing增减序列
#include <bits/stdc++.h>
using namespace std;
#define cin ios::sync_with_stdio(false); cin // cin 优化加速
#define N 110000
typedef long long ll;
ll n, m, i, j, p, q, a[N];
int main() {
freopen("note.txt", "r", stdin);
freopen("ans.txt", "w", stdout);
... |
// BRice & CHubbell
//=================================================================
// Declare Global Variables & Header Files
//=================================================================
// Including Arduino's I2C library, as well as the ultrasonic,
// motorshield, and LCD libraries.
#include <Wire.h>
... |
// mips.cpp
#include "mips.h"
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <cmath>
using namespace std;
char res[100];
/*
* Return an initialized computer with the stack pointer set to the
* address of the end of data memory, the remaining registers initialized
* to zero, a... |
C/C++获取本地日期时间常见方法
1.跨平台方法
1.1方法一:手动暴力法(snprintf)
snprintf()函数用于格式化输出字符串到指定大小的缓冲,可以获取我们想要的日期时间格式。
#include <iostream>
using namespace std;
#include <time.h>
time_t t = time(NULL);
struct tm* stime=localtime(&t);
char tmp[32]{0};
snprintf(tmp,sizeof(tmp),"%04d-%02d-%02d %02d:%02d:%02d",1900+... |
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cout << "가격 입력 : ";
cin >> a >> b >> c;
cout << "상품1 :";
cout.width(7);
cout << a << "원\n";
cout << "상품2 :";
cout.width(7);
cout << b << "원\n";
cout << "상품3 :";
cout.width(7);
cout << c << "원\n";
}
|
////////////////////////////////////////////////////////////////////////////////
#include <polysolve/FEMSolver.hpp>
#include <catch.hpp>
#include <iostream>
#include <unsupported/Eigen/SparseExtra>
////////////////////////////////////////////////////////////////////////////////
using namespace polysolve;
TEST_CASE("... |
#ifndef TREEWIDZARD_AUXILIARYCONTROLLER_HPP
#define TREEWIDZARD_AUXILIARYCONTROLLER_HPP
#include <fstream>
#include <iostream>
inline void show_manual() {
// random settings (not implemented in this version) [-random <seed> <intro
// vertex probability> <forget vertex probability> <ping number>]
//
/*
Random Searc... |
class Solution {
public:
int lengthOfLongestSubstring(string s) {
unordered_map<int, int> m;
int res_length = 0;
int cur_length = 0;
for(int i = 0; i < s.length(); i++)
{
if(m.find(s[i] - 'a') == m.end())
{
m[s[i] - 'a'] = i;
... |
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source c... |
// Copyright Epic Games, Inc. All Rights Reserved.
#include "PuzzlePlatformers.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, PuzzlePlatformers, "PuzzlePlatformers" );
|
#ifndef BSCHEDULER_DAEMON_NETWORK_MASTER_HH
#define BSCHEDULER_DAEMON_NETWORK_MASTER_HH
#include <chrono>
#include <unordered_map>
#include <unordered_set>
#include <unistdx/net/interface_addresses>
#include <bscheduler/api.hh>
#include <bscheduler/daemon/master_discoverer.hh>
#include <bscheduler/ppl/socket_pipelin... |
#ifndef __LINBOX_matrix_SlicedPolynomialMatrix_SlicedPolynomialMatrixMulKaratsuba_INL
#define __LINBOX_matrix_SlicedPolynomialMatrix_SlicedPolynomialMatrixMulKaratsuba_INL
#include <givaro/givpoly1dense.h>
#include <givaro/givpoly1denseops.inl>
#include "linbox/matrix/MatrixDomain/blas-matrix-domain.h"
#include "linbo... |
#include <Arduino.h>
#include <ESP8266WebServer.h>
#include <PubSubClient.h>
#include <ESP_MQTTLogger.h>
#include "led_peripheral.h"
#define LED_PIN 2
LedPeripheral::LedPeripheral() {}
void LedPeripheral::begin(ESP_MQTTLogger& l) {
// set up the logger
_logger = l;
_updateable = true;
_publishabl... |
#include <iostream>
#include <cstdio>
using namespace std;
int x[100], y[100], z[100], i;
int KUCHKA1(int a1, int i)
{
}
int KUCHKA2(int a2, int i)
{
}
int KUCHKA3(int a3, int i)
{
}
void FUNKCIAPvP(int a)
{
int a1, a2, a3, k;
for (i = 0;i < a;i++)
{
x[i]++;
y[i]++;
z[i]++;
}
a1 = a;
a2 = a;
a3 = a;
co... |
#include "Video.h"
namespace photon {
int num_initialized = 0;
};
void photon::Video::initialize() {
if(num_initialized == 0)
SDL_Init(SDL_INIT_VIDEO);
num_initialized++;
}
void photon::Video::destroy() {
num_initialized--;
if(num_initialized == 0)
SDL_Quit();
}
|
/**
* This is an example demonstrating the use of the LiFuelGauge library
* The example uses an LCD display to show battery status information
* When an Alert Threshold interrupt is generated, the lowPower ISR is
* called and the a sign appears on the LCD display
*
* Note:
* After exiting sleep mode or resett... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
ll n,x;cin>>n;
vector<int>a(n+1);
for(int i=0;i<n;i++) {
cin>>x;
a[x]=i+1;
}
int l=1,ans=1;
for(int i=1;i<=n;i++){
if(l>a[i]) ans++;
l=a[i];
}
cout<<ans;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt","r... |
#include "mpi.h"
// for local development
//#include "/usr/lib/openmpi/include/mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>
#include "mpi_openmp_barrier.h"
#include "../OpenMP/centralized/openmp_centralized_barrier.h"
#include <unistd.h>
#define ROUND 100
int main(int argc, char** argv){
if (argc !... |
// Charlie Company Loadouts
// By SFC.Atherton.H version 0.1
// Squad
class Cav_B_C_AutomaticRifleman_F : Cav_B_Charlie_base_F { //General AR : 28kg
//backpack[] = {"B_AssaultPack_mcamo"};
//goggles[] = {"rhs_googles_clear"};
headgear[] = {"rhsusf_ach_helmet_ocp"};
uniform[] = {"... |
/*
Copyright (c) 2014, Martin Björkström
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 an... |
#include<iostream>
#include<cstring>
using namespace std;
int m,n;
int dp[51][51];
int x1,y1,x2,y2;
int mxy[4][2]=
{
1,2,
1,-2,
2,1,
2,-1
};
int main()
{
cin >>n>>m;
cin >>x1>>y1>>x2>>y2;
memset(dp,0,sizeof(dp));
dp[x1][y1]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
//if(dp[i][j]>0)
f... |
#include <fstream>
#include <stdexcept>
#include "ppm.h"
namespace ppm {
void
write_ppm(const std::string& filename, const std::vector<unsigned char>& data,
unsigned int width, unsigned int height)
{
std::ofstream outfile {filename, std::ios_base::out};
if (!outfile.is_open()) {
throw std::... |
/*
* Generating fibonnaci numbers
* with__Dynamic Programming__
*/
#include <iostream>
#define rep(i,n) for(i=0;i<n;i++)
#define x 94
using namespace std;
main()
{
unsigned long long int f[100];
int i;
f[0] = 0; f[1] = 1;
for(i=2;i<x;i++)
{
f[i] = f[i-1] + f[i-2];
}
rep(i,x)
{
if(0)cout<<f[i]<<endl;
... |
#include <algorithm>
#include <iterator>
#include <vector>
#include <string>
#include <iostream>
template<typename T>
struct Not_starts_with{
public:
Not_starts_with(const T& val) : value_{val} { }
template<typename U>
bool operator()(const U& x) { return *(std::begin(x)) != value_;}
private:
T value_... |
/****************************************
*
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
* Copyright (C) 2019 Victor Tran
*
* 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 Foundati... |
#include <iostream> // iostream
#include "Course.h"
#include <vector>
#include <string>
#include "HASH_NODE.h"
using namespace std;//Hello world
const int COURSE_SIZE = 83;
Course courseList[COURSE_SIZE];
const int HASH_SIZE = 111;
HASH_NODE* hashTable[HASH_SIZE];
struct RESULT{
Course result_course;
int s... |
#ifndef HTTPENDPOINTJSONGET_H
#define HTTPENDPOINTJSONGET_H
#include "httpendpoint.h"
#include "jsonconverter.h"
#include <functional>
template <typename T> class HttpEndpointJsonGet : public HttpEndpoint {
public:
using callback_t = std::function<const T(void)>;
HttpEndpointJsonGet(const String &endpoint) : HttpE... |
//
// Created by Peter Chen on 5/29/16.
//
#ifndef CUBEWORLD_ITEMDEFINITION_H
#define CUBEWORLD_ITEMDEFINITION_H
class ItemDefinition {
};
#endif //CUBEWORLD_ITEMDEFINITION_H
|
#include<iostream>
template <class T>
T function(T a, T b, T f)
{
return (a + b - f / a) + f * a * a - (a + b);
}
// (2 + 3 - 4 / 2) + 4 * 2 * 2 - (2 + 3)
//44
int main()
{
int a = 3;
int b = 2;
int f = 5;
std :: cout << function(a, b, f) << '\n';
std :: cout << function(3.1, 4.2, 2.7) << '\n';
std :: cout <<... |
#include "BinaryTree.h"
template <class TKey, class TItem>
class IDictionary {
private:
//BinaryTree<TKey, TItem>* Tree;
int Capacity;
int Count;
public:
BinaryTree<TKey, TItem>* Tree;
IDictionary(int capacity = 100) {
this->Capacity = capacity;
this->Count = 0;
this->Tree = new BinaryTree... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.