Questions tagged [c++]

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

Filter by
Sorted by
Tagged with
1
vote
0answers
16 views

Primiitve calculator

So, the problem task is: Given an integer 𝑛, compute the minimum number of operations(+1, x2, x3) needed to obtain the number 𝑛 starting from the number 1. I did this using this code: ...
0
votes
1answer
42 views

tic tac toe code in c++ with two players [closed]

My main problems are making draw case and any player can choose a place which is chosen by another player here is the code : ...
3
votes
2answers
54 views

Mergesort (using vectors) and some questions about memory

Back from a long C++ hiatus. I thought to implement mergesort from memory, using containers and not based on CLRS's pseudocode and arrays. The compiles and runs ok on the test cases. ...
2
votes
1answer
62 views

Program for chopping overlapping image areas and filling up to a specific ratio

I've written a little program that I need for fixing two problems in my spherical panorama images. It does two things: If the image does overlap horizontally, it cuts away the overlapping pixels from ...
2
votes
2answers
68 views

LeetCode 273: Integer to English Words

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Convert a non-negative integer to its English words representation. ...
1
vote
1answer
44 views

LeetCode 639: Decode Ways II

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem A message containing letters from A-Z is being encoded to numbers ...
3
votes
1answer
70 views

Find lowest consecutive value

I have created a program where I first set the size of the array and how many times I will look for consecutive values, then I fill in the array and finally I insert the consecutive values, it should ...
1
vote
0answers
33 views

Implementing a Queue with Small size optimization

I was trying to implement a queue implementing the small size optimization. I was wondering any ways I can make this code better (more performant, better code style, etc). It seems to work fine (in ...
-1
votes
0answers
23 views

Ending Infinity-loop [closed]

In one of my projects I try to loop a main Menu. Somehow the used infinity-loop ends. I even tried to use labels to recall the loop. Thanks for your help Here is my code: ...
2
votes
2answers
49 views

LeetCode 862: Shortest Subarray with Sum at Least K

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Return the length of the shortest, non-empty, contiguous subarray ...
2
votes
1answer
54 views

c++ program to help find move sequences to solve Rubiks cubes

This program takes a text file and parses the initial cube start position, the pattern that the result should have and an optional start sequence. The cube is using numbers instead of colors for more ...
3
votes
2answers
83 views

HybridSort of QuickSort and MergeSort

I'll try to publish a paper about the programming language I've made (ArithmeticExpressionCompiler, short AEC) in Osječki Matematički List and, in order to demonstrate its usability for implementing ...
2
votes
0answers
34 views

Dynamic fixed width flat file parser in C++

I am doing a research to implement a dynamic system of parse and generation of fixed width flat files in C++.... The system works, but, it is not reliable ... The class "FlatFileStructure", ...
3
votes
0answers
30 views

JsonStatus - A tiny C++ JSON writer

JsonStatus (as in status file) Goal A simple and fast JSON writer in C++ (JSON output only). When you need something so small that you're not sure you even need a JSON library and you don't feel like ...
3
votes
1answer
43 views

LeetCode 894: All Possible Full Binary Trees

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem A full binary tree is a binary tree where each node has exactly 0 ...
-5
votes
0answers
31 views

approach to solution and time complexicity

The city is rectangular in shape of size having 'r' rows and 'c' columns. The city is divided into 'r x c' cells. Each cell is either '#' or '.' denoting whether the cell is BURNING or is SAFE, ...
1
vote
1answer
34 views

LeetCode 410: Split Array Largest Sum

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given an array which consists of non-negative integers and an ...
-2
votes
0answers
24 views

Primitive Calculator [closed]

Problem Introduction You are given a primitive calculator that can perform the following three operations with the current number 𝑥: multiply 𝑥 by 2, multiply 𝑥 by 3, or add 1 to 𝑥. Your goal is ...
1
vote
0answers
28 views

LeetCode 284: Peeking Iterator

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given an Iterator class interface with methods: ...
-2
votes
0answers
23 views

Std::lower_bound not giving expected result [closed]

I'm trying to get a method to return the closest value to 0.5, and used std::lower_bound. Why does this return the incorrect value, and a value that isn't even in the array? ...
-1
votes
0answers
33 views

Re-implementing a C++ library in Go [closed]

I need to re-implement three features of C++ OpenVDB library in Go language: Mesh to volume ...
3
votes
0answers
65 views

Particle Swarm Optimization template

I am trying to create a PSO algorithm template for my project. I've decide to make the Swarm as separate type and ...
0
votes
0answers
34 views

LeetCode 212: Word Search II

I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time! Problem Given a 2D board and a list of words from the dictionary, find all ...
2
votes
1answer
73 views

Constexpr circular queue - follow-up #1

Follow up to my question here: Constexpr circular queue . I've taken the time to fix the many problems pointed out there and am asking for any tips/corrections for the new version below. The queue ...
0
votes
1answer
31 views

LeetCode 652: Find Duplicate Subtrees

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Given a binary tree, return all duplicate subtrees. For each kind ...
2
votes
1answer
43 views
2
votes
1answer
114 views

std::vector remake

Out of the majority of my c++ projects, the most used thing is std::vector because it allows me to not have to my own memory management. However previously I had never really thought much about how ...
4
votes
2answers
95 views

LeetCode 1032: Stream of Characters

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Implement the StreamChecker ...
6
votes
2answers
859 views

Simple Multiclass C++ Project

So I'm working through a beginners C++ book and they had this example demonstrating class hierarchy, which was originally in a single file. I tried recreating it with multiple files (header files + ...
1
vote
0answers
12 views

QTableView implementation

I've put together my first table using Qt's QTableView and a custom data model. Currently, some data is populated on initialisation, and the user has the option of adding and deleting entries. ...
2
votes
1answer
59 views

Library for parsing CSV data

Please review my C++ CSV parsing class. I have some specific questions: Should get_next_record be a static function? CsvParser ...
8
votes
2answers
346 views

C++, sort integers using knowledge of entire vector

I am solving the "Sort" problem on Kattis. Mirko is a great code breaker. He knows any cipher in the world can be broken by frequency analysis. He has completely the wrong idea what ...
2
votes
1answer
53 views

LeetCode 753: Cracking the Safe

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem There is a box protected by a password. The password is a sequence ...
3
votes
0answers
39 views

Small Automatic Differentiation Library

Introduction As a programming exercise I recently wrote this automatic differentiation library based on forward accumulation. It should offer a simple way to create mathematical functions whose ...
5
votes
2answers
42 views

Iter 2: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type

This is the 2nd iteration of a code review. The 1st iteration (completed) is at Iter 1: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type 1. Goal My intention is to ...
5
votes
1answer
47 views

Using Boost.Spirit to transform expression to AST

Is there a better way to transform some expression to AST using Boost.Spirit? I have built it, but I think it's messy and can be simplified a lot. Code is also available on Godbolt. ...
1
vote
0answers
26 views

A word generator meant to be piped to hashcat/jrt which would then use amplificators (rules)

This piece of code does a linear generation with two 'tweaks': It sets a global loop as an index to reference variables that are holding values that need to be ...
3
votes
1answer
61 views

Compare folders and find common files

I found this Powershell command useful in comparing folders and find common and different files. Since I really like C and C++, I've decided to create a program to do that. It will get all files in 2 ...
1
vote
2answers
80 views

LeetCode 1293: Shortest Path in a Grid with Obstacles Elimination

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Problem Given a m * n grid, where each cell is either 0 (empty) or 1 (obstacle). In ...
4
votes
1answer
61 views

A mathematical expression parser with custom data structures

I recently wrote a mathematical expression parser in C++. The software can read valid mathematical expressions and evaluate them. An example of an expression the code can parse is ...
3
votes
2answers
80 views

Code to modify string as per instructions

I solved this problem statement on dear old codeforces. The Problem Statement wants users to replace occurrences of '10' in the given string with either '1' or '0' until there is no occurrence of '10' ...
1
vote
1answer
51 views

LeetCode 552: Student Attendance Record II

I'm posting my code for a LeetCode problem copied here. If you have time and would like to review, please do so. Thank you! Problem Given a positive integer n, return the number of all possible ...
2
votes
1answer
61 views

OOP Based TicTacToe - Logic Improvement/Best Practices

Looking for any feedback to improve practices on the following logic, and I have removed large chunks of documentation to reduce noise. I feel the areas that could expect heavy criticism are the win/...
1
vote
1answer
53 views

LeetCode 1320: Minimum Distance to Type a Word Using Two Fingers I

I'm posting my C++ code for LeetCode's 1320. If you have time and would like to review, please do so. Thank you! Problem You have a keyboard layout as shown above in the XY plane, where each English ...
-1
votes
1answer
53 views

LeetCode 375: Guess Number Higher or Lower II

I'm posting my C++ code for LeetCode's Guess Number Higher or Lower II. If you have time and would like to review, please do so. Problem We are playing the Guess Game. The game is as follows: I pick ...
1
vote
0answers
46 views

LeetCode 200: Number of Islands

I'm posting my C++ code for LeetCode's Number of Islands (which is a famous problem). If you have time and would like to review, please do so. Thank you! Problem Given a 2d grid map of '1's (land) ...
5
votes
1answer
56 views

Iter 1: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type

This Q&A was iteration 1. Now there is Iter 2: Reusable, robust c++ std::hash<mpz_class> for GMP's big integer type 1. Goal My intention is to provide a fast hashing algorithm to hash ...
5
votes
1answer
82 views

LeetCode 146: LRU Cache I

I'm posting my C++ code for LeetCode's LRU Cache. If you have time and would like to review, please do so. Thank you! Problem Design and implement a data structure for Least Recently Used (LRU) cache....
2
votes
0answers
64 views

C++ threaded task manager

I've been writing a little task manager in C++ in my spare time. It's also the first time I am posting here for a review, I hope someone can spot any mistakes. There's still a lot to implement and ...
4
votes
2answers
90 views

C++ multithreading logger class

I have designed a logger class to log messages to a file. It uses an independent thread to log the messages save to a queue previously using the main thread. I want to receive reviews about it. ...

1
2 3 4 5
154