arrays

Quickest way to find missing number in an array of numbers

I have an array of numbers from 1 to 100 (both included). The size of the array is 100. The numbers are randomly filled in the array but there is one random slot empty in the array. What is the quickest way to find that slot as well as the number that should be put in the slot? A java solution is preferable. ...

compare int arrays for 'similarity' - more accurate than weighted average?

say there is a number of arrays with length 12, containing signed integers in a range of roughly ±100, how can i compare the 'signature' or 'harmonic content' of these arrays to each other, in a way that is more accurate than a simple weighted average? Would i have to look into neural networks (if this even would be suitable, i don't kn...

How do I check if an object contains a byte array?

I'm having an issue with the following code. byte[] array = data as byte[]; // compile error - unable to use built-in conversion if (array != null) { ... I only want to assign the data to array variable if the data is actually a byte array. ...

Order include file depending on inherit

Hi there people and greetings from Sweden! I have a really tricky problem here. I'll try to show exactly what I mean. I'm building a modulebased CMS, and some modules inherit from a parent module. My problem is that the parent modules need to be included before the "children". I fetch moduleinfo from a XML file and store it in an arra...

Initializing Constant Static Array In Header File

Hi, I have just found out that the following is not valid. //Header File class test { const static char array[] = { '1', '2', '3' }; }; Where is the best place to initialize this? Thanks in advance; ...

Display JSON array in a list

Hi guys, Can someone help me with this? I hope so... Well, I'm struck for displaying that JSON array in a HTML list : [{"foo":"30000","bar":"Nimes"},{"foo":"30100","bar":"Ales"},{"foo":"30110","bar":"Branoux Les Taillades"},{"foo":"30110","bar":"La Grand Combe"},{"foo":"30110","bar":"La Levade"},{"foo":"30110","bar":"Lamelouze"},{"foo":...

How to get A-B in PHP?

$arr1=array(23,43,54); $arr2=array(34,23,3456,43,11,54); I want to get elements of $arr2 that's not in $arr1 ...

Output array elements randomly with PHP

How could I echo 5 elements randomly from an array of about 20? Thanks. ...

How to Use LLIST *mylist[N];

I get this: LLIST *mylist[N]; Where N is the number of rows of the input file. Then mylist[i] is a pointer to the ith linked list. I call a function LLIST *list_add(LLIST **p, int i){ LLIST *n; n = (LLIST *) malloc(sizeof(LLIST)); if (n == NULL) return NULL; n->next = *p; /* the previous element (*p) now ...

PHP: Problem merging arrays

OK I have this function (I got as the answer to this question) that merges an array like so: Functions function readArray( $arr, $k, $default = 0 ) { return isset( $arr[$k] ) ? $arr[$k] : $default ; } function merge( $arr1, $arr2 ) { $result = array() ; foreach( $arr1 as $k => $v ) { if( is_numeric( $v ) ) { ...

Directory to array with PHP

Whats the most efficient way of turning the filenames in a directory into an array of strings? Thanks. ...

PHP/Krumo: accessing arrays within arrays?

I'm using krumo to output data from a page, all the data is accessible through the $page variable. I have a field called customer with the following structure: customer (Array, 1 element) 0 (Array, 1 element) id (String, 2 characters ) 85 How do i actually access id? I've tried $page->customer->id but it doesn't work. On...

Referring to: How to Use LLIST *mylist[N];

This does work LLIST *mylist[10] = {NULL}; But would if I wanted to do this I get errors: int x=10; LLIST *mylist[x] = {NULL}; x can be any value I'm setting it to 10 for the time being. x is going to be used as a counter. ...

Excel VBA Programming with Arrays: To Pass them or Not To Pass them?

Question: I am wondering which is the optimal solution for dealing with Arrays in Excel 2003 VBA Background: I have a Macro in Excel 2003 that is over 5000 lines. I have built it over the last 2 years adding new features as new Procedures, which helps to segment the code and debug, change, or add to that feature. The downside is tha...

Java: Expanding array size, can't seem to keep all values in original locations.

For my current homework, I'm trying to sort my array through a generic class as the user inserts values into its locations. When the size reads as fully loaded, the array class calls in an expansion method that increases the size of the array while retaining its values in proper locations, which I followed from my Professor's note. For s...

Still problems with LLIST *mylist[x]

So I have... int x; LLIST *mylist[x]; x =10; bzero(mylist, sizeof(LLIST *)*x); this does not seem to be a valid solution.. I did add the -std=c99 to my make file, just this alone did not work which is why emil suggested the above approach, because I had originally: int x=10; LLIST *mylist[x] = {NULL}; My make file lo...

How to push both value and key into array with php

$GET = array(); $key = 'one=1'; $rule = explode('=',$key); /* array_push($GET,$rule[0]=>$rule[1]); */ I'm looking for something like this so that: print_r($GET); /*output:*/ $GET[one=>1,two=>2,...] is there a function to do this (because array_push won't work this way). thanks! ...

AS3: Compare Two Arrays, Get Uncommon Values

I have a simple problem that I'm having trouble thinking around: var oldValues : Array = [ 4, 5, 6 ]; var newValues : Array = [ 3, 4, 6, 7 ]; I want to get the values from newValues that aren't in oldValues - 3, 7 I want to get the values from oldValues that aren't in newValues - 5 A way of getting both sets of values together would ...

Call a function if a variable contains any items in an array?

How can i call a javascript function if a string contains any of the items in an array()? Yes, i can use jquery :) ...

Array of all subjects.

Hello, i want two arrays first one of all subjects and the second of all degrees which study in all universities (all over the world) But a big problem is that i dont know how many subjects and how many degree are there.? (in all over the world) I just want two array the remaining logic i have made already. All subject array ...