Jump to content
  • Advertisement

Kaycon11

Member
  • Content Count

    42
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Kaycon11

  • Rank
    Member
  1. I have an excercise in a book I am working on, here it is: Write a program that uses a for statement to sum a sequence of integers. Assume that the first integer read specifies the number of values remaining to be entered. Your program should read only one value per input statement. A typical input sequence might be 5 100 200 300 400 500 where the 5 indicates that the subsequent 5 values are to be summed. ------------------------------------------------ I got it all working just fine, but I don't know how to make it only read one value per input, I could I do this. By the way, All I did was make a for loop and I used an if statement to see if counter was zero which set loop continuation to the first number and then another if statement for when counter is >= 1 and then adds the number to a running total, thats all thats in the for statement. for ( int counter = 0; counter <= counter2; counter++ ) { cout << "Enter an integer number: "; cin >> number; if ( counter == 0 ) counter2 = number; // set the sentinel value if ( counter >= 1 ) total += number; // add to running total }
  2. Quote:Original post by Morrandir The answer you posted isn't correct. Maybe just a typo, but: *** Source Snippet Removed *** At the first comment, I used greater-or-equal, this is needed for the case that the largest and second largest numbers are the same number. When you are checking for ranges, never forget the border values! At the second comment, your code would find the largest number, but you don't set the secondLargest correctly. It has to become the former largest number. At the third comment, that code is meaningless. Why assign 'number' to 'number', you can just leave it be and do nothing. ahh... I understand. Thank you very much.
  3. Quote:Original post by SiCrane For 1) you also need to think about what happens to the second largest number. In C++ you need to do something like (secondLargest < number) && (number < largest). However, in Python, secondLargest < number < largest would work like you expect. I got it!!!!! The solution was if ( number > largest ) { largest = number; secondLargest = secondLargest; } else if ( (secondLargest < number) && (number < largest) ) secondLargest = number; else number = number; Thank you very much! One more thing, I don't really care but, I don't think that was the way the book wanted me to solve it because the book has not taught the && thing yet, but this probably makes it work better anyways.
  4. Quote:Original post by SiCrane Well think about it. If you keep track of the largest and second largest numbers you've seen so far, what happens when you process a new number? There are three situations: 1) the number is bigger than both the largest and the second largest you've seen so far, 2) the number is in between those two numbers and 3) the number is less than both numbers. What should you do in each of those cases? well, for 1) The number would be set to largest, for 2) the number would be set to secondLargest, and 3) nothing, could set number to itself. I think.... But, for something like 2), could you use an in between statement in C++ or any programming language ( 1 < X < 10 )???? I tryed this... if ( number > largest ) largest = number; else if ( secondLargest < number < largest ) secondLargest = number; else number = number; and it did not work, the highest number worked but again for the second highest it gave me the last number inputted that did not equal the highest.
  5. NOTICE: I typed my topic wrong, I'm trying to find the 2 highest numbers of 10 numbers. Hello, I'm doing an exercise in a book and I'm currently trying to make a program using a while loop to find the two highest numbers of 10 numbers. I can make it find the highest number, but I don't know how to make it find the second highest. Also, in the book it has a hint that says "You must input each number only once." int main() { int counter; // control loop int number; // number of items sold int largest; // largest number int secondLargest; // second largest number // pre-processing stage counter = 1; largest = 0; secondLargest = 0; // processing stage while ( counter <= 10 ) { cout << "Enter quantity sold: "; cin >> number; if ( number > largest ) largest = number; // This is where i'm stuck if ( largest != number ) secondLargest = number; counter++; // increment counter by 1 } // termination phase cout << "The largest number is " << largest << endl; cout << "The second largest number is " << secondLargest << endl; system( "pause" ); return 0; } The part where I'm stuck is the fact that I have no Idea how to make it check to see if it is not greater than the largest but also greater than the second largest.
  6. Ok, I got that working now. But I do have one warning. LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library Does anyone know what that is?? By the way, I got all my lua header files in the include folder, I got my lua51.lib and lua5.1.lib in the lib folder of the VC directory. Also, do you usually have to move the script yourself to the Debug/Release folder??? Because when I go to test the EXE, the script is not there so it executes without the script, but of course once I place a copy of the lua script file into the directory, it works just fine.
  7. ok, now it works but now when the console lanches I get a runtime error that says Application as made an attempt to load the C runtime library incorrectly. Does anyone know whats wrong???
  8. Kaycon11

    What to do first?

    If you want to program then you need to focus on math in school and take the highest levels of math you can. As for college programs, you should look for computer science, which is all about computers and specifically software design. Also, if you want to see some jobs and the requirements they impose for most positions, go to websites like Bungie.net, IDsoftware.com, Epicgames.com, and other game companies like that, most programming requires C++ and a bachelors degree in computer science or math, along with other skills. p.s. also, you could start by teaching yourself to program, if I were you, I would prolly teach myself the basics with Visual basic or Free basic, and then move onto C++, C#, or java, prolly C++, and then after that you should learn a graphics api like Direct X or OpenGL, and after or during, you should learn about scripting languages such as python, lua, unrealscript, action script, and ruby, which are incorporated into a game so you can edit different variables without having to rebuild a solution.
  9. Ok, I am new to using scripting languages in my applications, I am doing this for the first time. My problem right now is this, the debug version works and runs, I can edit the lua file and rerun the program without rebuilding, but when I try to build a release version(I'm using MSVS2008) I get like 6 linking errors. Here is my C++ code, Its a Win32 console application. -------------------------------------- extern "C" { #include<lua/lua.h> #include<lua/lualib.h> #include<lua/lauxlib.h> } #include<iostream> using std::cout; using std::endl; int main (int argc, char *argv[]) { int s=0; lua_State *L = lua_open(); //load the libs luaL_openlibs(L); //run a Lua scrip here luaL_dofile(L, "do-me.lua"); cout << "\nI am done with Lua in C++.\n" << endl; lua_close(L); system( "pause" ); return 0; } -------------------------------------- here is my lua code (file name do-me.lua) -------------------------------------- print "Start" for i=1,12 do print(i) end print "End" -------------------------------------- Like I said, it works like it's suppose to, I can edit the lua file and the rerun the program without rebuilding, but the only problem is the fact that when I build a release version it fails and gives me this: ----------------------------- ------ Build started: Project: new lua, Configuration: Release Win32 ------ Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol _luaL_newstate main.obj : error LNK2001: unresolved external symbol _lua_pcall main.obj : error LNK2001: unresolved external symbol _luaL_loadfile main.obj : error LNK2001: unresolved external symbol _luaL_openlibs main.obj : error LNK2001: unresolved external symbol _lua_close C:\...\Visual Studio 2008\Projects\lua\new\Release\new lua.exe : fatal error LNK1120: 5 unresolved externals Build log was saved at "file://c:\...\Visual Studio 2008\Projects\lua\new\new\Release\BuildLog.htm" new lua - 6 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ------------------------------------ Please, if anyone could help me, I would appreciate it very much. Also, as I said before I'm a noob, but my debug exe. file works, but it won't show the lua code without the lua file in the same directory, I'm just assuming thats the way it's suppose to be, correct??? p.s. sry for the way I display the code, I don't know how to display it as code.
  10. Kaycon11

    Angel Script a real alternative?

    So... do the developer consoles that games like half-life, quake, unreal, and others use a scripting language? And does that allow them to edit variables of different things such as bullet speeds and damage on the fly without having to rebuild everything??? And if so, How do they make a console for a game(in generalization)???
  11. Kaycon11

    Angel Script a real alternative?

    Quote:Original post by niteice Quote:I would like to know how scripting languages are used, are they used in the C++ code??? Not directly. The C++ code generally will kick off some action within the script, but that's it. Quote:Are they implemented inside the game engine??? Yes. Quote:I really just want to know how you use scripting languages for games. The C++ code sometimes will be responsible for creating and managing objects, sometimes the script will be. Sometimes C++ may only be a thin layer between the code and the operating system, other times scripts may be small chunks of code relative to the amount of C++. Where the line is drawn between C++ and scripts is dependent on the game's design. Ok, but like, where do the programmers actually place the scripting code, like lets say you're using MS visual studio, could you make an open gl project or something and also incorporate a scripting language into the IDE and use it in the project???
  12. Quote:Original post by rozz666 Quote:Original post by GogetaX you see? well thats the point! i saw lots of demos, i saw lots of samples, i dont understand why it cant handle a massive game? i never saw a game made on OpenGL that handles that.. no idea rly why.. does anyone here can answer that? You've seen Quake 2, Quake 3, Doom 3, Quake 4? These are massive games. If you mean massive in the context of multiplayer, then graphic API has really nothing to do with it. Correct, it's all about the game engine itself.
  13. Kaycon11

    Angel Script a real alternative?

    Hello, Im just a noob when it comes to game programming, right now i'm just teaching myself C++. I would like to know how scripting languages are used, are they used in the C++ code??? Are they implemented inside the game engine??? I really just want to know how you use scripting languages for games.
  14. Quote:Original post by phear- If you need any help or want to chat with some programmers (beginners to experts) you should add this contact in msn: mgroup104430@hotmail.com Its an msn group chat contact which allows multiple users to talk to each other at the same time all the time. We currently have 8 people in it and everyone is very active. Alright man, I'll look into it sometime if I need some help.
  15. Quote:Original post by hlsl Personally I have used these tutorials years ago. I really liked them although the coding style is not that awesome. Try these also. Thanks man, SDL sounds like a good way to get my feet wet in game programming with C++.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!