## array

# 1
02-25-2008
array

If I am given an array which contains 10 positive intergers, how to write in Unix shell returning any two numbers which sum up as 10, how about in perl which is easier
Thanks
 ccp View Public Profile for ccp Find all posts by ccp
# 2
02-25-2008
Probably an easier way, but this will work:
Just change the numbers inside the list to play around with it.
 matt.d View Public Profile for matt.d Find all posts by matt.d
# 3
02-25-2008
But I would assume I don't know any intergers in the array
so I need to make sure no intergers is last than 10, if so, the game is over,
if not, we can use double loop? how about if we don't know how many numbers in array ( not necessarily 10)
 ccp View Public Profile for ccp Find all posts by ccp
# 4
02-26-2008
Quote:
Originally Posted by ccp
But I would assume I don't know any intergers in the array
so I need to make sure no intergers is last than 10, if so, the game is over,
if not, we can use double loop? how about if we don't know how many numbers in array ( not necessarily 10)
You are not explaining your situation very well. Have you written any code yet to try and figure this out? How is the array going to be populated with numbers? Can there be duplicates in the array so you can have combinations like 5 + 5 = 10? Can there be many duplicates in the array so you can have something like 5 + 5 = 10 many times? Try and clarify your question or expect answers that are very general in nature.

## Help reading the array and sum of the array elements

Hi All, need help with reading the array and sum of the array elements. given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large. Input Format The first line of the input consists of an...

## Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (...

## Pass array to a function and display the array

Hi All I have multiple arrays like below. set -A val1 1 2 4 5 set -A val2 a b c d . . . Now i would like to pass the individual arrays one by one to a function and display/ do some action. Note : I am using ksh Can you please advise any solution... Thanks in advance.

## Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do...

## PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if \$datevar is present in \$filename. If so, i need to replace \$filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance.

## Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I...

## perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the...

## PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array...

## Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ...

## create array holding characters from sring then echo array.

Hi, I wish to store \$string1 in \$string1array a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: ...