- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
14 Posted Topics
[CODE]public Node<E> remove (int index)[/CODE] i need to recursively implement this method. Node<E> nodes contain two fields, next (a reference to the next node in the linked list) and element (a reference to the data it contains) [CODE]public E element; public Node<E> next;[/CODE] Do not worry about the checking for … | |
Imagine a windows paint program that draws a square. I wrote some code to do the following: A vertex change may make a square bigger or smaller (or unchanged if the vertex value is the same). You must adjust the other vertices, as necessary, to keep the shape a square. … | |
Ive written these two methods but they are giving me lots of problems. [CODE]public int indexOf(Object element) 128 { 129 for(int i = 0; i < list.length; i++) 130 { 131 if(list[i] != null && list[i].equals(element)) 132 { 133 return i; 134 } 135 } 136 137 throw new IndexOutOfBoundsException(); … | |
I'm writing an indexOf method for a class called BasicArrayList. i have two private instance variables an Object[] called list, and an int called size. [CODE]public int indexOf(Object element) 67 { 68 for(int i = 0; i < size; i++) 69 { 70 if(list[i].equals(element)) 71 { 72 return i; 73 … | |
I wrote this code to find the mode of an array of values. [CODE]double mode (double * array, int numItems) { int j, i, maxRepeats = 0; double mode; for(i = 0; i < numItems; i++) { j = 1; while(array[i] == array[i+j]) { ++j; } if(j > maxRepeats) { … | |
I wrote this function for an assignment. It utilizes dynamic memory, which grows and shrinks as needed. I wrote it like this at first: [CODE]int user_input (int * array, int intSize) { printf("Please enter any number of integers (80 characters per string max), enter an empty string to signal input … | |
[CODE]void user_input (int * array, int intSize) { printf("Please enter any number of strings (80 characters per string max), enter an empty string to signal input completion\n\n"); int i = 0; int j = 0; int arrayMax = MAXARRAY - 1; char input[81]; while (input[0] != '\0') { printf("->"); i … | |
I wrote a short piece of code to give me a .dat file for use in another program. But i cant figure out what is wrong. I run on a mac, and use Xcode. [CODE]#include <stdio.h> #define ARRAYSIZE 1500 #define BINDATA "file://localhost/Users/Hub/Desktop/231A4binData.dat" int main (void) { int i; double dblData[ARRAYSIZE]; … | |
i know there is probably a trick for this in C that i do not know, but i attempted to write my own function for finding the mode of an array of data (As large as 1500 doubles). Heres my crack at it. [CODE]void mode (double * array, int numItems) … | |
So does this code adequately satisfy this question? Write a function named tokenize() that will receive the following parameters: a char * to the string to tokenize, and a char * [] that will receive pointers to all of the tokens generated, in their order of generation. The function will … | |
I have no syntactical errors, but i cant figure out why this wont work. Heres the code. [CODE]#include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> int main (void) { char str[100]; int i = 0, line_count = 0, len = 0, alpha = 0, lower = 0, upper = 0, … | |
Re: You might be getting errors from here. [CODE]char *ptr = (char *)malloc(4);[/CODE] change to something like. [CODE]char * ptr = malloc(sizeof(char)*2)[/CODE] might do something for you. | |
Heres the assignment. 1. Declare a string, e.g. char str[81]; 2. Input a string from the keyboard (spaces included) using the (while statement while( while (str[i] = getchar() != '\n' ) adjusted so that it only inputs a certain number of characters ( in the above example that would be … | |
supposed to declare a string of a certain size (eg. char str[81]) Then input a string from the keyboard (spaces included) using the while (NOT, gets(), or fgets()) technique (while ((str[i] = getchar()) != '\n')) adjusted so that it only inputs a certain number of characters (in the above example … |
The End.