Array Definition and 481 Threads
-
C
C Programming: freeing array of structs causes heap overflow
Homework Statement Error: warning: HEAP[Happy Birthday.exe]: warning: Heap block at 006E15A8 modified at 006E1688 past requested size of d8 My Struct: struct student { // Defines a student. char firstName[NAMELENGTH], lastName[NAMELENGTH]; int day, month, year; }; My Code...- cubanmissile
- Thread
- Array C programming Programming
- Replies: 5
- Forum: Engineering and Comp Sci Homework Help
-
R
Strength of magnets in an array
Hello all, I need to make a magnetic surface using neodymium disc magnets... the purpose for the surface is to hold on to a sheet of ferrous material, as strongly as possible. I tend to want to assume that a checkerboard array would be best... alternating the poles of the magnets in the...- RyderS
- Thread
- Array Magnets Strength
- Replies: 1
- Forum: Electromagnetism
-
Z
Reading .txt files to an array in C language
I have a .txt file with 100,000 integers from 1-100,000, with each integer in a newline. I am facing a problem in using the fgets function. How do I read the integers into an array? #include <stdio.h> //Program to count number of inversions in an input file of integers using Brute force...- zorro
- Thread
- Array C language files Language Reading
- Replies: 11
- Forum: Programming and Computer Science
-
T
Fortran Creating 2-d array from a text file in fortran
I have a text file of the format x1 y1 x2 y2 . . . . . . I need to read this into an array. How is this done in Fortran?- tcmoore3
- Thread
- Array File Fortran Text
- Replies: 1
- Forum: Programming and Computer Science
-
Q
How to replace zeros in a matrix by elements of an array in Matlab?
Homework Statement I have a matrix that contains zeros but it may contain also ones. For example: ID=[1 0 0 0; 0 0 0 0; 1 0 1 1] I'm trying to replace all the ones by zeros and all the zeros by elements of an array EA going...- quetzal
- Thread
- Array Elements Matlab Matrix
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
S
Fortran FORTRAN-Passing array to subroutine-segmentation fault
Hi all ! I am new to fortran. Please see the following code. It is a simple code to pass an array to a subroutine and print it, but doesn't behave that way: program exp_realloc implicit none integer,allocatable,dimension(:,:):: array integer::i,j...- shitij
- Thread
- Array Fault
- Replies: 5
- Forum: Programming and Computer Science
-
S
Sum of Pascal Array Problem Homework
Homework Statement I need to write a program which calculates the sum of all the numbers of an array of unknown length. The input of a[i] ends when a's value is the letter 'D'. Homework Equations The Attempt at a Solution program homework; uses wincrt; var a:array[1..100] of integer; S...- shinokk
- Thread
- Array Pascal
- Replies: 26
- Forum: Engineering and Comp Sci Homework Help
-
S
Mathematica Mathematica array plot won't plot and it erases all of my stored variables
Hi, I wrote some code on a computer at school. dim = 50; Ediff = ConstantArray[0, {dim, dim}]; \[Lambda] = .5; steps = 10; Ediff = ConstantArray[0, {dim, dim}]; L = 1; For[xs = 1, xs <= dim, xs++, For[ys = 1, ys <= dim, ys++, Ediff[[xs, ys]] = Ediff[[xs, ys]] +...- swooshfactory
- Thread
- Array Mathematica Plot Variables
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
Finding Array Element Index in Java?
Homework Statement If I am given a regular, single dimensional array in Java, how do I search for an element in it, and then how do I get the index of that element? I have been trying: int largest; //some number that has been predetermined in earlier code int index3 =...- stripes
- Thread
- Array Index
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
S
Fortran Fortran error: Big array size, solution?
Hi everybody; I'm not programmer or computer expert, but during working with my thesis got serious problem with my program seemingly about big size of matrices. I'm working with meshes and using Fortran to analyze entire of my mesh including nodes and elements. The biggest size of my matrix has...- Sarahberg
- Thread
- Array Error Fortran
- Replies: 3
- Forum: Programming and Computer Science
-
K
Returning values in array in c
#include<stdio.h> #include<conio.h> float average(float[],float ); float highest(float[],float ); float lowest(float[], float ); void main (void) { float temper[15]; float x,n, y, z; int day; clrscr(); printf("enter the no.days to read temperature for=\n"); scanf("%d",&n)...- konvictx
- Thread
- Array
- Replies: 4
- Forum: Programming and Computer Science
-
L
Fortran Fortran - Allocate array in subroutine
I try to write a small program to allocate a variable in small subroutine and I've passed it, now i allocate array in a loop or many loops but i don't have any ideas about it. Has anyone done like me , can share some experiences ??- luonganh89
- Thread
- Array Fortran Subroutine
- Replies: 6
- Forum: Programming and Computer Science
-
How to store large rank-4 array to file?
I am writing a code to calculate and to operations with a large set of matrix elements, indexed by four numbers. I am also writing these subroutines within a much larger code structure, so I do not have total freedom to modify the objects I am using. I am trying something like this, which...- gluons
- Thread
- Array File
- Replies: 1
- Forum: Programming and Computer Science
-
S
Reading a two-dimensional array in namelist, f90
I'd like to create some test data to read 2-dim arrays in f90 with namelists. Suppose I have this in the main program: integer, dimension(2,3) array_in, array_out namelist /WW_ARRAY/ array_in, array_out ... Open(unit=WW_ARRAY_infile, file="WW_ARRAY_in.dat", status =...- solarblast
- Thread
- Array Reading
- Replies: 7
- Forum: Programming and Computer Science
-
A
Comp Sci 90 degree rotation of a 2D array in c++
Homework Statement I am trying to rotate a 2D array of type string. I am not sure what the problem is with my function. Flipping does occur but for some reason, it's not by 90. Homework Equations The Attempt at a Solution The program consists of a function and the main. Here's...- Absolutism
- Thread
- 2d Array C++ Degree Rotation
- Replies: 15
- Forum: Engineering and Comp Sci Homework Help
-
A
Comp Sci Transfering data from a text file into a 2D vector array in c++
Homework Statement I am attempting to transfer the data from a file into a 2D vector array. The data look like this: 1 2 3 4 5 6 7 8 9 However, the dimensions must be detected dynamically. Homework Equations The Attempt at a Solution There are two files in this code, but I attempted to...- Absolutism
- Thread
- 2d Array C++ Data File Text Vector
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
T
Pascal's Triangle: Pointers and Dynamic Memory Allocation
Here is the given problem. I have a question for part c and e. Calculate and print first 12 rows of the famous Pascal triangle, as shown below. Each number is the sum of the two numbers immediately above it. As our intent is to practice pointers, functions, loops, and dynamic memory...- TheSourceCode
- Thread
- Array Pointers
- Replies: 2
- Forum: Engineering and Comp Sci Homework Help
-
S
Convert symbolic equation to 6x5 double array (Question simplified)
Hi. I perform huge computations worth 70 lines. After those 70 lines, i have these equations in my internal memory. %(stored internally) Wnet=(99*((57443*((4018*y*(66875/(57036*x))^(2528214091580831/18014398509481984))/5 - (57443*y)/50 + (2894969*x^(200/623))/50))/(50*((57443*y)/50 -...- sgvaibhav
- Thread
- Array Convert
- Replies: 1
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
C/C++ C++ array with variable no. of elements?
#include <iostream> using namespace std; int a; int main() { cin >> a; int c [a]; for (int i = 1;i!=a+1;i++) { c [i] = i; } for (int i = 1;i!=a+1;i++) { cout << c [i] << endl; } return 0; } This compiles and does exactly what it's supposed to. But wait...- Whovian
- Thread
- Array C++ Elements Variable
- Replies: 8
- Forum: Programming and Computer Science
-
Fortran Fortran complex array assignment
I have a an array of type complex. I am trying to assign a value to it in a loop, but I get a strange error "Unclassifiable statement at (1)". I really don't understand why. do t = 1, count real(in(t)) = cos(2 * pi * f0 * t) aimag(in(t))=sin(2 * pi * f0 * t) end do thanks.- xaratustra
- Thread
- Array Assignment Complex Fortran
- Replies: 4
- Forum: Programming and Computer Science
-
J
Comp Sci Why Does My C++ Array Program Give a Cannot Convert Double to Double Error?
Homework Statement I am not completely finished with the assignment, but I was trying to test to make sure that my functions "low" and "high" would in fact return the proper value (the lowest number in the array, and the highest number in the array, respectively). However, when I compile, I...- Joe_K
- Thread
- Array C++ Program Urgent
- Replies: 8
- Forum: Engineering and Comp Sci Homework Help
-
P
Infinitely many primes in every row of array
I asked this question on one another forum but didn't get any answer . Consider the following array of natural numbers : \begin{array}{ccccccccc} 1 & 2 & 4 & 7 & 11 & 16 & 22 & 29 & \ldots \\ 3 & 5 & 8 & 12 & 17 & 23 & 30 & 38 & \ldots \\ 6 & 9 & 13 & 18 & 24 & 31 & 39 & 48 & \ldots...- pedja
- Thread
- Array Primes Row
- Replies: 7
- Forum: Linear and Abstract Algebra
-
V
Fortran Read array from a file in Fortran
Hi every one. I had try to make a simple program but it doesn't work because i am an amateur The program as following: PROGRAM: Sum_row_n_col ! ! PURPOSE: Read the 2-rank array from input disk file and calculate sums of all of the data in each row and each column in the array. ...- volcano5683
- Thread
- Array File Fortran
- Replies: 4
- Forum: Programming and Computer Science
-
T
GNU Scientific Library determinant of complex array help
So I suck at programming, but I need to find the determinant of a complex 6x6 array using GSL in C (not GSL complex, complex.h complex). Here is what has failed so far starting with a 6x6 double complex array named mymatrix: gsl_matrix_complex_view m = gsl_matrix_complex_view_array(mymatrix, 6...- tosburn3
- Thread
- Array Complex Determinant Scientific
- Replies: 10
- Forum: Programming and Computer Science
-
T
Pressure drop across an array of different nozzles?
I have a question about calculating the pressure drop in a large flow meter across an array of nozzles. Basically its inside of a tunnel... air flows in this tunnel until it reaches a "gate" which is blocked off except for six nozzles of different size, which discharge back into an open...- tectactoe
- Thread
- Array Drop Pressure Pressure drop
- Replies: 2
- Forum: Mechanical Engineering
-
A
Image array processing, need function ideas
I want to write a code for a MCU, the MCU will output an image to a TFT screen, and here is the tricky part: I want to make the final display to mimic old CRT, which means it will shrink, skew, and out of sync randomly, and the image will be constantly shaking. I hope the FPS would be 60...- Alex_Sanders
- Thread
- Array Function Ideas Image Processing
- Replies: 7
- Forum: Programming and Computer Science
-
S
Algorithm Complexity: Sorted Arrays into Sorted Array
Homework Statement We have k >= 1 sorted arrays, each one containing n >= 1 elements (all equal length). We want to combine all of them into a single sorted array with kn elements. We have a "naive" algorithm: merge the first two arrays, then merge the third array into the result, then merge...- sodiumbromate
- Thread
- Algorithm Array Arrays Complexity
- Replies: 12
- Forum: Engineering and Comp Sci Homework Help
-
A
MATHCAD Array Operation Doesn't Work for Long Vectors
Hello, I am looking for some advice. I'm trying to perform array operations on vectors in MATHCAD. I am able to do it for vectors and matrices that have both dimensions that are 9 units or shorter. Anything that is 10 units or longer (ex, a vector with 10 elements) outputs a result such as...- Abagnale
- Thread
- Array Mathcad Vectors Work
- Replies: 2
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
A
Can You Shift an Array by a User-Inputted Value Using For Loops?
So I am trying to use for loops to shift the index an array by a user inputted value. The code i have so far is printMessage(); cin >> choice; if(choice == 2){ cout << endl; cout <<"Please enter...- AST3019
- Thread
- Array Indices
- Replies: 2
- Forum: Programming and Computer Science
-
S
Solving DFT of f(n*t) vs t Data Array in C
I have a f(n*t) vs t data areay how to find out its (DFT) Fourier transform in c. I find every time that every program needs its real and imaginarry part. but i have only magnitude. please help me out to find DFT of these data .- souhal.67
- Thread
- Array Data Dft
- Replies: 10
- Forum: Other Physics Topics
-
M
Fortran Fortran 90 creating an array of unknown size
I was given an assignment to create a program that solves the Josephus Problem ([URL="[PLAIN]http://en.wikipedia.org/wiki/Josephus_problem"].[/PLAIN] the program needs to work for n amount of people, and it must use an array. Problem: I need to create a subroutine that will allow the user...- max2112
- Thread
- Array Fortran
- Replies: 3
- Forum: Programming and Computer Science
-
D
MHB How can I increase the equation size in an array for better alignment?
I had to use an array to center and left align two different equations--a system of DEs. However, by using array, the equations are smaller than I would like. How can I increase the the equation size in the array. $$\displaystyle\begin{array}{lcl} \frac{dN_1}{dt} & = & r_1N_1\left(1 -...- Dustinsfl
- Thread
- Array
- Replies: 4
- Forum: MATLAB, Maple, Mathematica, LaTeX
-
K
Building a Full-Spectrum LED Light Array for My Grow Station
I recently began making a cabinet into a grow station. It's almost finished, but I'm having trouble with the lighting system. In the beginning the idea was to make a full-spectrum LED light array of no particular voltage. I wanted to mimic this array I saw on LED Lights and Light Fixtures...- kamko15
- Thread
- Array Building Led Light
- Replies: 47
- Forum: Electrical Engineering
-
C
Simple program to fill an array
#include <stdio.h> int main() { double sum, theta[100]; int i; sum = 0.0; i = 0; while (i < 100) { sum = sum + theta[i]; i = i + 1; } printf("The sum of the array is %lf\n", sum); } when i run it i get a wrong answer...i don't know how to initialize the array- cs23
- Thread
- Array Program
- Replies: 13
- Forum: Programming and Computer Science
-
E
Comp Sci Creating an Array of Pointers to Objects in C++ Without Using Virtual Functions
Homework Statement suppose i have class A. now i have 2 derative classes: A_1, A_2. i would like to create a 4'th class: Array_Class. Array_Class will have 2 pointers array (one for each class - A_1, A_2). i want to be able to get an object pointer from class A_1 or A_2, and place it in...- erezb84
- Thread
- Array C++ Pointers
- Replies: 4
- Forum: Engineering and Comp Sci Homework Help
-
K
Comp Sci Fortran element by element array multiplication
Homework Statement Hello, I'm having a problem in multiplying two vectors together in a specific way in Fortran. I can do it in Matlab, but can't work out how to do it in Fortran. The problem is that i want to multiply two vectors together, but only each element by it's corresponding...- Kwetla
- Thread
- Array Element Fortran Multiplication
- Replies: 4
- Forum: Engineering and Comp Sci Homework Help
-
V
Python Fixing ValueError: Setting Array Element w/ Sequence in Python
Homework Statement fname[i]='%05s - %05s . %05s - %05s' % (xstart,xend,ystart,yend) gives the error ValueError: setting an array element with a sequence. Basically I wanted to turn the statement '%05s - %05s . %05s - %05s' % ('50','50','50','50') to a string/name that goes into an array of...- vorcil
- Thread
- Array Error Python
- Replies: 5
- Forum: Programming and Computer Science
-
B
Powering an LED Array On and Off at 1kHz
So I have a question about a circuit I'm making for class. I'm using this PowerSupply is a power supply I'm using in the lab. The 1kHz square wave is 700mV pk to pk with a 350mV offset. LEDarray is a red LED light array (http://www.ledtronics.com/Products/ProductsDetails.aspx?WP=2003). When I...- bluurple
- Thread
- Array Led Led array
- Replies: 6
- Forum: Electrical Engineering
-
K
Why is My C Code Unexpectedly Changing Other Elements in a 2D Array?
if(gameBoardState[i][col] == 0) { gameBoardState[i][col] = playerTurn; break; } This code is supposed to change the values in gameBoardState[i][col] (a 2D array), but it changes values in other elements too. For example, when col = 0, and i = 5...- kyacout
- Thread
- Array Change
- Replies: 1
- Forum: Programming and Computer Science
-
R
C# Converting integer into array of single digits in C#?
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- rollcast
- Thread
- Array Integer
- Replies: 4
- Forum: Programming and Computer Science
-
W
Resistance controlled voltage source (for led array
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 ...- whatchitfoool
- Thread
- Array Led Led array Resistance Source Voltage Voltage source
- Replies: 5
- Forum: Electrical Engineering
-
H
Checking then removing duplicates in array
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...- Hiche
- Thread
- Array
- Replies: 10
- Forum: Programming and Computer Science
-
G
C/C++ Need help in putting data into an array in c++
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...- googled123
- Thread
- Array C++ Data
- Replies: 3
- Forum: Programming and Computer Science
-
H
Copying arrays/assigning the 'value' of the array to another.
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.- Hiche
- Thread
- Array Value
- Replies: 1
- Forum: Programming and Computer Science
-
J
Fortran Array arrangement in Fortran 77
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...- jic1892
- Thread
- Array Fortran
- Replies: 2
- Forum: Programming and Computer Science
-
Comp Sci C++ Array Interchange: Solve Homework Problem
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...- Saitama
- Thread
- Array
- Replies: 38
- Forum: Engineering and Comp Sci Homework Help
-
M
Generating a Random Number from an array for a blackjack simulator-Matlab
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 =...- Matt12
- Thread
- Array Random Random number
- Replies: 1
- Forum: Engineering and Comp Sci Homework Help
-
L
Fortran Fortran - compilator dependent, intrinsic array manipulation, memory problem
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)...- lacek
- Thread
- Array Fortran Manipulation Memory
- Replies: 1
- Forum: Programming and Computer Science
-
Comp Sci Declaring an array in a for loop (Java) or similar
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...- stripes
- Thread
- Array Java Loop
- Replies: 8
- Forum: Engineering and Comp Sci Homework Help
-
M
Sorting 2d array with qsort, keeping rows in order (C)
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...- Mute
- Thread
- 2d Array Sorting
- Replies: 5
- Forum: Programming and Computer Science