C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms (1)

0
votes
0answers
7 views

RadixSet - A growing-only Radix/Patricia Tree

I'm looking for a structure to store large amounts of strings (5k to 100k) and then test for existence of new strings against the previous inserted data, in the least possible amount of time (memory ...
-1
votes
0answers
30 views

Balanced Bracket Algorithm (Recursion) in C++ [on hold]

I have tried out my own new balancing algorithm using recursion. The function parses through a string and when a new opening bracket is encountered, it calls itself using the latest encountered ...
3
votes
2answers
40 views

Time conversion program optimization

I have just finished working on a problem on hackerrank dealing with time conversion in C++. I'm still fairly new to programming as I only have a few semesters of programming classes under my belt ...
1
vote
4answers
319 views

String Reversal

Wrote a practice code for reversing a string say. Input = "This is funny" Expected output = "ynnuf si siht" This code works for me. Want to know your comments and a better optimised way to perform ...
1
vote
0answers
14 views

Shortest bitonic tour

This a solution to the shortest bitonic tour using dynamic programming. Bitonic tour starts at the leftmost point then goes strictly rightward to the rightmost point and finally strictly leftward to ...
4
votes
2answers
69 views

Doubly linked list reimplemented with smart pointers

I need some suggestions on my reimplementation of a doubly linked list with smart pointers since I'm new to smart pointers in C++. I read some docs on smart pointers and found out there are ...
-5
votes
0answers
16 views

Unable to compile correct code? C++ Real Simple Array Loop [on hold]

For some reason I cannot get this code to compile. I get an error specifically at names.size(). As you can see, I've actually included the library but yet Eclipse ...
10
votes
1answer
241 views

Match Three game for a job interview using Cocos2d-x

The problem is that I had an interview for a gaming company and I had to write a prototype of a Match Three style game. The time line was 3 days. I made the code in about 2 days and sent it to them. ...
5
votes
1answer
137 views

Palindrome evaluator in C++

I started learning C++ a few days ago, and this is my first full program. It takes in words until an end-of-file character prompt is given, and then outputs which of those words are palindromes and ...
-1
votes
0answers
33 views

Spaceship Arcade Battles V0.1

I am trying to implement something like this spaceship shooting game using SFML and Box2D. I don't know how my code is. Please, look and criticize. Well, I've put here most important classes. The ...
3
votes
1answer
46 views

Managing IDs using AVL trees

In a txt file there are IDs and next to them there are their neighbours like this: 1 1 1 2 1 3 2 1 2 4 2 8 3 5 Using AVL trees I store the IDs in one AVL ...
-5
votes
1answer
40 views

Refactor code that violates “Needless Repition” principle [on hold]

Assume class Animal which does Eat, Sleep and Make Noise. Assume class Mammal : public Animal which also does MakesBaby Assume that Mammal also does Eat, Sleep and Make Noise which it inherits from ...
-3
votes
0answers
17 views

Regarding Global Variables [on hold]

Binary gap as defined here https://codility.com/programmers/task/binary_gap/ As the title implies, I try to write a program to count how many numbers with a binary gap less than or equal to 3 in the ...
-3
votes
0answers
21 views
1
vote
1answer
57 views

CUDA brute force 48 bit key

I have a cryptographic function with two 24 bit keys. I have two blocks of input and two blocks of output, and want to brute force the keys using CUDA. Overview: The function is composed to two ...
0
votes
1answer
70 views

Deleting duplicate elements from a single-linked list in C++11

The code below is a simple coding exercise I got from a book that asks to remove the duplicates from a single-linked list (using a simple struct; this is part 2, ...
1
vote
0answers
15 views

Different method to calculate blob area in OpenCv

I'm trying to use a different method to calculate a blob area from contourArea, using the countNonZero function. I want to see if there is significant approximation ...
2
votes
1answer
40 views

Maximum clique problem: fast heuristic

I have implemented an algorithm which computes a maximum clique via a heuristic. The pseudo-code can be found in this Paper (see Algorithm 2). Maximum Clique Problem Given an undirected, simple ...
1
vote
0answers
41 views

Longest palindrome subsequence

This algorithm finds the longest palindrome that is a subsequence of a given input string in \$\Theta(n^2)\$. Example Input: character Output: ...
3
votes
1answer
60 views

Pong game with a random twist

I made a simple Pong game using SDL2, with a twist: You don't get to play :), only the 2 AIs get to. ;) Because Pong is a very small game, I put everything in a single file (...
2
votes
1answer
54 views

Mirror image of a binary tree

I wrote a small routines to create a mirror for any binary tree. I am just sharing my necessary routines instead of full class. could you please let me know your comments on this. I just curious to ...
1
vote
0answers
18 views

Practicing rogue-wave I/O

What I'm doing: Searching in current directory for a set of files. Filtering the set. Searching through the filtered set of files for a specific line sequence. Write to an output file that line ...
8
votes
2answers
102 views

Histogram generator

This is some code to generate a histogram (or maybe: histochart) in the form of a simple list of words and how many of that word were found in the input file. It accepts an input file name on the ...
-5
votes
0answers
21 views

Bad argument (response #900 is not integral) in cvPreprocessCategoricalResponses [closed]

I'm writing a program in opencv and C++: ...
3
votes
3answers
97 views

C++ Dynamic array based stack

This is my first post so if I am doing something wrong in the post please let me know. I have implemented a dynamic array based stack. Can someone point out any pitfalls or things that can be done ...
0
votes
3answers
73 views

Extend number of arguments in std::hypot

I would like to call std::hypot with many arguments (not just 2 or 3). Mandatory requirements: fast run at compile time when possible Non-mandatory ...
-1
votes
0answers
22 views

Simple Dictionary opinion C++ [closed]

Can someone see my code and say if my program's logic is correct and if i can improve something in my way of reading the file in member functions or maybe add more functions to the class. ...
3
votes
2answers
107 views

C++ Graph Class Implementation (adjacency list)

I've got a barebones C++ graph class implemented as an adjacency list. The graph consists of a vector of vertices. Each vertex has a vector of outgoing edges that store the destination vertex id. ...
0
votes
1answer
72 views
4
votes
0answers
69 views
+50

type_list with utilities

The post is follow up to my previous Typelist with extractor. The code of type_list and extraction feature is identical to the accepted answer (by user2296177). The ...
-1
votes
0answers
12 views

Creating a 2D Grid With Command line C++ Putty [closed]

I am new to coding and was trying to run some example code in my Putty terminal, but ran into a problem when trying to create a 2D grid for this game. It requires command-line arguments, but I'm ...
2
votes
1answer
84 views

A different way to execute a hangman game

Most hangman implementations I have seen keep a list of characters the player has already guessed and compares them to the players current guess each time to see if they have already made the same ...
3
votes
2answers
92 views

Building a simple singly-linked list in C++11

The implementation below works, but I'm wondering if there's a modern C++ alternative. For example: Should I replace the raw new with a braced initializer? ...
0
votes
0answers
31 views

CodeJam Milkshakes attempt [closed]

I have been practicing code challenges, and came across this one from Google's CodeJam. You can see the requirements here. To solve this, I took the approach of making a vector of maps which ...
4
votes
1answer
39 views

Monitor and video mode querying

I am working on a large project that requires information about the monitor(s). Please don't be confused by the organization of the following structs. The design intent is to be cross-platform, so ...
0
votes
0answers
9 views

Check if cells content is equal [closed]

I have a matrix of orders ( orders vs k*ordes) and I want to clean/erase the content of the cells that have the same order in both axis.. So, basically I would like to do something like this: ...
3
votes
1answer
28 views

Handling GetTickCount() overflow in timeouts

This is code which must run on XP, so no GetTickCount64, and which should correctly handle the value wrapping around after 49 days. Can it be improved? ...
1
vote
2answers
42 views

Crawling SPOJ through cURL and C++

I am trying to write industry standard code. https://www.quora.com/How-do-I-follow-a-user-on-Spoj-for-solving-problems-Refer-Details Someone gave me this A2A. And I wrote this code for it ...
1
vote
1answer
45 views

Exposing a data member in a class [closed]

I have a class a which has some methods(geti, seti) which I want to have in all classes b, b1, b2,...b100 I can only think of using a macro right now and it makes debugging a pain, is there a better ...
1
vote
3answers
71 views

C++11 Blocking Queue learning exercise

As part of my own C++11 learning exercise I have implemented this Blocking Queue using the new C++11 thread API. One of the aspects I would like to improve is efficiency i.e. in the ...
2
votes
2answers
99 views

Simple TicTacToe game in C++

I just started learning C++, and this is one of my projects. It's just a simple 2-player (No AI) TicTacToe game that runs from the console. The project was to familiarize myself with arrays, so review ...
3
votes
3answers
87 views

Counting the number of primes in C and C++11

I found this old piece of code that I wrote while I was learning C a while back: ...
1
vote
4answers
312 views

Reading HTML files, removing HTML tags, and writing content and summary to a file

Write a multithreaded C++ application (executable) for Windows Platform. This program uses the two threads to read and process the input data and store it into an output file. Candidate is free ...
-1
votes
1answer
56 views

Pointer arithmetic or array

The following is a full example to illustrate my question: ...
5
votes
1answer
96 views

Caches implementation in C++

I had a test task for internship where the main part was in implementing fixed size caches with different displacement policies (LRU/LFU/FIFO). I did that task, but was refused afterwards. Now I am ...
1
vote
0answers
82 views

Snake game in C++ for Windows console

To give you a simple background, I've been programming in C++ for about a week and decided I wanted to build a simple snake game. I made one over the course of a day and this is the end result. What ...
3
votes
2answers
65 views

calloc, malloc, free and realloc wrappers to store the size being allocated

I'm currently building a node.js addon for libcurl. Right now I'm trying to correctly use v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory to ...
1
vote
0answers
21 views

Customized streambuffer for C++ istream

Basically I implement a traditional file-descriptor-based streambuffer for istream operations. The implementation overrides the ...
4
votes
4answers
141 views

Subdividing intervals that contain the largest error values

I'm trying to accomplish the following: Start out with 1 interval on the real line. This interval is processed in some function and out comes an array of errors (size < 10 usually). The maximum ...
4
votes
2answers
375 views

Inorder, Preorder, and Postorder traversal of a binary tree in C++

I am a newbie in this world of data structures and algorithms (returning to these topics after 5 long years). Can someone please check if the code I have written for Binary Tree is OK? Test-case 10, ...