Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4014298
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:28:47+00:00 2026-05-20T09:28:47+00:00

void GameBoard::print(const GameBoard& computerBoard) { Grid[0][0] = ‘1’; Grid[0][1] = ‘2’; Grid[1][0] = ‘3’;

  • 0
void GameBoard::print(const GameBoard& computerBoard)
{
Grid[0][0] = '1';
Grid[0][1] = '2';
Grid[1][0] = '3';

int i, j;
int sides = SIZE;

cout << "        Your bombs:                    Your navy:" << endl << endl;

for(i=0; i<SIZE; i++)
{
    // prints your bombs
    cout << sides << "  ";
    for(j=0; j<SIZE; j++)
    {
        cout << computerBoard.Grid[i][j] << "  ";
    }
    cout << "    ";

    // prints your ships
    cout << sides << "  ";
    for(j=0; j<SIZE; j++)
    {
        cout << Grid[i][j] << "  ";
    }
    cout << endl << endl;
    sides--;
}

j = 0;
cout << "\n   ";

for(i=0; i<SIZE; i++)
{
    j = i + 'A';
    cout << (char)j << "  ";
}
cout << "       ";

for(i=0; i<SIZE; i++)
{
    j = i + 'A';
    cout << (char)j << "  ";
}
cout << endl << endl;

}

I am constructing a game like battleship, and need to change the for loop to read..

for(i=8;i>0;i--)

why does this produce an error?

Sorry if this doesnt make sense, Grid[0][0] should be on the bottom left, but it is currently at the top left.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:28:48+00:00Added an answer on May 20, 2026 at 9:28 am

    I guess what you want is something like

    for(i=SIZE-1; i>=0; i--)
    

    because this is equivalent to

    for(i=0; i<SIZE; i++)
    

    both of these go from 0..SIZE-1 while

    for(i=SIZE; i>0; i--)
    

    goes from 1..SIZE (and so if you access an array of length SIZE using arr[i], will produce an error).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

void max_idxs(vector<int> &pidxs){ vector<fragment *> ids; max_ids(ids); for(size_t i = 0; i < ids.size();
void merge(vector<int> dst,vector<int> first,vector<int> second) { int i=0,j=0; while(i<first.size()&&j<second.size()) { if(first[i]<second[j]) { dst.push_back(first[i]); i++;
void turtle (int gtot) { int msg; fcntl(gtot,F_SETFL,O_NONBLOCK); read(gtot,&msg,4); gotoxy(12, 21); printf(The value of
void trim(string &str) { string::iterator it = str.begin(); string::iterator end = str.end() - 1;
void weight_data::rev_seq(string &seq){ //TODO std::reverse(seq.begin(), seq.end()); } In this C++ method, I think this
-(void) dropCategories{ if (deleteCategoryStmt == nil) { const char *deleteSql = delete from tb_category;
-(void) callme { //statements here I call another method callmeagain } } But it
-(void)LoadOriginalListFromFile { NSMutableArray *temp; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths
- (void)viewDidLoad { [super viewDidLoad]; //..do stuff.. } or - (void)viewDidLoad { //do stuff
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class tictac2 implements ActionListener{ static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.