406 Posted Topics
Re: You might appreciate a full answer but we don't appreciate the idea of giving code here in this forum. So write your own program to implement the [URL="http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm"]Jhonson Trotter[/URL] algorithm or Heap permute algorithm using binary heaps given in A. Levitin, Introduction to The Design & Analysis of Algorithms, Addison … | |
Re: Solution is quite simple.Don't insert it from the end insert it from the beginning. Assume the below given is your list : N1->N2->N3->N4->N5->NULL Say you have a pointer called head which does nothing but points to the starting node of the list then your list looks like : head->N1->N2->N3->N4->N5->NULL The … | |
Re: Check out the implementations of [URL="http://www.cplusplus.com/reference/stl/map/"]map[/URL] and [URL="http://www.cplusplus.com/reference/stl/multimap/"]multimap[/URL] if you want to know about the implementation of hash tables. But in my view instead of creating a separate hash table why not use the functionality of priority_queue itself which has the largest element always at top? Try to collect the … | |
Re: @alwaysLearning0 : What you said is almost right but there is nothing called static memory in the context we are talking. every process is arranged into following segments : Text Segment : Which holds the code. Data Segment : Which holds the static and global variables. The remaining memory allocated … | |
Re: [URL="http://www.daniweb.com/forums/thread319487.html"]***Your previous thread for the same question****[/URL] Why did you create a new thread for the rectification in the question you posted...? You could have did the correction in the previous thread itself. Moreover it has been answered already in the previous thread.Now its your work to put in a … | |
Re: This is definitely not an exam question its a question picked up from some coding competition or as the "Note:" section says that its an assignment as it speaks of the submission and the criteria to be met before the submission. Anyways these type of question normally follow a format … | |
Re: @Unimportant : hours(minutes/60) would act like a ground function and give 4 hours for 241 minutes and not five.(you need to increase minutes by 60 or add 1 to the hours value in order to make it act like a ceiling function i,e (241+60)/60 = 5 and (241/60)+1 = 5). … | |
Re: cout always looks out for a type which it can output or another object of its own data type that is "ostream&" but you are passing a void type to it by using the myObject.displayObject() in line with cout.Rectify it and you are done. | |
Re: State your question properly . And show us some code that you have tried to write... | |
Re: Its quite straight forward right ? Assuming int n = strlen( <Message> ); Then the order of the matrix say ord should be the smallest integer i which satisfies the equation i*i*2 >= n ( where i is the smallest integer which satisfies this equation ) Now for any square … | |
Re: The algorithm just says : [code] //Input Array[0..n-1] unsorted //Output Array[0..n-1] sorted for i ranging from 0 to n-2 min = i; for j ranging from i+1 to n-1 if Arr[j] < Arr[min] min = j; Swap( Arr[i] , Arr[min] ) [/code] You can implement the above algorithm of selection … | |
Re: @andy124 : So this turns out to be a good opportunity for you to learn C++. Try to implement thats the only way you will learn. | |
Re: *+abc should be treated as (a+b)*c so in a prefix expression traverse the expression until you find two operands after an operator and use that operator on that operand then go on doing the same thing for the rest of expression. If you know queue then you can obviously play … | |
Re: If you have inp_Sec as your input of seconds then you can use it as : [code=c++] //Here you are trying to acquire all those seconds which cannot be converted to minutes ie anything short of sixty seconds out_Sec = inp_Sec % 60; //Here you convert it into proper minutes … | |
Re: @AncientDragon and Rahul.menon What Ancient Dragon has suggested and what you are trying to do is both right but I have a suggestion here which may sound a bit off the line. Why not read the floating value as a string(char array) instead of a float ? Because as we … | |
Re: Instead of reading the entire line at a stretch and then trying to cut it convert it etc try reading column by column with space as the delimiter as [code=c++] //istream& getline ( istream& is, string& str, char delim ); getline(fPtr,str,' '); [/code] If you know exactly how the file … | |
Re: Few things you can try out : 1)Read the blurred out print of the image you so nicely posted(If you can read). 2)Understand the problem and try to solve it.(If you have time) 3)Refer to some good links on the net to get more knowledge(On C++)rather than chickening out. After … | |
Re: @myk45: Just explaining what gerard4143 said in simple words. First usage is allowed as what ever usage of pointer you make its still remains a pointer and takes up a standard amount of memory which is normally equal to the size of your integer variable.So it can be defined without … | |
Re: You are in the right track.But try to see the code in this way for ease of visualization... [CODE=c++] for(int i = 0; i < n-1; i++) { x=(int)pow(2,i); for(int j = 1; j <= x; j++) cout << j << endl; } [/CODE] You can see that here too … | |
Re: Post the code area in which you are finding a problem. | |
Re: [B]Problem 1:[/B] [I]Legend : [/I] Summation where z ranges from low to high( ) :: S-z-[low]-[high]( ) Above stated problem is as follows... S-i-[0]-[n-1]( S-j-[0]-[i-1]( S-k-[0]-[j-1]( 1 ) ) ) S-i-[0]-[n-1]( S-j-[0]-[i-1]( j ) ) S-i-[0]-[n-1]( (i-1)*i/2 ) S-i-[0]-[n-1]( (i^2-i)/2 ) 1/2 * { S-i-[0]-[n-1]( i^2 ) - S-i-[0]-[n-1]( i … | |
Re: All that I can see is that in an odd numbered line its adding 1 and in even numbered line the multiples of that even number are printed... Any more inputs ...??? | |
Re: [URL="http://www.cplusplus.com/reference/string/getline/"]getline[/URL] marches forward in the file once it has read the line,and you have made no effort in "case 1" to read the file from starting again. There lies your problem. In order to check , first try to find account number 1 then 2 then 3 it does give … | |
Re: Well your requisites aren't clear so mention them in detail. Apart from it you can initiate a char array and then get the input through simple scanf() function. Then use strtok() with array address and space as delimiter to get the first token and then loop over and get the … | |
Re: [QUOTE=Tom Gunn;1015603]Why not?[/QUOTE] For several obvious reasons Tom Gunn : 1)Because it is sub standard. 2)Uses all the extinct headers and commands. 3)It is not according to the c99 standards. 4)void main is valid in it. 5)The blue screen irritates a lot... ;) And loads other stuff......... | |
Re: Explain your needs properly and paste in the code which you have[B] tried[/B]. | |
Re: [B]@micjan : [/B][COLOR="Red"]Congrats you got the code !!! I certainly wish the two smart people above get you everything you want in your life ... because with this attitude you are not gonna learn or earn anything...!!![/COLOR] | |
Hello Everyone, I am developing a kernel module which acts as a sniffer and also a module which edits the TCP packet window size as per requirement of the admin. And in the process I developed this kernel module which is tainting my kernel (Opensuse11.2).The sniffing module developed by me … | |
Re: C runs on some rules,you need to learn them before trying out something,and ya you cannot just translate a code to C and expect it to work. [code=c] int maxprimes; int count = 1; int value = 1; int primes[maxprimes]; int composite; int i = 1; int j; printf ("How … | |
Re: [B]You can do these :[/B] [B]1>[/B]Well if its just a matter of printing then [icode]"%.nf"[/icode] where n is the number of digits after the [icode]"."[/icode] you want to print in a floating point number. [B]2>[/B]If its really about conversion then you can know the IEEE floating point format for your … | |
Re: May be a printf within a printf would do the trick.Because the inner printf doesn't require the semicolon. | |
Re: [B]I just hope I could key in the same number of characters from keyword in 30 sec[/B].At least that would help me to code in hell lot of code in minutes ;) | |
Re: Woooosh......!!! Don't worry Sid you'll get the stuff you need...the OP will pay you with these for writing out her program ;) if she could get away from all our flaming !!! :) | |
Re: [B][U]@somaja :[/U][/B] Ya ya you have caught our attention , now can you please stop using the [COLOR="Red"][b]BOLD RED COLOURED[/b][/COLOR] text...??? And ya use [URL="http://www.daniweb.com/forums/misc-explaincode.html"]code tags[/URL] when posting your code. [B][U]@somaja & squ :[/U][/B] Post in your progress in solving the program till now you will definitely get help from … | |
Re: This OP deserves an applaud, he is so honest that he is directly giving us his assignment copy and asking us directly to code for him. :D Really sorry,here your honesty doesn't pay you the code you need.You need to work.Work hard and code yourself. | |
Re: [QUOTE=hiprakhar;1019344]Hi this is the code for life, universe and everything problem, where the program stops only when the user inputs the number "42" I tried to understand the problem, but could not make it that how the program stops at exactly 42. Any help would be extremely appreciated. [CODE]#include <iostream> … | |
Re: [B]Before worrying about big things please pay some attention towards small things[/B]... There is a lot of difference between [B]1 and '1'[/B] . The input you are taking is a character so the cases of switch should be as case '1' : case '2' : and all , else make … | |
Re: There are several problems and it starts from main() only. 1)[code=c++] char *c; *c = line [0]; [/code] Assigning a character value to an address which doesn't point to any memory. According to your code this line has to be: [code=c++] char *c; c = &line [0]; //or char *c … | |
Re: Idea for the topic Yes...Code a simple software for a shop or something.It involves file handling as you need to use them for information write and fetch operations. And a complete no for the example... Because we want you to code. | |
Re: [COLOR="Red"]No you will not have the program code[/COLOR]. Such programs are called [B][U]QUINES[/U][/B] if you want the program,read about them and then write. [B]We are not a bunch of jobless people waiting to code for free.[/B] | |
Re: Your code snippet can be shortened tux...here it goes: [code=c++] void reverse(char p[]) { int len=strlen(p); for(int i=len-1, j=0;j<i; i--, j++) { // exchange elements p[i]^=p[j]^=p[i]^=p[j]; } } [/code] Try it and do tell me what do you think...??? | |
Re: You need to pay more attention in your classes.Very silly mistakes. [B]1)[/B] [code=c++] vowels::vowels () { int a=0; int e=0; int i=0; int o=0; int u=0; int y=0;input=""; } [/code] Class functions are used to manipulate the variables declared within the class.Here by declaring the variables again you are just … | |
Re: [B]@dangutdavid and Phil++[/B] : [COLOR="Red"]Both of you need to understand your basics well because without it you cant code anything.[/COLOR] Error 1 : Line 7 : Initializing A even before declaring it. Error 2 : Line 38 : getch() ??? And please tell me that this program has no logic,the … | |
Re: Why did you post the code here...??? | |
Re: Lots of problems only in pointers. [B]1)[/B] Yes you guessed it right the declarations should be of form [iCODE]<function>(char *)[/ICODE] format. [B]2)[/B] Consider the following example: [code=c++] void function(char *a) { // Function Definition } // Somewhere in main char arr[20],a; char *p; p=&a; // Call can be either like … | |
Re: Your customers function is a total mess. Apart from the errors mentioned by Ancient Dragon and jonsca above I felt these were wrong. 1) The criteria should be matched with a previously available list of customers but here you are creating a new customer list which totally makes no sense. … | |
Re: Here is your faulty code : [code=c++] for(;k%5==0;) y++; k++; [/code] Your [icode]k%5[/icode] checks if its value is 0 until its not zero k++ executes very well.Once k becomes a multiple of 5 then the for loop [code=c++] for(;k%5==0;) y++; [/code] Will never quit because you will increase y , … | |
Re: These are the steps: 1)First write a program to dynamically allocate memory for a matrix,input values to it and print them. 2)Now take a pen and paper and find the inverse of that matrix step by step. 3)Analyze the steps and code for it finally. 4)Correct the mistakes which you … | |
The End.