عضو شوید
عضویت سریع
آمار مطالب
آمار کاربران
کاربران آنلاین
آمار بازدید
package queue;
public class QueueTest {
public static void main(String[] args) { Queue a=new Queue(); try{ a.add(12); a.add(13);// a.add(14);// System.out.println(a.take()); System.out.println(a.take()); System.out.println(a.take());// System.out.println(a.take()); } catch(IsEmptyException e){ System.err.println(e.getMessage()); } catch(IsFullException e){ System.err.println(e.getMessage()); } }
}
برای دانلود به ادامه ی مطلب رجوع شود.
حل المسائل فصل های ۲-۳-۴-۵ کتاب آمار و احتمالات نعمت اللهی
قسمت main برنامه
public class Stack { final int MAX_SIZE = 1024; private int top; private T[] buffer; public Stack() { top = 0; //buffer = new T[MAX_SIZE]; buffer=(T[]) new Object[MAX_SIZE]; }
public boolean isEmpty() { return (top == 0); }
public boolean isFull() { return (top == MAX_SIZE); }
public void push(T x) throws FullStackException{ if (isFull()) { throw new FullStackException("پشته پر است"); } else { buffer[top] = x; top++; } }
public T pop() throws EmptyStackException{ if (isEmpty()) { throw new EmptyStackException("پشته خالی است"); } top--; return buffer[top]; }
public T top() { return buffer[top - 1]; } }
برای دانلود به ادامه ی مطلب رجوع کنید
برای دانلود به ادامه مطلب رجوع کنید
جهت دانلود به ادامه ی مطلب رجوع کنید
public class sclass { int top=0,x; int []buffer=new int[4]; public void push(int x){ buffer[top]=x; top++; } public int pop(){ top--; return buffer[top]; }}
قسمت main برنامه:
public static void main(String[] args) { Scanner console=new Scanner(System.in); int i,j,x; sclass a=new sclass(); for(i=0;i<=3;i++){ x=console.nextInt(); a.push(x); } j=3; while(j>=0){ System.out.print(a.pop()); j--; } } }
جهت دانلود تمرین ها فایل پیوست را ذخیره نمایید
RSS