C/C++ :: Iterating Over Either Row Or Column?
Jul 31, 2014
Suppose I want to represent an apartment building in terms of floors and rooms with a single data object. Each floor has the same number of rooms at any given time. During the course of the program, I will need to change the number of floors occasionally and will need to change the number of rooms on each floor occasionally. (Don't worry about the building permits needed to do this.)
Now, I also want to be able to iterate over either each floor (think "row") or each room (think "column"). For example, I might want to program the equivalent of "Johnson, go fix all the front doors on the 8th floor" or the equivalent of "Johnson, go fix all the front doors to room B on each floor". (Yeah, I know, for the latter I could iterate over each floor and then access room B but that doesn't feel as "clean" as being able to iterate over a separate room/column.)
View 2 Replies
ADVERTISEMENT
Jul 3, 2014
Suppose I want to represent an apartment building in terms of floors and rooms with a single data object. Each floor has the same number of rooms at any given time. During the course of the program, I will need to change the number of floors occasionally and will need to change the number of rooms on each floor occasionally. (Don't worry about the building permits needed to do this.) Now, I also want to be able to iterate over either each floor (think "row") or each room (think "column"). For example, I might want to program the equivalent of "Johnson, go fix all the front doors on the 8th floor" or the equivalent of "Johnson, go fix all the front doors to room B on each floor". (Yeah, I know, for the latter I could iterate over each floor and then access room B but that doesn't feel as "clean" as being able to iterate over a separate room/column.)
View 7 Replies
View Related
Apr 4, 2013
Suppose I have a struct with 20 members. I want to assign each of those structs with values. Instead of accesing by explicit convention, i.e.:
Code: struct.member1 = 1;
struct.member2 = 2;
...
...
...
struct.member20 = 6;
Is there any way to encapsulate it in a for loop and use an iterator variable to indicate the member? i.e.:
Code: for (int i = 0; i < 20; i++)
struct.i = i;
The above is pseudocode but Im sure you get what Im trying to do?
View 2 Replies
View Related
Sep 4, 2014
If I have a Vector of pointers, how can I iterate through that vector, to access the name function of each object in the vector? There seems to be a problem with my implementation, the output returns only random symbols.
Implementation of the name() function in Drug.cpp:
//name() is a function returning the name in the parent class
string Drug::name() {
string out = "Drug: ";
out += mName + " [ ";
//The problem is with this loop
for (int k = 0; k < mComponents.size(); k++)
[Code] .....
View 10 Replies
View Related
Jan 31, 2013
there is a way to iterate through the controls on a webpage. For instance, I tried EnumChildWindows using the parent window of the browser, but I haven't had any luck - it returns nothing. s where I can start researching how to find the child controls?
I'm using Visual Studio 2010, programming in C++.
View 6 Replies
View Related
Mar 17, 2015
what do I do if the while loop repeat iterating and do not stop running even if it did meet the conditions required?
View 3 Replies
View Related
May 2, 2012
I am writing code to access vector elements as, to print first "n" elements of vectors out of its total N elements at a time.
For example, Total vector elements : N= 23
Want to print n elements at time : n =3
How this can be explored using vectors?
View 6 Replies
View Related
Apr 11, 2013
For example If I have the following . How would I sum each row and column ??
For example
1 2 3 4 5
0 1 3 8 9
View 6 Replies
View Related
Dec 16, 2013
If i have current index and row/columns count how do i get on which row and on which column index is individually?
This is what i have tried, but column index is incorrect:
#include <iostream>
int main()
{
int rows = 5;
int colm = 6;
int inx = 12;
int rowInx = inx % rows;
int colInx = inx % colm;
std::cout << "row: " << rowInx << std::endl;
std::cout << "col: " << colInx << std::endl;
return 0;
}
View 4 Replies
View Related
Oct 18, 2013
I have a 2d array where I manage donations and requests for different foods. I output a menu to the user who picks the options to either make a donation, make a request, fulfill a request, or print a status report of all the donations and requests. What I'm having trouble with is the fulfilling requests option. When the user picks fulfill requests that means that the donations are supposed to be subtracted from the requests. For example if there are 10 donations for grains and 15 requests for grains then after picking fulfill request there should be 0 donations for grains and 5 requests for grains but I don't know how to make the program do that since the values are in a 5 row by 2 column array. The five rows correspond to the five foods and the two columns correspond to donations and requests, respectively. Here's my code so far. Just disregard everything but the third case.
Code:
#include <stdio.h>int main(){
int foodbank[5][2]= {
{0,0},
{0,0},
[Code]....
View 6 Replies
View Related
Oct 24, 2013
i have a matrix containing a lot of points and each point has its coordinates x and y. That is a nx2 size array. I want to sort it according to the first column ascending, with x coordinates. For points that have the same x coord i would like to sort according to y coord. Here is what i did and i cannot get a good result.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int a[5][2] = {{1,0}, {4,2}, {2,4}, {8,6},{4,8}};
int temp=0;
int i=0;
int j=0;
[Code]...
View 4 Replies
View Related
Apr 6, 2013
I need sorting a particular column (column 1) of a .cvs file (the file has 10 columns) by alphabetic order. How I can accomplish this ?
View 1 Replies
View Related
Feb 21, 2014
void calcWeeklyPay(double empData[][COLS], const int count) {
double wage;
double hour;
int row;
for (row = 0 ; row < count; row++); {
hour = empData[row][0];
wage = empData[row][1];
[Code] ....
I'm really stuck on this problem...Why is it in my salary column all it outputs its 0? How would i fix this ?
View 2 Replies
View Related
Feb 18, 2014
I'm using GCC 4.8.1 and I want to implement a XML parser using TinyXML and port it to AngelScript
Now, it says: reference to 'Column' is ambiguous
I've declared a class called xml_parser and I've added everything of tinyxml as it's public member when I call Column(), and also Row(), it give's this error. what should I do?
This is it's code:
xml_parser.hpp:
#ifndef AGK_XML_PARSER_H
#define AGK_XML_PARSER_H
#define TIXML_USE_STL
#include <tinyxml.h>
[Code] .....
View 16 Replies
View Related
Jul 11, 2013
I suppose to have the following matrix
A). I want to remove a generic row and column. For instance the second row and column, then I get
B). How can I realize it in C?How to do.
A) B)
a00 a01 a02
a00 a02
a10 a11 a12a20 a22
a20 a21 a22
View 2 Replies
View Related
Oct 2, 2014
I have .db3 file, and he has 14 tables,and every table has certain number of columns. Example i have table called "BASIC_INFO" and that table has columns "First Name", "Last Name" and "Age".
How can i get name of table and name of every column,so if i some day add column "Male" i get name of this column too. I need first to calculate number of columns,put that in some integer, and then for example create string array which will contain : array[0] = "First Name" ,array[1] = "Last Name"...
SQLiteConnection myConn = new SQLiteConnection("Data Source=" + DB3Path + ";Version=3;New=False;Compress=True;");
//string query = "Select * From " + DB3Path + ".INFORMATION_SCHEMA.COLUMNS";
string query = "Select * From BASIC_INFO.INFORMATION_SCHEMA.COLUMNS;";
SQLiteCommand sqCommand = new SQLiteCommand(query);
[Code] ....
I tried this too:
string query = "select * from INFORMATION_SCHEMA.COLUMNS"
+ "where TABLE_Name='BASIC_INFO'"
+ "order by ORDINAL_POSITION;";
string query = "SELECT TOP 0 * FROM BASIC_INFO";
View 2 Replies
View Related
Oct 18, 2014
I am writing a code in which i need to grab a column from a variety of tables. So basically there are 10 tables in which they hey have the same columns inside of them (Submitted and Amount). I need to grab the amount column from all the tables. What would be the c# sql command for that.
View 5 Replies
View Related
Oct 7, 2014
I have question regarding Gridview.
Can i set each column in Gridview with different Datasource ? for example I create Gridview with 3 column , can I set each column with different datasource ?
View 2 Replies
View Related
Apr 24, 2014
I cannot check the checkbox in my datagridview.
Here is my code.
First, I added a checkbox column.
private void addCheckBoxColumn() {
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
checkColumn.Name = "clmCheck";
checkColumn.HeaderText = "";
checkColumn.Width = 100;
checkColumn.ReadOnly = false;
dgv1.Columns.Add(checkC
[Code] ....
View 4 Replies
View Related
Oct 19, 2014
When I try to link combobox with sql column i get error !!
void comfunction() {
string constring = "Data Source=LC-VAIO\SQLEXPRESS;Initial Catalog=sample1;Integrated Security=True";
string query = "select * from tbltest";
SqlConnection cn = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand(query,cn);
SqlDataReader dreader;
[Code] ....
I got error from "string sname = dreader.GetString("name"); "
And this how i try to link it...
View 9 Replies
View Related
Nov 23, 2012
You have two array and you want to replace the column of one of them to the row of another?
View 4 Replies
View Related
Jan 8, 2015
I am new in c programming and my teacher gives me home word to do. the home work is to create dynamic matrix that check if i have same number in row or in column. for example the matrix
1 2 3
2 3 1
3 1 2
is legal matrix and this matrix is illegal
1 3 3
2 1 3
3 2 1
I created the matrix and sent it to function but there I don't know how build the code.
View 8 Replies
View Related
Oct 25, 2013
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int main()
#define rows 9
#define columns 9
[code]....
View 9 Replies
View Related
Jan 23, 2013
Here is the draft of code that i designed. My task is here to create the matrix, allocate the dynamic memory for it, and to find the biggest sum of the column elements that is located over main diagonal. So main points is correct memory allocation, and the sorting to the biggest sum of column higher than diagonal.
View 14 Replies
View Related
Jul 20, 2014
I have two doubts in the following code,the doubts are marked..PLs note that the following code is correct .This is a program to read 2d array using pointer ()i.e Dynamic array ,to calculate its rowsum and column sum and display this array along row sum and column sum.
#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
int *Val,*Rsum,*Csum;
int MaxR,MaxC,i,j;
[Code] .....
View 2 Replies
View Related
Mar 21, 2014
Basically when I type in different widths and heights for the col and rows, the buttons that make up the width get cut off. Something is messed up but I'm not sure what!
InitializeComponent();
int _col = int.Parse(cols);
int _row = int.Parse(rows);
int width = groupBox1.Width;
int height = groupBox1.Height;
int bW = width / _col;
int bH = height / _row;
[Code] ....
View 4 Replies
View Related