C++ :: Finding Grid Of Mines?
Aug 8, 2014
Code: There is a rectangular grid of numbers. The grid has m rows and n columns. So it has m*n cells in total.The rows are numbered from 1 to m and the columns are numbered from 1 to n. The top most row has number 1, the row next to it has number 2 and so on. Similarly, the left most column has number 1, the column next to it has number 2 and so on. Each cell in the grid has a unique coordinate which is (x, y) where x is the row number and y is the column number of that particular cell.
Each cell in the grid has an integer in {0, 1, 2, 3, 4, 5, 6 ,7 ,8}. Number in cell (x,y) is number of mines in neighboring cells (cells have at least 1 common vertex with cell (x,y))
Your task is to find grid of mines, i.e display an m*n grid of numbers {0, 1} (cell (x, y) is 1 if there is a mine in cell (x, y)).
Input
First line of the input contains two space separated integers, m and n. Next m lines, each line has n numbers in {0, 1, 2, 3, 4, 5, 6 ,7 ,8}.
Output
A grid of numbers {0, 1}
View 4 Replies
ADVERTISEMENT
Jan 13, 2014
I'm trying to extract data from a grid, it's a Dev Express grid. I have got an object which if I hover over it in debug mode shows me the data I'm after. In the code below if I hover over "row" I can drill down through "Row" and then "ItemArray" and I can see the data I want in an array but I can't find how to get at it.
private void gridShowUsers_Click(object sender, EventArgs e)
{
Object row = gridView1.GetFocusedRow();
string [] rowarray = new string [50];
[Code].....
View 14 Replies
View Related
Aug 20, 2013
I'm trying to create a grid using the following characters: !, @, #, $, &.
It's an 8 x 8 grid, and should contain the characters in no particular order (trying to create a Bejeweled-like game).
I already defined the width and length to be 8, so:
#define WIDTH 8
#define LENGTH 8
Code:
void makegrid(char grid[])
{
int j;
int k;
for ( j = -1; j < LENGTH; j++ )
{
for ( k = -1; k < WIDTH; k++ )
{
/* I don't know what to type here anymore :( */
}
} }
View 14 Replies
View Related
Aug 15, 2014
I'm stuck on printing my grid from my class file to the main file.If I pull out the print code and put in on the actual main program, it prints, but if I try to put in the class methods and call the function from main, I get an error.
testfile.cpp
#include <iostream>
#include <vector>
#include <string>
#include "DUPoint.h"
#include "Grid.h"
using namespace std;
[code]....
View 3 Replies
View Related
Apr 1, 2013
I have a map that is full of 4+ rooms each with one randomly selected door on one of its sides. I need to create a tunnel connecting all of the doors together. I'm not sure the best way to do this A* seems to complicated for me to do at the moment and I cannot think of a way to connect these rooms.
My world is currently a vector<vector<Tiles>> and the tiles contain entities like tunnel, wall, stair, floor, etc.
View 8 Replies
View Related
Apr 9, 2014
How do you use a stored procedure with a WebGrid? Our coding standard say we cannot write sql statement directly in the code to include HTML.
[var Grid = new WebGrid(DB.Query("Select * from Menu")]
The above call must be a call to a stored procedure.
View 4 Replies
View Related
Sep 30, 2013
So my program is to check if a certain 9x9 sudoku grid is valid. i have to get the input through command argument. so for example.
./a.out sudoku.txt
So we have make my c program to use FILE I/O open and what not
program behavior must be as follow File does not exist.File contains something other than a sequence of 81 integers (too many, too few, non-int).
One or more of the values is not in the range 1..9 Violation of Sudoku rules (this is the big one!) In case 4, you should report the violation (or any one of the violations if there are multiple -- you do not need to exhaustively enumerate all violations).
For example: Row Violation: entries (2,2) and (2,6) are both equal to 7. (Similarly for column and box violations). All i know is that i need to make a 2d 9 by 9 array
View 12 Replies
View Related
Aug 27, 2014
Write a menu driven program that will fill grid with values between 1 and 100. Begin the program by declaring a array of type int. Then present the user with the following menu
Enter 1 to add
Enter 2 to edit
Enter 3 to delete
Enter 4 to search
Enter 5 to display
Enter 0 to Quit
Each item of the menu must be implemented as a function. The program should Only allow values between 1 and 100
Always ask the user to apply coordinates for the cell to be changed
Flag an error when try to delete or edit a cell with a zero (0)
Flag an error when try to add to a cell that is not blank
Display the complete and nicely formatted grid when option 5 is selected
View 2 Replies
View Related
May 1, 2014
I have to make a grid 40 X 40 with random numbers 0-9. I have already done this and it prints out great. My problem is I need to be able to choose a row number and output the sum of the number in that row. Here is what I have so far.
#include <iostream>
using namespace std;
int main(){
int Values[40][40];
int rows, cols;
[Code] ....
View 7 Replies
View Related
Mar 21, 2014
I am trying to draw a 2d grid array for a battleships game. I need the grid to have a border around each cell, how to do this. so far my code is:
#include<iostream>
using namespace std;
int main(){
int grid[5][5] = {{0}};
[Code] .....
View 4 Replies
View Related
Nov 11, 2014
I have been trying to bind an xml response from a web service to a gridview but to no success. bellow is my code
soapInvoker.setMethod("GetAgentProducts");
XDocument AgentproductsRequest = SoapMethods.GetAgentProducts(pin);
XDocument AgentproductsResponse = soapInvoker.CallSoapServiceInternal(AgentproductsRequest);
XDocument xmlDoc = new XDocument(AgentproductsResponse);
var vrresult = from a in xmlDoc.Descendants("product")
[Code] ....
And I always get an error that is not explained dont know whether is coz i bootstrapped my master page or what but all errors caught where there are it shows this Runtime Error
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
View 1 Replies
View Related
Jan 28, 2014
I'm trying to make a dynamic 2d array of a Tile Object I created, the Dynamic 2d array was working when I tested it as an int array but not that I gave it a type of Tile it is giving me the above error. I'm reading values from a .txt .
tile Tile;
Tile **grid;
grid = new Tile*[a];
for (int i = 0; i < a; ++i) {
grid[i] = new Tile[b];
}
View 9 Replies
View Related
Mar 20, 2014
I'm trying to draw a 5x5 grid for a battleships game.
How to draw the grid with borders and individual cells.
I'm using dev c++
View 14 Replies
View Related
Oct 8, 2014
why filtering don't work??
This is code for load data into dataGridView
private void Izvestaj_Load(object sender, EventArgs e) {
connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTomyDesktopzadatak2zadatak2fedek_OldVersion(2002-2003).mdb;User Id=admin;Password=;";
dt = new DataTable();
OleDbDataAdapter sda = new OleDbDataAdapter("SELECT korisnici.korisnik,dogadjaji.dogadjaj,Tomislav.Datum
[Code] .....
And this is code for filtering by typing into textbox, when type nothing happening
private void textBox3_TextChanged(object sender, EventArgs e) {
DataView DW2 = new DataView(dt);
DW2.RowFilter = string.Format("dogadjaji.dogadjaj LIKE '%{0}%'", textBox3.Text);
dataGridView1.DataSource = DW2;
[Code] .....
And this is by filtering on dataPickers, range of date, and show me what happens on that dates, but show me exception when click button
private void button1_Click(object sender, EventArgs e) {
if(dateTimePicker1.Value>dateTimePicker2.Value) {
MessageBox.Show("Takav opseg nije moguc. Datum Od mora biti veci od datuma Do.", "Opseg datuma", MessageBoxButtons.OK, MessageBoxIcon.Error);
[code].....
View 13 Replies
View Related
May 8, 2015
implementing a game of chess, i was able to easily implement the grid with an 8x8 multidimensional array.but here is the case I need to implement a grid made of hexagons(six sided but in future may be seven sideded or eight may be needed): like a beehive something.
How can such a grid be implemented in c++ taking notes of coordinates and borders and stuff? From where i can start working from? this grid has to be just like the chess grid only we got six sided boxexs instead of four,
View 6 Replies
View Related
Jan 24, 2014
I've got a Dev Express hierarchical grid and I need to which row is in focus in the level that's in focus. In the code below I need to replace "gridControl1.FocusedView.GetRow(0)" with "gridControl1.FocusedView.GetRow(x)" where x is the row number in the focused row but I can't find a property for it.
private void gridControl1_Click_1(object sender, EventArgs e)
{
//int i = gridView1.GetFocusedDataSourceRowIndex();
[Code]....
View 1 Replies
View Related
Apr 8, 2014
I don't really have an issue with the math behind this, rather it's more with the code structure itself. Basically, every row is right, except for the last row. The last row (year) needs to be depreciated by the value at the beginning of the last row (year).
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
[Code]......
View 2 Replies
View Related
Jun 13, 2014
Basically I wanna make my textbox to contain only positive numbers. I was able to do that via masking and regex. I should let you know that the column is bound to a variable which is an int. Therefore, the user always have to type an int (no letters or characters). Like I said, I have been able to prevent user from typing anything but numbers.
Now to the problem:When the user leaves the cell blank and chooses to get out of that cell, they'd get "Input string was not in correct format" next to that cell.
-My approach is: whenever there is nothing in the cell, just replace it with 0. I have code that I thought will do that, but it wont. Seems like the cell was not null, because the if clause won't execute. This is the code:
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) {
GridView view = sender as GridView;
if ((view.GetRowCellValue(e.RowHandle, colPriority).ToString() == "") ) {
list.ElementAt(this.gridView1.FocusedRowHandle).priority = 0;
}
}
-Another approach is to change the display or the error message to like "Please enter a number." I have tried doing this but no luck. When I try this concept with the code below, it pops me a dialog box say "Do you wanna change the value?". I dont want it to pop up a dialog box. Also, i was looking for a message that I tried to give it. Looks like it doesn't even get in the if clause because I have checked. And its because its not null? I dont know. This is the code:
private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) {
GridView view = sender as GridView;
GridColumn priority = view.Columns["Priority"];
if (view.GetRowCellValue(e.RowHandle, colPriority) == null) {
e.Valid = false;
//Set errors with specific descriptions for the columns
view.SetColumnError(colPriority, "Incorrect Value");
}
}
PS:I have checked that both of these methods get executed, so it isn't like they don't. I used some console.write stuff to check this.
View 2 Replies
View Related
Jul 5, 2013
I have a CScrollView that displays a bitmap and I'm trying to draw a grid that I can turn off and on by check box and when the mouse is over a section of the grid that square highlights... I do all the drawing in the ondraw function... But when I have many grid squares it becomes slow to scroll and to highlight the square the mouse is over... I'm not sure the best way to go about this and where to place code to speed it up... The bitmap is only loaded once... But in ondraw the grid has to redraw every time scrolled and when mouse moved over a square.. In onmousemove I call invalidate so the square under mouse changes...
View 5 Replies
View Related
Sep 14, 2013
I have been working with both Chris Mander's MFC grid and the Ultimate Grid.
See for details:
The Ultimate Grid Beginner's Guide By The Ultimate Toolbox, 25 Aug 2007 : [URL] ....
MFC Grid control 2.27 By Chris Maunder, 6 May 2010 : [URL] ....
Both of these grid controls work nicely in a SDI CView windows. But when I create a split window using CSplitterWnd and the following code in an attempt to create a split window with a CListView and and a CView using this code:
Code:
// in CMainFrame.h
// Attributes
public:
CSplitterWnd m_wndSplitter;
//..
// in CMainFrame.cpp
//..
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
[Code] .....
The grid in the CView window appears but is frozen in both instances. I suspect there is some notification necessary to for the grid to send and receive messages from the split CView window, but I cannot figure out how to implement this notification.
Unfortunately, even a demo application would be too large to append, but for anyone that is interested, the split method is encapsulated in the code I've presented here and the implementation of both grid controls is well explained in the links provided.
View 6 Replies
View Related
May 14, 2014
I have a program which generates lots of data points in 2D (x and y co-ordinates). Perhaps 1,000,000+ of these points. These are floating point numbers. The values all fall within a specific range -R/2 and +R/2.
I want to impose an 'imaginary' grid. Such that I can collect the number of each of these points falling within a specific grid location. The actual 'grid' size is variable.
Should I try and collate this data from my C++ program and then post-process it in some other s/w like matlab?
View 3 Replies
View Related
Sep 18, 2013
How to code the following:
I have two random numbers which are generated and are related to each other (representing x and y co-ordinate). These random numbers are generated within a specified range: (-range, +range).
I want to categorize these values in a (2-dimensional) grid. The grid size is not definite and so can be varied by the user would be in the order of 400 x 400. (e.g., think CCD detector). For each random number pair (x, y) I want to store a hit (a plus one) in the corresponding grid reference.
In the order of 500,000 related random numbers (x and y) are to be generated and the position recorded according to grid reference. So code needs to be fast.
View 8 Replies
View Related
Dec 23, 2011
i m working on a simple project, i want to populate my text boxes and comboBoxes through DataGridView, means when i double click on cell content then the text boxes are populated.my question is that if i have to populate comboBox with the specific value then what i have to do then because comboBox.selectedItem is an object but my class property is a string..
e.g
combobox shows 30 days in it and my class is Code: class account
{
public string day{set;get}
[Code]....
but that does not happen because "comboBox.selectedItem" is an object so if i have to do that what i have to do then?
View 3 Replies
View Related
Jul 3, 2013
Currently I am working on a program that will find the actual distance between two points on a grid. It also determines the angle of the line segment in degrees. Now, i need it to be able to find any other points on or near the line. It will be running in a loop to find each additional point sequentially until all the points have been plotted. Unfortunately, I am not entirely sure how this is done. So far, I think that I could develop an algorithm that converts the angle into a ratio of vertical movements to horizontal ones.
View 7 Replies
View Related
Apr 18, 2014
I need to take a single column and all the rows in the column from a datagridview to a listbox using a for loop. My code is giving me no errors just not showing any data in the listbox.
private void frmProject6_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'enrollmentsDataSet.Enrollments' table. You can move, or remove it, as needed.
this.enrollmentsTableAdapter.Fill(this.enrollmentsDataSet.Enrollments);
[Code] .....
View 1 Replies
View Related
Oct 7, 2014
I am trying to draw a grid for checkers. I could draw a square at the starting point from origin with the code below(attached the pic below how it looks) however I am not being able to draw a grid when the program runs.
#include "ccc_win.h"
// GameDemo.cpp
// Shows how to place a piece accurately on a grid after a mouse click.
#include "ccc_win.h" // for graphics classes and functions
using namespace std;
int ccc_win_main(void) // main function for graphics program
[Code] ....
View 3 Replies
View Related