105 Posted Topics

Member Avatar for Gusts

First question is interesting one, I researched on it, but the below mentioned link has figured out some really good stuff regarding your first question. [url]http://aperiodic.net/phil/archives/Geekery/find-duplicate-elements.html[/url]. will try your 2nd question tomorrow :).

Member Avatar for Alex Edwards
0
307
Member Avatar for Dannyo329

What I understand from your question is that, you want your int menu() function to be the entry point of your program, in C99 Standard its defined that the int main() and int main (int argc, char* argv[]) OR int main (int argc, char** argv) should be the starting point …

Member Avatar for Laiq Ahmed
0
162
Member Avatar for nurulshidanoni

I have interesting solution other than Selection Sort, just for knowledge. You fetched the numbers from the stream and put it in the array, then sort the array using the desired algorithm. What if you make a sorted link list and insert in it directly?. just compare the complexities of …

Member Avatar for nurulshidanoni
0
3K
Member Avatar for kse989

Well ! I don't think you don't know recursion, otherwise you wouldn't have such a good implementation :). good efforts :). let's have a expert look on that implementation, hope you'd agree. I don't like you Copy Constructor's Syntax. [code] void TreeType<ItemType>::operator=(const TreeType& originalTree); [/code] why? would be your question, …

Member Avatar for Laiq Ahmed
0
904
Member Avatar for akshayygarg

I don't know what your code really does, I just check the language semantics. [code] ilc *ob; ob=get_activities(ob); [/code] check the codding of get_activities(..), it returns pointer to array of object of type ilc but within the function get_activities (...). line number 300. [code] delete [] ob; [/code] so according …

Member Avatar for akshayygarg
0
157
Member Avatar for cb02061

you just need to include [code] #include <fstream> #include <iostream> [/code] don't use .h suffix. also encapsulate the Dragon's function in some class and make that a static member. and your simplest logger is ready :).

Member Avatar for Necrolis
0
3K
Member Avatar for complexcodes

Hey! you are not considering all the cases, you are finding the sum of link list, NOT SUM IN THE LINK LIST. let me give you some example. lets suppose we have a link list containing following element 1, 5, 4, 3, 2, 8. and I tell you whether the …

Member Avatar for Laiq Ahmed
0
3K
Member Avatar for nurulshidanoni

agreed with niek_e he has given you the good resource for selection sort. let me discuss what I know about selection sort. selection sort is simple it just select the element and put the selected element in correct position. in your case the data is 50, 90, 40. if you …

Member Avatar for Laiq Ahmed
0
90
Member Avatar for Icetigris

I think you forgot to push the polygon element in the vertex. first you need to push element in the vector then use vector's at (index) function. if you want to assign, use array operator instead which returns the reference. and let you add element like below [code] m.Polygon.push_back (p); …

Member Avatar for Laiq Ahmed
0
106
Member Avatar for dreamgirl

first let me point out some problems in your existing code [code] //check that price is double/float i.e. 25.5 etc. double total (int qty, double price) { double t; t = qty* price; return t; } [/code] what ever the total is you need to return the total whether its …

Member Avatar for dreamgirl
0
107
Member Avatar for Brent.tc

Try Reading Socket Programming. what you are actually doing is creating a server listening on Port, this can be achieved using WinSock on windows Plateform, same can be done on linux using the socket API defined for linux. [code] int main () { // Initialize the Socket Environment. // Create …

Member Avatar for Laiq Ahmed
0
97
Member Avatar for rsk8332

Lets do some binary Tree. What your algorithm says. [quote] I pick a pivot p from a database S of strings, compute the median r of the distances of the string objects to p and then divide the objects into roughly equal-sized subsets S1 and S2 as follows: S1={o ε …

Member Avatar for rsk8332
0
125
Member Avatar for Adrian99420
Member Avatar for harkw002_UniSA

returning iterator is perfectly valid C++ code. but if you need an object you can derefer the iterator. but the thing is that how will you identify where the object is found or not ( either by returning "" --> empty string) . The semantics of iterator define not found …

Member Avatar for harkw002_UniSA
0
7K
Member Avatar for theausum

difference b/w const and #define (macro). 1. Type Checking:- macros are not type safe where as const are type safe. since the macros are replaced by definition at the time of preprocessing (which is done before compilation). the storage area of macros is not defined where as const has static …

Member Avatar for Laiq Ahmed
0
138
Member Avatar for nurulshidanoni

Hey Sorting is a huge topic and there are several ways of sorting the data. which technique you want to use to sort this data. Radix sort can do a job. lets understand what you want 1 91 25 2 168 20 3 2080 46 4 680 56 5 15 …

Member Avatar for Ancient Dragon
0
112
Member Avatar for xsoniccrackersx

Hope the following code. helps. [code] int main () { ifstream inputFile ("C:/inputFile.txt"); if ( !inputFile.is_open ()) { cout<<"File not opened"<<endl; } string line; string userId, answers; while (std::getline (inputFile,line, '\n')) { std::stringstream inStream(line); inStream>>userId; std::getline(inStream, answers, '\n'); cout<<"The userId is :"<<userId<<" and answers are: "<<answers<<endl; } inputFile.close (); return …

Member Avatar for xsoniccrackersx
0
1K
Member Avatar for obsolucity

Lets analyze what the mergesort do. The first Function you've written [code] void merge_sort(int low,int high) { int mid; if(low<high) { mid=(low+high)/2; merge_sort(low,mid); print("decomposed", low, mid); merge_sort(mid+1,high); print("decomposed", mid + 1, high); merge(low,mid,high); } } [/code] it simply spit the array of size n from mid and do it untile …

Member Avatar for Laiq Ahmed
0
320
Member Avatar for TSharma

great stuff to implement. do you understand the cin, stringstream, check to see the functionality they provide, and what they basically are ( HINT: they are specialization of templates ). if you are good C++ developer then you'll figure out what they exactly do. [code] typedef basic_stringstream<char, char_traits<char>, allocator<char> > …

Member Avatar for Laiq Ahmed
0
92
Member Avatar for yonex

well I can see several errors. I don't know your level of C++, but assume you must be good enough, because you are using STL. [code] struct attribute { const char* name; int id; }; int main () { static attribute attr; std::string str = "Laiq"; attribute* attrPtr = 0; …

Member Avatar for Laiq Ahmed
0
137
Member Avatar for GPXtC02

Narue its a part of utility.h in VS2008 and in Utility.h and xstring on VS2005.

Member Avatar for GPXtC02
0
262
Member Avatar for rukshenaa

you have problem with Fibonacci heaps or Dijikstra algorithm. I think you have coded the algorithm using array, so you might getting the problem with fibonacci heaps, paste your efforts regarding fibonacci heaps.

Member Avatar for Salem
0
185
Member Avatar for terrorblade

1. avoid using Magic Numbers 6, 12. make them constants. with meaningfull names. i.e. [code] const int MONTHS=12; [/code] 2. Associate the pointer with type or identifier not in the middle [code] double *monthRanking(double * aYearData) [/code] it should be like this [code] double *monthRanking(double *aYearData) // OR double* monthRanking(double* …

Member Avatar for Laiq Ahmed
0
240
Member Avatar for rzr.copperhead

make sure you understand the anciant dragon's post completely :). your algorithm doesn't do the right thing in reading it should read after opening file directly remove your first read call one more thing return the vector<>& from readFile function replace the file.read (...) , problem lies there. you will …

Member Avatar for rzr.copperhead
0
119
Member Avatar for Yellowdog428

Lets do some sorting. First of all the sorting technique you are using is sort by swapping. famous as a bubble sort. before sorting lets improve your code. which is more strutured Why are you keeping the two related things separate? why don't keep these two things rainfall & month …

Member Avatar for Yellowdog428
0
147
Member Avatar for vaid.abhishek

I have analysed your code and finds that the nth_element works as it should, I tested it on VC++ 2005 and VC++ 2008. After changing the code you suggested [code] for ( long i = 1 ; i <= 1 ; i++ ) { generate ( arr.begin(), arr.end(), myIntegerRand ); …

Member Avatar for Ancient Dragon
0
296
Member Avatar for gothicmisery85

what about the following code. [code] template<class T> T const& Absolute(T const& v) { if (v < 0) { return (v + (-v*2)); } return v; } [/code] requires minute mathematics.

Member Avatar for Laiq Ahmed
0
249
Member Avatar for bis student

set the prototype of functions like this [code] void setW(); void setL(); [/code] replace above two with [code] void setW(double num1) void setL(double num2) [/code] remember to add semicolon where required.

Member Avatar for BlackJavaBean
0
200
Member Avatar for flash121

Deleting a node is not difficult. let me tell you the algorithm. Algorithm. Delete (value) 1. Check if head is null return 2. if the value matches head set temp = head set head = head->next free head. 3. Link previous = head; 4. Link temp = head->next; 5. while …

Member Avatar for Laiq Ahmed
0
700
Member Avatar for nurulshidanoni

why don't you traverse the array and check if the value is non zero add them, [code] // traverse the array. if ( a[i] != 0) sum += a[i]; // after loop cout<< sum; [/code] this is what i understand from your description.

Member Avatar for Laiq Ahmed
0
193
Member Avatar for fallen_prisoner

writting a better code is not difficult until and unless you think that you will not avoid the things you know and well understand the problem. first of all this is not an OOP. if you are willing to write OO Program you should think in terms of objects and …

Member Avatar for Laiq Ahmed
0
111
Member Avatar for ayk-retail

your link list implementation is stack based implementation, to reverse it you first need to know how to reverse the list. there are three ways of doing this. 1. Recursive. 2. using explicity stack. 3. using iterative approach. ( the one you are using). your code says the following [code] …

Member Avatar for Laiq Ahmed
0
395
Member Avatar for bramprakash1989

one thing, return 0 from main not 'o' (not o) your code will work try this [code] j = rand()%50; [/code] and replace your condition [code] if (!(j >= 50&&j<=0)) cout<< j<<endl; else cout<<"out of range"<<endl; [/code] and only print the j what is does ? requires minute mathematics.

Member Avatar for Ancient Dragon
0
248
Member Avatar for doublediamond

what it actually does. Let me tell you what it actually does, and what it should do first what it does [code] template <class T> void myVector<T>::grow(){ while(size >= capacity) { T* temp; temp = data; capacity *= 2; data = new T[capacity]; for(int i = 0; i < size; …

Member Avatar for doublediamond
0
214
Member Avatar for pad510

_cdecl and _stdcall has some difference, I think you are calling the function from the library written using different calling convention than the one you are using. Its basically a name decoration issue, not resolved by linkers. In VC++ 6.0 _cdecl is the default calling convention. _cdecl In this type …

Member Avatar for Ancient Dragon
0
177
Member Avatar for legendarya49
Member Avatar for Laiq Ahmed

Can any1 tell me about the tutorials and description regarding new c++ standard. specially the improvement in STL.

Member Avatar for vijayan121
0
107
Member Avatar for mapaputsi

[quote=mapaputsi;325533]Can anyboby help me i really dont get the feeling of big o notation, i just want to understand it.[/quote] Big O Notation is used to denote the complexity of the algorithm ( worst case complexity)... for example the following code has complexity O(n) [code] for(int i=1;i<=n; ++i ) { …

Member Avatar for ~s.o.s~
0
161
Member Avatar for Laiq Ahmed

I want to generate the following pattern using for() loop only.... how can i do this i've tried but unfortunately failed to solve .... when user inputs 3 [COLOR=#008000]1 1 1 1 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 1 1 1 …

Member Avatar for Laiq Ahmed
-1
116
Member Avatar for virsa

[quote=virsa;320615]access c++ private data members without using the " Friend" type main() can be a friend function?[/quote] its against OOP concept but still... this might help [code] [COLOR=#0000ff]class[/COLOR][COLOR=#000000] A { [/COLOR] [COLOR=#0000ff]private[/COLOR][COLOR=#000000]:[/COLOR] [COLOR=#0000ff]int[/COLOR] a; [COLOR=#0000ff]char[/COLOR] b; [COLOR=#0000ff]public[/COLOR][COLOR=#000000]:[/COLOR] A(): a(1), b([COLOR=#800000]'A'[/COLOR]) {} }; [COLOR=#0000ff]int[/COLOR][COLOR=#000000] main() [/COLOR] { A* obj = [COLOR=#0000ff]new[/COLOR] …

Member Avatar for Laiq Ahmed
0
140
Member Avatar for Laiq Ahmed

i want to calculate the complexity of the following code snippet [code] for(int k=0;k<n; ++k) for(int j=0; j<k; ++j) for(int i=0; i<j; ++i) cout<< "Hello World" <<endl; [/code] here! i got the hint! that summation of natural numbers series would be used if its correct why ? bit confused:sad:

Member Avatar for Infarction
0
96
Member Avatar for Laiq Ahmed

please help me understand the folowing code.... [code] class A { int a; public: A() : a ( 0 ) {} int get() { cout << "Hello WOrld " << endl; return 0; } }; int main( int argc, char** argv ) { cout<< ((A*)3)->get() << endl; return 0; } …

Member Avatar for Ancient Dragon
1
126
Member Avatar for dilip.mathews

You can get the [B]effect [/B]of Virtual Constructor by using Factory design pattern...... which doesn't violates the objected oriented rules specifically inheritance structure........ but its helpful. and some times needed.... The vptr not necessarily initialized by the compiler in the constructor it might be initialized during the construction... its totally …

Member Avatar for Laiq Ahmed
0
158
Member Avatar for SHWOO

This is the first time i found such code to read from the ostream....... i can just help you with the syntax i m also trying to code this... soon i'll conquer or will give up..... :d. [code] [COLOR=#0000ff]class[/COLOR][COLOR=#000000] PhoneNumber {[/COLOR] string area_; string exchange_; string line_; [COLOR=#0000ff]public[/COLOR][COLOR=#000000]:[/COLOR] [COLOR=#000000][/COLOR] PhoneNumber(string …

Member Avatar for SHWOO
0
225
Member Avatar for dev.cplusplus

The problem you've described might consists of pair of key value... using pair< T1,T2> template is agood choice .....then. I totally agree with salem, every Data Structure has some advantages and tradsoff, its depends upon your need and how it fits the scenario... in LIFO(Last in First Out) link list …

Member Avatar for Laiq Ahmed
0
459
Member Avatar for Laiq Ahmed

I want to read a Source Code file and separate the lexemes (words) and want to track the line number with the separated words? I just come up with the raw code like that... i) A struct holding a string , int pair; ii) making the link list of above …

Member Avatar for Micko
0
92
Member Avatar for Laiq Ahmed

I've just tried to code the Binder2nd, almost same as standard code provided in functional...... please point out the mistakes........ and suggest me guidelines to write effective code.......... [code] [COLOR=#0000ff]#include[/COLOR][COLOR=#000000] <iostream>[/COLOR] [COLOR=#0000ff]#include[/COLOR][COLOR=#000000] <vector>[/COLOR] [COLOR=#0000ff]#include[/COLOR][COLOR=#000000] <functional>[/COLOR] [COLOR=#0000ff]#include[/COLOR][COLOR=#000000] <algorithm>[/COLOR] [COLOR=#0000ff] using[/COLOR][COLOR=#000000] [/COLOR][COLOR=#0000ff]namespace[/COLOR][COLOR=#000000] std;[/COLOR] [COLOR=#000000][/COLOR] [COLOR=#0000ff] template[/COLOR][COLOR=#000000] <[/COLOR][COLOR=#0000ff]class[/COLOR][COLOR=#000000] _Fn> [/COLOR] [COLOR=#0000ff]class[/COLOR][COLOR=#000000] Binder2: [/COLOR][COLOR=#0000ff]public[/COLOR][COLOR=#000000] …

Member Avatar for GloriousEremite
0
143
Member Avatar for joshilay

Pointer to function are the pointers which have the ability to call the function pointed to by them.As the ordinary pointers take the address of variable and can change the value pointed by them, the function pointer almost does the same. [code] #include <iostream> #include <string> using std::string; using std::cout; …

Member Avatar for Laiq Ahmed
0
116
Member Avatar for joshilay

I can just explain you how to code on code it in any language of your desire Algorithm Suggest: - i) visit the left Subtree ii) visit the Node iii) visit the right Subtree You are interested in making the Non Recursive version of the above traversal. You can make …

Member Avatar for Laiq Ahmed
0
169
Member Avatar for Marthy

[quote][I]What is the Importance and uses of data stuctures in Programming using C/C++ when using it?[/quote][/I] [I]I think data storage and retrieval + usage of memory effeciently etc are the concepts that are the basis of Data Structure,...[/I] [I]answer my Few Question: - [/I] [I]In a drawing software can you …

Member Avatar for Laiq Ahmed
0
90

The End.