How to search for an element in a 2D vector? Programming Software Development by Crouchinho … guys, I could sure use some help regarding this search methond in C++. I have a 2D vector which i read… Calling a methond Programming Software Development by Mitja Bonca How to call a comboBox1_SelectedIndexChanged(object sender, EventArgs e) method from this code: [CODE]private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { // Get subdirectories from disk, add to treeView1 control AddDirectories(e.Node); // if node is collapsed, expand it. This allows single… Re: Calling a methond Programming Software Development by Antenka Hello. All you need is decide what objects to pass to that method and then - call it. E.g.: [code=c#] comboBox1_SelectedIndexChanged(comboBox1, new EventArgs()); [/code] Re: Calling a methond Programming Software Development by DdoubleD If you set the [ICODE]comboBox1.SelectedIndex[/ICODE] to a value, it will call the event handler automagically... Re: how to attach sqldatabase with sql server dbms from a form of vb.net Programming Software Development by saleemwazir … procedures using SQLCommand object.[/QUOTE] ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Thank u sir! Sir which methond of sqlcommand object is used to run the above mentioned… Re: Create an array from txt file Programming Software Development by JoeK … everyone. I have been doing some research on the scanner methond. I am very new to Java and I am having… Re: Time or cronjob Programming Software Development by newbie14 Dear Purijatin, Can you guide me how to use and apply ScheduledThreadPoolExecutor? I would like to replace it with my existing methond then. Thank you. Re: Iframe X-Frame-Options error for youtube video Digital Media UI / UX Design by Rizi004 Problem solved i was embeding video with wrong method WRONG METHOND <iframe src='http://www.youtube.com/watch?v=VIDEO-IDfeature=youtu.be'></iframe> CORRECT METHOD <iframe src='http://www.youtube.com/embed/VIDEO-ID'></iframe> Re: Need help with Inventory program Homework Programming Software Development by zolymo … are in line 99,100 and 107. because ur calling methond 'printf' and inside, u doesn't put variables for this… Re: How to search for an element in a 2D vector? Programming Software Development by iamthwee [QUOTE]The idea here is I have to search for the leftmost '1' in the highest possible row it is present in. [/QUOTE] Explain... Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho [quote]The idea here is I have to search for the leftmost '1' in the highest possible row it is present in. Explain... [/quote] lets say I have a text file as follows: 00000 01010 00011 In this textfile, The 2nd element in the second row contains the first occurence of '1'. I need to design my code in such a way that I shall be able… Re: How to search for an element in a 2D vector? Programming Software Development by iamthwee Um... [code] #include <iostream> #include <string> using namespace std; int main() { int lines = 3; string crap[] = {"0001010010", "01010010100", "010101010"}; for ( int i = 0; i < lines; i++ ) { for ( int j = 0; j < crap[i].length(); j++ ) { if ( crap[i][j] == '1' )… Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho Yes, that would probably work. But that code looks like its for a specific file. Now my assignment requires me to use the STL algortihms in order to search for the element. I was thinking of using the find_if algorithm, but somehow its is giviing me errors. Any idea on on how to the find_if algorithm? Re: How to search for an element in a 2D vector? Programming Software Development by iamthwee Seems like overkill to me. What is your assignment can you explain it from the beginning? Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho Okay, here it is. We are given a textfile which has a certain number of rows and columns (unspecified number, could be any size). The rows and columns are filled with random '1's and '0's. We have to figure out where the first '1' is and find a simple polygon of which consists of all the '1's in the table. We have to move counter-clockwise … Re: How to search for an element in a 2D vector? Programming Software Development by Dave Sinkula [code=c++] int a = 1; typedef std::vector< std::vector<int> >::iterator iter; for ( iter it = array.begin(), end = array.end(); it != end ; ++it ) { typedef std::vector<int>::iterator iter2; iter2 found = std::find((*it).begin(), (*it).end(), a); if ( found != it->end())… Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho Thanks a lot Dave! but I wanted to find out how necessary is this piece of code in the solution? [code] if ( found != it->end()) { std::cout << "row " << (it - array.begin()) << ", col " << (found - (*it).begin()) << '\n'; break;… Re: How to search for an element in a 2D vector? Programming Software Development by iamthwee Post a sample text file. Re: How to search for an element in a 2D vector? Programming Software Development by Dave Sinkula [QUOTE=Crouchinho;428095]Thanks a lot Dave! but I wanted to find out how necessary is this piece of code in the solution? [code] if ( found != it->end()) { std::cout << "row " << (it - array.begin()) << ", col " << (found - (*it).begin()) << '\n';… Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho heres a sample textfile: 3 4 0000 0100 0110 Re: How to search for an element in a 2D vector? Programming Software Development by iamthwee And what are you supposed to do, show the coords of all the '1's that join together so to speak? Show me an example of another bigger file. Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho yeah pretty much show the coords of all the '1's that form a polygon so heres another sample file 5 7 0000000 0111100 0101000 0000000 0000000 The lines between the elements are the coordinates, so for this text file the output I am supposed to show is [1,1],[3,1],[3,2],[2,2],[2,3],[3,3],[3,4],[2,4],[1,4] Re: How to search for an element in a 2D vector? Programming Software Development by Dave Sinkula I don't quite understand the expected output. [code] int key = 1; typedef std::vector< std::vector<int> >::const_iterator riter; for ( riter row = array.begin(), end = array.end(); row != end ; ++row ) { typedef std::vector<int>::const_iterator citer; [COLOR="Green"]citer col, … Re: How to search for an element in a 2D vector? Programming Software Development by Crouchinho The coordinates are supposed to be between the elements. like say for the element 'a' in this sample: 000010 00a000 000000 The 'a' four coordinates around it. Its co-ordinates will be [1,2], [2,2], [2,3] and [1,3] Its confusing I know. But I hope this helps. we have to find the co-ords around the polygon, however if the 1's are next … Re: How to search for an element in a 2D vector? Programming Software Development by Dave Sinkula Danke. I'm zero-based, so I see the highlighted points corresponding to [1,2],[2,2],[2,3],[1,3]. [code]000010 00[COLOR="Red"]a[/COLOR][COLOR="Red"]0[/COLOR]00 00[COLOR="Red"]0[/COLOR][COLOR="Red"]0[/COLOR]00[/code]