Posts
 
Reputation
Joined
Last Seen
Ranked #4K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
2
Posts with Upvotes
2
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
~12.6K People Reached
Favorite Tags

37 Posted Topics

Member Avatar for starletcharmed

also can be done recursively..but stack almost equals recursion... for example: [code=c++]#include <iostream> #include <string> using namespace std; void do_the_stuff() { char c; c = getchar(); if( c == '\n' ) return; do_the_stuff(); putchar( c ); } int main( void ) { cout << "Enter:" << "\n"; do_the_stuff(); return 0; …

Member Avatar for d_a_y_o
2
4K
Member Avatar for gregorynoob

okay, i don't have a problem coding the game... that part would be easy. but the problem is to output the lease number of rotations needed to complete the game, so for example... 123 => 413 456 => 526 789 => 789 (rotation of the top left corner) that's what …

Member Avatar for frogboy77
0
165
Member Avatar for DemonGal711

ehh, now i'm confused... it would be helpful to see some code you've done already, but this is my suggestion: don't use a stack. it's a maze... a pretty straightforward graph. if you know where you should start, and where you should finish, you bfs through the graph, keeping track …

Member Avatar for stilllearning
0
129
Member Avatar for Code Shark

[QUOTE=Code Shark;722383] As title says is this code ok or should i do it another way?[/QUOTE] depends on what it's supposed to do :)

Member Avatar for gregorynoob
0
114
Member Avatar for DaJoker

hmm, define test case...? i don't get it... you can write some numbers onto a piece of paper, add them up and divide by the their quantity... enter those numbers into your program and check if the results match!

Member Avatar for dickersonka
0
117
Member Avatar for cicigirl04

hmmm...lemme analyze this abit: [code]#include <iostream> #include <cmath> using namespace std; const int MAX = 10 + 1; //let it have more space //Main Module int main() { int A[MAX] ; // declare the size of the array int sum ; // declare sum as integer float mean ; // …

Member Avatar for DaJoker
0
283
Member Avatar for gregorynoob

heya... ok, so i was browsing the net to find out if there's a good text on this algorithm, but i don't seem to be able to find one. people are obviously using it, but, hey, there's no info on it. the part i get is the theory on how …

Member Avatar for Lerner
0
185
Member Avatar for gregorynoob

okay, so i came up with this idea of making a program to evaluate my code. it's supposed to take the code, compile it, run it on several test cases (given in one file each) and report how the code did (which test cases it passed, which cases it failed...) …

Member Avatar for Salem
0
239
Member Avatar for gregorynoob

okay...i've got another wired counting problem, this time it's about rectangles! gotta find the minimum number of lines to divide a rectangle into squares! i went for...ehh well a dumb idea of cutting the max square off, and cutting the little ones recursively, but... doesn't always work. you're given the …

Member Avatar for dmanw100
0
149
Member Avatar for wqzerboom

you can access them by memory addresses... so the integers should be given addresses that are consecutive. could count as pointing really.

Member Avatar for rhoit
0
186
Member Avatar for rhoit

yea, you gotta either macro it or typedef with specifying the actual template type :P sucks in a way... but hey, what's the deal with the box thing, it's pretty small and easy to write... i use typedef for long, looooong names, like: [code=c++] typedef my_monumental_structure<another_huge_type>::iterator sit;[/code] and then i …

Member Avatar for rhoit
0
2K
Member Avatar for gregorynoob

okay, this is the problem (variation of the knapsack coins problem): you've got 4 coin types: 1 cent, 2 cents, 5 cents and a quarter...infinite amount of each. I'm supposed to find the number of ways in which the coins can be arranged to form the sum of some integer …

Member Avatar for VernonDozier
0
389
Member Avatar for acoxia

if you could post a more detailed description of the problem... if you're only working with square binomials it should be really simple. for example, if the shape of the input is ax^2 + bx + c, all you have to do is isolate a, b, and c, solve the …

Member Avatar for acoxia
0
150
Member Avatar for cuthien

well... i'm not that good with c++ I/O (c ftw), but if you're using fstream, you can make two streams and use them for I/O, for example if the input stream is called 'input' you can go with [code=c++]while( input >> aa ) {/*blahblah...*/}[/code] ...well i guess you can... hmm, …

Member Avatar for gregorynoob
1
95
Member Avatar for tones1986

well this is a simple implementation of the sieve... [code=c++]#include <cstdio> #define MAX 100000 bool prime[ MAX ]; void sieve() { for( int i = 0; i < MAX; ++i ) prime[i] = 1; prime[1] = 0; for( int i = 2; i < MAX; ++i ) for( int j …

Member Avatar for skatamatic
0
428
Member Avatar for gregorynoob

every time i make my own rounding routine with precision, i see my compiler suggesting a function long double round(long double x, int precision); so i was wondering if someone knows what library it comes from, i surely wasn't able to find it... thanks

Member Avatar for ArkM
0
180
Member Avatar for FumarMata

well if you know the exact position of those chars you can easily extract them from the string you read them in... for example, the given the position and length of the integer, you could go with something like this: [code=c++]#include <cstdio> char str[ 256 ]; int pos, len, sol …

Member Avatar for FumarMata
0
170
Member Avatar for gregorynoob

i got myself a big pile of components yesterday, an amd dual core procesor, a new motherboard (biostar ta770 a2+) and a new graphics card, nvidia(club3d geforce 9600gt overlocked). so now i've put it all together, the computer starts normally but i don't get any output on my monitor, the …

Member Avatar for zeroth
0
80
Member Avatar for gregorynoob

ok, so this is my problem... i have an array of items, which i want to sum to x or above in a most efficient way... is there a way for doing this? cause all the values are 64 bit ints. i tried recursion but it's slow cause i can …

Member Avatar for VernonDozier
0
272
Member Avatar for gregorynoob

given two arrays of n numbers, a[] and b[], and a number c, find the largest sum of elements from a[] so the sum of same-indexed elements from b[] don't go over c... i really have no idea... only recursion works but too slow :( heeeeelp!

Member Avatar for gregorynoob
0
86
Member Avatar for gregorynoob

could someone please tell me if there are local stores in NY where i can get this calculator? if there are can i please have the adress or something? thanks.

0
39
Member Avatar for gregorynoob

okay, so i gotta make a good enough hash function that should be able to make me a key for out of two integers ( -1000000 <= x, y <= 1000000 ), and should work...well atleast 80% of the time so i could store these in an one-dimensional array... i've …

Member Avatar for gregorynoob
0
95
Member Avatar for gregorynoob

okay so i've got n and an array of n numbers, i have to go through all the three's of numbers like a[i], a[j], a[k] so that i < j < k and take the maximum of each such numbers (max of a[i], a[j], a[k]). my first guess is three …

Member Avatar for gregorynoob
0
172
Member Avatar for disturbedfan

Umm, system() calls don't work on all platforms... you can use cin.get() but i think it executes every time you press enter so you might need an army of those. for example: [code=C++]#include <iostream> int main( void ) { int a; std::cin >> a; std::cout << a; std::cin.get(); return 0; …

Member Avatar for gregorynoob
0
145
Member Avatar for gregorynoob

the problem is to find the minimum numbers to be popped from an array to make it sorted. so for example 12534756, you can pop all but one, but it's best to pop 5 and 7 cause it's the least needed to make it sorted. I'm having difficulties finding a …

Member Avatar for ArkM
0
103
Member Avatar for THAPELO

I'll just hope you're not in highschool yet so...here's the first function you'll need...it's pretty straightforward: [code]char letter( int mark ) { if( mark <= 39 ) return 'F'; else if( mark <= 49 ) return 'E'; else if( mark <= 59 ) return 'D'; else if( mark <= 69 …

Member Avatar for Narf!!!
0
104
Member Avatar for jonabie

i don't know any alternative way of clearing the screen...so i guess this code of mine is not portable but it works...in a more fancy way. [CODE]#include <iostream> #include <conio.h> #define MAX 256 int main() { using namespace std; char ch, len; while ((ch = getch()) != '\r') { if( …

Member Avatar for jonabie
0
268
Member Avatar for glecymay

nothing fancy, if you know how to convert a binary representation to decimal on paper...just implement that! i'd use a string to input 1's and 0's but you can use a long long or something using a simple algorithm to seperate digits: [CODE]#include <iostream> using namespace std; int main( void …

Member Avatar for glecymay
0
194
Member Avatar for robertmacedonia

namespaces are generaly used to avoid conflicts that could happen if you have two functions, classes, etc. with a same name... so if you've got a libraries "libA" and "libB" and in each of those you have a function named "f" you need a way to know which function you …

Member Avatar for William Hemsworth
0
256
Member Avatar for arun_lisieux

I guess this could help also... i don't know how really clever this is but why not use all the nice stuff STL gives? for example you could use a set structure to check when the cyclic array of numbers starts to repeat by inserting results into it and checking …

Member Avatar for arun_lisieux
0
209
Member Avatar for Agni

Depending on the spacing...(if it doesn't matter) you can use a LIFO stack... I'd use the STL stack...the code would look like this: [CODE]#include <iostream> #include <string> #include <stack> using namespace std; stack<string> sstack; string word; int main( void ) { while( cin >> word ) sstack.push( word ); while( …

Member Avatar for Agni
0
346
Member Avatar for osirus0830

i guess xor swapping could do here too, no need for another variable! slightly fancier code: [CODE] for (j = 0, i = word.size() - 1; j < i; --i, ++j) { word[i] ^= word[j]; word[j] ^= word[i]; word[i] ^= word[j]; }[/CODE] or even simplier [CODE] for (j = 0, …

Member Avatar for gregorynoob
0
185
Member Avatar for gregorynoob

given x and y (the field dimensions) and x*y numbers, (pieces of cheese on each square) calculate the best way for the mouse to get from (1, 1) to (x, y), he has to get as many cheese as possible... also you can only move closer to the (x, y) …

Member Avatar for gregorynoob
0
706
Member Avatar for gregorynoob

I guess there is a "standard" algorithm for problems of this type.. the template would look like this: given the integer n and n numbers, find the smallest sum you can get by adding the numbers like this: n1+n2+n1+n2+n3+n1+n2+n3+n4... the obvious way for me was to do some math on …

Member Avatar for RemoB
0
79
Member Avatar for gregorynoob

Okay, so i got the volume I of Sedgewick's Algorithms in C++ and I'm pretty much lost in the first chapter. I understand all the given examples and such things but the exercises seem impossible. I'm still just starting highschool and the math used there aren't that easy and the …

Member Avatar for gregorynoob
0
125
Member Avatar for gregorynoob

a mouse is trapped in a labyrinth.. and he has to find the cheese! the input is W and H (height and width), and a graph like this one: [CODE] ##...# C###.. ...... .####. .....M [/CODE] i'm supposed to calculate the shortest amount of steps he needs to make to …

Member Avatar for gregorynoob
0
187
Member Avatar for gregorynoob

I've started programming a few months ago, i've done basic before, then i tried pascal for a while but now i'm comfortable with C++. The problem is, i'm trying to learn as much as i can from the net and books, but i can't find a good book i could …

Member Avatar for VernonDozier
0
113

The End.