Would you start a new thread for your question.
triumphost commented: Perfect! I never ever saw that before. Thank you. +5
mike_2000_17 commented: That's an awesome coincidence! +0
Would you start a new thread for your question.
Initialize you letter grades.
char A('A'), B('B'), C('C'), D('D'), E('E'), F('F');
Taking a quick look,
" index=sub.find_first_not_of("aeuio");
cout << "first consonant:"<< sub[index]<<endl;
"
what happens when that find_first_not_of fails?
How about adding some graphical feature to show the statistics on the number of successes the job finding site has acomplished?
Can you post the website, so we can get a better feel for what you have. That would help with further suggestions.
The second one should be invalid, since p2 isn't defined. That shouldn't work.
Innovative...hmmm
Some bullshit I can think of are ...
- Better design
- Cleaner Interface
- Great Client Usability
- More stuff about good design, usability, accessability...
@nitin1: Be kind, we're taking our time to help you. We could be going on with other matters, but instead we realize that we were also like you at one point, and thus (for me at least) the feeling of empathy and wanting to help is the reason I am help you. I can choose not to and so can others. So before anything, get you attitude in order.
Now instead of writing the code, I'm going to give you an idea on how to start, say we want to find all suffix of the string "bananna", well one way to achieve that is to find all suffix from position 0, the go on and find all suffix from position 1, and so on. Here is an instance example,
startIndex = 0:
b -> (0,1) #starting and ending position in the string 'bananna'
ba -> (0,2) #starting and ending position in the string 'bananna'
ban -> (0,3) #starting and ending position in the string 'bananna'
...
bananna -> (0,7) #starting and ending position in the string 'bananna'
startIndex = 1:
a -> (1,2) #starting and ending position in the string 'bananna'
an -> (1,3) #starting and ending position in the string 'bananna'
ana -> (1,4) #starting and ending position in the string 'bananna'
...
ananna -> (1,7) #starting and ending position in the string 'bananna'
and so on, you get the drift. After you have that, you can worry about sorting later.
@imathewee, my friend gave me this ecopy of a famous book called Big Beyond Belief, it takes a really scientific approach to working out, and explains in essential details of eating/form/training/resting and everything else. At the end it gives you a choice of 3 optimal workout that you can choose from, 4-day 1 workout per day, 6-day 1 workout per day, 6-day 2 workout per day. The last one is claimed to be the most efficient and has faster growth but each one is listed to accomidate most people's schedual. Let me know if you want a copy. FYI, you have to be serious about it though. So far, its been good to me.
Do you have a website? You can use java::Applet to embed java stuff on web.
Does the suffix array need to handle only one word? Is the amount of word to represent by the suffix tree not bound? Your example seems trivial, meaning that you can simply just use std::string to hold a string data and print out the suffix tree by for loops. How about a general problem statement or the actual problem statement
difference = fabs(f - arr[ i+1 ]);
That will be out of bounds in the case where i = (h-1) since arr[h] is not valid, because index stats at 0.
smallest[h]
You also shouldn't be allowed to create a variable sized static array.
Basically your algorithm is finding the smallest difference between position i against positions j, and for each position i, storing its minimum difference computed against position j in your smallest[h] array, then finding the minumim value in the smallest[h] array. That is a naive and simple way to solve this problem. After you get this working try to think of another way, possibly using hashmap or something.
You listed the answer, 1 = 5 therefore 5 = 1.
Sometimes simplicity is overlooked.
I was intrigued how you started, and then segwayed into an allegory. You possess the art of storytelling and you do it well.
Hey thank you iamthwee, that means a lot.
So the first point you made about being externally dependent, that is what one might initially get out of the above story, after all I did talk about colorful object giving me some kind of happiness. But the main message hidden was exactly the total oposite of that. The main message was not being externally dependent, but instead become self aware, self reflective and observant. The man observing the 'key' was supposed to be that key-point. In a way, it represented the key to himself. The guy began to observe the key a little by little, noticing different details, some atomic detail others more compound. And as he noticed the details, he became aware of those details, realizing the purpose for each detail. Almost like a self help process. And soon after, good things came his way -- all the colorful objects. You have highlighted the main message towards the end of your post nicely.
Hope you enjoyed it. Writing was never my strong point, so getting complimented on it means that much more to me than getting complimented on something I know I am good at.
Didnt compile it but just to show some of the things you should be doing is breaking things into functions and using constants.
#include <iostream>
using namespace std;
enum WeaponType{ ROCK, PAPER, SCISSOR, MAX_OPT};
enum GameStatus{ PLAYER_WIN, DRAW_GAME, PLAYER_LOSS };
static const WeaponType options[MAX_OPT] = { ROCK, PAPER, SCISSOR };
define stringify(str) #str
WeaponType getUserChoice(){
bool isValid = false
WeaponType choice;
while(!isValid){
cout << "Pick one, rock = 1 , paper = 2, scissor = 3 " << endl;
int opt = 0;
bool streamValid = (cin >> opt );
if(streamValid && opt > 0 && opt <= MAX_OPT ){
choice = options[ opt - 1];
isValid = true;
}
else if(!streamValid){
cin.clear();
cin.getline(60,'\n')
}
cout << "Please Enter a valid options...\n\n" << endl;
}
return choice;
}
GameStatus evaluate(WeaponType c1, WeaponType c2){
//switch or static int arrays is fine
switch( c1 ){
case ROCK:
switch(c2){
case ROCK: return DRAW_GAME;
case PAPER: return PLAYER_LOSS ;
case SCISSOR: return PLAYER_WIN;
} break;
case PAPER:
switch(c2){
case ROCK: return PLAYER_WIN;
case PAPER: return DRAW_GAME;
case SCISSOR: return PLAYER_LOSS ;
} break;
case SCISSOR:
switch(c2){
case ROCK: return PLAYER_LOSS ;
case PAPER: return PLAYER_WIN;
case SCISSOR: return DRAW_GAME;
} break;
}
}
void displayStats(const unsigned playerWin, const unsigned drawGames, const unsigned gamesPlayed){
cout << "Number of times you have won thus far = " << playerWin << endl;
cout << "Number of times you have loss thus far = " << (gamesPlayed - playerWin - drawGames) << endl;
cout << "Number of …
A more sub-blocked version.
The Step Forward
The path that I have taken in life seems to be the path that many follow. Although weird at first, this path seems to lead to the same end goal for each and every one of us, which is to find happiness, whatever that may be. Let’s call this path, The Step Forward. In this writing, I want to share you my personal journey I underwent while exploring The Step Forward.
Before exploring The Step Forward, I had to first come to the realization that the current path I am walking on now did not provide the satisfaction that I wanted and needed. Although, that thought may not be concrete in detail, it was an instinctual feeling that I had felt.The current path that I was walking on now, made me sad. It made me depressed. It made me nervous. It made me anxious. It made me feel alone. Now you might wonder why I took that path in the first place then. Well, the reason why I was in that path was because it was the only path I knew how to walk on. It was the only path I felt comfortable with. There was no disruption in that path.
Occasionally there would be few colorless objects I see come and go, but for the most case, it was a long and bland path. I would occasionally see other, more promising paths, but I would never have enough courage to jump onto …
The Step Forward
The path that I have taken in life seems to be the path that many follow. Although weird at first, this path seems to lead to the same end goal for each and every one of us, which is to find happiness, whatever that may be. Let’s call this path, The Step Forward. In this writing, I want to share you my personal journey I underwent while exploring The Step Forward.
Before exploring The Step Forward, I had to first come to the realization that the current path I am walking on now did not provide the satisfaction that I wanted and needed. Although, that thought may not be concrete in detail, it was an instinctual feeling that I had felt. The current path that I was walking on now, made me sad. It made me depressed. It made me nervous. It made me anxious. It made me feel alone. Now you might wonder why I took that path in the first place then. Well, the reason why I was in that path was because it was the only path I knew how to walk on. It was the only path I felt comfortable with. There was no disruption in that path. Occasionally there would be a few colorless objects I see come and go but for the most case, it was a long and bland path. I would occasionally see other, more promising paths, but I would never have enough courage to jump onto that path. …
For that case you need to define what empty means. For example it could be this
struct Foo{
int x;
string y;
Foo(): x(0), y(){};
}
//it is empty only if x == 0 and y contains no letter
bool isEmpty(const Foo& f){ return x == 0 && y.empty(); }
int main(){
Foo f[10];
bool isFirstElementEmpty = isEmpty( f[0] );
return 0;
}
Another way is to use pointers.
struct Foo{
int x;
string y;
Foo(): x(0), y(){};
}
int main(){
typedef boost::shared_ptr<Foo> FooPtr;
FooPtr foo[10];
bool isFirstElementEmpty = f[0].get() != NULL;
}
What exactly is the problem? What isn't working? What are you seeing versus expecting?
First you want to look at batch programming, at least I think that's a good starting point to showoff to your friends. Second, grow some balls. Who cares what they think? Why do you need to impress them. They are not programmers and probably never will be. They do not have any knowledge in our field. They just go by whatever is shown in the movies. Third, get a internship, get a job, contribute to open source, create an open source project, make your own programming projects. Do stuff that you can put on your resume. That's how you will impress recruiters.
Although, to be efficient you would probably want to implement a caching scheme to that search to prevent having to search every node each time you call quad_max.
Or if its needed frequently, just have a variable to keep track of current max/min
Since you are using C++ maybe avoid using C stuff.
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct RemoveFile{
bool operator(const std::string& fileToRemove)const{
if( std::remove( fileToRemove.c_str() ) ){
std::cout << "removed: " << fileToRemove << endl;
return true;
}else{
std::cout << "failed to remove: " << fileToRemove << endl;
return false;
}
}
};
int main(){
const std::string files[] = {"f1.txt" , "t2.txt" };
std::vector<std::string> filesToRemove(files, files + sizeof(files)/sizeof(files[0]));
std::for_each(filesToRemove.begin(), filesToRemove.end(), RemoveFile());
return 0;
}
not really tested but give you an idea.
if g = 0 then i can range from 0 to m
if g = 1 then i can range from 1 to m
...
if g = (m-1) then i can range from (m-1) to m
What I am trying to get at is, you cannot get a unique mapping with just 'i' and 'g'.
Can you provide a tl;dr version for the lazy like me?
*tl;dr = too long, didn't read
Instead of passing 'x' pass in a struct, but make sure to cast it as necessary
Either manually make sure the vector size isn't correct, or use an static array, or inherit from vector and make the resize function private.
Another option is to make a File struct.
struct FileInfo{
std::string name;
//possibly other things
explicit FileInfo(const std::string& name = ""): name(name){}
}
class Lexical{
ReturnType read(const std::string& sentence);
ReturnType read(const FileInfo& fileInfo);
}
but I suggest to go the istream route as suggested in previous post.
I would like to suggest to create a seperate sub-forum specifically for this purpose. Thus it will be more maintainable and easier to look through different snippets from different language. It also avoids that popularity advantage. This event needs to be so more formal. I really don't know what to expect and what's considered elegant/efficient. I mean one could make a case for why this or that is elegant/efficient but who says that people will geniunely understand that. I think we should have a topic to program against. Or a problem to solve. That way comparing elegant and efficiency and whatnot would become easier. Otherwise, it might become a popularity game or in essence comprimise the integrity of this event.
And I have partly to thank you guys. I joined DW a while back only occasionly used it. Then stoped. Then started using it more and more. Over the years it has been great. Everything has been great. Everyone has been great. I wish it was possible that we could all go out and have a drink or something. I feel like I owe you guys one. Anyways, I don't want to get too mushy gushy. You guys have been a good part of my life. I remember constantly logging on here to either ask questions or answer them. While I was obsessed with programming for a few years a while back, you guys gave me the resource and fire to fuel that obsesison. Now it has died down a bit. You guys might not know it but you guys helped me through life a lot. From programming to relationship issues to religion. Extra thanks to imthewee, man you are one awsome person. I don't really know the point of this article, but I just want to show my appreciation to you guys. Man I'm such a bitch lol. Time flies by so quick. Hope everyone has been well up to this point. I like the new DW look although some new features annoy me. Take care ladies/gents.
yours truly,
D.Chhetri
Can you place them just before an actual collision could happen? Since they are static object there should be no problem with worrying about them moving
You're looking for conversion operator. Something like
class Point{
private:
int x,y;
public:
operatir POINT()const{
return POINT(x,y);
}
};
Matlab would be a easier starting point. It already has many functions implemented for you to handle audio processing.
Maybe you want to take a more object oriented approach at this just to gain some experience. Check out the Command Pattern. Fits very well for redo-undo stuff
How could one insert new elements in the vector ?
By using std::vector::push_back or std::vector::insert function
Would it be a good idea to create the vector within the class / the constructor?
Sure, if you need an array of something, then std::vector is usually a good choice.
Yea so this is a problem of collision response. Once a collision is detected what do you do? Well in this case you should move your player back just before the collision point. So if there is a collision, shift back the player's position so that there is not a collision anymore. Get it?
You can read it as a string
I think the syntax is
int rowSize = 5;
int colSize = 5;
float **matrix = new float*[rowSize];
for(int i = 0; i < rowSize; ++i){
matrix[i] = new float[colSize];
}
//do stuff with matrix[i][j]
//delete
for(int i = 0; i < rowSize; ++i){
delete [] matrix[i];
}
delete [] matrix;
Of course you can avoid all of this by using std::vector.
int rowSize = 5;
int colSize = 5;
std::vector< std::vector<float> > matrix( rowSize, std::vector<float>(colSize) );
//use matrix[i][j]
//no need to worry about deleting matrix
You can think an Abstract class as a class that combines the similarity of many things into one object. Thus when inheriting from the ABC, you will have to type less redundent code.
Never seen this concept in discrete, but I'm guessing so because one loop looks like it influences the other
Please reformat your code. What is the problem you are having?
How are the commands stored?
One approach is to do something of the following:
struct Command{
/* whatever makes a command, insert variables here */
friend ostream& operator>>(ostream&, Command& cmd){
//given a stream, try to read in a command
}
}
int main(){
//open file and stuff
std::vector<Command> commands;
Command tmpCmd;
//read until failure
while( fileInput >> tmpCmd) commands.push_back(tmpCmd);
//print and stuff
return 0;
}
glTranslate translate the current view matrix, not just one object. So it can be used for different things
If you convert the matrix of double into a matrix of chars, you might lose some data since char cannot hold the same range of data as double can. You can copy like so std::vetor<unsigned char> pixels(matrix.begin(),matrix.end())
. What problem are you having exactly?
Your Edge class can be stripped down to this
class Edge
{
public:
Edge()
{
}
Edge(int from, int to, double weight = -1)
: from (from), to (to), weight (weight)
{
}
int from;
int to;
bool directed;
double weight;
};
Since the compiler generated functions will suffice.
In line 51,52, you make no use of the parameter 'n'
Also in line 60, and 64,make the function 'const-corrected' meaning that add a const after the function prototype. For example bool isDirected()const{return directed;}
Notice the const.
"First part is simple, my name is mike. The second part is an enigma for you guys. 2000 taken to the power 17 is about the total mass of the observable universe measured in grams. No, actually 2000 bitshifted 17 times writes FA00000 in hex which is cool. I'm kidding, seriously, 2000 and 17 is the longitude and lattitude of this private island that I own. Muhuahaha, you'll never figure out what it means!
Also python (the animal) is spelled pyton in Finnish.
Yeah, when a finnish colleague of mine proposed to use "pyton" for a project we had, said in the finnish pronounciation, it took me a while to realize he was talking about Python. Minä rakastan Suomi, mutta se on mahdotonta oppia suomea!"
Hmmm, hurricane michael ? Occured in the year 2000 on the 17th of october as a tropical storm?
So you are trying to read in a input from cin and you want to save only the inputs that starts with a number or a negative sign, and any other type of input you want to insert back into istream? Is that right? Do you have to reinsert them into istream? Why can't you just discard them?
Why are you taking pain by handling memory yourself. Use power of STL.
Its ironic, because C++ has a stack implementation already. So why even do what you did above?