- Strength to Increase Rep
- +15
- Strength to Decrease Rep
- -3
- Upvotes Received
- 518
- Posts with Upvotes
- 443
- Upvoting Members
- 244
- Downvotes Received
- 104
- Posts with Downvotes
- 86
- Downvoting Members
- 52
- PC Specs
- Computers
Re: Since you are already using std::string, I figure to help you concise this function : [code] //method to check if the current character is a vowel bool IsVowel(char chr) { switch (chr) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'Y': case 'a': case 'e': case … | |
Re: If your comfortable with the math, you should be fine | |
Re: 1) Why ? 2) need compile time variable meaning there will be a fixed amount of inputs to get 3) Need to implement your own sorting method and use it inside main, so technically it won't be a function. If not then you will need a lot of if/else or … | |
Re: You can prove this by giving just 1 simple example. No need for general proof, because if it can't work for even 1 case, then its incorrect. | |
Re: First off, this code : [code] #define false 0 #define true 1 char s[100]; char sr[100]; [/code] Is bad already. You do not need to use define. C++ already has, "true" and "false" defined. Next : [code] int main(){ InputString(); system("PAUSE"); return 0; } [/code] No need to use a … | |
Re: The key idea is to use the [URL="http://en.wikipedia.org/wiki/Modulo_operation"]modulo operation[/URL]. For example [icode]if(num % 2 == 0){...}[/icode] means that [i]num[/i] is evenly divided by 2, thus checks if num is even. Use that idea. Your algorithm is more complicated than it needs to be. | |
Re: >> And it's kinda the whole point of C++ No its not. C++ != OOP. C++ has OOP, but does not mean C++ is OOP. | |
Re: Just a quick explanation on [B]Abstract [/B]Data Type(ADT) [b]WHO[/b]: Abstract Data Type [b]WHAT[/b]: Abstract Data Type are data-type that combines the common functionalities from different related objects into one package, so that those different but related object's interface can inherit from the ADT thus making it more flexible and and … | |
Re: >>[B]I want to my program to prompt user to input a number with three or more integers [/B] You know how to get the user input into a variable right ? [code] int var1 = 0 , var2 = 0, var3 = 0; cin >> var1 >> var2 >> var3; … | |
Re: [QUOTE=Nick Evan;1268790][B]>>If there are three logic bugs in total and one's down, two are left. [/B] Holy shit. That's some amazing math! Although you obviously think otherwise: I'm not stupid. I was asking [I]where[/I] the two remaining errors are.[/QUOTE] I think he got this code from the book. And the … | |
Re: Of course we're not gonna do this, unless you pay me $20.00 dollars for this problem. But to start you off, this is the quadratic equation : [code] x = -b/(2a) +- sqrt(b^2 - 4ac) / (2a). [/code] Since they gave you a,b, and c. You just have to plug … | |
Re: Bad naming, time is already defined in ctime [code] #include <iostream> #include <ctime> using namespace std; int main() { clock_t start = clock(); cout << "press enter..."; cin.ignore(); clock_t finish = clock(); double doneTime = float(finish-start)/CLOCKS_PER_SEC; cout << "you took " << doneTime << " seconds\n"; return 0; } [/code] | |
Re: Piece of cake, kinda crude approximation tho. [code] #include <iostream> #include <cmath> #include <string> #include <vector> using namespace std; const unsigned CANVAS_WIDTH = 20; const unsigned CANVAS_HEIGHT = 20; const unsigned char BACKGROUND_FILL = '#'; const char POINT = '*'; const float PI = 3.14159265f; const float DEGREE_TO_RADIAN_FACTOR = 0.0174532925f; … | |
Re: A problem I see by the suggested solutions so far that is, it is inefficient if one calls the function numerous times. So in the long run it will probably be better to read it into a vector and use that vector to extract lines. That way you get rid … | |
Re: That's why people shouldn't jump too early into graphics without good knowledge of the basics. Ball is a function. It is not a class nor a struct. Thus you cannot use the dot operator on ball. A easy way to get the ball to move is by doing something like … | |
Re: Royal blue, bought my first car last summer. 2007 tiburon GT. Sexy little self. Got it for a bargin too. 21K miles for 8G. | |
Re: For part a) make a copy. For that copy, uppercase the first letter. Print it backwards. For part d) make a copy. Swap certain positions. Print out the copy backwards. | |
Re: Pretty cool. Looks something someone will see if they were high of drugs. | |
Re: If you know how to convert from base 10 to base 2, then you know how to convert from any base to any other base. So the question remains, do you know how to convert from base 10 to base 2? | |
| Re: They all suck and have their weakness. So there isn't one. |
Re: a) In a 32-bit system, a reference variable needs at least 4 bytes of memory and in a 64-but system, it needs at least 5 bytes. That's because a reference points to the memory of the variable its pointing to. Thus it needs only enough memory to store a memory … | |
Re: Data Abstraction means something like this : //Shape provides no implementation of the draw functions //It abstracts the draw function from other shapes meaning that it //defines functions that all type of shapes should necessarily have. class Shape{ public: virtual void draw()const=0; }; class Ellipse : Shape{ public: void draw()const{ … | |
Re: You can use your browser and setup an autofill option, so that when needing to fill out a form, the browser can try to autofill it. Other than that, you need to justify why you would want to do this. | |
Re: [code] int i = 0; while(!cin >> i) { cout<<"\nNot valid Try again : "<<endl; cin.clear(); while(cin.get() != '\n') ; } cout<<"Valid\n"; [/code] | |
Re: You can use the .exe file in your project directory. | |
Re: Its not possible to do this with just C++. But you can approximate it like so : [code] #include <iostream> #include <string> #include <ctime> using namespace std; int ask(const string& question){ cout << question; int ans = 0; cin >> ans; return ans; } int main(){ const int MAX_TIME_LIMIT = … | |
Re: "Shake sphere game us to be or not to be ", computer gave us 0xFF" -------------------- 2B|~2B = 0xFF -------------------- | |
Me? Oh nothing much, just bored at work. Working on a new web-app project on my free time. Planned to be in the appstore. Going to hit #1, just watch. How about you? |