Eat. Sleep. Code: The Computer Programming Thread, Ver. 010

good basic sites to learn c++?

Youā€™re not gonna learn C++ from a BASIC site.

For games, I have yet to use any sort of calculus in anything I worked on. Itā€™s algebra, trig, and physics you should know.

this jokeā€¦soooo bad :rofl:

guess thats only for the gaming side. my friend is more of an it guy i guess for the govt. lol dudes gonna be gone to korea for a year doing boring it stuff.

You opened yourself up for that one, but hereā€™s another one you might hate.

[details=Spoiler]One programmer says to another, ā€œIā€™ve lost a flag. Can you help me find it?ā€

The other programmer says, ā€œIn a bit.ā€[/details]

I havenā€™t posted anything in this thread in a while but I did discover this when I was looking for an emulator frontend.

http://gambas.sourceforge.net/en/main.html

From what I gather itā€™s similar to Visual Basic in language (which I havenā€™t used in years), but it uses a Java-style interpreter to run what it compiles. It was made for Linux so its Windows version isnā€™t good according to the site. But if youā€™ve used VB, the environment is similar. Uses forms and objects in a drag-and-drop style. Also supports GTK+ and such in its project wizard.

I donā€™t have any ideas to do anything with it other than when I needed to debug the emulator frontend, just thought Iā€™d share it.

Hmm I never thought of masters as learning material. I always thought of it as a degree to make your status look good.
I could go for a master in programming but something I am not that great with. Maybe management or design.

I have a funny one for you all:

Spoiler

So Iā€™m a high school student that has a vested interest in programming for a living once I get around to settling down. Imagine my surprise when I found that my punk-ass public school (69% graduation rate, and thatā€™s a generous estimate) actually had a computer science course. I immediately signed up, hoping that I could at least get some basics of programming down.
Apparently, the teacher has taught C++ for 10 years. The district wanted to get all smart and shit and told him to ā€œget with the timesā€. What language did they offer as an alternative? JAVA. In reality, they just wanted to cop out of getting new computers. If Iā€™ve learned one thing so far, itā€™s apparently that C++ can not be programmed on a Windows 7 computer.
The teacher is still going back and forth with the principal over it, so 6 weeks into the year we are beginning to start learning programming. ON PAPER.

Thatā€™s not funny heā€™s actually going through the motions of teaching you computer science not a few scripts for you to go have fun with.
You have a lot to learn.

Is it possible to be bad at math but good at comp sci? I struggle really hard to get Cā€™s in all my math classes but coding and comp sci classes come really easy to me. When i told my comp sci advisor this she basically told me to switch to business =\

I do like to think of it this way. If I am spending money on a MS:

  1. I better get more money in the long run, even if the MS doesnā€™t teach me new things.
  2. I better learn a hell of a lot of things Iā€™d never or barely thought of before.

For me, my MS was a lot of Math that has helped me tremendously and it was a specific topic for my research that got me a job I enjoy in that field.

Spend more time on Math.

Whenever I see someone struggle in math, itā€™s because for some reason they struggle with following the directions for this specific subject. If you donā€™t think itā€™s motivation (e.g. math class is boring) thenā€¦
Since you can obviously follow instructions for programming, itā€™s probably a matter of some missing background in math. Something is confusing you that may be taken for granted in your current courses. You may have to grapple this by starting over at Algebra, or perhaps, learning how to do ā€œbasicā€ arithmetic. I say ā€œbasicā€ because really, the algorithms to do division, multiplication, and fractions are not as obvious as one might think, especially if you want to do it in your head, and especially if you need to write software/hardware to do it.

In answer to your initial query, Iā€™d find it hard to believe that you are not good at math and are good at programming. I personally think you simply have a lot of hard work you need to catch up on. I had the same problem until I busted my ass to catch up. It was literally a matter of hard work for me.

I would recommend taking calc before tackling physics.

So i have been learning some java from codeacademy.com, and I already know quite a bit of C++ so the java seems really easy right now.

I was wondering if it feels easy because I am used to C++ and alot of the instructions and script are quite similar or is it because codeacademy isnt really teaching that much, if that makes sense.

I tried the opposite actually and picked up C++ pretty fast.

The languages are kinda similar once you get past the structures and the syntaxs.

Thats what I thought but just wanted to make sure the codeacademy site was a good learning tool

http://www.if-not-true-then-false.com/

Really good page that my teacher showed me today.

Thanks for the feedback in Java, but right now im heavily into *NIX OSĀ“es, and Databases (DBA, SQL and PL/SQL). After i have a better grap on those, i think im going to start learning Java.

Sorry to bump this thread for this, but do you guys know of any really good forums for Programming in general? Iā€™m trying to get advice on how to build a programming portfolio.

When I got laid off, I intended to start working on projects and building one of these. However, I never knew where to start, as my skills were lacking. Also, unemployment wants me to apply to 2 jobs a week. That would be easier if I had more experience and the money to move out of my city (damn near every job I actually want is at least an hour away). As of now, itā€™s kind of a hustle. Still, itā€™s been over a month and I havenā€™t done any projects. Iā€™m looking for ways to get started. I figure that I always manage to find some jobs to apply to week after week, so I can focus more on my skills now.

Got a interesting question in class last week. See if you can figure it out. Apparently this is an interview question.

The time is 11:49. We represent the time by two variables hours and minutes, that is hours = 11; and minutes = 49;. Write a Java program that computes the angle between the hour hand and the minute hand on a analog clock. Angles should be measured counterclockwise from hour to minute hand. The result should be rounded and normalised so that it is between 0 and 359 (inclusively). E.g. 3:00 and 9:00 hours should be 90ā—¦ and 270ā—¦ respectively:
(Pro tip 1 minute ā‰ƒ 6ā—¦, 1 hour ā‰ƒ 30ā—¦. Start from 12 oā€™clock.)

Note that your program must be able to compute the output for arbitrary inputs, in which hours may take values from 0 through 24 and minutes from 0 to 60.

Test your program for the following times: 9:00, 3:00, 18:00, 1:00, 2:30, and 4:41 (with results 270ā—¦, 90ā—¦, 180ā—¦, 30ā—¦, 255ā—¦, and 254ā—¦, respectively).

int GetDegreeDifference (int hour, int minutes)
{
//calculate % of minutes
int degreesPerMinute = 360 / 60; //6 degrees per minute
int degreesPerHour = 360/12; // 30 degrees per hour
float hourHandDegreesPerMinute = degreesPerHour / 60; // 0.5 degrees per minute

int minuteDegrees = (degreesPerMinute * minutes) % 360;
int hourDegrees = ((degreesPerHour * hour) % 360);
//add in the hour hand moving as the minute hand moves
hourDegrees += hourHandDegreesPerMinute * minutes;

return abs(hourDegrees - minuteDegrees);

}

thatā€™s a really dirty, not very pretty way to do it, but that should work no?

So I checked, and the absolute value doesnā€™t work like I originally thought, but this code works fine:



public class ClockCalculator {

	
	
	//calculate % of minutes
	static final int degrees = 360;
	static final int minutesPerHour = 60;
	static final int hoursPerCycle = 12;
	static final int degreesPerMinute = degrees / minutesPerHour; //6 degrees per minute
	static final int degreesPerHour = degrees / hoursPerCycle; // 30 degrees per hour
	static final float hourHandDegreesPerMinute = (float)degreesPerHour / minutesPerHour; // 0.5 degrees per minute 
	
	static int GetDegreeDifference (int hour, int minutes)
	{
	
		hour = hour % 12;

		int minuteDegrees = degreesPerMinute * minutes;
		int hourDegrees = degreesPerHour * hour;
		//add in the hour hand moving as the minute hand moves
		hourDegrees += hourHandDegreesPerMinute * minutes;
	
		return ((hourDegrees - minuteDegrees + 360) % 360);		

	}
	
	public static void main(String[] args){
		
		int degrees;
		degrees = GetDegreeDifference(9, 0);
		System.out.println("Degrees for 9:00: " + degrees);
		
		degrees = GetDegreeDifference(3, 0);
		System.out.println("Degrees for 3:00: " + degrees);
		
		degrees = GetDegreeDifference(18, 0);
		System.out.println("Degrees for 18:00: " + degrees);		
		
		degrees = GetDegreeDifference(1, 0);
		System.out.println("Degrees for 1:00: " + degrees);
		
		degrees = GetDegreeDifference(2, 30);
		System.out.println("Degrees for 2:30: " + degrees);
		
		degrees = GetDegreeDifference(4, 41);
		System.out.println("Degrees for 4:41: " + degrees);	
		
	}
}


results

Easy peasy, do I get the job? : )

Also I got thrown at first that it took in military time, had to account for that as well

edit: cleaned up the code. The return value works without any if conditions, but not as readable. But meh. If it was a job interview question Iā€™d probably make it look simplier over this, as somebody later on might be confused.

Angle is measured in a particular direction, so you canā€™t just do abs(a - b) for the distance.
Without thinking too hard I believe (hourDegrees - minuteDegress + 360) % 360 gets you it quick and dirty. (Except theyā€™re floats in Java so you need Math.Abs() Math.Mod() or whatever). You also probably should not be truncating the output to an integer.