nooc9
Members-
Content Count
31 -
Joined
-
Last visited
Everything posted by nooc9
-
Here is an example solution where I'm using a b-tree on the stack. #include <stdio.h>#include <stdlib.h>/* node */typedef struct _item { char a[30]; int b, c; struct _item *l,*r;} item;/* print tree */void print(item* t){ if(t) { print(t->l); printf("%s %d %d\n",t->a, t->b, t->c); print(t->r); }}/* read items from file into tree stored on stack */void readItem(FILE* f, item** t){ item i,*n; if(fscanf(f,"%s %d %d",&i.a, &i.b, &i.c)==3) { i.l=i.r=0; /* clear leafs */ /* insert into tree */ if(*t == 0) *t = &i; else { n=*t; for(;;) { if(n->c <= i.c) { if(n->r) n = n->r; else { n->r = &i; break; } } else { if(n->l) n = n->l; else { n->l = &i; break; } } } } readItem(f, t); /* recurse to next read or print tree */ return; } print(*t); /* must print here because tree is on stack */}int main(void){ /* tree root */ item* tree = 0; FILE* f = fopen("input.txt","r"); if(f==0) { printf("file error\n"); return; } /* process */ readItem(f,&tree); fclose(f);}
-
Finding The Rgb Color Of An Image Using any programming language
nooc9 replied to longtimeago's topic in Programming
As this was posted in C/C++ I feel it should be mentioned that if on windows, there are the windows GDI functions/classes to use and thus, no need for 3rd party libs or .NET. #include <gdiplus.h>...Bitmap* bm = new Bitmap("image.jpg");...// bm->LockBits() or bm->GetPixel()...delete bm;... -
Personally I don't see any significant changes happening in that timespan. Maybe we will be hit by a space rock. Who knows.And speaking of rocks in space, you could use opengl to simulate a space rock hitting your country 2020.. You would need a sphere, a rock model and the textures (earth, rock, stars background).There is no fancy programming involved. I suppose you would have to know what a vector and matrix is and how to use them, and also be able to export a 3d model to some raw format that could easily be passed to opengl. There are plenty of good opengl "hello world" tutorials out there.
-
You should try asking your question in blitzbasic forums: http://www.blitzbasic.com/Community/_index_.php
-
How To Make A Point'n Click Escape The Room Type Game?
nooc9 replied to Unfair Lady's topic in Programming
I also googled some and found a flash game engine: http://www.hugedomains.com/domain_profile.cfm?d=pushbuttonengine&e=com According to the site, they're also working on an editor for it. -
No, not a slip up. Its just another regex constructor seen a lot in perl and it allows you to pass flags. In my expression I had the i flag (case insensitive). If you omit the $ at the end then you don't need ".*" either.
-
Yes, indeed. I'm escaping the slashes because they have special meaning here, ie. you construct a regex by using /expression/flags.
-
I guess you want something like this: function urlIsOk(url){ return url.match( /^http:\/\/(www\.)?example.com/i )) != null;}
-
How good error messages are is not a language thing but a compiler thing. Sometimes the error message has to be very general to fit all scenarios and that can be a pain to debug, especially if your code is large and complex. C++ is my favorite language. It fills all my non web needs and I love pointers.. In other words, what annoys them is programming in general. I can understand that many find pointers difficult, but you can't write anything useful without data structures (any language). Templates are a huge help. Gui handling looks pretty much the same in almost every oo language.
-
I think Wiktionary definition 2 is pretty nice: "An incompatibility of two things that cannot be simultaneously fulfilled." The word is pretty general and I think it would be wrong to try to specialize it. If you know the general meaning of the word then you will know what it refers to in whatever context it is used in.
-
Exercises How about some programming exercises :)
nooc9 replied to Томму's topic in Programming
#include <iostream>class Resistor{ float R;public: Resistor& setR(float r) { R=r; return *this; } float getI(float E) { return E/R; } float getE(float I) { return R*I; } float getP(float I) { return I*getE(I); } Resistor() :R(0) {} Resistor(float r) :R(r) {}};int main() { Resistor r(5); std::cout << "Resistor(5).getE(0.5) = " << r.getE(0.5f) << " V" << std::endl; std::cout << "Resistor(100).getI(12) = " << r.setR(100).getI(12) << " A" << std::endl; std::cout << "Resistor(1200).getP(0.01) = " << r.setR(1200).getP(0.01) << " W" << std::endl; return 0;} Ok, so here is a silly one from me. Let Variables be a map of string to float: typedef std::map<std::string,float> Variables; Let Operation be an abstract class that has the following declaration: struct Operation { virtual float evaluate(const Variables& vars) = 0;}; Implement Add, Sub, Mul, Div, Const, Var that extend Operation so that the following example is possible: // Create expression: (A+10)*(1/(B-3))Mul expression( Add( Var("A"), Const(10) ), Div( Const(1), Sub(Var("B"),Const(3)) ) );// Create variable mapVariables vars;vars["A"] = 2.5;vars["B"] = 7;// Evaluate expression using variables in vars mapfloat result = expression.evaluate(vars);You may add abstract methods to Operation. -
I made a small game in flash a long time ago where you steer a space ship with the arrow keys through an obstacle field. I used MovieClip.hitTest() for that. Create a list of (x,y) points that define your characters perimeter. Put the collideable level in one movie clip and call clip.hitTest(x,y,true) for each item in the perimeter list each move frame.
-
Did you request permissions in the jnlp and are the jars signed?
-
Almost all the hosts that I've used that had outgoing access had the curl extension enabled. curl is a widely used add-on and is enabled on many hosts.
-
Anything that has to do with browser security will probably require the user to manually change some setting.If you want to create a wrapper then you will need to use something like curl, if using php, to handle cookies and stuff.
-
Why not try wrapping the game in php. When someone loads your page, you load the game page and inject whatever you want into the page and also filter the links and change them so they will load through your script. You would not have the domain security problem.
-
Twenty Cities Most At Risk Due To Climate Change
nooc9 replied to shangshaptak's topic in General Discussion
I find it hard to believe that there are people who think that spewing 27 giga tonnes of extra co2 into our atmosphere, an equilibrium evolved under millions of years, has no consequences. It is very sad to see how money can buy some scientists and make them cover the tragedy humans have caused this planet. The truth is that most scientists acknowledge human induced climate change. Those who speak against it are usually somehow connected to money channels leading back to the corporations who profit from various things that are upsetting the climate. Not only that, but they are a minority and usually get a lot of media focus, and sad but true, people will believe anything if presented with sugar on top. I just want to say.. this. -
Just set a cookie in your timeout callback. see http://www.w3schools.com/jS/js_cookies.asp
-
The first result I get when googling on ORTS is Open Real-Time Strategy. Is this the server? They talk about a OpenGL client. I think Java is the best choice for this. That said, you'll want to check out LWJGL and JOGL. If you don't want to reinvent the wheel then also check out these 3d engines: jME, jPCT, Xith3D. If you need scripting then look here.
-
The html will never show because the script will exit before it reaches the html. The "else { exit; }" should be removed.
-
You can use javascript to communicate with flash. You can also append variables in urlencoded format to flash (movie.swf?var=vallue&.. ) and then read them from the movies url from within the movie.
-
Read about program execution in the manual http://se2.php.net/manual/en/book.exec.php
-
First, go over the language basics at http://docs.oracle.com/javase/tutorial/java/index.html and then write a handful of console programs starting with a "hello world", then moving towards increasingly challenging exercises. When you think you have mastered the basics, you can move on and start learning the web specific parts without getting stuck with basic things.
-
Please Check My Code And Tell Me What I Did Wrong.
nooc9 replied to jossylala's topic in Programming
Here is an example function that should work.. function frihostSend($user, $passw, $to, $from, $data, $type='text', $port=80){ $ch = curl_init(); $content = urlencode($data); // construct the url call curl_setopt($ch, CURLOPT_URL, "http://forums.xisto.com/no_longer_exists/; ."user=$user&password=$passw&to=$to&from=$from&content=$content&content_type=$type"); curl_setopt ($ch, CURLOPT_PORT, $port); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // uncomment the below to support redirection //curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); //curl_setopt($ch, CURLOPT_MAXREDIRS,1); $response = curl_exec($ch); $code = curl_getinfo($ch)['http_code']; curl_close($ch); return array($code,$response); // return an array with the results} -
Please Check My Code And Tell Me What I Did Wrong.
nooc9 replied to jossylala's topic in Programming
Where exactly are you setting the $port variable you're passing to curlopt as CURLOPT_PORT? Also, its not certain that a POST will work if the spec says you should GET.