@orzhyun

حل حق

February 02, 2023 · Java
import java.util.NoSuchElementException;

class LinkedList {
private Node first;
/* Constructs an empty linked list */
public LinkedList() {
first = null;
}
/* Returns the first element in the linked list. */
public Object getFirst() {
if (first == null)
throw new NoSuchElementException();
return first.data;
}
/* Removes the first element in the linked list. */
public Object removeFirst() {
if (first == null)
throw new NoSuchElementException();
Object element = first.data;
fi

myLabth2

updated February 02, 2023 · Java
import java.util.NoSuchElementException;

class LinkedList{
class Node{
      public Object data;
      public Node next;
}
private Node first;
public LinkedList(){
    first = null;
}
public void addFirst(Object element){
Node newNode = new Node();
newNode.data=element;
newNode.next=first;
first=newNode;
}
public Object getFirst(){
  if(first==null)
  throw new NoSuchElementException();
    return first.data;
}
public Object removeFirst(){
    if(first==null)
  throw new NoSuchElementException

mylab2

updated January 30, 2023 · Java
import java.util.*;
import java.lang.*;
import java.io.*;


class Main {
    private static Scanner scanner;
    
    static void fib(int n){
      int preTwo = 0 , preOne=1 , fibval;
      System.out.print(preTwo+" "+preOne+" ");
      for(int i=2; i<n;i++){
         fibval=preTwo+preOne;
         preTwo = preOne;
         preOne=fibval;
         System.out.print(fibval+ " " );
      }
       
    }
    public static void main(String[] args) {
     scanner = new Scanner(System.in);
     System