All pastes #458789 Raw Edit

Something

public java v1 · immutable
#458789 ·published 2007-04-26 02:22 UTC
rendered paste body
import java.util.*;import java.io.* ;import javax.swing.JOptionPane ;public class quiz1 {	public static Node reverse(Node first){		Node a = first;		Node b = first;		int c=0;		while(a.next!=null){			a=a.next;			c++;		}		Node last = a;		for(int n = c; n>0;n--){			for(int r=n-1;r>0;r--){				b=b.next;			}			b.next=null;			a.next=b;			a=a.next;			b=first;		}		return last;	}	public static void main(String[] args){		//----------node shit		Node root = new Node("r",null);		Node r1 = new Node("1",null);		Node r2 = new Node("2",null);		Node r3 = new Node("3",null);		Node r4 = new Node("4",null);		Node r5 = new Node("5",null);		Node r6 = new Node("6",null);		root.next=r1;		r1.next=r2;		r2.next=r3;		r3.next=r4;		r4.next=r5;		r5.next=r6;		Node lol = reverse(root);		System.out.println("lol");		//      Circular array-------------------//		CircularArrayQueue x = new CircularArrayQueue(10);//		for (int n=0;n<10;n++){//		x.add(new String("lolz"+n));//		}//		System.out.println(x.remove());//		System.out.println(x.remove());//		System.out.println(x.remove());		//      File reading shit-------------------------		//		boolean done = false ;//		while (! done) {//		try {//		String fname = JOptionPane.showInputDialog("Insert file name");				//		FileInputStream fin = new FileInputStream(fname);//		int lines=0,words=0,chars=0;//		while(true){//		int in = fin.read();//		if (in==-1){//		lines++; //		break;//		}//		char c = (char)in;//		switch(c){//		case ' ': words++;break;//		case '\n': lines++; words++;break;//		default: chars++;break;//		}//		}//		System.out.println("Lines: "+lines+" Words: "+words+" Chars: "+chars);//		}//		catch(IOException e){//		done=true;//		}//		}	}}//-----------------------those gay stack/que rewrites he wanted + a nodeimport java.util.ArrayList;class ArrayListStack{	private ArrayList list;	public ArrayListStack(){		list = new ArrayList();	}	public Object pop(){		Object b = list.get(list.size()-1);		list.remove(list.size()-1);		return b;				}	public void push(Object o){		list.add(o);	}	public Object peek(){		Object b = list.get(list.size()-1);		return b;	}	public int size(){		return list.size();	}}class CircularArrayQueue{	private int head;	private int tail;	private int theSize;	private Object[] elements;	public CircularArrayQueue(int capacity){		elements = new Object[capacity];		head=0;		tail=0;		theSize=0;	}	public void add(Object x){		if (theSize==elements.length) 			throw new IndexOutOfBoundsException();		elements[head]=x;		if (head==elements.length-1) head=0;		else head++;		theSize++;	}	public Object remove(){		Object o = elements[tail];		elements[tail] = null;		if (tail==elements.length-1) tail=0;		else tail++;		theSize--;		return o;	}	public int size(){		return theSize;	}		}class Node {	public Object n;	public Node next;	public Node(Object o, Node nx){		n=o;		next=nx;	}}