244 Posted Topics
Re: Is there a reason you are not permitted to use strings and a simple loop? | |
Re: for the first question google SRAND line 42 you create an array of ints then on line 45 you attempt to read a value to this array without specifying which location in the array you want to store it. I think you want to take in the digits of the … | |
Re: Why do you have 2 loops when you just add to sum after line 16. This can be easily done without the need for arrays. | |
Re: The only reason i have came across for a function with nothing sent to it and no return is output to the console. Google [B]cout[/B]. | |
Re: For b) what about [CODE]((1 + (rand() % 5)) * 2)+1;[/CODE] | |
Re: [CODE]#include <iostream> #include <string> using namespace std; bool is_pal(string a) { int b=a.length(); for(int i=0;i<(b/2);++i) if(a[i]!=a[b-i-1])return false; return true; } int main() { string s; cout<<"Please enter a string:\n"; cin>>s; if(is_pal(s)) cout<<"This is a palindrome.\n"; else cout<<"This is not a palindrome.\n"; return 0; }[/CODE] | |
Re: Why the { on line 27? What if n%10=1? i.e n=11 or 21? EDIT Beat me to that Nick:) I have also been led to believe goto is BAD. A while or do while loop may be better. | |
Re: I think this is what you need. [URL="http://www.daniweb.com/software-development/cpp/threads/78223"]here[/URL] | |
| |
Re: I think he is referring to [URL="http://en.wikipedia.org/wiki/Letter_frequency"]this[/URL]. | |
Re: [QUOTE]If you're like me and enjoy Steam's service (not having to mess with DVDs and CDs),[/QUOTE] [URL="http://www.bbc.co.uk/news/technology-15690187"]http://www.bbc.co.uk/news/technology-15690187[/URL] | |
Re: Well it is difficult to kill 127 of one's schoolmates without one. DUH. | |
![]() | Re: You're in over your head. Get a book and start reading. :) |
Re: 1 Where are your #includes and namespace? 2 What is str.length (why would that give you the size of k)? 3 Where is your output line? EDIT If this is a snippet ignore 1, if not you need to check your braces and there is no return statement. | |
Re: [QUOTE]I a still confused, maybe I am looking too much into it, but I am so lost. Please someone help me.[/QUOTE] No what you mean to say is "Please someone do it for me." Much more precise. (see i have already helped) | |
Re: It is repeating the loop. Try a couple of cout lines to find out where you're going wrong(ie right before line 21). | |
Re: works fine for me with the mentioned changes | |
| |
Re: I doubt she's going to do everything for you. Unless she's in a really really really good mood. | |
Re: you could try [CODE]srand(time(NULL));[/CODE] worked in the past for me but hey i'm not good at this so "pinch of salt". | |
Re: line 3 remove the .h line 38 remove the void | |
English rioting for no apparent political reason, more a case of get what you can while the going is good. Does it get much worse than [URL="http://www.bbc.co.uk/news/magazine-14487982"]this[/URL]? Is society really broken? | |
Re: I didn't realise there was an age limit. Could you let me know what it is. I'm 3 years old by the way. | |
Re: [QUOTE]I don't do graphics. My expertise is in back-end development.[/QUOTE] [URL="http://www.transforminglives.co.uk/buttock-implants.html?incoming=googlead&gclid=CLLYiMzrgasCFeYmtAodpFf70g"]Like this?[/URL] | |
Re: [QUOTE]42% of Brits have not sent a snail mail letter in the last six month[/QUOTE] that would have been true for me before email [QUOTE]51% of British workers would rather send an email than pick up the phone to a colleague, whereas only 24% would do the rather do the … | |
Re: you are replacing tmp every time you compare 2 values. ie on the very last check if person[9]>person[8](or nine in this case, checking against itself) you replace the value. this doesn't mean it was the biggest of all. one loop should be sufficient for this task. | |
Re: I doubt anyone will help you without some sign you have attempted the problem yourself. Even if someone were so charitable (i.e stupid) your description of the problem is a little vague. Go away make an effort and come back with a specific problem. | |
![]() | ![]() |
At what point does conciseness become more important than readability, or vice-versa (given that there is no difference in performance)? Is there an element of snobbery amongst programmers to certain techniques or are certain things just purely bad practice? | |
Re: In line 23 if I enter 100+99 why would the second character in the string be an operator? Line 25 in the second i believe chars are compared with '' not "" edit: that's single not double quotes (though i think this project may be flawed at the planning stage) | |
Re: [QUOTE]No doubt, the easiest language to write a compiler for is Brainf*ck. Writing an interpreter for this language is probably gonna require less lines of code that the "Hello World" program in Brainf*ck.[/QUOTE] That's pretty strange. Then again so is [URL="http://en.wikipedia.org/wiki/Fractran"]this[/URL]. | |
Re: I think i prefer atheism on the basis that spending eternity in hell sounds pretty bad but spending eternity in a place with all the "good" people sound like the christmas day with the family ad infinitum.:scared: ![]() | |
Re: I would consider making 2201 posts in 2 months an obsession or something more malicious. (i.e spammer or very lonely person) | |
I wrote this test code trying to work out a problem. The code gives the correct answer for the example (zero) but to understand the problem i need to understand what the code is doing on a sort of step by step basis. In other words how to do it … | |
Re: The problem is the poor(including myself) don't have the will and drive of the rich, otherwise we'd have taken all they've got by now. | |
Re: I watched every second. I am never prouder than the occasions where i partly finance an event for people i don't know or will probably ever meet. Proud to be British. | |
Re: The search for his Mac or listening to him tell you about it? | |
Re: I can dance in my lounge for free, and look like an idiot (not very often), why would i pay for the privilege? |
The End.