I am writing a tic-tac-toe game in Java.
I have a 2D array representing a 3-by-3 grid, and need a method to check if there are 2 bits set in such a way that a row of 3 can be formed by adding a third bit.
The only way I could think of doing this is to iterate along the rows, checking for a blank space, then checking the bits around it,...
I know that all arrays in .net are limited to 2 GB, under this premise, I try not to allocate more that n = ((2^31) - 1) / 8 doubles in an array. Nevertheless, that number of elements still doesn't seem to be valid. Anyone knows how can I determine at run time the maximum number of elements given sizeof(T)?
I know that whatever quantity...
I need to split an array of indeterminate size, at the midpoint, into two separate arrays.
The array is generated from a list of strings using ToArray().
public void AddToList ()
{
bool loop = true;
string a = "";
Console.WriteLine("Enter a string value and press enter to add it to t...
I need a way to go through all the text on my page, including links and other controls and find words that are in a certain list and add the html character entity ™ () to them.
I need this to be fast too.
The list is held in a javascript array. I've already got code using .each to find all Links on the page with text from that lis...
The following application is not rendering the information that I am getting back from a web service into the datagrid. I know I am being able to connect to the webservice because I am getting the count for the class array. I am being able to get a Response.Write but when I try to pull all the information from the array class I haven't ...
Okay, I'm a beginner when it comes to C, so bear with me.
Here's the problem: I have a text file with up to 100 IP addresses, 1 per line. I need to read each address, as a string, into an array called "list". First, I'm assuming that "list" will need to be a two-dimensional char array. Each IP address is 11 characters in length, 12 if y...
My application needs to deal with arrays of fixed size. The problem is that sometimes elements are nil but nil is a forbidden value. I think an easy way is to replace nil values with an the closest non-nil value (right before or right after).
The nil values can be first, last or even multiples. Here are some examples of what I'm looking...
I'm planning on writing a simple text viewer, which I'd expect to be able to deal with very large sized files. I was thinking of using Tie::File for this, and kind of paginate the lines. Is this loading the lines lazily, or all of them at once?
...
I have an array that looks something like this
array(7) {
[0]=> "hello,pat1"
[1]=> "hello,pat1"
[2]=> "test,pat2"
[3]=> "test,pat2"
[4]=> "foo,pat3"
[5]=> "foo,pat3"
[6]=> "foo,pat3"
....
}
I would like to push it into another array so the output of the array2 is as follow:
array(7) {
[0]=> "hello,pat1"
[1]=> "tes...
I have a requirement to create a java cache which holds all the cities and airports. So, if i query the cache for a location, lets say a city, it should return all the airports in that city and if I query a location which is an airport, i should get back that airport.
Also, each location has to be stored as a byte array in cache.(as the...
I have a table with (among other things) a name and a rank. I'd like to return the set of all unique names, but for each name returned, I'd like to pick the row with the highest rank. This is simple with two nested SELECT statements:
SELECT * FROM (SELECT * FROM foo ORDER BY rank DESC) AS ordered GROUP BY name
MySQL takes the first ...
i've got an array with existing key/value-pair and i want to add values to the keys after the existing ones without deleting anything.
how do i do that?
...
I've got an array like this one:
arrayname[1] = "jacob";
arrayname[2] = "peter";
arrayname[3] = "jacob";
arrayname[4] = "nicholas";
I want to remove the double jacob so it will be like
arrayname[1] = "jacob";
arrayname[2] = "peter";
arrayname[3] = "nicholas";
How do I do that?
...
I'm working on an application that allows user to select multiple entries. Once those entries are selected, the user can choose to delete them all. When clicking on the delete button (after selected one or more entries), a modal dialog window is displayed showing the entries that the user has selected with a confirmation button.
Current...
hi,
I was using C to display a sentence in three lines. The piece of code which worked successfully in VC++ is giving an unexpected output in Borland C++. The ouptut is a charcter array of size n. In the output I could receive more than n characters for the array. How can I avoid this?
...
What's going in below isn't an arrayname always a pointer to the first element in C?
int myArray[10] = {0};
printf("%d\n", &myArray); /* prints memadress for first element */
printf("%d\n", myArray); /* this prints a memadress too, shows that the name is a pointer */
printf("%d\n",sizeof(myArray)); /* this prints size of the whole arr...
We get our data from a sensor which records and stores data like hashes.
At any time it measures a few stuff like that:
{:temperature => 30, :pression => 100, :recorded_at => 14:34:23}
{:temperature => 30, :pression => 101, :recorded_at => 14:34:53}
{:temperature => 31, :pression => 102, :recorded_at => 14:34:24}
{:temperature => 30, :p...
I've little idea of how arrays are implemented in PHP, and know that for most OOP languages the complexity is one of constant time, O(1), for an array of a predefined type. So what's the deal in PHP with it's dynamic typing, extending arrays, etc.?
...
Having used Java for a long time my standard method for creating long strings piece by piece was to add the elements to an array and then implode the array.
$out[] = 'a';
$out[] = 'b';
echo implode('', $out);
But then with a lot of data.
The (standard PHP) alternative is to use string concatenation.
$out = 'a';
$out .= 'b';
echo $ou...
The following code gives me a segmentation fault when run on a 2Gb machine, but works on a 4GB machine.
int main()
{
int c[1000000];
cout << "done\n";
return 0;
}
The size of the array is just 4Mb. Is there a limit on the size of an array that can be used in c++?
...