15,895,667 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13277493 (Top 42 by date)
Member 13277493
23-Sep-19 23:48pm
View
I want tp use it for detecting a loop in a linked list
Member 13277493
22-Sep-19 11:53am
View
I just wanted to build a hash function for linked list nodes, which would take as an input their addresses and gave me hashTable index
Member 13277493
22-Sep-19 11:52am
View
thank you! My stringstream approach was different, I didn't know about str() function, I should have studied stringstream well before using it.
Member 13277493
22-Sep-19 3:56am
View
Sorry, I misunderstood the answer. I will try and see if there will be any problems.
Member 13277493
22-Sep-19 3:43am
View
I need that conversion for creating my hash function, but if it is not possible, then I will think another hashing function, thanks!
Member 13277493
14-Jun-19 2:24am
View
thanks, I tried to understand using debugger but there were some problems I encountered, I will try again
Member 13277493
30-Dec-18 5:36am
View
thanks, I will think about it
Member 13277493
30-Dec-18 4:17am
View
thanks!
Member 13277493
18-Oct-18 2:44am
View
thanks, I will try that way
Member 13277493
18-Oct-18 0:04am
View
no, I just need to print the n-th prime number for each input data
Member 13277493
1-Sep-18 7:50am
View
thanks! I will try that way
Member 13277493
1-Sep-18 7:49am
View
Deleted
thanks! I will try that way
Member 13277493
1-Sep-18 6:39am
View
yes its complex, the problem is from Project Euler. https://projecteuler.net/problem=13
Member 13277493
1-Sep-18 5:32am
View
yes, they are chars, and the istringstream is one of the ways(if not the only way) to get the integers from the string. In this case, the string does not contain any special delimiter.
Member 13277493
1-Sep-18 5:27am
View
But will the istringstream buffer accept it as an input? I tried like that, the IDE marks red below. Maybe I made a mistake in writing the code. The code is below. I didn't write the loop for each index of the member, for this example it's just the 0 index element of the string.
std::vector<std::vector<int>>iv;
for(const auto &row: sv)
{
iv.push_back(std::vector<int>());
for(const auto &v: row)
{
const auto v_at=v.at(0);
std::istringstream ss(v);
int i;
ss>>i;
iv.back().push_back(i);
}
}
Member 13277493
1-Sep-18 4:55am
View
I know that, my question is how can I store not the whole string in "i" but each element of the string then push it to the vector one by one
Member 13277493
29-Aug-18 10:18am
View
I needed only the numbers from 0 to 9, yes I think that I did not understand that code good enough
Member 13277493
29-Aug-18 10:17am
View
thanks!
Member 13277493
5-Jul-18 7:28am
View
thanks!
Member 13277493
5-Jul-18 5:53am
View
thanks!
Member 13277493
9-Mar-18 14:41pm
View
the code is not running, it has some errors with overloaded operators
Member 13277493
9-Mar-18 14:40pm
View
thanks for a good advice!
Member 13277493
30-Jan-18 17:23pm
View
thank you very much, I will fix them. And one more question, they are as many linked lists as the vertices are, am I right? For each vertex, there is a linked list created by its adjacent vertices.
Member 13277493
17-Jan-18 4:17am
View
thanks!
Member 13277493
17-Jan-18 3:47am
View
That means I must connect the end node of the loop to nullptr, am I right?
Member 13277493
9-Dec-17 16:40pm
View
thanks, it really helped
Member 13277493
9-Dec-17 15:54pm
View
:)
Member 13277493
9-Dec-17 15:42pm
View
oh thanks, I have forgotten to write else before the statements
Member 13277493
9-Dec-17 15:33pm
View
I don't think so, I have not connected the last node to the first node why it must be circular
Member 13277493
8-Dec-17 11:13am
View
ok I will do that. now when I write this code it does not print 40 only
#include <iostream>
using namespace std;
struct node {
int value;
node *left, *right;
};
node *root;
class search_tree {
public:
search_tree()
{
root=NULL;
}
void copy(node *from_tree, int to_heap[] ,int i);
node *insert(node *m_node, int key);
void print(int to_heap[], int size);
};
node *newNode(int item)
{
node *temp=new node;
temp->value=item;
temp->left=NULL;
temp->right=NULL;
return temp;
}
node *search_tree::insert(node *m_node, int key)
{
if(m_node==NULL)
{
return newNode(key);
}
if(key<m_node->value)
{
m_node->left=insert(m_node->left, key);
}
if(key>=m_node->value)
{
m_node->right=insert(m_node->right, key);
}
return m_node;
}
void search_tree::copy(node *from_tree, int to_heap[], int i)
{
if(from_tree==NULL)
{
return;
}
to_heap[i]=from_tree->value;
i++;
copy(from_tree->left, to_heap, i);
int right=i+2;
copy(from_tree->right, to_heap, right);
right=i+2;
}
void search_tree::print(int to_heap[], int size)
{
for(int j=0; j<size; j++)
{
cout<<to_heap[j]<<endl;
}
}
int main()
{
search_tree tree;
node *root=NULL;
root=tree.insert(root, 50);
tree.insert(root, 30);
tree.insert(root, 20);
tree.insert(root, 40);
tree.insert(root, 70);
tree.insert(root, 60);
tree.insert(root, 50);
int size=7;
int to_heap[size]={};
int i=0;
tree.copy(root, to_heap, i);
tree.print(to_heap, size);
}
Member 13277493
7-Dec-17 18:08pm
View
it gets incremented and decremented also
Member 13277493
7-Dec-17 18:07pm
View
it gets incremented when the node is not null, it is the index of array that must be filled
Member 13277493
7-Dec-17 17:53pm
View
thank you very much for responding, sadly I used debugger many times in this code and don't understand the problem, maybe I am not using debugger well
Member 13277493
30-Nov-17 11:34am
View
Thanks for helping. I must find question1 and traverse the left and right subtrees to find question2. yes?
Member 13277493
25-Oct-17 13:24pm
View
sorry if my question is stupid but I wrote like this, this added true mark for also one test, I don't fully understand what happens with the array
bool almostIncreasingSequence(std::vector<int> sequence)
{
int count=0;
int i=0;
while(i<(sequence.size()-1))
{
if(sequence[i]>sequence[i+1])
{
sequence.erase(sequence.begin()+(i+1));
count++;
}
if(sequence[i]==sequence[i+1])
{
sequence.erase(sequence.begin()+i);
count++;
}
i++;
if(count>1)
{
return false;}
}
if(count<=1)
{
return true;
}
}
Member 13277493
25-Oct-17 12:55pm
View
Deleted
Mr CPallini do you mean if sequence[i]<=sequence[i-1] starting from index 1(because -1 index cannot be), then remove the sequence[i]?
Member 13277493
25-Oct-17 12:54pm
View
Deleted
Mr CPallini do you mean if sequence[i]<=sequence[i-1] starting from index 1(because -1 index cannot be), then remove the sequence[i]?
Member 13277493
25-Oct-17 12:46pm
View
Deleted
Mr CPallini do you mean if sequence[i]<=sequence[i-1] starting from index 1(because -1 index cannot be), then remove the sequence[i]?
Member 13277493
25-Oct-17 12:10pm
View
It works, but some tests are not working correctly.
Member 13277493
25-Oct-17 5:00am
View
#include <iostream>
#include <vector>
using namespace std;
bool almostIncreasingSequence(std::vector<int> sequence)
{
int count=0;
int i=0;
while(i<sequence.size()-1)
{
if(sequence[i]>=sequence[i+1])
{
count++;
sequence.erase(sequence.begin()+(i+1));
}
i++;
if(count>1)
{
return false;}
}
if(count<=1)
{
return true;
}
}
int main()
{
vector<int>arr{1,6,5,8,9};
cout<<almostIncreasingSequence(arr)<<endl;
}
is this the right code?
Member 13277493
25-Oct-17 4:33am
View
this is a problem in codefights website, they are some tests that this problem does not pass.
Member 13277493
23-Sep-17 11:51am
View
thank you very much for answer, but can you explain what do you mean by splitting them out? :)
Show More