Array Definition and 501 Threads

  1. S

    Why Won't My C Program Compile for Finding the Smallest Integer in an Array?

    Homework Statement I am writing a program so that a user can input up to ten integers and then sought through and print the smallest from that input i.e. enter in up to ten integers: "7 5 6 19 4 8" the smallest number is 4 Homework Equations The Attempt at a Solution...
  2. C

    Comp Sci Finding the Location of Two Elements with a Sum of 100 in an Array of 3 Elements

    I have an array of 3 known elements.I know that 2 elements of them have the sum of 100 and I need to find the location of the two elements which have this sum ex. A[3] 5 25 75 the solution for this prob. is second & third location Thanks,
  3. M

    PCSPIM - declaring an array of strings

    Hey all, So declaring integers successively in memory (using .word) in an array is all well and understandable. Since an integer is 4 bytes in length, as is a memory word. For example: .data x: .word 2, -13, 24, 123 #initialization of elements 0 to 3 of array x However, how would...
  4. P

    Updating a JLabel with an integer array

    halfway through my code so its a bit of mess but this is simple what i need to do. I have a JLabel array of 6 labels. a random number is generated, its then split into its digits into a 6 element array of integers. now i need to update the Jlabels with the integer array of digits. my...
  5. T

    C/C++ [C++] Declaring an array within a loop

    The following code block is in C++ Everything is inside the first for loop. for( int i=0; i<=2; i++) { int a[3]={0}; for(int j=0; j<3; j++) a[i]=j; for( int i=0; i<=2; i++) cout<<a[i]; cout<<endl; } basically I am trying to get the screen to output...
  6. Y

    [Android] Retrieve pixel array after an image is taken

    I am working on an app that needs to access an array of pixels from a picture after it is taken. The main Activity is below. I have a good amount of java experience but extremely limited experience with images past displaying them on the screen. I see the byte array being passed to the picture...
  7. N

    What alternatives can be used instead of dynamic arrays in Verilog and Quartus?

    hello everyone I know that dynamic array is not supported in Verilog and Quartus. I want to know does anybody has an idea or algorithm to use instead of dynamic array. I mean I am searching for something that works instead of a dynamic array. thanks
  8. V

    Fortran [Fortran] Passing elements of array to subroutine

    I have one main program where I have calculated some array, say A(i,j) If I want ot use the values in subroutine, and calculate some more values and give back the result to main program, how my syntax should be? I tried this way. Its not working. program a...
  9. M

    Deleting an entry from an array in MATLAB

    I want a code in MATLAB that produces A\{4}, where A={3,6,1,-3,4,8}. I know for instance: A=[ 3 6 1 -3 4 8]; A(5)=[]; produces 3 6 1 -3 8 But what should I do if I don't know the index (in this case 5) for the entry '4'; and I want to get [ 3 6 1...
  10. 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...
  11. 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...
  12. 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...
  13. 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?
  14. 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...
  15. 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...
  16. 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...
  17. 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]] +...
  18. stripes

    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 =...
  19. 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...
  20. 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)...
  21. 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 ??
  22. gluons

    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...
  23. 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 =...
  24. 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...
  25. 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...
  26. 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...
  27. A

    Constructing an Algorithm for a 2-D Array Pattern Match

    Homework Statement So basically I got this problem and I am still constructing an algorithm for it. I am not entirely sure the algorithm is going in the right direction, though. The problem is as follows: The 2-D array and the pattern are read from two input files named Array and Pattern...
  28. 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 -...
  29. Whovian

    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...
  30. xaratustra

    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.
  31. 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...
  32. 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...
  33. 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. ...
  34. 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...
  35. 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...
  36. 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...
  37. 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...
  38. 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...
  39. 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...
  40. 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 .
  41. 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...
  42. 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 -...
  43. 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...
  44. 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
  45. 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...
  46. 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...
  47. 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...
  48. M

    Concept of a new thermopiple array above 10% efficiency?

    Is is possible to design a more efficient thermopipe using a laminer flow heat source? A. Test piece incorporates a length of 1.5 x 24 " black iron pipe to produce laminer flow. B. A variable fan is used to input the air into one end of the pipe. C. Fuel source is a 20 lb. propane bottle...
  49. 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...
  50. 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...
Back
Top