- 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
2,712 Posted Topics
Re: Giggidy Giggidy Giggidy - Family Guy, Quagmire. | |
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? | |
Re: Skip defines and macros. Use enums when you need type saftey and when it makes more sense. | |
Re: C++ doesn't have an interface to allow you to create any GUI code, but you can use external libraries to draw the GUI stuff and control it with C++. For example here is a gui application in C++ using the QT library: #include <qapplication.h> #include <qpushbutton.h> int main( int argc, … | |
Re: I use that mapeditor, but usually export it to json. Actually exporting it to json is what you need. It has a "data" attribute which is an array of numbers like you have above, and each number represents a tile. | |
Hey guys, haven't been on here for a while. Just thought, I'd get the ball rolling and interact with the community. Anyways, tell me and everyone else on the internet, the derivation of your username? Why? How? What? When? Who? WTF? | |
Re: I'm using Phaser engine for a 2d web platformer game, its not too bad, give it a shot | |
Re: Can you just use notepad search/replace to format the csv file? or is this just for practice | |
Re: let me start you off. This snippet generates prime up to 100. Fill in the conditions. Its in java...hehe. So you need to understand the logic and convert it. Then you can fill in the needed requirements. [code] package helloworld; public class Main { static boolean isPrime(int num) { if(num … | |
Re: [QUOTE=ShawnCplus;507456][code=c++] #include <iostream> #include <cstdlib> #include <ctime> #include <string> using namespace std; int main() { srand ((unsigned) time(0) ); //<----Only seed once //A string is not necessary, you aren't using any the facilities of the class char* RandNum; //What is this supposed to do? There's no input from the user? … | |
Re: Else statement is connected to the if statement. Once the if statement is executed, else statement is not executed even if the while statement inside the if returns false or true or never returns. | |
Re: Try this ` cout << " just inserted new element. " << (ret.second==true) << endl;` or better yet just `cout << " just inserted new element. " << ret.second << endl;` | |
Re: Usually you overload the operator[] for constant-ness. Are those operators defined in some class? Consider these statement T* a = getA(); const T*b = getB(); if(a[0] == 1) doA(); if(b[0] == 1) doB(); Without the `const T& operator[](int)const` version, the `b[0] == 1` would not compile because b is declared … | |
Re: Use [URL="http://www.cplusplus.com/reference/clibrary/cctype/toupper/"] toupper[/URL] function in cctype header file. | |
Re: Interesting history post. Thanks for the information. Off topic kinda but I wish more people would just stop what they are doing for 5 minutes and just observe. Observe the society, observe the body languages, observe the human interaction, observe nature and its wonderful mathmatical creation, observe people and their … | |
Re: Be nice. So you want to alternate rotation. In that case you need a little bit more logic like so: if( isSpaceKeyPressed()){ int currentRotation = line.getRotation(); if(currentRotation == 90){ //is horizontal( flat line ) line.setRotation(0); //make it straight line }else{ line.setRotation(90); //make it flat line } } | |
Re: What will knowing that data structure FB used will help you in anyway? If you have a problem of picking which data structure to use, then either post it here or compare the pro's and con's of each data structure and pick the one that best suites the problem. They … | |
Re: Maybe this startup hint would help you #include <iostream> using namespace std; void getMonthsData(int data[], const int SIZE){ //print message //for i = 0 to size //ask for data[i] } void getYearData(int data[], const int SIZE){ //print message //for i = 0 to size //ask for data[i] } void getAverate(int … | |
Re: I am not saying its faster than sqrt, but it calculates it without using sqrt. [code] sqrt(a) = x x^2 = a ln(x^2) = ln(a); 2ln(x) = ln(a) ln(x) = ln(a) / 2 x = e ^ (ln(a)/2) //same as sqrt(a); //you can decompose it back to sqrt like so … | |
Re: Member functions are not the same as regular functions. There is a little more work, here is an example: class SampleClass { public: int plusfunc (int a, int b); }; int SampleClass :: plusfunc (int a, int b) { return a + b; } typedef int (SampleClass::*functor3) (int a, int … | |
Re: Seems to work http://codepad.org/Y6oXRlOf | |
Re: Is this operation being performed on Actors only? Do you have a list of Actors available to apply the filtering? |
The End.