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

  • SEARCH
  • Home
  • 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 3391980
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:51:59+00:00 2026-05-18T03:51:59+00:00

quick question here. I’m wondering how to create a 2D vector from user input.

  • 0

quick question here. I’m wondering how to create a 2D vector from user input. For a project, I am storing my “board” as a 2D vector, and the user will enter the height and width of it, as well as perhaps the starting configuration.

If my board is stored as:

vector<vector<int> > myBoard( width, vector<int> (height) ); 
//Not sure how to get width and height from input...

I will need to initialize it to the given parameters and (if the user supplies the information), fill in the board with pieces. The user will input all this information on 1 line, via 1 cin. So like this…

Please type the board config: 3 3

or

Please type the board config: 3 3 . . . . . . X . O

or

Please type the board config: 3 3 ABFDFL($%$

With the last one being an example of bad input. The first example would create a 2D vector, 3 by 3. The second would create a 2D vector, 3 by 3, and fill in the board with the position given. In this case, “.” is a 0, “X” is a 1, and “O” will be a -1. That’s the part I’m having the most trouble with. I could store it to a string, but it seems that going through and parsing it would be a pain in the butt…

  • 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-18T03:52:00+00:00Added an answer on May 18, 2026 at 3:52 am

    I would try to infer the dimensions from the user input.

    An example session:

    A board consists of characters ., X or O.
    An example board:
    .XO
    ...
    X..
    
    Enter the board, end with two Returns:
    .....
    ..XO.
    .XXX.
    OOOOO
    .....
    

    Then you would scan the first row to find the width, check each row for valid characters and the same width, and count the rows to find the height.

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

Sidebar

Related Questions

Here's a quick question I've been banging my head against today. I'm trying to
Quick question here: is there any obvious benefit to use asynchronous communication with the
Quick question here: why not ALWAYS use ArrayLists in Java? They apparently have equal
Quick question here. I'm implementing a UITableView with cells, some of the cells contain
Quick question here about short-circuiting statements in C#. With an if statement like this:
quick question here. Is there any Wordpress 3.0 documentation available? Some kind of list
Another quick question here, I have this code: string sa[6] = { Fort Sumter,
A quick question here about the new WCF Ria services beta: If I do
Just a quick question here. I have a program in which I need to
just a quick question here. How can I add an image to my UIViewController.

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.