User Profile

Collapse

Profile Sidebar

Collapse
DeFault
DeFault
Last Activity: Dec 7 '06, 09:44 PM
Joined: Sep 19 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DeFault
    replied to Duplicate element in array
    in Java
    DeMan -

    The code you wrote if I wanted to compile and use it would it work for my problem?

    kotoro -

    I know for sure that I can use java.util

    I want to make a method called printArray() so I can print out the results so would this work?

    Code:
    public static void printArray(int[] a) {
            for (int i = 0; i < a.length; i++) {
                System.out.pr
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    replied to Duplicate element in array
    in Java
    Thanks alot for the info but I'm just a beginner so all this is going over my head.

    The method I'm trying to write is a basic one. I would also say now I want to make a copy of array of integers. When a copy is made, then I would remove duplicates.

    Would method work conceptualy?

    Code:
    public static String [] remove(String [] arr, int index){
    		if(index < 0 || index >= arr.length){
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    replied to Duplicate element in array
    in Java
    I first created this method that would search an array and would return the first element. How can I change this method to delete a duplicate entry?

    Code:
    public int findFirstElementLog(int [] arr,int x) {
           
                if(arr[0] == x ) {
                count++;
                return 0;
            }
    
    
                if(arr[arr.length - 1] == x && arr[arr.length - 2] != x
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    started a topic Duplicate element in array
    in Java

    Duplicate element in array

    I'm trying to create a method removedDuplicat e() in which this method would find and remove a duplicated entry in an array of integers.

    I would like any advice on how I would create this method.
    See more | Go to post

  • DeFault
    started a topic C Beautifier
    in C

    C Beautifier

    I would to attempt a simple code beautifier but I would like to know the right way to start this.

    The process I would like to attempt is:
    1. Start count out at zero.
    2. Read in lines of original.c one by one.
    3. For each line:
    4. Remove all the white space (tabs and spaces) from the front of the line.
    5. If the first non-white character of the line is ‘}’ decrease count by one.
    6. Insert...
    See more | Go to post

  • DeFault
    replied to Linked List
    in C
    This is a silly question but when I ask how to improve insertFirst() and the code you wrote I would have to put that in insertFirst() right? The same goes to the malloc part I would have to put that in main right?
    See more | Go to post

    Leave a comment:


  • DeFault
    replied to Linked List
    in C
    To answer your question about what is being passed to insertLast() that is basically inserting a node containing val at the end of a linked list.

    For the code you wrote I would have a sentinal 'end' node so could you so me how it would be then by your code....
    See more | Go to post

    Leave a comment:


  • DeFault
    replied to Linked List
    in C
    Is this any better?

    Code:
    Node* insertLast ( Node **head, int val)
    {
    
    Node *current;
    Node *previous;
    Node *last;
    
    
    current = (Node *)malloc(sizeof(Node));
    
    if (current != NULL)
    
       previous = current;
       current = current->link;
    
       last = (Node *)malloc( sizeof( Node ));
       last->value = val;
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    replied to Linked List
    in C
    -Sicarie

    Thanks I'll give that a try.

    I was also thinking about adding a function called insertLast() I haven't tried yet it but what do you think of this.

    Code:
    Node* insertLast ( Node **head, int val)
    {
    
    Node *last;
    Node *temp;
    
    if (*head != NULL)
    
       last = (Node *)malloc( sizeof( Node ));
       last->value = val;
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    started a topic Linked List
    in C

    Linked List

    I'm messing around with linked lists and so far I was able to do a little something. However, I want to improve this code so I would like for any help.

    First, I want improve the function insertFirst() so that it tests if memory allocation worked.

    Second, I want improve main() so that it tests if insertFirst() returns NULL. If it does, main() should write out an error message and terminate any loop.

    ...
    See more | Go to post

  • DeFault
    started a topic Consonants and Vowels
    in C

    Consonants and Vowels

    I have an assigment that deals with strings and I just need an idea how to start writing these functions.

    Write a function that determines if a string is nice. A string is nice if it has an equal number (including zero) of consonants and vowels.

    int isNice(char *str);


    Write a function that determines if a string is balanced. A string is balanced if there is the same number (including zero) of...
    See more | Go to post

  • DeFault
    replied to Loaded Dice Tester
    in C
    Please forgive the errors in code I just wanted to get it written down to understand it. If there is anything that I have missed could please explain what it is.

    Code:
    int dieA();
    int dieB();
    int dieC();
    
    #include <stdio.h>
    #include "threeDice.h"
    
    int main ()
    {
        int a_store[0];
        int b_store[0];
        int c_store[0];
        int
    ...
    See more | Go to post

    Leave a comment:


  • DeFault
    started a topic Loaded Dice Tester
    in C

    Loaded Dice Tester

    I have this assigment to do that determines which of three dice are loaded. The dice are actually three C functions called dieA(), diaB(), and dieC()each of which returns an int in the range 1 – 6 when called.

    I would have to exercise each of the dice functions and determines which one is “loaded.”


    This is my idea of how to make ten throws of die A
    Code:
     #include 
    "threeDice.h" /* header
    ...
    See more | Go to post
No activity results to display
Show More
Working...