Whats the easiest way to take an integer in C# and convert it into an array of length equal to the number of digits and each element is a digit from the integer?
EG. If I had the integer 12345 I want to convert it to an array like so {1, 2, 3, 4, 5}
Thanks
AL
hi all,
I'm looking for a cheap (and by extension simple) circuit.
i have a special pot (Piher's 10mm hex PT-10) that can't be changed. the pots can be physically changed but i have to use this type. the series has a 150mw power rating, with resistances of ...
Well, the title pretty much sums up my question.
public static int[] removeDuplicates(int[] x)
{
for (int i = 0; i < x.length; i++)
{
for (int j = i + 1; j < x.length; i++)
{
if (x[i] == x[j])
System.out.print("Found a duplicate!");
}
}
}
I...
Hi guys,
I need to create an array in c++. But before I declare how many elements are in the array I want to prompt the user for input. I want to ask the user how many elements do they want in the array.
What ever the user said, 5 or 20. I then want to enter these 5 values or 20 values...
int[] aCopy = new int[a.length];
for (int i = 0; i < a.length; i++)
aCopy = a;
Is this the way to 'copy' an array? Basically, I want the elements inside the the array [I]a to be copied or assigned to the array [I]aCopy.
Hello,
I am working on a Fortran 77 program for my computational physics course in which
the program is an averaging of distances walked by a number of walkers for an nth step.
I have started the calculations of the program by having an input seed generate a sequence
of pseudo-random numbers...
Homework Statement
Write a program to read an array of elements and interchange each element with the next one in the following manner:-
Example:-
Input:1 2 3 4 5
Output:21435
Homework Equations
The Attempt at a Solution
I have almost reached the solution but i am still...
Generating a Random Number from an array for a blackjack simulator--Matlab
I have a homework problem where I have to generate a single hand of blackjack to a player and allow the player to hit or hold. I'm ahving trouble generating the random card.
My attempt:
x =...
Welcome all,
I have a following code:
program aaaa
implicit none
double precision, dimension(:), allocatable :: inp,outp
integer ::n,i
read(*,*) n
allocate(inp(n),outp(n))
write(*,*) allocated(inp), allocated(outp)
write(*,*) inp(1)
inp=cshift(outp,-size(outp)/2)...
Homework Statement
I need to create a loop that asks the user to input double numbers into an array. The number of elements in the array is not predefined; the user will continue to enter numbers as long as they wish until a NEGATIVE number is entered, at which point the control will exit...
I have been trying to get qsort to sort the rows of a 2d array I read in from a data file, and I have not been having much success to get it to do what I want.
My array is a 4xarraysize array, where arraysize is the number of columns read in from a data file, with four entrees per row. I...
I am VERY new to this, i am trying to start a pseudo code write where i need to make an array. I have my flowchart done (at least i think i do ) but i am not sure how to actually start the code. The examples my teacher had are confusing and he is not answering my emails. I have to write pseudo...
Homework Statement
struct student
{
char name[20];
int id;
float gpa;
};
student a[20];
Homework Equations
insert another element into the array a.
The Attempt at a Solution
#include<iostream>
using namespace std;
#include <stdio.h>
#include <string.h>...
hello,
since a while my mind is caught by an idea. This idea is concerned with underwater sound massage system.
For this purpose i would like to build an array of underwater sound transducers, which can all be steered individually (to do a coarse beam forming).
However, since i am...
supposed to reverse an array of strings recursively. this is in a class that has an array object.
i came up with what's below. but it reverses the array in a weird order. the array is a 5 element array, the elements are {hello, how, are you, ?}. i passed in the object and after printed out...
I know that it's often considered better practice to use C's "typed constants" instead of "#define" as it may offer better error/type checking. I'm wondering however what happens if a const is used to declare the size of an array. For example consider the two possible methods below.
#define...
hi every one ,
i am new in data structure course
i need help in this :
Struct Person
{
Char name[20];
int id;
float gpa;
};
Person student[5];
Compute the addresses of all the elements of array student and show a memory layout for the array if the address of the first...
Hi
I have an array going from 0 to n (where n has been previously defined) but I want the array to be in steps of 5 rather than increasing each value by 1
eg 0,5,10,15,20,25...n
how can I do this?
Thanks
Replacing specific array elements in IDL - solved!
Hi
I was just wondering if there was any way, other than using FOR loops, to replace specified elements of an array?
For example, say A is a 1D array of 50 elements, each equal to 1.0. Is it possible to change say elements 0-9 and 30-49...
I'm trying to understand a sorting algorithm (selection sort, to be exact). I started out with this:
public static void selectionSort1(int[] x) {
for (int i=0; i<x.length-1; i++) {
for (int j=1; j<x.length; j++) {
if (x[i] > x[j]) {
//... Exchange...
Dear please read this exercise and the codes and tells me what wrong with you codes
Part 1
You are provided with a skeleton program, where the data is stored in arrays. Your task is to add the code that will do the following:
Examine the data in the arrays. The data shows the results from...
This is not a homework, too old for that! I just have a question that I create myself. All the books only show the pattern that is more obvious...they show either the E or the H pattern. I took an exercise that asked for the H pattern, in turn, using the pattern multiplication to try to find the...
Hello.
I've got an idea to build a plot in real time. What i want to do:
1) I've got a row (array) of numbers
2) for these numbers i calculate values of the expression i want to plot, put them into array,
3) use list plot or smth like that with the row and the array.
The question is : how...
Is it possible to increase the size of an already allocated array in FORTRAN, without reallocation?
e.g. if in start A(3)=[4, 5, 6] and now I want something like A(4)=[4, 5, 6, 7].
Currently I am using a temporary array to do this
allocate(A(3))
A=(/4, 5, 6/)
allocate(temp(3))
temp=A...
I am getting compilation errors in the following segment of my code:
_underlyingStorage was declared in the following way: private T[] _underlyingStorage = (T[]) new Object[128];
public T next() {
_currentIndex++;
if(_underlyingStorage[_currentIndex] ==...
I need to create an empty array but the length of the array is determined by the start and end numbers entered by the user
for example if the range of numbers the user was interested in was 4-10 inclusive then i want the array to be of length 7
How to I go about doing this?
Other...
Hello!
I have a difficult problem I have been working with recently. I have been trying to model the ever changing position of a solar PV array system. The system is a single axis tracker and orientates itself to have the smallest angle of incidence(AOI) to the suns beam as possible (the best...
I was wondering if anyone knows a fast method of finding the maximum value in a Cuda C array. I can't get max_element to work, but not sure its very fast anyways. I know I could do a for loop, but for an array with 100,000+ elements (smallest cases) it takes a lot of time (plus it has to...
Homework Statement
Define an array with 100 integer values, and fill the array with random numbers in the range from 0-99. Then write a function named split () that reads the array and places numbers from 0-50 and another array that places numbers from 50 to 99.
I wrote this code which...
Hey peeps,
I was bored the other day and wanted to paint something, so I started tweaking images in mathematica to make them eaiser to paint/draw and I came across de jong attractors and the following http://flam3.com/flame.pdf" .
Basically I immediately remembered I had forgotten most of...
I'm a Matlab newbie. I have an array of strings, for example:
header = {'Fred', 'Tom'}
When I do:
header(1)
I get 'Fred'
I want to be able to change elements--for example:
header(1) = 'Jill'
But I get this error:
? Conversion to cell from char is not possible.
I would be...
Hi All,
Sorry to bother anyone, but I have run into a inheritance problem.
I have a base class which contains a member variable of array type, and an abstract method. Subsequently I created a sub class which derived from the base class. And I provide implementation for the abstract methods...
Hello!
I was hoping someone on this board might be able to point me in the right direction to solve my problem. I am trying to determine how the tilt angle (from the horizontal) and azimuth of a solar array changes as the array rotates around a fixed axis running from north to south.
The...
Well the issue here is that I will have 21 numerical values written into one array,but then goes iterative procedure and get 21 values for model 2.How to write l(m0),l(m1)?I will need these arrays later for calculations.
I have the following function
function [W] = calcw(k1,k2,d,x)
if x<d
W = k1*x;
elseif x>=d
W = k1*x+2*k2*(x-d);
end;
save('varw.mat');
with the following script
k1 = 10e4;
k2 = 1.5e4;
d = 0.1;
x = 0:0.01:0.3;
weight = calcw(k1,k2,d,x);
plot(weight,x);
but...
help me with this vector program
i want to create a program that will have an arraycalled array1[] of 30 sets of 3 one digit numbers i.e 804, 450,430 etc)
i will have 13 vector containersor arrays defined with a series of 3 one digit numbers. i want the program to find any series of numbers...
Hi All,
does anyone know of a mathematica function that efficiently circularly shifts all array elements?
e.g.
{1,2,3,4,5} -> {4,5,1,2,3}
without iterating? The reason I ask is because I have a huge data set I'm working with and right now iterating through is very processing intensive...
Hello everybody
Basically as the topic states: How can you calculate "The spatial wavelength of a Halbach array" (symbol lambda)?
Context:
The reason I ask is that since I've got bored during my easter holidays I decided to try a wee science project and try and make a model of an...
We have a sensor in the lab that measures two quantities and uses two different sampling rates. All four of these vectors are saved into the same text file. How can I load this into MATLAB when it is non-rectangular?
Thanks for your help.
Homework Statement
Input a list of n integer values into a 1-D array and do the following:
• determine and output the number of positive values and the number of negative values
• update the array values as follow
• if the value is located at an even-numbered subscript, replace the value by...
Greetings,
I am rather clueless about this stuff so I'll leave it to you guys to come up with any bright ideas for this. I'm building an array of LED's for my high school that flash to music. I'm using a TIP31C transistor to get this effect. My problem is they're wanting a 1 foot by 1 foot...
Hello,
I have a list {a,b,c,d}
and i want a array of the form:
{{a,b},{b,c},{c,d}}
I think it is easy, but I'm new in mathematica and I don't know what funtion to use.
Thanks.
Hi intelligent people,
Forgive me for a silly question, but I am really new to Mathematica and thus I need your help for my own research (I am done constructing NIntegrate values for some "non-integrable" functions, involving multiple steps, and I am kinda stuck at the last step. Here is the...
Hi,
I have a rather large program written in fortran 77/90. In one of the subroutines a lot of local dynamic arrays are declared.
In order to make this program able to calculate more stuff, I need to bring these dynamic arrays back into the main program.
I have tried to define the...
Hi. I'm trying to make a pointer point to sections of a rank-2 array given by specific values of
it's second index. I other words: given a table I wan't a pointer to point to specific columns, making of it a "filtered" table.
The method I was trying was like
DOUBLE PRECISION...
Homework Statement
An infinite array of identical 1-microFarad capacitors are arranged in a grid setup, where junctions are between capacitors, and each junction is connected to 4 other junctions separated by another capacitor.
The array is initially uncharged. A battery is connected...
I'm trying to input a .txt file with a variable number of rows and 3 columns into an array. The first row is just a single number expressing the remaining number of rows. so we have something like this
3
3 5.12 3
5.3 3 5
4 3 4
All the individual numbers are separated by spaces. So far...