Search Results

Search found 3545 results on 142 pages for 'arrays'.

Page 4/142 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • commands&creating pointer [closed]

    - by gcc
    input 23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x //according to input,i should create int pointer arrays. pointer arrays // starting from 1 (that is initial arrays is arrays[1].when program sees n ,it // must be jumb to arrays 2 // the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays expected output: elements of arrays[1] 3 4 5 42 elements of arrays[2] 23 0 9 9 elements of arrays[5] 3 9 9 another input 12 2 3 4 n n 2 3 4 n 12 3 x expected output elements of arrays[1] 2 3 4 elements of arrays[3] 2 3 4 elements of arrays[4] 12 3 specification: x is stopper n is comman to create new pointer array i am new in this site anyone help me how can i write

    Read the article

  • n & x commands&creating pointer&with using malloc [closed]

    - by gcc
    input 23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x //according to input,i should create int pointer arrays. pointer arrays // starting from 1 (that is initial arrays is arrays[1].when program sees n ,it // must be jumb to arrays 2 // the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays expected output arrays[1] 3 4 5 42 arrays[2] 23 0 9 9 arrays[5] 3 9 9 another input 12 2 3 4 n n 2 3 4 n 12 3 x expected output arrays[1] 2 3 4 arrays[3] 2 3 4 arrays[4] 12 3 x is stopper n is comman to create new pointer array i am new in this site anyone help me how can i write

    Read the article

  • reopen or read and say why not reopened [closed]

    - by gcc
    input 23 3 4 4 42 n 23 0 9 9 n n n 3 9 9 x //according to input,i should create int pointer arrays. pointer arrays // starting from 1 (that is initial arrays is arrays[1].when program sees n ,it // must be jumb to arrays 2 // the first int input 23 is num_arrays which used in malloc(sizeof(int)*num_arrays expected output: elements of arrays[1] 3 4 5 42 elements of arrays[2] 23 0 9 9 elements of arrays[5] 3 9 9 another input 12 2 3 4 n n 2 3 4 n 12 3 x expected output elements of arrays[1] 2 3 4 elements of arrays[3] 2 3 4 elements of arrays[4] 12 3 specification: x is stopper n is comman to create new pointer array i am new in this site anyone help me how can i write

    Read the article

  • PHP splitting arrays into groups based on one field's value

    - by Dan
    I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name. Array ( [0] => Array ( [0] => a [1] => Alanis Morissette ) [1] => Array ( [0] => a [1] => Alesha Dixon ) [2] => Array ( [0] => a [1] => Alexandra Burke ) [3] => Array ( [0] => b [1] => Britney Spears ) [4] => Array ( [0] => b [1] => Bryan Adams ) ) I'd like to display them grouped by that first initial, eg: A - Alanis Morissette Alesha Dixon Alexandra Burke B - Britney Spears Bryan Adams etc... Is this at all possible?

    Read the article

  • JavaScript Multidimensional Arrays

    - by JasonS
    This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser. I am trying to create a multi-dimensional array. var photos = new Array; var a = 0; $("#photos img").each(function(i) { photos[a]["url"] = this.src; photos[a]["caption"] = this.alt; photos[a]["background"] = this.css('background-color'); a++; }); Error message: photos[a] is undefined. How do I do this? Thanks.

    Read the article

  • JavaScript Multi-Dimensional Arrays

    - by JasonS
    This wasn't the question I was going to ask but I have unexpectedly run aground with JavaScript arrays. I come from a PHP background and after looking at a few websites I am none the wiser. I am trying to create a multi-dimensional array. var photos = new Array; var a = 0; $("#photos img").each(function(i) { photos[a]["url"] = this.src; photos[a]["caption"] = this.alt; photos[a]["background"] = this.css('background-color'); a++; }); Error message: photos[a] is undefined. How do I do this? Thanks.

    Read the article

  • Are stack based arrays possible in C#?

    - by Bob
    Let's say, hypothetically (read: I don't think I actually need this, but I am curious as the idea popped into my head), one wanted an array of memory set aside locally on the stack, not on the heap. For instance, something like this: private void someFunction() { int[20] stackArray; //C style; I know the size and it's set in stone } I'm guessing the answer is no. All I've been able to find is heap based arrays. If someone were to need this, would there be any workarounds? Is there any way to set aside a certain amount of sequential memory in a "value type" way? Or are structs with named parameters the only way (like the way the Matrix struct in XNA has 16 named parameters (M11-M44))?

    Read the article

  • Java, filling arrays, and inheritance

    - by Arvanem
    Hi folks, I think I'm running into an inheritance conceptual wall with my Java arrays. I'm kind of new to Java so please tell me if I have things upside down. In essence, I want to do three things: Create a runnersArray with the attributes of my Runners class. Fill my runnersArray using my GenerateObjects method of my GenerateObjects class. Access the contents of my filled runnersArray in my Evaluating method of my Evaluating class. The problem seems to be that runnersArray is not visible to the methods in steps 2 and 3 above, but their classes (due to design reasons) cannot inherit or extend Runners class. Thanks in advance for any suggestions. Here are some code snippets showing what I'm trying to do: public class Runners extends Party { Runners[] runnersArray = new Runners[5]; } and public class GenerateObject extends /* certain parent class */ { public GenerateObject (int arrayNum) { runnersArray[arrayNum] = /* certain Runners attributes */; } } and public class Evaluating extends /*certain parent class*/ { public Evaluating (int arrayNum) { System.out.println(/* String cast attribute of runnersArray[arrayNum]*/; } }

    Read the article

  • Arrays in database tables and normalization

    - by Ivan Petrov
    Hi! Is it smart to keep arrays in table columns? More precisely I am thinking of the following schema which to my understanding violates normalization: create table Permissions( GroupID int not null default(-1), CategoryID int not null default(-1), Permissions varchar(max) not null default(''), constraint PK_GroupCategory primary key clustered(GroupID,CategoryID) ); and this: create table Permissions( GroupID int not null default(-1), CategoryID int not null default(-1), PermissionID int not null default(-1), constraint PK_GroupCategory primary key clustered(GroupID,CategoryID) ); UPD: Forgot to mention, in the scope of this concrete question we will consider that the "fetch rows that have permission X" won't be performed, instead all the lookups will be made by GroupID and CategoryID only Thoughts? Thanks in advance!

    Read the article

  • Arrays & Pointers

    - by Thomas
    Hi, Looking for some help with arrays and pointers and explanation of what I am trying to do. I want to create a new array on the heap of type Foo* so that I may later assign objects that have been created else where to this array. I am having troubles understanding what I am creating exactly when I do something like the following. Foo *(*f) = new Foo*[10]; Also once I have created my array how do I access each element for example. (f + 9)->fooMember(); ?????? Thanks in advance.

    Read the article

  • PHP Comparing 2 Arrays For Existence of Value in Each

    - by Dr. DOT
    I have 2 arrays. I simply want to know if one of the values in array 1 is present in array 2. Nothing more than returning a boolean true or false Example A: $a = array('able','baker','charlie'); $b = array('zebra','yeti','xantis'); Expected result = false Example B: $a = array('able','baker','charlie'); $b = array('zebra','yeti','able','xantis'); Expected result = true So, would it be best to use array_diff() or array_search() or some other simple PHP function? Thanks!

    Read the article

  • Efficiency of PHP arrays cast as objects?

    - by keithjgrant
    From what I understand, PHP objects are generally much faster than arrays. How is that efficiency affected if I'm typecasting to define stdClass objects on the fly: $var = (object)array('one' => 1, 'two' => 2); If the code doing this is deeply-nested, will I be better off explicitly defining $var as an objects instead: $var = new stdClass(); $var->one = 1; $var->two = 2; Is the difference negligible since I'll then be accessing $var as an object from there on, either way?

    Read the article

  • routine to generate a 2d array from two 1d arrays and a function

    - by intuited
    I'm guessing that there's a word for this concept, and that it's available in at least some popular languages, but my perfunctory search was fruitless. A pseudocode example of what I'd like to do: function foo(a, b) { return a * b // EG } a = [ 1, 2, 3 ] b = [ 4, 5, 6 ] matrix = the_function_for_which_I_search(foo, [a, b] ) print matrix => [ [ 4, 8, 12], [5, 10, 15], [6, 12, 18] ] // or function concatenate(a,b) return a.b } print the_function_for_which_I_search( concatenate, [ a, b ]) => [ [ '14', '24', '34'], ['15', '25', '35'], [16', '26', '36'] ] In other words, function_for_which_I_search will apply the function given as its first argument to each combination of the elements of the two arrays passed as its second argument, and return the results as a two-dimensional array. I would like to know if such a routine has a common name, and if it's available in a python module, cpan package, ruby gem, pear package, etc. I'm also wondering if this is a core function in other languages, maybe haskell or R?

    Read the article

  • Distance between numpy arrays, columnwise

    - by Jaapsneep
    I have 2 arrays in 2D, where the column vectors are feature vectors. One array is of size F x A, the other of F x B, where A << B. As an example, for A = 2 and F = 3 (B can be anything): arr1 = np.array( [[1, 4], [2, 5], [3, 6]] ) arr2 = np.array( [[1, 4, 7, 10, ..], [2, 5, 8, 11, ..], [3, 6, 9, 12, ..]] ) I want to calculate the distance between arr1 and a fragment of arr2 that is of equal size (in this case, 3x2), for each possible fragment of arr2. The column vectors are independent of each other, so I believe I should calculate the distance between each column vector in arr1 and a collection of column vectors ranging from i to i + A from arr2 and take the sum of these distances (not sure though). Does numpy offer an efficient way of doing this, or will I have to take slices from the second array and, using another loop, calculate the distance between each column vector in arr1 and the corresponding column vector in the slice?

    Read the article

  • Javascript array - merge two arrays into one

    - by estrar
    I have two arrays, one with name of the country and one with the currency type. I would like to merge these together and use the country key instead of the currencies array. What would be the best way to accomplish this? This is what my code looks like now: var country = new Array(); country["SEK"] = 'Sweden'; country["USD"] = 'United states'; var currencies = ["SEK","USD"]; var options = ''; for (var i = 0; i < currencies.length; i++) { options += '<option value="' + currencies[i] + '" id="' + currencies[i] + '">' + currencies[i] + ' (' + country[currencies[i]] + ')</option>'; }

    Read the article

  • ruby: sum corresponding members of two arrays

    - by jjnevis
    I've got two (or more) arrays with 12 integers in each (corresponding to values for each month). All I want is to add them together so that I've got a single array with summed values for each month. Here's an example with three values: [1,2,3] and [4,5,6] = [5,7,9] The best I could come up with was: [[1,2,3],[4,5,6]].transpose.map{|arr| arr.inject{|sum, element| sum+element}} #=> [5,7,9] Is there a better way of doing this? It just seems such a basic thing to want to do.

    Read the article

  • C# Object Array CopyTo links both arrays' values?

    - by Dutchie432
    Okay, I have what I think is a simple question.. or just a case of me being a C# beginner. I have an array of custom objects (clsScriptItem) that I am populating from a database. Once the items are loaded, I want to back them up to "backup" array so I can revert the information back after changing the main array. However, when I use CopyTo to copy the array and then alter the original array, the backup array is also being altered... I though CopyTo merely copied values + structure from one array to another. private void backupItems() { lastSavedItems = new clsScriptItem[items.Length]; items.CopyTo(lastSavedItems, 0); //items[0].nexts[0] is 2 //lastSavedItems[0].nexts[0] is 2 items[0].nexts[0] = "-1"; //items[0].nexts[0] is -1 //lastSavedItems[0].nexts[0] is also -1 } How do I backup this data without having the two arrays be 'linked'??

    Read the article

  • Using Large Arrays in VB.NET

    - by Tim
    I want to extract large amounts of data from Excel, manipulate it and put it back. I have found the best way to do this is to extract the data from an Excel Range in to a large array, change the contents on the array and write it back to the Excel Range. I am now rewriting the application using VB.NET 2008/2010 and wish to take advantage of any new features. Currently I have to loop through the contents of the array to find elements with certain values; also sorting large arrays is cumbersome. I am looking to use the new features, including LINQ to manipulate the data in my array. Does anybody have any advice on the easiest ways to filter / query, sort etc. data in a large array. Also what are the reasonable limits to the size of the array? ~Many Thanks

    Read the article

  • making arrays from tab-delimited text file column

    - by absolutenewbie
    I was wondering if anyone could help a desperate newbie with perl with the following question. I've been trying all day but with my perl book at work, I can't seem to anything relevant in google...or maybe am genuinely stupid with this. I have a file that looks something like the following: Bob April Bob April Bob March Mary August Robin December Robin April The output file I'm after is: Bob April April March Mary August Robin December April So that it lists each month in the order that it appears for each person. I tried making it into a hash but of course it wouldn't let me have duplicates so I thought I would like to have arrays for each name (in this example, Bob, Mary and Robin). I'm afraid to upload the code I've been trying to tweak because I know it'll be horribly wrong. I think I need to define(?) the array. Would this be correct? Any help would be greatly appreciated and I promise I will be studying more about perl in the meantime. Thank you for your time, patience and help. #!/usr/bin/perl -w while (<>) { chomp; if (defined $old_name) { $name=$1; $month=$2; if ($name eq $old_name) { $array{$month}++; } else { print "$old_name"; foreach (@array) { push (@array, $month); print "\t@array"; } print "\n"; @array=(); $array{$month}++; } } else { $name=$1; $month=$2; $array{month}++; } $old_name=$name; } print "$old_name"; foreach (@array) { push (@array, $month); print "\t@array"; } print "\n";

    Read the article

  • Passing Variable Length Arrays to a function

    - by David Bella
    I have a variable length array that I am trying to pass into a function. The function will shift the first value off and return it, and move the remaining values over to fill in the missing spot, putting, let's say, a -1 in the newly opened spot. I have no problem passing an array declared like so: int framelist[128]; shift(framelist); However, I would like to be able to use a VLA declared in this manner: int *framelist; framelist = malloc(size * sizeof(int)); shift(framelist); I can populate the arrays the same way outside the function call without issue, but as soon as I pass them into the shift function, the one declared in the first case works fine, but the one in the second case immediately gives a segmentation fault. Here is the code for the queue function, which doesn't do anything except try to grab the value from the first part of the array... int shift(int array[]) { int value = array[0]; return value; } Any ideas why it won't accept the VLA? I'm still new to C, so if I am doing something fundamentally wrong, let me know.

    Read the article

  • Evaluating Javascript Arrays

    - by FailBoy
    I have an array that contains an array of arrays if that makes any sense. so for example: [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]] I want to see whether an array exists withing the array, so if [1, 2, 3] is duplicated at all. I have tried to use the .indexOf method but it does find the duplicate. I have also tried Extjs to loop through the array manually and to evaluate each inner array, this is how I did it: var arrayToSearch = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]; var newArray = [1, 2, 3]; Ext.each(arrayToSearch, function(entry, index){ console.log(newArray, entry); if(newArray == entry){ console.log(index); }; }); This also does not detect the duplicate. the console.log will output [1, 2, 3] and [1, 2, 3] but will not recognize them as equal. I have also tried the === evaluator but obviously since == doesn't work the === wont work. I am at wits end, any suggestions.

    Read the article

  • most efficient method of turning multiple 1D arrays into columns of a 2D array

    - by Ty W
    As I was writing a for loop earlier today, I thought that there must be a neater way of doing this... so I figured I'd ask. I looked briefly for a duplicate question but didn't see anything obvious. The Problem: Given N arrays of length M, turn them into a M-row by N-column 2D array Example: $id = [1,5,2,8,6] $name = [a,b,c,d,e] $result = [[1,a], [5,b], [2,c], [8,d], [6,e]] My Solution: Pretty straight forward and probably not optimal, but it does work: <?php // $row is returned from a DB query // $row['<var>'] is a comma separated string of values $categories = array(); $ids = explode(",", $row['ids']); $names = explode(",", $row['names']); $titles = explode(",", $row['titles']); for($i = 0; $i < count($ids); $i++) { $categories[] = array("id" => $ids[$i], "name" => $names[$i], "title" => $titles[$i]); } ?> note: I didn't put the name = value bit in the spec, but it'd be awesome if there was some way to keep that as well.

    Read the article

  • jQuery arrays - newbie needs a kick start

    - by Jonny Wood
    I've only really started using this site and alredy I am very impressed by the community here! This is my third question in less than three days. Hopefully I'll be able to start answering questions soon instead of just asking them! I'm fairly new to jQuery and can't find a decent tutorial on Arrays. I'd like to be able to create an array that targets several ID's on my page and performs the same effect for each. For example I have tabs set up with the following: $('.tabs div.tab').hide(); $('.tabs div:first').show(); $('.tabs ul li:first a').addClass('current'); $('.tabs ul li a').click(function(){ $('.tabs ul li a').removeClass('current'); $(this).addClass('current'); var currentTab = $(this).attr('href'); $('.tabs div.tab').hide(); $(currentTab).show(); return false; }); I've used the class .tag to target the tabs as there are several sets on the same page, but I've heard jQuery works much faster when targetting ID's How would I add an array to the above code to target 4 different ID's? I've looked at var myArray = new Array('#id1', 'id2', 'id3', 'id4'); And also var myValues = [ '#id1', 'id2', 'id3', 'id4' ]; Which is correct and how do I then use the array in the code for my tabs...?

    Read the article

  • How are two-dimensional arrays formatted in memory?

    - by Chris Cooper
    In C, I know I can dynamically allocate a two-dimensional array on the heap using the following code: int** someNumbers = malloc(arrayRows*sizeof(int*)); for (i = 0; i < arrayRows; i++) { someNumbers[i] = malloc(arrayColumns*sizeof(int)); } Clearly, this actually creates a one-dimensional array of pointers to a bunch of separate one-dimensional arrays of integers, and "The System" can figure you what I mean when I ask for: someNumbers[4][2]; But when I statically declare a 2D array, as in the following line...: int someNumbers[ARRAY_ROWS][ARRAY_COLUMNS]; ...does a similar structure get created on the stack, or is it of another form completely? (i.e. is it a 1D array of pointers? If not, what is it, and how do references to it get figured out?) Also, when I said, "The System," what is actually responsible for figuring that out? The kernel? Or does the C compiler sort it out while compiling?

    Read the article

  • Merging two arrays in PHP

    - by Industrial
    Hi everyone, I am trying to create a new array from two current arrays. Tried array_merge, but it will not give me what I want. $array1 is a list of keys that I pass to a function. $array2 holds the results from that function, but doesn't contain any non-available resuls for keys. So, I want to make sure that all requested keys comes out with 'null':ed values, as according to the shown $result array. It goes a little something like this: $array1 = array('item1', 'item2', 'item3', 'item4'); $array2 = array( 'item1' => 'value1', 'item2' => 'value2', 'item3' => 'value3' ); Here's the result I want: $result = array( 'item1' => 'value1', 'item2' => 'value2', 'item3' => 'value3', 'item4' => '' ); It can be done this way, but I don't think that it's a good solution - I really don't like to take the easy way out and suppress PHP errors by adding @:s in the code. This sample would obviously throw errors since 'item4' is not in $array2, based on the example. foreach ($keys as $k => $v){ @$array[$v] = $items[$v]; } So, what's the fastest (performance-wise) way to accomplish the same result?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >