blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 117 | path stringlengths 3 268 | src_encoding stringclasses 34
values | length_bytes int64 6 4.23M | score float64 2.52 5.19 | int_score int64 3 5 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | text stringlengths 13 4.23M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
395b35ed4fa6e14051d684840d9e6317895bdb1c | C++ | tmdrnahs/algorithm | /DFS/blob.cpp | UTF-8 | 2,770 | 2.953125 | 3 | [] | no_license | // 문제 설명
// 해마다 열리는 꿀꿀이 올림피아드에는 여러 종목들이 있는데, 요즘에는 꿀꿀이들의 교양을 겨루는 ‘미술관람 대회’가 인기를 끌고 있다. 이 대회는 사회자가 빨강, 초록, 파랑으로 이루어진 N × N 픽셀의 그림을 보여주면 그 그림에 포함된 영역의 수를 빠르고 정확하게 맞추는 것이 목표이다. 동일한 색깔이 네 방향(상, 하, 좌, 우) 중 한 곳이라도 연결되어 있으면 하나의 영역으로 간주한다.
// 예를 들어, 아래 그림은 각각 2, 1, 1개의 빨간색, 초록색, 파란색 영역이 있어 총 4개의 영역이 있다.
// 한편, 꿀꿀이들의 절반 정도는 선천적인... | true |
10b2d731e5c80bb45ad433564e865e110328beeb | C++ | andreyciupitu/ray-tracing | /Source/RayTracingDemo/Collider.h | UTF-8 | 467 | 2.859375 | 3 | [] | no_license | #pragma once
class SceneObject;
namespace Physics
{
struct Ray;
struct HitInfo;
class Collider
{
public:
Collider(SceneObject *obj) : sceneObject(obj) {}
virtual ~Collider() {}
// Computes the intersection of the collider with the ray.
// Returns the hit details in the hit info, and returns false
// ... | true |
f1e662eb9241b623ce345734ec4bfab298aa709a | C++ | hanrick2000/Algorithms-9 | /Ad hoc/codechef_lisdigit.cpp | UTF-8 | 950 | 2.671875 | 3 | [] | no_license | /*--------------------------------------------------------------------------------------------------------
* Name : CNatka
* Problem : LISDIGIT
* Source : Codechef
* Link : https://www.codechef.com/problems/LISDIGIT
* DS : NA
* Algo : NA
* Date : Jan 22, 2017
* Complexity : O(T*n) || AC(0.04 sec)
* Solve... | true |
b5aec84263ed04e2617bfe2243ffc1ffa2eb8af5 | C++ | FlashNoob98/unina | /Aritmetica/media_num_pari/media_num_pari.cpp | UTF-8 | 475 | 3.53125 | 4 | [] | no_license | /* Media algebrica dei numeri pari */
#include <iostream>
using namespace std;
int main(){
int n,x,p=0,somma=0;
cout << "Questo programma esegue la media dei numeri pari inseriti"<<endl;
cout << "Di quanti numeri vuoi fare la media?: ";
cin >> n;
for (int i=0; i<n; i++){
cout << "Inserisci il "<<(i+1)<<"° numero... | true |
16b24607ba4bbb3a4481b00b39c232e5169ecd2c | C++ | nnngu/my_first_cpp_book | /p366_C++是如何实现指针变量的静态类型和动态绑定的.cpp | UTF-8 | 2,887 | 4.0625 | 4 | [
"MIT"
] | permissive | /*
C++是如何实现指针变量的静态类型和动态绑定的?
我们知道,C++ 是一种强类型的编程语言,它的每一个变量都有其确定的类型。但是,
当这个变量是指针的时候,情况就有些特殊。我们有一个某种类型的指针,而它实际上指向的是其派生类的
某个对象。例如,一个 Human* 指针实际上指向一个 Student 对象。
Student st;
Human* pHuman = &st; // 将基类指针指向派生类对象
这时,pHuman 指针就有了两种类型;指针的静态类型(在此是 Human)和它所指向的对象的
动态类型(在此是 Student)。
静态类型意味着成员函数调用的合法性将被尽可能早地检查:编译器在编译时,编译器可... | true |
16614ed0554b33b75ea3bcc6f872054edc610c55 | C++ | marin117/Collision_detection | /src/AABBTreeNode.h | UTF-8 | 568 | 2.640625 | 3 | [] | no_license | #ifndef AABBTreeNode_h
#define AABBTreeNode_h
#include "AABB_box.h"
#include <memory>
#include <vector>
class Node {
typedef std::unique_ptr<Node> ptr;
public:
Node() = default;
Node(const AABB_box bbox);
Node(ptr &left, ptr &right);
bool isLeaf();
void insertLeaf(ptr &leaf);
void treeTraverse();
v... | true |
a183b560c03bd65bc5a3cf35ae430d9d9baf238f | C++ | bboyifeel/parallel_and_grid_classes | /pi/2_boost_mpi.cpp | UTF-8 | 1,929 | 2.59375 | 3 | [] | no_license | #include <mpi.h>
#include <iostream>
#include <cmath>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <boost/mpi.hpp>
namespace mpi = boost::mpi;
void mpiSimpsonsPiCalc(int argc, char *argv[]);
int main(int argc, char *argv[]) {
mpiSimpsonsPiCalc(argc, argv);
return... | true |
fa52047d326f27eb8a426e4af8d20dbdb8b29074 | C++ | pcruiher08/LosDesafiosDeJuanito | /Soluciones/1.1 - Triangulos.cpp | UTF-8 | 334 | 3.234375 | 3 | [] | no_license | #include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
/*
Problema 1.1
Complejidad de tiempo: O(1)
*/
int main() {
int casos;
cin >> casos;
for (int i = 0; i < casos; i++) {
int lado;
cin >> lado;
float altura = lado * sqrt(3) / 2;
cout << fixed << setprecision(2);
cout << altura ... | true |
7d64d85582ad7ff4396bfab65feb06c8743f5d0f | C++ | dwax1324/baekjoon | /code/15903 카드 합체 놀이.cpp | UTF-8 | 689 | 2.796875 | 3 | [] | no_license | #include <bits/stdc++.h>
// 그리디
// 항상 작은것 두개만 더해주면됨
// 우선순위큐사용 (오름차순)
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
priority_queue<long long, vector<long long>, greater<long long>> pq;
for (long long i = 0; i < n; i++) {
long long a;
cin >> a;
pq.push(a);
... | true |
ba9ad783736d1dd406487ab5b01f2f24a3ee10be | C++ | jbebe/all-my-projects | /priv/desktop/C++/daily programmer @reddit/challenge 17.cpp | UTF-8 | 209 | 2.671875 | 3 | [] | no_license | #include <iostream>
#include <regex>
int main(){
std::string first = "Daily Programmer",
second = "aeiou ";
std::cout << std::regex_replace(first,std::regex("["+second+"]"),"");
getchar();
return 0;
} | true |
f501588aaf2f26de259e4a090c97951016b2d177 | C++ | docppp/Computer-aided-analysis-of-colorymetric-tests | /drug.cpp | UTF-8 | 3,380 | 2.875 | 3 | [] | no_license | #include "drug.h"
#include <QDebug>
#include <QString>
#define LOG std::cout<<
#define TEST
int Drug::loadFromLine(std::string line)
{
int n = 0;
for (int i = 0; i < line.size(); i++) if (line[i] == ';') n++;
if (n != NUMBER_OF_TESTS * 2)
{
#ifdef TEST
LOG "DRUG: ERROR! Line " << lin... | true |
f00176d30e6f42a28f6574bae72ce9749d5b827e | C++ | HariniJeyaraman/DSAPrep | /rotateList.cpp | UTF-8 | 2,052 | 3.96875 | 4 | [] | no_license | //Rotate linked list right by k nodes
#include<iostream>
#include<cstdlib>
#include<vector>
struct node
{
int data;
struct node *nptr;
};
struct node* hptr=NULL;
void insertNode(int pos, int x)
{
struct node *temp=new node;
if(temp==NULL)
std::cout<<"Insert not possible\n";
temp->data=x;
... | true |
bc0226302ba7f41e66c2a665ed011fc8a2343e0a | C++ | tihonov-e/cpp_stepik | /SET_MAP/Source/lab6.cpp | UTF-8 | 5,247 | 3.046875 | 3 | [] | no_license |
//1.11 Словари и множества
/**
Однажды, разбирая старые книги на чердаке, школьник Вася нашёл англо-латинский словарь.
Английский он к тому времени знал в совершенстве, и его мечтой было изучить латынь.
Поэтому попавшийся словарь был как раз кстати.
К сожалению, для полноценного изучения языка недостаточно только ... | true |
c0f35e823fa1f6d4702ccf97031a528b4b062d25 | C++ | sd-ot/sdot | /src/sdot/Support/Stat.cpp | UTF-8 | 1,667 | 2.90625 | 3 | [] | no_license | #include <iostream>
#include <iomanip>
#include "Stream.h"
#include "Stat.h"
#include "Mpi.h"
namespace sdot {
Stat stat;
Stat::~Stat() {
size_t max_length = 0;
for( auto td : stats )
max_length = std::max( max_length, td.first.size() );
for( const auto &st : stats ) {
if ( st.second.ste... | true |
902bb481caf87ec4c280b77016209338804e73e0 | C++ | JohnHonkanen/ProjectM | /Game/Scripts/test/InventoryPopulator.h | UTF-8 | 712 | 2.53125 | 3 | [
"MIT"
] | permissive | /*
InventoryPopulator class used as a helper to test the warehouse inventories
at runtime.
*/
#pragma once
#include "components\Behaviour.h"
class InventoryPopulator : public Behaviour
{
public:
InventoryPopulator();
InventoryPopulator(class PlayerActions* pla, class Resources* res);
void Onload();
// Creates te... | true |
ae38a803ded624aaee14ab61e6d27ee89d3a185e | C++ | Spoders/motMystere | /tp01/main.cpp | ISO-8859-1 | 2,754 | 3.375 | 3 | [] | no_license | #include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;
int calculeLigne();
string chercheMotAlea(int nombreDeLigne);
string melangeMot(string motMystere);
int main() {
string motMystere, motMelange, motTemporaire, reponse = "n";
int nombreDeLigne = 0, nb... | true |
4a31c41b0707777e8404023d8ccabd9fd502dfda | C++ | windwarrior/Codesign-Project | /Eindopdracht/SpiderLib/SpiderController.h | UTF-8 | 682 | 2.734375 | 3 | [] | no_license | #ifndef _SPIDER_H_
#define _SPIDER_H_
#include "Arduino.h"
#include "Motor.h"
enum Turn{
TURN_LEFT,
TURN_RIGHT,
};
class SpiderController{
public:
SpiderController();
void turnLeft();
void turnRight();
void forward();
void back();
void begin(int leftpin, int middle... | true |
d1105a7ea60d8b291b258c7beb781ba23a62639c | C++ | Abhishek765/DSA_Final | /DP/ShortestCommonSuperSequence.cpp | UTF-8 | 1,052 | 3.0625 | 3 | [] | no_license | #include<bits/stdc++.h>
using namespace std;
//! TC: O(n*m)
//! SC: O(n*m)
class Solution
{
public:
int LCS(string x, string y, int n, int m){
int dp[n+1][m+1];
// bottom-up approach
for(int i=0; i<=n; i++){
for(int j=0; j<=m; j++){
... | true |
86891af23acb0f42f40d5222d0b623c986a00813 | C++ | Iamsobad1990/SmartPeak | /src/smartpeak/include/SmartPeak/core/WorkflowManager.h | UTF-8 | 2,270 | 2.765625 | 3 | [
"MIT"
] | permissive | #pragma once
#include <SmartPeak/core/ApplicationHandler.h>
namespace SmartPeak {
class WorkflowManager {
public:
/**
Copies the passed application_handler and sets up the async run of the workflow. Only one
workflow is managed at a time
@param[in,out] The application_handler that gets copi... | true |
fb33d707b115df149dd5253d0b1ad724059b6b86 | C++ | asphaltbuffet/cg-practice-cpp | /test/testFactorial.cpp | UTF-8 | 1,003 | 2.765625 | 3 | [
"MIT"
] | permissive | /*
* Copyright (c) 2019 Ben Lechlitner (otherland@gmail.com)
* Distributed under the MIT License.
* See accompanying file LICENSE.md or copy at http://opensource.org/licenses/MIT
*/
#ifdef USE_CATCH2
#include <catch2/catch.hpp>
#elif USE_GTEST
#include <gtest/gtest.h>
#endif // USE_CATCH2
#include "cg-practic... | true |
4a445be718da6339f729dec83e9ef308ecae4cb2 | C++ | pthaike/coder | /hiho/hiho101.cpp | GB18030 | 3,881 | 3.203125 | 3 | [] | no_license | /**
http://hihocoder.com/contest/hiho101/problem/1
1У1tʾ1t10
tݣÿĸʽΪ
1У2n,mʾݵ2n,m100
2..n+1Уÿmֻ01
1..tУiбʾiǷڽ⣬"Yes""No"
2
4 4
1 1 0 1
0 1 1 0
1 0 0 0
0 1 0 1
4 4
1 0 1 0
0 1 0 0
1 0 0 0
0 0 1 1
No
Yes
*/
#include <stdio.h>
using namespace std;
#define MAXLEN 100
int matrix[MAXLEN];
struct _node
{
st... | true |
f9c34d448d8f40cf35aafeb5fc463ece1c1df94b | C++ | chanthamoney/csci3081 | /project/src/observer.h | UTF-8 | 1,333 | 2.84375 | 3 | [] | no_license | /**
* @file observer.h
*
* @copyright 2017 3081 Staff, All rights reserved.
*/
#ifndef SRC_OBSERVER_H_
#define SRC_OBSERVER_H_
/*******************************************************************************
* Includes
******************************************************************************/
#include <iostr... | true |
8e78a1128db1e299e03fe89d11838920b7a92133 | C++ | StroudCenter/S-CAN-Modbus | /src/scanAnapro.h | UTF-8 | 2,597 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | /*
*scanAnapro.h
*/
#ifndef scanAnapro_h
#define scanAnapro_h
#include <scanModbus.h> // For modbus communication
#include <TimeLib.h> // for dealing with the TAI64/Unix time
//----------------------------------------------------------------------------
// FUNCTIONS TO CREATE PRINTOUTS THAT WILL READ IN... | true |
a57077f89d1e646c380f6093d5e8dd066d851a04 | C++ | GreJangre/algorithm_C | /11720.cpp | UTF-8 | 249 | 2.59375 | 3 | [] | no_license | #include <stdio.h>
int main() {
int N=0;
char num[101];
int sum=0;
scanf("%d\n", &N);
scanf("%s", num);
for (int i=0; i<N; i++) {
sum += num[i] - '0';
}
printf("%d", sum);
return 0;
}
| true |
d85f04fdf668216b6a380c132d351027aa1b618f | C++ | glaSSSeaweed/DataStructureAndAlgorithm | /1_5/3.cpp | UTF-8 | 1,028 | 2.640625 | 3 | [] | no_license | class Solution {
public:
Solution() :counter(0),tmparr() {}
void ms(vector<int>& arr, int L, int R);
vector<int> tmparr;
int counter;
int reversePairs(vector<int>& nums) {
int len = nums.size();
if (len < 2)
return 0;
tmparr = vector<int>(len);
ms(nums, 0,... | true |
5d32bd2f6a707ebdad4c26f1aeeabd46e032ca71 | C++ | wanliuestc/mengmengda | /c++/testfriend.cpp | UTF-8 | 375 | 3.15625 | 3 | [] | no_license | #include <iostream>
#include <string>
using namespace std;
class T
{
private:
int a;
string s;
friend void testfriend(T *);
friend class O;
public:
T():a(0),s("hello"){}
};
class O
{
};
void testfriend(T *t)
{
cout << t->a << " " << t->s << endl;
}
int main(void)
{
T *t = new T(... | true |
dc33dce689d611e188f4d429b336abe3ac24ef96 | C++ | wusuopubupt/hackerrankcpp | /introduction/arrays.cpp | UTF-8 | 393 | 2.765625 | 3 | [] | no_license | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
for(int j = n-1;... | true |
ed7d11c94b5fa37645f2d59365f1ac1201927d36 | C++ | jethrokuan/cpp-algos | /kattis/apaxiaaans.cpp | UTF-8 | 187 | 2.78125 | 3 | [] | no_license | #include <iostream>
using namespace std;
char c;
int main() {
char prev = 0;
while (scanf("%c", &c) == 1) {
if (c != prev) {
prev = c;
printf("%c", c);
}
}
}
| true |
c39e44c1d48eda9fbfde3d2938f4a151365fe5c9 | C++ | bmcdonnel/data-structures | /cpp/exercises/reverse_bits.cpp | UTF-8 | 1,349 | 3.640625 | 4 | [] | no_license | #include <iostream>
#include <cstdint>
#include <bitset>
uint32_t easy_reverse_bits(const uint32_t number)
{
uint32_t rebmun = 0;
for (int i = 0; i < 32; ++i)
{
rebmun = (rebmun << 1) + ((number >> i) & 1);
}
return rebmun;
}
uint32_t fast_reverse_bits(const uint32_t number)
{
// 0x01234567 becomes ... | true |
49e00e32e00619d4a531667698a277f301dbf81d | C++ | LuminousAme/Dam-Defense | /modules/Titan/include/Titan/Graphics/ITexture.h | UTF-8 | 1,374 | 2.671875 | 3 | [] | no_license | //Titan Engine, by Atlas X Games
// ITexture.h - header for the base class that different types of textures inherit from
#pragma once
//precompile header, this file uses cstdint, memory, glad/glad.h, and GLM/glm.hpp
#include "Titan/ttn_pch.h"
namespace Titan {
//base class for different texture types
class TTN_ITe... | true |
087ae598b9a70f2371ed00e784669767bb55a25c | C++ | stephaneAG/Qt_tests | /qt_arduino_test1/corresponding_arduino_sketch/QtArduino1.ino | UTF-8 | 844 | 3.21875 | 3 | [
"MIT"
] | permissive | /*
** Arduino - Qt 'qextserialport' lib test file 1
**
** controls the brightness of a LED present on the pin 9
**
** ~schematics: Gnd <->l LED L<->1KOhm resistor<->pin9
**
*/
const int ledPin = 9; // the pin the LED is attached to
//const byte ledBrightness = 150;
void setup()
{
Serial.begin(9600); //st... | true |
6dd8b8340d19a8d106107fe4ea791cc751cfa9a9 | C++ | chrisburr/Kepler | /Tb/TbEvent/src/TbTrack.cpp | UTF-8 | 1,718 | 2.515625 | 3 | [] | no_license | #include "Event/TbTrack.h"
using namespace LHCb;
//=============================================================================
// Track copy constructor
//=============================================================================
TbTrack::TbTrack(const LHCb::TbTrack& rhs) :
KeyedObject<int>(),
m_time(rhs.m_... | true |
07d765175dcac5d7ec64e405ae6dcadaf5c6174b | C++ | Muhammad-Ihsan-SanSanS/Tugas062320 | /Tugas062320.cpp | UTF-8 | 1,078 | 3.03125 | 3 | [] | no_license | #include <iostream>
using namespace std;
int main () {
cout << "_=-*PENGISIAN BIODATA*-=_\n\n";
string nama;
cout << "Ikuti Langkah Berikut untuk Memasukkan Data Diri Anda!\n";
cout << "Siapa Nama Anda?\n";
getline (cin, nama);
cout << "\nHello " << nama << ", Mari Isi Lebih Lengkap Datanya!\n";
... | true |
c0a804cd3154448ac3b48ca33bf0f9cd78cd011e | C++ | Manash-git/C-Programming-Study | /array using loop.cpp | UTF-8 | 196 | 2.703125 | 3 | [] | no_license | //
#include<stdio.h>
#define array_size 5
int main(){
int manash[array_size] = {10,20,30,40,50};
for(int i=0;i<array_size;i++){
printf("\tManash[%d] is : %d\n",i,manash[i]);
}
return 0;
}
| true |
06b57552353cae19e21946b0456ce9cda56a4a4f | C++ | victorfarias/Introduction-Programming-ES-20181 | /moodle_matrizes/quadrado_magico.cpp | UTF-8 | 1,004 | 3.328125 | 3 | [] | no_license | #include <iostream>
using namespace std;
void ler_matriz(int n, int m, int mat[][3]){
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin >> mat[i][j];
}
}
}
int quadrado_magico(int n, int m, int mat[][3]){
int base =0;
for(int i=0; i<n; i++){
base += mat[i][i];
... | true |
e1a24ee3c2fa8528789991ae6c505b0292601729 | C++ | Ace-HasIssuesToo/SP3Remade | /Base/Source/Sensor.cpp | UTF-8 | 3,463 | 2.59375 | 3 | [] | no_license | #include "Sensor.h"
#include "Player.h"
#include "Enemy_Poison.h"
#include "Enemy_Psychic.h"
#include "Enemy_Ghost.h"
#include "EnemyDark.h"
#include "GameState.h"
Sensor* Sensor::m_pointer = new Sensor();
void Sensor::Init()
{
float Speed = 1.f;
Save = MeshBuilder::GenerateSpriteAnimation("Save", 1, 8);
Save->te... | true |
461e6a3320c463a1a4b2d15f13a1390dcb6d5196 | C++ | Zhgsimon/Parametric_landscapes_generator | /astre.h | ISO-8859-1 | 627 | 2.640625 | 3 | [] | no_license | #ifndef ASTRE_H_INCLUDED
#define ASTRE_H_INCLUDED
#include "environnement.h"
///Dclaration de la classe abstraite "Astre" qui hrite de la classe
///"Environnement" et mere des classes soleil, lune, etc...
///fais hriter une couleur et des coordonnes sera utilis dans leur fonction addCercle... pour dessiner la figure ... | true |
42d279299dbc9667869df2033e44ea9363631cbf | C++ | PacktPublishing/Cpp-for-game-developers | /Module 1/B04920_Code/B04920_Code/B04920_08_FinalCode/roguelike_template/src/Gold.cpp | UTF-8 | 840 | 3.234375 | 3 | [
"MIT"
] | permissive | #include "PCH.h"
#include "Gold.h"
// Default constructor.
Gold::Gold()
{
// Randomly generate the value of the pickup.
this->goldValue = std::rand() % 21 + 5;
// Choose a sprite based on the gold value.
int textureID;
if (this->goldValue < 9)
{
textureID = TextureManager::AddTexture("../resources/loot/gold/... | true |
3879af114fc7572c145a4759ea4a3b6eda5c593c | C++ | vijay532/Game-Using-c- | /RockPaperScissor.cpp | UTF-8 | 1,522 | 2.984375 | 3 | [] | no_license |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
ll n,i,j;
//cin>>j;
do
{
cout<<"How many Rounds will be there ?"<<endl;
cin>>n;
cout<<"Rock=r or R Paper=p or P Scisor=s or S..... | true |
dd3f6cef99f2c83073f3e0e1df023c3cc4471f1f | C++ | christosg88/hackerrank | /Data_Stractures/2-Linked_Lists/Compare_two_linked_lists/compare-two-linked-lists.cpp | UTF-8 | 1,122 | 4.375 | 4 | [
"MIT"
] | permissive | /**
* Compare two linked lists A and B.
* Return 1 if they are identical and 0 if they are not.
*
* Node is defined as:
* struct Node
* {
* int data;
* Node *next;
* }
*/
/**
* Compares two linked lists for equality. Two linked lists are considered equal
* if they contain the same number of nodes a... | true |
e89cbd54866839bb6c099120083381de19614678 | C++ | leesatoh/itCep | /snippets/small/chronotest.cpp | UTF-8 | 584 | 2.984375 | 3 | [] | no_license | #include <iostream>
#include <unistd.h>
#include <chrono>
int main(){
std::chrono::system_clock::time_point start, end; // 型は auto で可
start = std::chrono::system_clock::now(); // 計測開始時間
// 処理
usleep(1000000);
end = std::chrono::system_clock::now(); // 計測終了時間
double elapsed = std::chrono::duration_cast<std::chro... | true |
344f9736a6013cda9596209d8a014fd94ecc6330 | C++ | AndrewKhusnulin/Labs-4b-6 | /Lab-5.cpp | UTF-8 | 711 | 3.40625 | 3 | [] | no_license | #include <iostream>
using namespace std;
int sum(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
int multiply(int a, int b)
{
return a*b;
}
int main(int argc, char *argv[])
{
setlocale(LC_ALL, "rus");
int a, b;
if (!sscanf_s(argv[1], "%d", &a))
{
cout << "Отсутствует параметр 1" ... | true |
690df1292cb5c6eeead98fd2c44e56d415be750d | C++ | zhangkari/exercise | /ICE/src/lib/security/CRc4.cpp | UTF-8 | 1,143 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | #include <IUnknow.h>
#include <IceType.h>
#include <string.h>
#include <CRc4.h>
#include <IID.h>
#include <ErrorCode.h>
ECode CRc4::QueryInterface(IID gid, void** ppv)
{
if(gid == IID_IRc4Encrypt)
{
*ppv = static_cast<IRc4*>(this);
return NOERROR;
}
if(gid == IID_IRc4Decrypt)
{
*ppv = static_cast<IRc4*>(th... | true |
0f40e5282d13a792afaed67c5ab1aeabe855371b | C++ | olee12/uva_onlinejudge_solutions | /Codes/10462 - Is There A Second Way Left.cpp | UTF-8 | 2,521 | 2.59375 | 3 | [] | no_license | #include<cstring>
#include<bits/stdc++.h>
using namespace std;
struct edge
{
int u,v,w,pos;
bool operator < (const edge& p) const
{
return w<p.w;
}
};
int par[110];
int find_par(int r)
{
return (r==par[r] ? r : (par[r]= find_par(par[r])));
}
vector<edge> e,sec_mst;
int x,y,www,pos;
int mst... | true |
c2e158974c22e7b3e690ead8cf3ea392b9aeb997 | C++ | pig0726/LeetCode | /problemset/Missing_Number.cpp | UTF-8 | 250 | 2.859375 | 3 | [] | no_license | class Solution {
public:
int missingNumber(vector<int>& nums) {
int size = nums.size();
int sum = (0 + size) * (size+1) / 2;
int x = 0;
for (int i = 0; i < size; i++) x += nums[i];
return sum - x;
}
};
| true |
02920cf42c59bf8170dd2445745ee474cfbc211b | C++ | CaptBoscho/earlycsclasses | /CS235/Project2/LineCounter.h | UTF-8 | 370 | 2.859375 | 3 | [] | no_license | #pragma once
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class LineCounter
{
private:
string word;
int number;
public:
LineCounter();
LineCounter(string w, int n);
string getWord() const {return word;}
int getNumber() const {return number;}
void... | true |
be512644aa8171b715cf1d9e36360993505c8367 | C++ | lithiumdenis/CSFData | /DSR/DSR2/DSR2/DSR2.cpp | UTF-8 | 969 | 2.765625 | 3 | [
"MIT"
] | permissive | #include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define N 120
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> text1;
vector<string> text2;
FILE *file1;
char arr[N];
fopen_s(&file1, "file1.txt", "r");
while (fgets(... | true |
fcfdb8244baa2a93677889cc9b74e6782938b8cd | C++ | leviathanch/QtVerilog | /verilog_ast.cc | UTF-8 | 88,531 | 2.84375 | 3 | [] | no_license | /*!
@file verilog_ast.c
@brief Contains definitions of functions which operate on the Verilog Abstract
Syntax Tree (AST)
*/
#include <string>
#include <cstdarg>
#include <assert.h>
#include <stdio.h>
#include "verilog_ast.hh"
#include "verilog_preprocessor.hh"
#include "verilogcode.h"
#include "verilogscanner.hh"
#... | true |
5ab1de5889af5da217037c7218427853d060e486 | C++ | aulitvinas/egzaminai | /2014menuleigis/menuleigis.cpp | UTF-8 | 1,399 | 2.75 | 3 | [] | no_license | #include <fstream>
#include <iostream>
using namespace std;
struct abc
{
int x;
int y;
};
int main()
{
struct abc abc;
int x0, y0, n, ivykdyta[99], ejimas, k, ejimai;
bool tikslas=false;
ifstream fr("U2.txt");
ofstream fd("U2rez.txt");
fr >> x0;
fr >> y0;
fr >> n;
for (int i=... | true |
c52556e91bb9cc4583fd9a9dccc99861e8c81b0e | C++ | allangit/clasesC | /ejemplo2.cpp | UTF-8 | 595 | 3.6875 | 4 | [] | no_license | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
class Rectangulo{
private:
float largo,ancho;
public:
Rectangulo(float, float);
void area();
void perimetro();
};
Rectangulo::Rectangulo(float _largo, float _ancho){
largo=_largo;
ancho=_ancho;
}
void Rectangulo::area(){
... | true |
c1a0b7514bd3896fb29efbdcf53befa2284bde86 | C++ | KostaPapa/DataStructures-Algorithms | /EXERCISE/30) Lecture10Wrappers&Adapters.cpp | UTF-8 | 408 | 3.09375 | 3 | [] | no_license | #include<iostream>
#include<vector>
#include<stack>
using namespace std;
template<class Object>
void Stack<Object>::push(const Object& x){
if(topOfStack == theArray.size()-1){
theArray.resize(theArray.size()*2-1);
}
theArray[++topOfStack] = x;
}
int main(){
Stack<int> s;
for... | true |
1a1837feb85334482c7cbebb5a0f83ad33f0195a | C++ | thervieu/Modules_CPP | /04/ex03/Cure.cpp | UTF-8 | 513 | 2.796875 | 3 | [] | no_license | #include "Cure.hpp"
Cure::Cure(void) : AMateria("cure")
{
return ;
}
Cure::Cure(const Cure &src)
{
*this = src;
_type = "cure";
return ;
}
Cure::~Cure(void)
{
return ;
}
Cure &Cure::operator= (const Cure &rhs)
{
if (this != &rhs)
{
this->_xp = rhs._xp;
}
return (*this);
}
AMateria *Cure::clone(voi... | true |
86cd7903a937816965ab08140bd397ef9230ba3b | C++ | apalomer/spatial_relationships | /include/quaternion_distance_cost_function.h | UTF-8 | 1,500 | 2.75 | 3 | [] | no_license | #ifndef QUATERNION_DISTANCE_COST_FUNCTION_H
#define QUATERNION_DISTANCE_COST_FUNCTION_H
#include <ceres/ceres.h>
#include "transformations.h"
#include "functions.h"
/*!
* \brief The QuaternionDistance cost function class
* \callgraph
* \callergraph
*/
class QuaternionDistance: public ceres::SizedCostFunction<1,... | true |
243f5d7c73e666d75eca29afeb42300f44197171 | C++ | louisway/Topic_model | /topic_model.hpp | UTF-8 | 2,727 | 3.015625 | 3 | [] | no_license | #include <unordered_map>
#include <string>
#include <vector>
#include <utility>
//raw document
class doc{
public:
int doc_len; //the len of the document
std::vector<int> content; //doc content with word index
int year; // year
public:
doc();
doc(int n,int y);
};
//raw corpus
class Corpus... | true |
6243fa98948f707c776e09dceb039e65a7db888f | C++ | Chunting/ur_ws | /src/lesson_move_group/src/send_urscript.cpp | UTF-8 | 1,374 | 2.609375 | 3 | [] | no_license | #include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
#include <math.h>
#include <sensor_msgs/JointState.h>
#include "std_msgs/Float64.h"
/**
* This tutorial demonstrates simple sending of messages over the ROS system.
*/
double current_joint4 = 0;
void Callback(const sensor_msgs::JointState& msg)
{... | true |
ec5d0ad89f303be8249448a1f21ba0649e1e2b65 | C++ | KillerOfFriend/MSG | /Common/Classes/UserAccount/UserAccount.cpp | UTF-8 | 9,912 | 2.640625 | 3 | [] | no_license | #include "UserAccount.h"
#include "Classes/DataModule/DataModule.h"
using namespace Core;
//-----------------------------------------------------------------------------
TUserAccount::TUserAccount(QObject *inParent) : TConnection(inParent)
{
fUserInfo = std::make_shared<TUserInfo>();
fContacts = std::make_sh... | true |
d67d7232e851ddd2f39426d78881df47c5a3da26 | C++ | varshitabhat/aps | /sparse_tree.cpp | UTF-8 | 585 | 2.546875 | 3 | [] | no_license | #include <iostream>
using namespace std;
int main()
{
int lookup[50][50];
int a[]={7,2,3,0,5,10,3,12,18};
int n=9,j,i;
for(i=0;i<n;i++)
lookup[i][0]=i;
for(j=1;1<<j<=n;j++)
for(i=0;(i+(1<<(j-1))<n);i++)
{
if(a[lookup[i][j-1]]<a[lookup[i+(1<<(j-1))][j-1... | true |
1c11e597597ce5523e61110914648de108c93627 | C++ | tanht-lavamyth/Algorithm | /Competitive Programming Exercises/Codeforces/HQ9+.cpp | UTF-8 | 466 | 2.828125 | 3 | [] | no_license | /*
* @Author: tanht
* @Date: 2020-09-19 17:47:36
* @Last Modified by: tanht
* @Last Modified time: 2020-09-19 19:56:14
* @Email: tanht.lavamyth@gmail.com
*/
#include <iostream>
using namespace std;
int main() {
string s; cin >> s;
bool isExectedAnyProgram = false;
for (int i = 0; i < (int)s.size(); ++i) {
i... | true |
b9549956ba941f1313be3985f4c5539063b86a2e | C++ | RGTHENO/ccomp1 | /my_stack.cpp | UTF-8 | 1,864 | 3.984375 | 4 | [] | no_license | #include <iostream>
#include <stack>
using namespace std;
int main(){
stack<int> pila;
/************************************** push() ****************************/
/**Inserta un elemento en la cima de la pila sobre su actual top elemento**/
pila.push(12);pila.push(13);pila.push(14);
/********************... | true |
cf416f4b5c4871050fd4ebf42aa0a89bffd0d5b3 | C++ | Pythoner-Waqas/Backup | /C Programming exercises/F_15.cpp | UTF-8 | 2,683 | 4.4375 | 4 | [] | no_license | /* The following program demonstrate the declaration and uses of friend functions of a class We set values in the constructors of the classes.
The program prompts the user to enter a choice of addition, subtraction, multiplication or division. And then performs the appropriate
operation by using the friend functions.... | true |
f8aee7f9cffbd481cf53ccad5201136f60fc59c0 | C++ | rol-x/MemoryConsoleGame | /MemoryConsoleGame/Board.cpp | UTF-8 | 7,157 | 3.140625 | 3 | [] | no_license | #include "Board.h"
void Board::loadCardsFromFile()
{
fstream cardsFile;
cardsFile.open("cards.txt", ios::in);
try
{
if (!cardsFile.good())
throw FileDoesntExistException();
vector<Card*> allCardsFromFile;
while (cardsFile.good())
{
string cardContent = "";
cardsFile >> cardContent;
Card * card ... | true |
d6d869bd5d36d8234349c78b0f5b12e9193fb072 | C++ | Rookfighter/MultiAgentExploration | /src/utils/StopWatch.hpp | UTF-8 | 736 | 2.59375 | 3 | [
"MIT"
] | permissive | #ifndef MAE_STOP_WATCH_HPP
#define MAE_STOP_WATCH_HPP
#include <sys/time.h>
#include <string>
namespace mae
{
class StopWatch
{
private:
struct timeval begin_;
struct timeval last_;
struct timeval worst_;
struct timeval best_;
bool newBestCase_;
bool newWorstCase_;
public:
StopWatch();
~Stop... | true |
35c4c573d0e8a5f44ffa3931b6e55feece3a78f2 | C++ | ZY1N/CPP_Piscine | /Day05/ex02/Form.cpp | UTF-8 | 3,579 | 2.875 | 3 | [] | no_license | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Form.cpp :+: :+: :+: ... | true |
51d853b5cf2830620d3895cf4457e746e15a2567 | C++ | smiley001/LintCode-Mine | /DistinctSubsequences.cpp | UTF-8 | 1,627 | 3.515625 | 4 | [] | no_license | /*************************************************************************
> File Name: DistinctSubsequences.cpp
> Author: Shaojie Kang
> Mail: kangshaojie@ict.ac.cn
> Created Time: 2015年08月21日 星期五 07时49分23秒
> Problem:
Given a string S and a string T, count the number of distinct subsequences of T in ... | true |
fcb58daaee47599bbf41657c688e9055d67acf08 | C++ | CompuCell3D/CompuCell3D | /CompuCell3D/core/CompuCell3D/plugins/PixelTracker/PixelTracker.h | UTF-8 | 1,390 | 2.640625 | 3 | [
"MIT"
] | permissive | #ifndef PIXELTRACKER_H
#define PIXELTRACKER_H
/**
@author m
*/
#include <set>
#include <CompuCell3D/Field3D/Point3D.h>
#include "PixelTrackerDLLSpecifier.h"
namespace CompuCell3D {
//common surface area is expressed in unitsa of elementary surfaces not actual physical units. If necessary it may
//need to b... | true |
3f32d62958433f24f591d4f40407fcf49765452d | C++ | FeiZhan/Algo-Collection | /answers/leetcode/Tree Depth-first Search/Tree Depth-first Search.cpp | UTF-8 | 1,264 | 3.15625 | 3 | [
"MIT"
] | permissive | //@type Tree Depth-first Search
//@result 209 / 209 test cases passed. Status: Accepted Runtime: 4 ms Submitted: 0 minutes ago You are here! Your runtime beats 11.54% of cpp submissions.
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *righ... | true |
36725cfd0c84761feeaa008db0eeeb07bf6177e1 | C++ | C00204076/Flow_Field_Pathfinding | /Flow_Field_Pathfinding/Tile.cpp | UTF-8 | 1,607 | 3.0625 | 3 | [] | no_license | //
// C00204076
// Brandon Seah-Dempsey
// Started at 10:27 8 November 2019
// Finished at
// Time taken:
// Known bugs:
#include "Tile.h"
//
Tile::Tile()
{
//initialise();
}
//
Tile::Tile(int type, int gridX, int gridY) :
m_type(type),
m_x(gridX),
m_y(gridY)
{
initialise();
}
//
Tile::~Tile()
{
delete this;
... | true |
306ea4ce328be80dce8ac78bca41c308cc6ea58e | C++ | achillebourgault/IndieStudio | /Include/Colors.h | UTF-8 | 898 | 3.203125 | 3 | [] | no_license | /*
** EPITECH PROJECT, 2024
** Colors.h
** File description:
** Created by Leo Fabre
*/
#ifndef COLORS_H
#define COLORS_H
#include <iostream>
enum Colors {
Green,
Gray,
LightGray,
White,
RayWhite,
Red,
DarkBlue,
DarkGray,
Black,
Blue,
Purple
};
static Color GetRaylibColor(... | true |
9e11657ed121574363fc98bb7c8534f103e850e1 | C++ | Clanghade/CNA_groundhog_2019 | /src/Groundhog.cpp | UTF-8 | 4,818 | 3.171875 | 3 | [] | no_license | /*
** EPITECH PROJECT, 2020
** Groundhog
** File description:
** Groundhog
*/
#include "../include/Groundhog.hpp"
#include <cmath>
#include <iomanip>
#include <algorithm>
Groundhog::Groundhog()
{
_previousValue = 0;
_relativeNdays = 0;
_period = 0;
_lastR = 9999;
_switch = 0;
_isSwitch = false... | true |
bed3ee9e92e624e5c591fe9997d716e24c4e1e8c | C++ | PrashanthPuneriya/CS-Lab-Programs | /OOP using C++/Inheritance_Single.cpp | UTF-8 | 769 | 3.671875 | 4 | [] | no_license | // Single Inheritance
#include<iostream>
using namespace std;
// Base Class
class Details {
public:
string name,id;
Details (string n, string i) {
name = n;
id = i;
}
virtual void display() {
cout<<"Name : " << name << endl;
cout<<"ID : " << id << endl;
}
};
// Derived Class
clas... | true |
cae4210c966e3972d8db31e79932ecb6ccfc40f6 | C++ | indra215/coding | /interviewbit/stacksandqueues/Min Stack.cpp | UTF-8 | 488 | 3.03125 | 3 | [] | no_license | stack<int> main_stack, min_stack;
MinStack::MinStack() {
}
void MinStack::push(int x) {
main_stack.push(x);
if(min_stack.empty()){
min_stack.push(x);
}else{
if(x <= min_stack.top()){
min_stack.push(x);
}else{
min_stack.push(min_stack.top());
}
}
}
void MinStack::pop() {
main_stack.pop();
min_sta... | true |
0bb9d7fddce7b55678470d2cef72207751225cc2 | C++ | VinInn/ctest | /floatPrec/sqrtV.cc | UTF-8 | 1,470 | 2.828125 | 3 | [] | no_license | #include<cmath>
#include<type_traits>
typedef float __attribute__( ( vector_size( 16 ) ) ) float32x4_t;
typedef float __attribute__( ( vector_size( 32 ) ) ) float32x8_t;
typedef int __attribute__( ( vector_size( 32 ) ) ) int32x8_t;
float32x8_t va[1024];
float32x8_t vb[1024];
float32x8_t vc[1024];
template<typename V... | true |
7ccc9c02f98f833658a53a5fa8fa08826a595ab2 | C++ | dyllawav/YazdaniDylan_CIS5_40106 | /Homework/Assignment_5/Gaddis_9thEd_Chap6_Prob10_Average/main.cpp | UTF-8 | 1,571 | 3.5 | 4 | [] | no_license | /*
* Author: Dylan Yazdani
* Created on January 24, 2019, 6:10 PM
* Purpose: a program that calculates the average of a group of test scores,
* where the lowest score in the group is dropped.
*/
#include <iostream>
#include <iomanip>
using namespace std;
int getScre(int tstScre,int i,int &total);
flo... | true |
e2260cb482ab01890e7285419aee2f96ff591950 | C++ | yohstone/programming-practice | /design_patterns/singleton.cpp | UTF-8 | 2,332 | 3.671875 | 4 | [] | no_license | #include<iostream>
using namespace std;
// 单例 - 懒汉模式
class Singleton{
private:
Singleton(){};
static Singleton *instance;
public:
static Singleton* getInstance(){
if(instance == nullptr){
instance = new Singleton();
}
return instance;
}
private:
class Garbo{ ... | true |
383195e48b9ee910a4973646a85cd78211e2c1d5 | C++ | gustavodiel/lang_tests | /cpp/particles/particles.cpp | UTF-8 | 1,705 | 3.296875 | 3 | [] | no_license | #include <iostream>
#include <thread>
#include <vector>
#include <chrono>
const int THREAD_COUNT = 8;
const unsigned long long int PARTICLES_COUNT = 10'000'000;
const unsigned long long int PARTICLES_PER_THREAD = PARTICLES_COUNT/THREAD_COUNT;
typedef struct p {
int iPosX, iPosY;
} Particle;
std::vector<Particle... | true |
1b94558e1b7c3eaffc0363dd04edef6f7bf3a10f | C++ | y761823/ACM-code | /LeetCode/p61.cpp | UTF-8 | 587 | 3.1875 | 3 | [] | no_license | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* rotateRight(ListNode* head, int k) {
if (!head) return head;
ListNode* p = head, *q = head;
... | true |
60c0dbb017db6fe0f6ec6def0da8ff991e35f698 | C++ | bxgaillard/boxland | /src/Ground.h | UTF-8 | 3,143 | 2.890625 | 3 | [] | no_license | /*
* ---------------------------------------------------------------------------
*
* Boxland : un petit Boxworld
* Copyright (C) 2005 Benjamin Gaillard & Nicolas Riegel
*
* ---------------------------------------------------------------------------
*
* Fichier : Ground.h
*
* Description : Case du plateau ... | true |
82c0bab1800707efdeacdd9554527b30e9621539 | C++ | sharpau/CS531-2 | /state.cpp | UTF-8 | 4,423 | 3 | 3 | [] | no_license |
#include "stdafx.h"
#include "state.h"
// checking if states have already been explored
bool state::operator == (const state& cmp) const {
for(int i = 0; i < pegs.size(); i++) {
if(pegs[i] != cmp.pegs[i]) {
return false;
}
}
return true;
}
bool state::isGoal(void) {
if(pegs[0].size() != num_disks) {
r... | true |
4af9422899b9791d3aac71cb9a76a7c91fe8e4de | C++ | amadi91/task1 | /SybmolFreq.cpp | UTF-8 | 2,853 | 3.734375 | 4 | [] | no_license | #include "stdafx.h"
#include "SymbolFreq.h"
using namespace std;
SymbolFreq::SymbolFreq() //Creating data members of the class dynamically in side of constructor
{
textfile = new string;
myMap = new map <char, int>;
myVector = new vector<pair<char, int>>;
}
SymbolFreq::~SymbolFreq() // Deleting ... | true |
2618dae3d295f9678bc7acc6146680c9d00bba89 | C++ | gabalwto/Prot | /system/synchronization/condvar_unittest.cpp | UTF-8 | 9,042 | 2.546875 | 3 | [
"MIT"
] | permissive | #include <test/ptutest.h>
#include "condvar.hh"
#include <system/thread.hh>
#include <system/time/tickcount.hh>
/** test return value */
typedef struct {
Lock::ILock* plock;
Lock::ConditionVariable* pcond;
Int32 count;
Int32 result;
} MyCondVarTestReturnValueData;
Void MyCondVarTestReturnValueFunc(Vo... | true |
b5773066e5535986fea5f3a3e738e9b96c61c21e | C++ | LiangSun1994/cplusplus_primer | /chapter_02/chapter_2_6_convert.cpp | UTF-8 | 264 | 3.484375 | 3 | [] | no_license | #include <iostream>
int stone2lb(int stone);
/*
int main(){
using namespace std;
int stone = 15;
cout<<"stone = "<<stone<<endl;
int pounds = stone2lb(stone);
cout<<"pounds= "<<pounds<<endl;
}
int stone2lb(int stone){
return stone*12;
}
*/ | true |
27c0f305628466b284e928d69b77f3f4655422b1 | C++ | shiv-jetwal90/Coding-Practice | /GeeksforGeeks/insert_middle_LL.cpp | UTF-8 | 746 | 3.453125 | 3 | [] | no_license | // function should insert node at the middle
// of the linked list
Node* insertInMiddle(Node* head, int x)
{
Node *imp=new Node(x);
if(head==NULL)
{
head=imp;
return head;
}
Node *temp1=head,*temp=head;
while(temp->next!=NULL&&temp->next->next!=NULL){
temp1=temp1->next;
temp=tem... | true |
87451b659173d4ed52f9a39d741183a6456de3fd | C++ | hengsok/nodejs-sonyflake | /cppsrc/main.cpp | UTF-8 | 7,508 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | /* cppsrc/main.cpp */
#include <napi.h>
#include <cstdint>
#include <string>
#include <cmath>
#include <functional>
#include <chrono>
#include <thread>
// ////////////////////////////////////////////////////////////////////////////////////////
/**
* Total number of bits allocated to an ID
*/
constexpr int TOTAL_BIT... | true |
7e70489ebd4c3ef5402c3b4b24439a6b914f41f8 | C++ | muzizhi/one-year-date | /数运算/寻找两个数组的中位数.cpp | UTF-8 | 2,434 | 3.59375 | 4 | [] | no_license | 4、寻找两个正序数组的中位数:两个有序数组,联合返回中位数,时间o(log(m+n))
思路:那是不是两个数组合并的意思呢,中位数直接返回最中间的,但是复杂度高了
依靠2分,类似于找数组中 第k个元素,本来想每个都取对应一半,但是不好减,之前都是n,现在m、n
那就按照官方思路每个比较k/2元素,存在赋值。如果k1《k2,不在k1前k/2个,num1后移动,k-k/2
如果一个没有,那么可以设为超大值,因为长的那个数组k/2肯定不对,不够啊
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>... | true |
95ca7269dcfae98c13adf8d688dd2205e322dfce | C++ | afmika/Core6502-Cpp | /src/main.cpp | UTF-8 | 1,924 | 2.75 | 3 | [] | no_license | #include <iostream>
#include "CPU.h"
int main(int argc, const char * argv[]) {
std::string final_prog = "";
std::string dg_flag = "-d";
bool debug_mode = false;
for (int i = 1; i < argc; i++) {
std::string temp( argv[i] );
if ( temp.compare(dg_flag) == 0 && i == 1 ) {
debug_mode ... | true |
673ecaa0b2365602be87973a332bacb38a53569d | C++ | QianYaoWei/braille | /component/orm_proxy.cpp | UTF-8 | 10,737 | 2.609375 | 3 | [] | no_license | #include "orm_proxy.h"
#include "sqlite_db.h"
#include "AnyType.h"
#include "stringutil.h"
using namespace utility;
bool OrmProxy::SelectFromDB(const std::string &strTable, OrmDBCallBack *callback)
{
char *sqlArr = SqliteDB::Instance()->GetSqlArray();
snprintf(sqlArr, SqliteDB::SQL_LEN, "SELECT * FROM %s;", s... | true |
e31fecc6598fcab21650bfe0d2373205b641d607 | C++ | raxracks/chadOS | /userspace/libraries/libutils/Optional.h | UTF-8 | 2,451 | 3.234375 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | #pragma once
#include <assert.h>
#include <libutils/Std.h>
#include <libutils/Tags.h>
namespace Utils
{
template <typename T>
struct Optional
{
private:
bool _present = false;
union
{
T _storage;
};
public:
ALWAYS_INLINE bool present() const
{
return _present;
}
ALW... | true |
673abb71960e040a6f738e5fbc6636df357b5789 | C++ | demian2435/42-ft_containers | /ft_containers/IteratorBinaryTree.hpp | UTF-8 | 4,047 | 2.71875 | 3 | [] | no_license | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* IteratorBinaryTree.hpp :+: :+: :+: ... | true |
e23ccce7a3d3b8117a035355140346512d98c236 | C++ | octopusprime314/manawar-engine | /drawbuffers/src/VAO.cpp | UTF-8 | 26,835 | 2.640625 | 3 | [] | no_license | #include "VAO.h"
#include "Model.h"
#include "GeometryBuilder.h"
#include "EngineManager.h"
#include "DXLayer.h"
VAO::VAO() {
}
VAO::~VAO() {
}
VAO::VAO(D3D12_VERTEX_BUFFER_VIEW vbv, D3D12_INDEX_BUFFER_VIEW ibv) {
_vbv = vbv;
_ibv = ibv;
}
void VAO::setVertexContext(GLuint context) {
_vertexBufferConte... | true |
8d4d25951280cb4c7ae72e3d85d607df1265bb80 | C++ | ArthurTorrente/4A_Anim_Numerique_Genetic_Algorithm | /Genetic_Algorithm/src/StickyCamera.cpp | UTF-8 | 1,362 | 2.546875 | 3 | [] | no_license | #include "StickyCamera.h"
#include "cinder/gl/gl.h"
StickyCamera::StickyCamera()
: m_eye(0.0f, 0.0f, 0.0f),
m_center(0.f, 0.f, 0.f),
m_up(-cinder::Vec3f::yAxis()),
m_cameraDistance(0.0f)
{
m_rotation.identity();
}
void StickyCamera::setup(float fov, float aspectRatio, float _near, float _far, floa... | true |
932189fe2bf308cc60935f8864abf6a1293c618d | C++ | hwenradiant0/B-BConsume | /B&B ConSume/3D_Game/ZCamera.h | UHC | 3,376 | 2.875 | 3 | [] | no_license | #pragma once
#include "Device.h"
/*
: ۺ
: ī Ŭ
: 2014.01.06
*/
class ZCamera
{
private:
D3DXVECTOR3 m_vEye; //ī (ī ġ)
D3DXVECTOR3 m_vLookAt; //ī ٶ (ī ü ġ)
D3DXVECTOR3 m_vUp; //ī 溤
D3DXVECTOR3 m_vCameraBasis; //īü ⺤(m_vLookAt-m_vEye)
D3DXVECTOR3 m_vCameraCross; //ī (m_vUp,m_vCameraBasis κ )
... | true |
21749c684f41f298f7a2057bb1d1e6e8a3bd0f34 | C++ | Jocoboy/Huffman-Coding | /TreeNode.h | UTF-8 | 606 | 2.6875 | 3 | [] | no_license | #pragma once
#include <iostream>
#include <ostream>
using namespace std;
class TreeNode
{
private:
char ch;
int tag;
int freq;
//Addons
string code = "";
TreeNode *lChild;
TreeNode *rChild;
public:
TreeNode(char, int, int,TreeNode *, TreeNode *);
bool operator<(const TreeNode &);
... | true |
8297d36a03466dcdf6fcb76de93f59d8bf307eba | C++ | Group-3/Pacman | /code/Pacman/Collision.cpp | UTF-8 | 1,679 | 3 | 3 | [] | no_license | #include "Collision.h"
Collision *Collision::_this = NULL;
Collision::Collision(vector<Player> *players)
{
this->players = players;
}
Collision *Collision::createInstance(vector<Player> *players)
{
if(!_this)
_this = new Collision(players);
return _this;
}
bool Collision::sphereVsSphere(D3DXVECTOR3 pos1, D3DXVE... | true |
8cdd46f2b3760dc836aa750a19dff956b92d83e4 | C++ | cchenziqiang/Algorithm | /P41.cpp | UTF-8 | 678 | 3.34375 | 3 | [] | no_license | #include <iostream>
#include "List.h"
using namespace std;
void PrintCommon(Node* head1, Node* head2) {
while (head1 != nullptr && head2 != nullptr) {
if (head1->value > head2->value)
head1 = head1->next;
else if (head1->value < head2->value)
head2 = head2->next;
else {
cout << head1->v... | true |
e33a7db09974efe6bb87866afbd5ce82eb496c16 | C++ | Mike-droid/EjerciciosDeCplusplus | /bloque 2/Ejercicio 8 bloque 2.cpp | ISO-8859-1 | 462 | 3.40625 | 3 | [] | no_license | /* 8. Escriba un programa que lea de la entrada estndar los dos catetos
de un tringulo rectngulo y escriba en la salida estndar su hipotenusa.
*/
#include <iostream>
#include <math.h>
using namespace std;
int main(){
float a,b,c,hipotenusa;
cout<<"Digite el cateto a:"; cin>>a;
cout<<"\nDigite el cateto b:"; cin... | true |
2621a8d7a55e92ec825109364a8bd5a5508b7e0a | C++ | Harryx2019/2021-pat | /第三章 入门篇(1)——入门模拟/3.5进制转换/B1022 D进制的A+B.cpp | UTF-8 | 269 | 2.640625 | 3 | [] | no_license | #include <stdio.h>
int main()
{
int a,b,d;
scanf("%d%d%d",&a,&b,&d);
int c = a+b;
int ans[31],num=0;
do{
ans[num++]=c%d;
c=c/d;
}while(c!=0);
for(num--;num>=0;num--){
printf("%d",ans[num]);
}
return 0;
}
| true |
a2878802174b7e22a7274bc9729f8682f100249b | C++ | phaass/ex2 | /Horse.cpp | UTF-8 | 717 | 2.984375 | 3 | [] | no_license | //
// Created by phaass on 1/15/18.
//
#include "Horse.h"
virtual static int Horse::move(int x, int y, int new_x, int new_y, int currentPlayer, Board board){
if ((isPossibleMove(x, y, new_x, new_y, currentPlayer, board)) == 0)
{
board.movePiece(x,y,new_x,new_y);
return 1;
}
return... | true |
6eff68dc40e837b0c9ddcafee3a1ce29757d96f7 | C++ | FSource/FEngine | /lib/libfaeris/src/stage/FsScene.cc | UTF-8 | 6,620 | 2.609375 | 3 | [
"MIT"
] | permissive | #include "stage/FsScene.h"
#include "stage/layer/FsLayer.h"
#include "support/util/FsSlowArray.h"
#include "mgr/FsObjectMgr.h"
#include "stage/layer/FsColorLayer.h"
NS_FS_BEGIN
Scene* Scene::create()
{
Scene* ret=new Scene;
return ret;
}
/* layer operation */
void Scene::push(Layer* layer)
{
if(layer->getScene(... | true |
c3e9ed4beadea9e0f3f6d1389d916eeff3097a94 | C++ | cbedregal/Compressed-Permutations | /src/wavelettree.h | UTF-8 | 5,874 | 2.84375 | 3 | [] | no_license | /* wavelettree.h
Copyright (C) 2009, Carlos Bedregal, all rights reserved.
Implementation of Compressed Representation of Permutations: Runs & SRuns.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free... | true |
b6d28706378eb4d3ab801537b7d6b44d2bbf4814 | C++ | sindri69/pizza420 | /PallaUpdate 11.12.2017/PP Backup/014 Payments tilbúið (Bara Pizzas)/VIEW/BasicView.cpp | UTF-8 | 382 | 2.625 | 3 | [] | no_license | #include "BasicView.h"
#include "BasicRead.h"
BasicView::BasicView() { }
void BasicView::view_basic() {
BasicRead br;
if (br.fileNotEmpty()) {
cout << "(L = $" << br.get_Line(1) << ") ";
cout << "(M = $" << br.get_Line(2) << ") ";
cout << "(S = $" << br.get_Line(3) << ")" << endl;
... | true |