• Picking up a programming language
    33 replies, posted
[QUOTE=zzzz;35703389]Well how do I specify what the program needs to do, then, if a single element of an array is changed? What if I need to specify that if something happens to element 5, for example, that the program is to do something in response (add an x over that element for example)?[/QUOTE] When someone play, you will check the array position with an 1 or a -1, IF the position is 0. Something like i = "position where the player will put a X or O" if (cell[i] == 0) { cell[i] = 1; // or -1, you will need a functin checking who is the player } then before every play, you will need to check if someone won the game or if its a draw. something like if ((cell[1] == cell[2]) && (cell[2] == cell[3])) { the winner is the guy who puts his X or O in the cell[1] (or cell[2], cell[3]... } in the end you will need to check for a DRAW, if all cells are occupied and there is no winner, its a draw. int i,flag=0; for (i=0;i<9;i++) { if (cell[i] == 0) { flag = 1; } } if (flag==0) { DRAW! }
[QUOTE=PvtCupcakes;35634851]C++ is a steam piling of garbage. The only good thing it does is Strings, and that it (more or less) does C. If your'e just going to use C++ to write C, then use the real C. If you want something with more features then use Python.[/QUOTE] I don't even know where to start correcting you. Dear God, that hurt to read.
I'd always advocate starting with C or Assembly. Believe me when I say, if you're doing a CS degree, starting at a foundation language that forces you to understand what you are actually doing in the process of programming will aid your understanding of the subject enormously. The C++ vs. The rest of the programming world clusterfuck could go on indefinitely. C++ is like anything else; it has problems and strengths that charm some people, and repulse others. No need to be aggressive about it, on either side.
[quote]Assembly[/quote] I couldn't agree more. It's véry important to understand how computers work.
Sorry, you need to Log In to post a reply to this thread.