Source code - Battle_Ship.zip

Find C and C++ source code to help you learn to program. You can submit your own code, or you can simply browse and download the code of others.

Finally, you might want to check out Code Cogs - An Open Source Scientific Library / Database in C++ for more code.

Index :: Games / Battle_Ship.zip
Battle_Ship.zip
resource information
Title Battle_Ship.zip
URL http://www.cprogramming.com/source/Battle_Ship.zip
Category 2
Description Battle ship without grapical interface.
Contact Michael_Marques
Added 06-17-2003 at 05:43 p.m.
Last Updated 06-17-2003 at 06:26 p.m.
rating
Current Rating 3.84615384615385
Rate Resource
 
reviews
Number of Reviews 28
Review this Resource
Reviews:
  • Worst piece of code I've ever seen. This simple game could be written in less than 1000 lines using 2D array and loops with all kinds of error check. I think you should NOT even touch any kind of programming since your logic is flawed everywhere.
    posted at 10:07 p.m. on 04-21-2013
  • Y
    posted at 08:01 p.m. on 11-29-2012
  • #include <iostream> #include <cmath> using namespace std; int main() { int test,i,n,m,temp,c; short int a[10000]; for(c=0;c<10;c++){ cin >> test; for(i=0;i<test;i++) { cin >> n >> m; a[i] = n-m; } temp = a[0]; for(i=0;i<test;i++) { if (abs(a[i]) >= abs(temp)) { temp = a[i]; } } if (temp<0) cout << 2; else cout << 1; cout << " " << abs(temp); } }
    posted at 06:49 p.m. on 01-25-2012
  • BXkxuQ <a href="http://gwiphkiafrox.com/">gwiphkiafrox</a>
    posted at 07:47 a.m. on 01-06-2012
  • OxfsOY , [url=http://tesytkwswkai.com/]tesytkwswkai[/url], [link=http://wffzlpcjefrz.com/]wffzlpcjefrz[/link], http://ufjqmwbsqelf.com/
    posted at 08:19 a.m. on 01-04-2012
  • hmoj3o <a href="http://asgnbvxhlqqi.com/">asgnbvxhlqqi</a>
    posted at 03:58 a.m. on 01-04-2012
  • Boom shaakklaa boom boom, problem solved.
    posted at 06:05 a.m. on 01-03-2012
  • wow! alot of reviews hating this program. only thing missing is the haters links to something workable that they have done better. For an educational site, seems alot of tearing down and little assistance learning... you know better? show us. i love learning from bad mouthed hecklers as much as other sources if their info is where there mouth is.
    posted at 12:41 p.m. on 09-18-2011
  • review *
    posted at 08:28 a.m. on 09-15-2011
  • Give unavailable position = game act weird, error prevention needed.
    posted at 01:16 a.m. on 08-11-2011
  • dud i had made a submarine game as a practice it took about 600 lines and it had chekings for everything!!! i will post it soon as a "currection" if that's the word for this thing
    posted at 01:35 p.m. on 06-24-2011
  • Just when you thought epic failing was bad. This just broke that limit and beat it by 911x...
    posted at 12:51 p.m. on 05-31-2009
  • Its funny to look at the spelling and grammar of the people bad-mouthing the spelling in the code. For example "Oh my god!!, what money(monkey?) programmed this.(should be a question mark maybe) Have u(spelling) enever hurd(spelling) of fuctions (spelling) to repeat tasks(comma) not writing out each event. plus (capitalise) there is no error checkinh (spelling) & you cant(apostrophe pleae) spell. u(it's 'you', just two extra letter PLEASE) cock monkey.
    posted at 03:42 p.m. on 03-30-2009
  • Froze my computer =(
    posted at 05:15 p.m. on 07-11-2008
  • The app is a little hard to follow. The source isnt exactly clear, so there could be more comments to tell why we do this or that.
    posted at 06:49 p.m. on 12-04-2007
  • Back when I first started programming, (with Visual Basic) I used to write code like that. My instructor used to get pissed at me because he couldn't read my source code, but it worked perfectly. Give the guy/girl a break. Assholes.
    posted at 11:32 p.m. on 07-17-2006
  • Clearly everyone here flaming the program, are actually pith no clue as the what is going on, and the people standing up for this guy are actually honest people with common sense. I mean, since when were people writing books flamed for writing simple programs in them, and since when was it a bad thing to copy these , and make your own , even if knowledge is limited.
    posted at 02:17 p.m. on 06-03-2006
  • Ok, some harsh reviews, but clearly the person is new to programming, I wouldn't know where to start writing a program like this, (maybe learning the rules of the game), and yes I could see a definite need for functions. The thing that I find bad, is the lack of comments mostly. -this game obviously has no error checking or anything built in, and with a gizillion switches and cases, I really can't be bothered learning what the hell is going on. I'm slightly dissapointed that this site doesn't have example code to learn from, and people have to post their beginning stuff!
    posted at 05:06 p.m. on 04-09-2006
  • good for noobs trying to learn C++
    posted at 12:13 p.m. on 06-12-2005
  • Now, from reading all the previous reviews I naturally assumed people were being a bit OTT, and needlessly harsh. But after looking at the code... whilst I'm certainly not advocating the personal insults that have been flying around, I've got to say that the code itself is dire. I have honestly never seen as many needless switch statements before- there must be over a thousand of them. Had you considered the possibility of a more straight-forward implementation- without relying on repetitive logic blocks? Additionally, a lot of the data-checking which is needed to make the game playable has simply been skipped out. Next time you write a program, sketch the basic structure of it out on paper first- and if you can't do that without wanting to use copy-and-paste, there's something wrong with your design.
    posted at 05:07 a.m. on 04-13-2005
  • Srry about the code being crapy. Im working on one with graphic in open gl. It was one of my first programs. The new one sould be poster soon.
    posted at 04:17 p.m. on 03-14-2005
  • Heheheh... Maybe the execution file and .cpp file he included in nice little package came from different sources? Maybe the guy is smarter than some of use would presume... I would write some bullshit long source , and put it in the zip, but then write a normal code with trojan in it... to compensate a gap?
    posted at 12:28 a.m. on 11-10-2004
  • This is horrible. You can not spell 'position', the interface is horrible, you can't tell what you're doing, and the source is too large. Not even Microsoft would make a program that long and cofusing.
    posted at 10:39 a.m. on 07-06-2004
  • Why is the code so long? You shouldn't make a program that you don't know how to make. To tell you the truth, I think it's a very bad program and it's a shame that people will see it and think that's the way you're supposed to make programs. BTW Learn to spell correctly (Here's a translation for you if you didn't understand me: Leran ot psell)
    posted at 07:44 p.m. on 04-29-2004
  • Ok. I'm new at C++, barely know anything. Probably couldn't even make that game you made. But what are you thinking with all that code!?!?!? Even I know there's ways to make it shorter and easier. Although I'm not new at programming, just C++. But christ man. Every time I try to open the source file, the damn program freezes. I think you should fix it, and repost it.
    posted at 06:12 p.m. on 12-17-2003
  • Oh my god!!, what money programmed this. Have u enever hurd of fuctions to repeat tasks not writing out each event. plus there is no error checkinh & you cant spell. u cock monkey
    posted at 08:05 a.m. on 08-29-2003
  • oh, and learn how to spell, people like you should not be allowed to use C++.. (Do you work for microsoft? way too much code to do a simple thing)
    posted at 11:48 p.m. on 08-14-2003
  • How stupid do you have to be to write out 28294 lines of code that dont even work well. Your interface is unclear, your ship entry lets you place multiple ships on top of each other and the list goes on.. You might as well check your code before you put crap like that on the internet
    posted at 11:46 p.m. on 08-14-2003