I have a simple assignment that the professor wants us to do.
Basically to pull in some numbers from a text file and load into a linked list.
I don't want to get to much into the details but I have a basic question.
He provided us with a function like so:
INTLIST* init_intlist( int n )
{
INTLIST *lst;
lst = (INTLIST *)malloc(sizeof(IN...
I have an array of ints ie. [1,2,3,4,5] . Each row corresponds to decimal value, so 5 is 1's, 4 is 10's, 3 is 100's which gives value of 12345 that I calculate and store as long.
This is the function :
public long valueOf(int[]x) {
int multiplier = 1;
value = 0;
for (int i=x.length-1; i >=0; i--) {
value += x[i]*mul...
I'm trying to write a recursive function that does some formatting within a file I open for a class assignment. This is what I've written so far:
const char * const FILENAME = "test.rtf";
void OpenFile(const char *fileName, ifstream &inFile) {
inFile.open(FILENAME, ios_base::in);
if (!inFile.is_open()) {
cerr << "Could...
Create a class MAT of size m x n. Define the following matrix operations for MAT type objects
a. Addition
b. Subtraction
c. Multiplication.
...
I'm having problems trying to pass an Integer object from a driver class as an argument for function of a SortedArray Generic class I created. From my driver class, I convert the user's int input into an Integer object to be cast onto Comparable of my SortedArray class.
I continue to receive the error: "Exception in thread "main" java.l...
Sooo I started taking my second computer science class ever! For my first class we used python and for this class we're using Java. Our first assignment (pretty much just practice) is to convert this craps program from Python to Java and I'm just having a hell of a time.
Could someone please help with what I've done and umm give me som...
For a class, I'm writing a simple crypt function. Everything works as expected:
int crypt(char *key, int (*callback)(int, char*, int, int))
{
int c, i = 0, n = strlen(key);
while((c = fgetc(stdin)) != EOF)
{
// only change the char if it's printable
if(c >= 32 && c <= 126)
c = callback(c, key, n, ...
I've been stuck on a question for a while and was wondering if anyone can point me in the right direction:
suppose binary heaps are represented using a pointer-based tree representation instead of an array. consider the problem of merging binary heap LHS with RHS. assume both heaps are full complete trees, containing (2^L) - 1 and (2^R)...
I'm working on a problem in C, and I have a quick question about it. The problem is as follows: I'm given some sorted array of integers, say, a[i] = { 1, 2, 3, 3, 3 }. Now, I am supposed to run a program that searches for a given integer, returns the location of the first occurrence and the number of occurrences of that integer in the ...
Hi there,
I'm a programming student, and for a project I'm working on, on of the things I have to do is compute the median value of a vector of int values. I'm to do this using only the sort function from the STL and vector member functions such as .begin(), .end(), and .size().
I'm also supposed to make sure I find the median whether ...
Hi, I have tried 2 questions, could you tell me whether I am right or not?
Regular expression of nonnegative integer constants in C, where numbers beginning with 0 are octal constants and other numbers are decimal constants.
I tried 0([1-7][0-7]*)?|[1-9][0-9]*, is it right? And what string could I match? Do you think 034567 will match...
/*
* code.c
*
* TASK
* Reverse a string by reversing pointers. Function should use return
* type char* and use a char* parameter as input.
*/
#include <stdio.h>
#include <string.h>
#define STRMAX 51
char* reverse(char* sPhrase[]);
int main() {
char sPhrase[STRMAX];
char sReverse[STRMAX];
printf("Enter string...
I'm having problem in the dry run of a program.. I'm not getting why my program is giving 0 in the output.. please help.. here is my code.. :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Task_8_Set_III
{
class Program
{
static void Main(string[] a...
I'm having a logic problem here.. i want to add the result of the factorial values.. how do i add them.. here's my code..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Task_8_Set_III
{
class Program
{
static void Main(string[] args)
{
...
Hi can someone explain me how to resolve this homework?
(n + log n)3^n = O((4^n)/n).
i think it's the same as resolving this inequality: (n + log n)3^n < c((4^n)/n)).
thanks in advance
...
I get this:
LLIST *mylist[N];
Where N is the number of rows of the input file. Then mylist[i] is a pointer to the ith linked list.
I call a function
LLIST *list_add(LLIST **p, int i){
LLIST *n;
n = (LLIST *) malloc(sizeof(LLIST));
if (n == NULL)
return NULL;
n->next = *p; /* the previous element (*p) now ...
Hello I recently asked some questions on linked lists in C.
The link was found here
First I want to thank everyone for helping me with this. But I have one issue I cannot understand. I even asked the professor but he emailed me back with little information. Basically I am writing a linked list in C (see above link). One of the thing...
i just want to know that whether i can generate a multiplication table from 1 - 9 with a single for loop??
...
In my project I have to deal with multiplication of bignumbers ( greater then java.long ) stared in my own BigNumber class as int[]. Basically i need to implement something like this :
157 x
121 y
----
157 result1
314 + result2
157 + result3
------
18997 finalResult
but how to implement it ?
I thought about e...
This does work
LLIST *mylist[10] = {NULL};
But would if I wanted to do this I get errors:
int x=10;
LLIST *mylist[x] = {NULL};
x can be any value I'm setting it to 10 for the time being. x is going to be used as a counter.
...