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

59 Posted Topics

Member Avatar for Shinedevil

I think this is quite good program. Some could say that redundancy is an issue but I don't think so. This program is quite good, however a bit redundant. Redundancy isn't so bad, it can be useful sometimes. Redundancy in this example isn't bad, it's important that this program is …

Member Avatar for mrpi64
0
2K
Member Avatar for BevoX

Just to tease you, this is quick program (written in 10 minutes) to generate primes using linear sieve. [CODE]#include <iostream> #include <vector> #include <cmath> using namespace std; void genPrimes(int n, vector<int>& result){ vector<bool> temp(n+1,true); temp[0]=temp[1]=false; for(int p=2;p*p<=n;){ int q=p; int x; while((x=p*q)<=n){ while(x<=n){ temp[x]=false; x=p*x; } while(!temp[++q]); } while(!temp[++p]); } …

Member Avatar for Microno
1
678
Member Avatar for iamcreasy

[QUOTE=Fbody;1505376]Some compilers, such as GCC, automatically initialize integers to 0 [/QUOTE] No, GCC doesn't initialize ints to 0. I run following program three times: [CODE]#include <iostream> int main(){ int a; std::cout<<a<<'\n'; }[/CODE] On GCC 4.4.5 it gives me -121776192, -1217650700 and -1218613260. Only global variables are initialized automatically to 0, …

Member Avatar for template<>
0
19K
Member Avatar for clutchkiller

According to system function discussion. For me system("pause") is the best way to leave window open for Windows users to see results. On my system I just get info in terminal that this command was not found and program finishes normally. If someone would use appreciated (according to sticky) getchar, …

Member Avatar for Narue
0
2K
Member Avatar for Ronnie147

Your primality tester is flawed, for example 49 according to this primitive test is prime (but for every number <49 it is correct). Also it will not finish if k>0, because only manipulation you do with k is incrementation in line 24, and in the following line you test it …

Member Avatar for Zjarek
0
204
Member Avatar for L3gacy

There is [URL="http://www.cplusplus.com/reference/algorithm/for_each/"]for_each[/URL] in c++, but I think this is not what you mean. There probably will be extension to for statement to allow Java like foreach, but for example it is not yet included in release version of GCC (it will be in 4.6, but it is now in …

Member Avatar for L3gacy
0
206
Member Avatar for subith86

Try using bigger table. For every 1 kb you use, you are outputting line to stdout and then you are flushing it (endl). If you try to do this for about 10^6 times it will take some time, allocating memory is a LOT faster then outputting text using cout<< <<endl.

Member Avatar for subith86
0
148
Member Avatar for DaniwebOS

In minus one day you can get negative day, and in function toname you only treat properly positive idx. If you give to this function negative number this value is not handled by switch, and you return nothing, and this nothing is treated as string, and after statement in line …

Member Avatar for jonsca
0
107
Member Avatar for agarg12

I just really like this "better" C++ code then #define MAX(a,b) (a>b)?a:b. Yes, I know that in this usage MAX(i++,j++) is wrong (to be honest I'd just use using namespace std and max function).

Member Avatar for agarg12
0
134
Member Avatar for blee93
Member Avatar for pokemal

Unfortunately I can only write Polish-English, French-Swahili and Chinese-Russian dictionaries.

Member Avatar for Zjarek
-3
85
Member Avatar for Labdabeta

I would check if you are trying to link with SDL library in this project.

Member Avatar for Labdabeta
0
262
Member Avatar for Zjarek

In my project I tried to use boost RNG in such manner [CODE] inline int rand(const int m){ uniform_smallint<> us(0,m-1); variate_generator<rnggen_t&,uniform_smallint<> > vg(rng,us); return vg(); }[/CODE] where rnggen_t is type of random number generator (rng). But using this (for every generator) instead of rand()%m, is slowing my program at least …

Member Avatar for Zjarek
0
484
Member Avatar for Zjarek

I am making basic project for "Computer simulations of polymers and biopolymers" using Monte Carlo simulation and I currently have access only to ASUS eee PC netbook. Could anyone run attached program on a faster hardware for input data [ICODE]100 50 50 1000000[/ICODE]. Last part of data is number of …

Member Avatar for Zjarek
0
111
Member Avatar for cwarn23
Member Avatar for mrnutty
0
840
Member Avatar for Transcendent

Iterator is not a pointer and you cannot automatically cast it in line 33 (also you try to convert it to char, I think you intended to write ThisOne = text.begin();, which isn't correct). If you want to use char* I would suggest using array of chars instead of string …

Member Avatar for mike_2000_17
0
328
Member Avatar for daviddoria

That depends. I wouldn't care much about overhead in constructors and destructors, they are called rarely. Pointers would be better if you move a lot of data inside Image container and are a must if you want to use Node derivatives. But for example you can have Image<Node> and use …

Member Avatar for daviddoria
0
165
Member Avatar for maikens

Don't update height during first phase of insertions. You have this tree: [CODE] B |1 \2 A C \1 D \ E [/CODE] And you mark D node to update, it gets 2 and on C node there is imbalance. You left rotate it and update C height. This way …

Member Avatar for maikens
0
1K
Member Avatar for Zjarek

I was researching this topic for a some time, but I can't find definite answer (and I don't hope to find it there). Is it feasible to do heavy computations using C++? I mean specially computations on large multidimensional arrays. C++ has mechanisms which can help writing quite clean optimised …

Member Avatar for mike_2000_17
0
207
Member Avatar for spoonlicker

Maybe you should just learn other language first, before diving into advanced C++. I suggest reading [URL="http://norvig.com/21-days.html"]this[/URL], it gives nice perspective how to learn programming. If you decide to still program in C++, you will find yourself in position, where pointers, or other elements of this language, are the best …

Member Avatar for katokato
-1
694
Member Avatar for mitrious

You need to think about how templates work. When you write vector<int> compiler have to generate code specially for vector of ints, vector<int> and vector<char> are two different classes. If you use templates it is necessary to have definition of them while compiling objects files for every .cpp file which …

Member Avatar for mitrious
0
150
Member Avatar for fsefsef23

polyinstance.setcoeff(Termholder[]); -- you don't need []. Also void setcoeff(Term)!=void poly::setcoeff(Term Termholder[]), first declares function taking one Term argument, and the second defines function taking array of Term argument.

Member Avatar for mike_2000_17
0
187
Member Avatar for twsmale

I think the easiest solution would be to try VBA. If you already have good knowledge of other programming languages you would pick sufficient (to write dirty, inefficient and unmaintainable script) knowledge of this language ("basically" you just need to find necessary function in reference manual). I don't know if …

Member Avatar for twsmale
0
146
Member Avatar for chaosgeneration

Std::set is ordered, you can't change order of numbers. You could just use presorted normal array (vector) for next_permutation.

Member Avatar for pseudorandom21
0
170
Member Avatar for kemkoi

First of all get some better c++ book, as I can see it is not very modern (iostream.h was deprecated a long time ago and now using it is an error). But in this example you just made spelling error with inc[U]lu[/U]de directive.

Member Avatar for Fbody
0
172
Member Avatar for MasterGberry

Char can be signed, or unsigned, it is implementation defined. Obviously in your compiler char is signed.

Member Avatar for MasterGberry
0
156
Member Avatar for kra9853

This program doesn't calculate distancem when p is pressed. Try moving line 24 outside if statement.

Member Avatar for Zjarek
0
127
Member Avatar for Rickay

Also (rdecimal % 1 != 0) is always false. Maybe you should try parsing the number, for example: [CODE] int posdot; int wyn=0; char c; while(c=cin.get()){ if (c=='.') posdot=i; else if(c<='9'&&c>='0') wyn=wyn*10+c-'0'; else break; } [/CODE]

Member Avatar for Rickay
0
635
Member Avatar for MasterGberry

You are just defining global const double variables. You need to use the same syntax as in methods, ie. const double A::member=3.0 .

Member Avatar for MasterGberry
0
142
Member Avatar for kunal2020

I think first of all you should buy new keyboard. In programming it is really important not to miss letters in words, and with your current equipment I see it is impossible. Or maybe you just write in such manner, but I don't suppose anybody would ask for help with …

Member Avatar for Celtrix
-1
114
Member Avatar for gth759k

In line 13 you mustn't add lowest and index variable should be integer (you could get some nasty rounding errors, maybe not in this example, but also it will be faster). This is not so important, but random_integer is bad variable name. You can also look into [url]http://www.boost.org/doc/libs/1_45_0/doc/html/boost_random.html[/url] , it …

Member Avatar for Zjarek
0
82
Member Avatar for TSims11
Member Avatar for GobanToba

rand()%2 is not guaranted to generate random number. Try something like rand()/((RAND_MAX+1)/2).

Member Avatar for Zjarek
0
163
Member Avatar for gunbuster363

Have you looked at this: [url]http://www.microsoft.com/downloads/en/details.aspx?familyid=2204a62e-4877-4563-8e83-4848dda796e4&displaylang=en[/url] ? (I didn't but I think it is what you were looking for). Most of major languages is capable of doing infinite number of things, main difference is in easy of programming (for specific task) /speed of program. From my experience python is quite …

Member Avatar for peter_budo
0
140
Member Avatar for gth759k

First of all, the compiler knows only about functions in object class definition. In your try it will just recursively call Object::findIntersection (or would call it if you use this->findIntersection). But you can declare function as virtual, then function call will be resolved during the runtime. Google some more info …

Member Avatar for vijayan121
0
2K
Member Avatar for knotholaze
Member Avatar for vijayan121
0
124
Member Avatar for Abdel_eid

Libreoffice is just rebranded OpenOffice with some additional patches from goOO (most of them are already in ubuntu version of OO)

Member Avatar for Zjarek
0
88
Member Avatar for AnonymousX

You can't call non const functions on const objects. You can declare const function by adding keyword const at the end of declaration, for example bool cmp(const Obj& snd) const. //nevermind, didn't see later code

Member Avatar for arkoenig
0
245
Member Avatar for massivefermion
Member Avatar for rbrt13
0
381
Member Avatar for elsiekins

You can try using vector.begin() as a pointer to a first element of table and use it as normal char* (but I didn't test it). You can make your function declaration fun(vector& v) and use it fun(v). //edit: you can't pass iterator as pointer, but &*vector_name.begin() should work

Member Avatar for elsiekins
0
144
Member Avatar for anglwthnati2de

vector<>(int n) constructs n objects, so above code is wrong, employees.size() is 10. The difference between push_back and default constructor is most of the time negligible.

Member Avatar for DarthMustard
0
119
Member Avatar for Spartan_MSU12
Member Avatar for tech9x

Cin doesn't read characters after number. Try using cin.ignore after cin>>.

Member Avatar for Zjarek
0
280
Member Avatar for stark025

I don't think conio.h is depraceted. I don't know other simple Windows terminal library, and in standard libraries you have only reading and writing to streams. You can use cin.get() instead of getch, but it doesn't exactly do the same. And how do you want to do clrscr() in standard …

Member Avatar for stark025
0
260
Member Avatar for faat99

Double has precision close to 10^-16, your weird results are caused only by this. You also lose precision on every addition, specially in Trap function (that's why for n=10^10 you get e=10^-5).

Member Avatar for DavidB
0
98
Member Avatar for لولوة

[QUOTE=Excizted;1090296] Hey Narue :), I'm just wondering, what difference does your example there have to this, without const? [CODE]int getx(){ return x; }[/CODE] [/QUOTE] Without const you could change x, for example std::swap(a.getX(), a.getY()).

Member Avatar for Dave Sinkula
0
212
Member Avatar for Spiderpig085

drawboard() is writing to standard input, and is returning void, so you can't print result to file. If you change function void Game::drawboard(void) to get reference to ostream, you will be able to print board on screen and to file. PS: Why do you flush cout so much?

Member Avatar for Ancient Dragon
0
105
Member Avatar for FancyShoes

('r' || 'p')==1 You need to change approach to this problem, || is just logic or.

Member Avatar for FancyShoes
0
132
Member Avatar for DevC++4.9.9.2
Member Avatar for r.stiltskin
0
125
Member Avatar for BigTito89

IIRC enemies is 2d array of Enemy. To compare in this way, you need to declare array of pointers to Enemy(dirty solution), initialized to null. Of course you need to remember to delete every not needed enemy etc and change every function, which use enemies. You can also make state …

Member Avatar for BigTito89
0
161

The End.