i have to create a list of ,let's say 50 people, (in Java) and display the list, and i don't really know how to do that. so this is what i have tried to do so far . please correct and complete some of my code .
public class Person {
String name;
String stuff;
}
public class CreatePerson {
public static void ang() {
...
Basically I'm creating a forest fire program that depends on the wind / dryness of the surround pieces. I have an array var Trees [,] that is 20 x 20. The middle square is set on "fire" what needs to be done once you click button1: Evaluate each square around the one that is set on fire to determine the probability for the others to catc...
Hi, I'm working on a hash function which gets a string as input.
Right now I'm doing a loop and inside the hash (an int variable) is being multiplied by a value and then the ASCII code for the current character is added to the mix.
hash = hash * seed + string[i]
But sometimes, if the string is big enough there is an integer overflow ...
I'm currently working on some code for a course. I can't post the code but I'm permitted to talk about some high level concepts that I'm struggling with and receive input on them. Basically the code is a recursive DFS on a undirected graph that I'm supposed to convert to a concurrent program. My professor already specified that I should ...
n=0;
disp('This program performs an angle conversion');
disp('input data set to a straight line. Enter the name');
disp('of the file containing the input Lambda in radian: ');
filename = input(' ','s');
[fid,msg] = fopen(filename,'rt');
if fid < 0
disp(msg);
else
A=textscan(fid, '%g',1);
while ~feof(fid)
Lambda = A...
How to write a kernel module that creates a directory in /proc named mymod and a file in it name is mymodfile. This file should accept a number ranged from 1 to 3 when written into it and return the following messages when read based on the number already written into it:
• 1: Current system time (in microseconds precision)
• 2: System ...
Hi Guys,
Basically I'm developing a (very) simple search engine. You can enter a search term and you are taken to the results page - which works fine. However on the results page, I have a button that will take you to the next 10 results: where $term is the $_POST['term'] value.
echo "<input type='hidden' name='term' value='" . $term ....
How would you characterize the below in big-O notation?
rotors = [1,2,3,4,5 ...]
widgets = ['a', 'b', 'c', 'd', 'e' ...]
assert len(rotors) == len(widgets)
for r in rotors:
for w in widgets:
...
del widgets[0]
...
I have translated the following code using ternary. However, I knew there was something wrong with it. Can someone please point me into the right direction?
ForwardA = 0;
ForwardB = 0;
//EX Hazard
if (EXMEMRegWrite == 1) begin
if (EXMEMrd != 0)
if (EXMEMrd == IDEXrs)
ForwardA = 2'b10;
if (EXMEMrd == IDEXrt && IDEXTest =...
This is a homework question,I'm trying to do a Depth-first search function in Scheme,Here's the code I've written so far:
(define explore
(λ(node visited)
(let* ([neighbors (force (cdr node))]
[next (nextNode visited neighbors)]
[is-visited (member? node visited)])
(cond
;if I ...
I know little of optimization problems, so hopefully this will be didactic for me:
rotors = [1, 2, 3, 4...]
widgets = ['a', 'b', 'c', 'd' ...]
assert len(rotors) == len(widgets)
part_values = [
(1, 'a', 34),
(1, 'b', 26),
(1, 'c', 11),
(1, 'd', 8),
(2, 'a', 5),
(2, 'b', 17),
....
]
Given a fixed number of widgets and a fixed number ...
How do I pass a pointer value to an array of the struct;
For example, on a txt I have this:
John Doe;[email protected];214425532;
My code:
typedef struct Person{
char name[100];
char email[100];
int phone;
}PERSON;
int main(){
PERSON persons[100];
FILE *fp;
char *ap_name;
char *ap_email;
char *ap_phone...
Hello, I have chosen to represent a graph in Haskell by a list of nodes (ex. n=[1,2,3,4]) and a list of pairs representing the edges (example m=[(1,2), (2,3)]). Now I have to see if the graph is strongly connected.
My main issue is how to find if there is a way between 2 nodes in the graph. I wrote something like that:
-- sees if 2 nod...
Would a hashtable/hashmap use a lot of memory if it only consists of object references and int's?
As for a school project we had to map a database to objects (that's what being done by orm/hibernate nowadays) but eager to find a good way not to store id's in objects in order to save them again we thought of putting all objects we create...
I want to define a function replicate to replicate a list of numbers by its value using only list comprehension, for example:
replicate [5,1,3,2,8,1,2]
output: [5,5,5,5,5,1,3,3,3,2,2,8,8,8,8,8,8,8,8,1,2,2]
I know this would be easy to use the 'replicate' built in function but only list comprehension is allow, how can I do this?
THAN...
Using higher order functions (map, fold or filter) and if necessary lambda
expressions. Write a definition for f1 and f2 so the following evaluation
is valid:
f1 (f2 (*) [1,2,3,4]) 5 == [5,10,15,20]
Any help would be appreciated, thanks.
...
Note:
Following is my homework/assignment, feel free not to answer if you will.
I want to delete/remove an element from an String array(Set) basic, I'm not allowed to use Collections..etc.
Now I have this:
void remove(String newValue) {
for ( int i = 0; i < setElements.length; i++) {
if ( setElements[i] =...
Define a function replicate which given a list of numbers returns a
list with each number duplicated its value. Use a fold, map, and take
..> replicate [5,1,3,2,8,1,2]
output: [5,5,5,5,5,1,3,3,3,2,2,8,8,8,8,8,8,8,8,1,2,2]
I've figure this out using List comprehension and recursion:
replicate2 [] = []
replicate2 (n:nn) = take n(repe...
If I have a 32 bit two's complement number and I want to know what is the easiest way to know of two numbers are equal... what would be the fastest bitwise operator to know this? I know xor'ing both numbers and check if the results are zero works well... any other one's?
how about if a number is greater than 0?? I can check the 31'st bi...
This is based on a past exam question.
The question is asking to describe the four types of message available using JMS.
The problem is it says the four, not just four. So it assumes their is only four, no more no less.
However according to this site their seems to be five;
streams
maps
text
objects
bytes
*Another book states th...