Jump to content


Photo

รบกวน ท่านผู้รู้ เกี่ยวกับ java ช่วยผมหน่อยครับ


  • Please log in to reply
75 ความเห็นในกระทู้นี้

#1 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 13:21



import java.util.Arrays;

public class Peg2 {
	static String[][] total = new String[7][7];
	static final int left = 1;
	static final int right = 2;
	static final int up = 3;
	static final int down = 4;

	public static void main(String[] args) {

		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					total[i][j] = "X ";
				}
				if (!except(i, j)) {
					total[i][j] = "  ";
				}
			}
		}
		total[3][3] = "O ";
		showArray(total);
		do {
			String s1 = null;
			int i1 = 0;
			int i2 = 0;
			String[] s = parseString();
			int[] one = parseOne();
			int[] two = parseTwo();
			try {
			    for (String stem : s) {
		                         s1 = stem;
				for (int ite1 : one) {
				        i1 = ite1;
					for (int ite2 : two) {

					i2 = ite2;
						if (change(s1, i1, i2) && !((i1 - 2) < 0)
							&& !((i1 + 2) > 6) && !((i2 - 2) < 0)
							&& !((i2 + 2) > 6)) {
							System.out.println(s1 + " " + i1 + " " + i2);

							if (select(s1, i1, i2)) {
							goSelect(s1, i1, i2);
							showArray(total);
							}
						} else {

					}
				}
			        }
			}
			Thread.currentThread().sleep(1000);//
			} catch (InterruptedException ie) {

			}
		} while (!end(total));
		System.out.println("You are genious guy");
	}

	public static boolean except(int i, int j) {

		if (i == 0 || i == 1 || i == 5 || i == 6) {
			if (j == 0 || j == 1 || j == 5 || j == 6) {
				return false;
			}
		}
		return true;
	}

	public static void showArray(String[][] temp) {

		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				System.out.print(total[i][j]);
			}
			System.out.println("");
		}
	}

	public static boolean canMove(int i, int j) {
		if (total[i][j].equals("O ")) {
			return true;
		} else {
			return false;
		}
	}

	public static boolean change(String direction, int i, int j) {
		boolean tem = false;
		if (canMove(i, j)) {

			tem = true;
		} else if (!canMove(i, j)) {

			tem = false;
		}
		return tem;
	}

	public static boolean goToX(int i, int j) {
		if (total[i][j].equals("X ")) {
			return true;
		} else {
			return false;
		}
	}

	public static boolean select(String direction, int i, int j) {
		boolean tem = false;
		if (direction.equals("left")) {
			if ((except(i, j - 2)) && (goToX(i, j - 2))) {
				tem = true;
			} else {
				tem = false;
			}
		} else if (direction.equals("right")) {
			if ((except(i, j + 2)) && (goToX(i, j + 2))) {
				tem = true;
			} else {
				tem = false;
			}
		} else if (direction.equals("up")) {
			if ((except(i - 2, j)) && (goToX(i - 2, j))) {
				tem = true;
			} else {
				tem = false;
			}
		} else if (direction.equals("down")) {
			if ((except(i + 2, j)) && (goToX(i + 2, j))) {
				tem = true;
			} else {
				tem = false;
			}
		}
		return tem;
	}

	public static void goSelect(String direction, int i, int j) {
		if (direction.equals("left")) {

			total[i][j - 1] = "O ";
			total[i][j - 2] = "O ";

		} else if (direction.equals("right")) {

			total[i][j + 1] = "O ";
			total[i][j + 2] = "O ";

		} else if (direction.equals("up")) {

			total[i - 1][j] = "O ";
			total[i - 2][j] = "O ";

		} else if (direction.equals("down")) {

			total[i + 1][j] = "O ";
			total[i + 2][j] = "O ";

		}
		total[i][j] = "X ";
	}

	public static boolean end(String[][] temp) {
		String[][] result = new String[7][7];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					result[i][j] = "O ";
				}
				if (!except(i, j)) {
					result[i][j] = "  ";
				}
			}
		}
		result[3][3] = "X ";

		if (Arrays.equals(result, temp)) {
			showArray(temp);
			return true;

		} else {
			return false;
		}
	}

	public static String[] parseString() {
		String[] s1 = new String[4];
		for (int temp = 0; temp < 5; temp++) {
			if (temp == left) {
				s1[0] = "left";
			} else if (temp == right) {
				s1[1] = "right";
			} else if (temp == up) {
				s1[2] = "up";
			} else if (temp == down) {
				s1[3] = "down";
			}
		}
		return s1;
	}

	public static int[] parseOne() {
		int[] ibay = new int[7];
		for (int temp = 0; temp < 7; temp++) {
			ibay[temp] = temp;
		}

		return ibay;
	}

	public static int[] parseTwo() {
		int[] ibay = new int[7];
		for (int temp = 0; temp < 7; temp++) {
			ibay[temp] = temp;
		}

		return ibay;

	}
}

 

คือ ผมลองทำแบบฝึกหัด ดูน่ะครับ แล้ว ลอง run ดู ปรากฏว่า มัน run ค้าง ไม่ไป แต่ดูเหมือน process ยังพยายาม อยู่ ทำไง ให้มัน run จนจบได้อะครับ


Edited by ทรงธรรม, 8 กุมภาพันธ์ พ.ศ. 2556 - 13:39.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#2 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 13:24

คือจะบอกว่า code นี่ มันมั่ว ๆ หน่อยนะครับ เพราะผม คิดเอง เขียนเอง ทั้งหมด

 

มันจะดูเย่นเย้อ กว่า ของคนอื่น แน่ ๆ

 

เป็น code เกี่ยวกับ การหา solution ของ เกม peg solitaire แบบ english อะครับ

 

ผมไปได้ แบบฝึกหัด มาจาก web นอก อะครับ

 

ผมลองทำแบบที่ ตอบโต้ ผ่าน command line แล้ว แบบ ให้ใช้ system in

 

อันนั้น ไม่มีปัญหา อะไร

 

แต่พอให้เครื่องมัน run เล่นเอง จนจบ มันค้างซะงั้น


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#3 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 13:38

อันนี้ เป็น code อีกแบบ

 

import java.util.Arrays;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Peg {
	static String[][] total = new String[7][7];

	public static void main(String[] args) {

		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					total[i][j] = "X ";
				}
				if (!except(i, j)) {
					total[i][j] = "  ";
				}
			}
		}
		total[3][3] = "O ";
		showArray(total);
		do {System.out.println("Please enter direction,row,column respectively");
			String s1 = parseString();
			if (s1.equals("left") || s1.equals("right") || s1.equals("up")
					|| s1.equals("down")) {

			} else {
				System.out.println("please enter left right up down");
			}
			int i1 = 0;
			int i2 = 0;
			
			i1 = parseOne();
			i2 = parseTwo();
			if(!((i1 - 2) < 0)
				&& !((i1 + 2) > 6) && !((i2 - 2) < 0)
				&& !((i2 + 2) > 6)) {
			System.out.println(s1 + " " + i1 + " " + i2);
			change(s1, i1, i2);
			}else{
				System.out.println("Cant go");
			}
		} while (!end(total));
		System.out.println("You are genious guy");
	}

	public static boolean except(int i, int j) {

		if (i == 0 || i == 1 || i == 5 || i == 6) {
			if (j == 0 || j == 1 || j == 5 || j == 6) {
				return false;
			}
		}
		return true;
	}

	public static void showArray(String[][] temp) {
		int [][] size = new int[7][7];
		int [] sizeO = new int[7];
		System.out.println("Enter \"row\" for vertical \"column\" for horizental");
		for(int k = 0;k<sizeO.length;k++){
			size[0][k] = k;
			System.out.print(size[0][k] + " ");
		}
		System.out.println(" ");
		for(int l=1;l<size.length;l++){
			size[l][0] = l;
			System.out.println(size[l][0]);
		}
		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				System.out.print(total[i][j]);
			}
			System.out.println("");
		}
	}

	public static boolean canMove(int i, int j) {
		if (total[i][j].equals("O ")) {
			return true;
		} else {
			return false;
		}
	}

	public static void change(String direction, int i, int j) {

		if (canMove(i, j)) {
			select(direction, i, j);
			showArray(total);
		} else if (!canMove(i, j)) {
			System.out.println("cant go");
		}
	}

	public static boolean goToX(int i, int j) {
		if (total[i][j].equals("X ")) {
			return true;
		} else {
			return false;
		}
	}

	public static void select(String direction, int i, int j) {

		if (direction.equals("left")) {
			if ((except(i, j - 2)) && (goToX(i, j - 2))) {
				total[i][j - 1] = "O ";
				total[i][j - 2] = "O ";
			}else{
				System.out.println("cant go");
			}
		} else if (direction.equals("right")) {
			if ((except(i, j + 2)) && (goToX(i, j + 2))) {
				total[i][j + 1] = "O ";
				total[i][j + 2] = "O ";
			}else{
				System.out.println("cant go");
			}
		} else if (direction.equals("up")) {
			if ((except(i - 2, j)) && (goToX(i - 2, j))) {
				total[i - 1][j] = "O ";
				total[i - 2][j] = "O ";
			}else{
				System.out.println("cant go");
			}
		} else if (direction.equals("down")) {
			if ((except(i + 2, j)) && (goToX(i + 2, j))) {
				total[i + 1][j] = "O ";
				total[i + 2][j] = "O ";
			}else{
				System.out.println("cant go");
			}
		}
		total[i][j] = "X ";
	}

	public static boolean end(String[][] temp) {
		String[][] result = new String[7][7];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					result[i][j] = "O ";
				}
				if (!except(i, j)) {
					result[i][j] = "  ";
				}
			}
		}
		result[3][3] = "X ";

		if (Arrays.equals(result, temp)) {
			showArray(temp);
			return true;

		} else {
			return false;
		}
	}

	public static String parseString() {
		String s1 = null;
		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			s1 = bufferedReader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s1;
	}

	public static int parseOne() {
		String s2 = null;
		int i1 = 0;
		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			s2 = bufferedReader.readLine();
			i1 = Integer.parseInt(s2);
		} catch (NumberFormatException ex) {
			System.out.println("Not a number !");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return i1;
	}

	public static int parseTwo() {
		String s3 = null;

		int i2 = 0;

		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			s3 = bufferedReader.readLine();
			i2 = Integer.parseInt(s3);
		} catch (NumberFormatException ex) {
			System.out.println("Not a number !");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return i2;
	}
}

 

อันนี้ แบบเล่นเกม ตอบโต้ อันนี้ เล่นได้ แต่ผมยังไม่เคยเล่นจบนะ ก็ลองไปหา solution โดย code แบบแรก

 

แต่ ให้ มัน run หา solution ดันค้างซะงั้น


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#4 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 15:38

คือ ผมขยายความ การ run สักหน่อยครับ มันไม่ขึ้น run time error ฟ้อง อะไรเลย

 

แต่ขึ้น การคำนวน สร้าง ตาราง dimension array ออกมา ได้แค่ 3 ช่วง แล้ว ก็ไม่ทำอะไรต่อเลยครับ

 

แต่แปลกที่ process ยังค้าง อยู่ บางครั้ง ผมต้อง มา end process ที่ task manager ถึงจะหยุดน่ะครับ

 

 

ผมไม่แน่ใจ ว่านี่ เป็น ลักษณะ long task หรือ ว่า เป็นความผิดปรกติของ code ที่ผมเขียน จนทำให้ไม่สามารถ ไปต่อได้ แต่ที่ runtime ไม่ฟ้องนี่ ทำเอาผมงง ไปหมด

 

เพราะปกติ มันจะขึ้น stacktrace ให้ผม ตามไปดูได้ ว่าผิดที่ตรงจุดไหน แต่มันไม่ขึ้นอะไรมาเลย งงมากครับ


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#5 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 16:44



import java.util.Arrays;

public class Peg2 {
	static String[][] total = new String[7][7];
	static final int left = 1;
	static final int right = 2;
	static final int up = 3;
	static final int down = 4;

	public static void main(String[] args) {

		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					total[i][j] = "X ";
				}
				if (!except(i, j)) {
					total[i][j] = "  ";
				}
			}
		}
		total[3][3] = "O ";
		showArray(total);
		do {
			String s1 = null;
			int i1 = 0;
			int i2 = 0;
			String[] s = parseString();
			int[] one = parseOne();
			int[] two = parseTwo();
			try {
				for (String stem : s) {
					s1 = stem;
					for (int ite1 : one) {
						i1 = ite1;
						for (int ite2 : two) {

							i2 = ite2;
							if (change(s1, i1, i2)) {

								System.out.println(s1 + " " + i1 + " " + i2);
								goSelect(s1, i1, i2);
								showArray(total);

							} else {

							}
						}
					}
				}
				Thread.currentThread().sleep(1000);//
			} catch (InterruptedException ie) {

			}
		} while (!end(total));
		System.out.println("You are genious guy");
	}

	public static boolean except(int i, int j) {

		if (i == 0 || i == 1 || i == 5 || i == 6) {
			if (j == 0 || j == 1 || j == 5 || j == 6) {
				return false;
			}
		}
		return true;
	}

	public static void showArray(String[][] temp) {

		for (int i = 0; i < total.length; i++) {
			for (int j = 0; j < total.length; j++) {
				System.out.print(total[i][j]);
			}
			System.out.println("");
		}
	}

	public static boolean canMove(int i, int j) {
		if (total[i][j].equals("O ")) {
			return true;
		} else {
			return false;
		}
	}

	public static boolean change(String direction, int i, int j) {
		boolean tem = false;
		if (canMove(i, j)) {
			if (direction.equals("left")) {
				if (!((j - 2) < 0) && (except(i, j - 2)) && (goToX(i, j - 2))
						&& (goToX(i, j - 1))) {
					tem = true;
				} else {
					tem = false;
				}
			}
			if (direction.equals("right")) {
				if (!((j + 2) > 6) && (except(i, j + 2)) && (goToX(i, j + 2))
						&& (goToX(i, j + 1))) {
					tem = true;
				} else {
					tem = false;
				}
			}
			if (direction.equals("up")) {
				if (!((i - 2) < 0) && (except(i - 2, j)) && (goToX(i - 2, j))
						&& (goToX(i - 1, j))) {
					tem = true;
				} else {
					tem = false;
				}
			}
			if (direction.equals("down")) {
				if (!((i + 2) > 6) && (except(i + 2, j)) && (goToX(i + 2, j))
						&& (goToX(i + 1, j))) {
					tem = true;
				} else {
					tem = false;
				}
			}

		} else if (!canMove(i, j)) {

			tem = false;
		}
		return tem;
	}

	public static boolean goToX(int i, int j) {
		if (total[i][j].equals("X ")) {
			return true;
		} else {
			return false;
		}
	}

	public static boolean select(String direction, int i, int j) {
		boolean tem = false;
		if (direction.equals("left")) {

		} else if (direction.equals("right")) {

		} else if (direction.equals("up")) {

		} else if (direction.equals("down")) {

		}
		return tem;
	}

	public static void goSelect(String direction, int i, int j) {
		if (direction.equals("left")) {

			total[i][j - 1] = "O ";
			total[i][j - 2] = "O ";

		} else if (direction.equals("right")) {

			total[i][j + 1] = "O ";
			total[i][j + 2] = "O ";

		} else if (direction.equals("up")) {

			total[i - 1][j] = "O ";
			total[i - 2][j] = "O ";

		} else if (direction.equals("down")) {

			total[i + 1][j] = "O ";
			total[i + 2][j] = "O ";

		}
		total[i][j] = "X ";
	}

	public static boolean end(String[][] temp) {
		String[][] result = new String[7][7];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result.length; j++) {
				if (except(i, j) || (i == 3 && j == 3)) {
					result[i][j] = "O ";
				}
				if (!except(i, j)) {
					result[i][j] = "  ";
				}
			}
		}
		result[3][3] = "X ";

		if (Arrays.equals(result, temp)) {
			showArray(temp);
			return true;

		} else {
			return false;
		}
	}

	public static String[] parseString() {
		String[] s1 = new String[4];
		for (int temp = 0; temp < 5; temp++) {
			if (temp == left) {
				s1[0] = "left";
			} else if (temp == right) {
				s1[1] = "right";
			} else if (temp == up) {
				s1[2] = "up";
			} else if (temp == down) {
				s1[3] = "down";
			}
		}
		return s1;
	}

	public static int[] parseOne() {
		int[] ibay = new int[7];
		for (int temp = 0; temp < 7; temp++) {
			ibay[temp] = temp;
		}

		return ibay;
	}

	public static int[] parseTwo() {
		int[] ibay = new int[7];
		for (int temp = 0; temp < 7; temp++) {
			ibay[temp] = temp;
		}

		return ibay;

	}
}

อันนี้ เป็น code แบบแรก ที่พยายามแก้ ให้ดูงง น้อยลงแล้วครับ แต่ ยัง run แล้วค้าง อยู่ดี รบกวนด้วยครับ

 

สำหรับ code นี้ ตรง method select รบกวน ข้ามไปเลยครับ ผมลืมลบครับ แหะ ๆ


Edited by ทรงธรรม, 8 กุมภาพันธ์ พ.ศ. 2556 - 16:46.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#6 kwan_kao

kwan_kao

    ขาประจำ

  • Members
  • PipPipPip
  • 1,444 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 17:55

สงสัยคุณเคนอิจิ จะไม่เห็นค่ะ

ต้องไปอัญเชิญมาค่ะ

หรือไม่ก็คงต้อง PM ไปหาค่ะ


Edited by kwan_kao, 8 กุมภาพันธ์ พ.ศ. 2556 - 17:59.

ขอเป็นเพียงดินก้อนเล็ก ๆ ก้อนหนึ่งของพ่อ ก็ภูมิใจแล้ว

#7 kwan_kao

kwan_kao

    ขาประจำ

  • Members
  • PipPipPip
  • 1,444 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 18:02

..

 

ขออนุญาตเชิญค่ะ


ขอเป็นเพียงดินก้อนเล็ก ๆ ก้อนหนึ่งของพ่อ ก็ภูมิใจแล้ว

#8 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 20:00

ตอนนี้ ยังใช้มือถืออยู่ คงยังไม่สามารถไล่โค้ดให้ได้นะครับ
แต่ถ้ารอไม่ไหว ผมมีข้อเสนอแนะให้

ทุกครั้ง ที่มีการวยลูป ให้ใส่ printf (i++) ลงไป
เพื่อให้มันแสดงหน้า console ให้เราเห็นว่า
มันเป็น long process หรือ forever loop
printf ก็คือการแสดงค่า i ออกหน้าจอ ไม่ทราบว่า เขียนโปรแกรม console หรือ window นะครับ
*ปล printf คือ ภาษา c ไม่แน่ใจว่า java ใช้เหมือนกันไหม

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#9 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 20:08

โอเค ก็คือ system.out.print (z) น่ะครับ

ถ้ามีหลายลูป ให้ใส่ชื่อลูปเข้าไปด้วย

print("loop methodA {0}", z++)
เพื่อคุณจะได้รู้ว่า ลูบไหน ที่เป็นปัญหา


print("loop methodA {0} i={1} j={2}", z++,i,j)
เพื่อ echo ค่าของ i และ j
จะได้รู้ว่า มันลูปไปเกิน หรือออกนอกช่วงที่คุณตั้งไว้
หรือคุณลืม ++ ที่ไหนไปรึเปล่า

เป็นต้นครับ

วิธีแก้ปัญหาง่ายๆ ด้วยตัวเอง เร็วกว่า review code ด้วยตาครับ ^^

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#10 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 8 กุมภาพันธ์ พ.ศ. 2556 - 20:17

ดูคร่าวๆ ก็น่าจะเป็น while loop ที่ end ไม่ return true สักทีนะครับ
ต้องถามก่อนว่า end จะมีบทจบยังไง

ตรงนี้ เหมือนปัญหา halting problem ที่คุณ Gop เคยถาม
จริงๆ เราอยากให้มันจบ
แต่ดันไปให้ค่ามันเดินตลอด มันเลยไม่จบ
อันนี้ อธิบายแถมเฉยๆครับ อิอิ

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#11 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 08:19

ดูคร่าวๆ ก็น่าจะเป็น while loop ที่ end ไม่ return true สักทีนะครับ
ต้องถามก่อนว่า end จะมีบทจบยังไง

ตรงนี้ เหมือนปัญหา halting problem ที่คุณ Gop เคยถาม
จริงๆ เราอยากให้มันจบ
แต่ดันไปให้ค่ามันเดินตลอด มันเลยไม่จบ
อันนี้ อธิบายแถมเฉยๆครับ อิอิ

 

ผมสงสัยที่อันนี้ เหมือนกันครับ เพราะ เมื่อวาน ผมลองทำตารางแล้วเล่นเอง แบบใช้มือเดิน

 

ตาม ลูป ที่ผม ทำให้มันเดิน ปรากฎ ว่า เงื่อนไข ที่ผมตั้ง บวกกับ ลูป ที่ผมให้มันทำตาม

 

ไม่สามารถ หา solution จุดจบได้ครับ เพราะ การหา จุดจบ ของ peg solitaire มันยากกว่า ที่ผม พยายามใส่

 

เงื่อนไข แค่ว่า ไม่ให้เดิน ยังไง เกมนี้ ต้องใช้สมองคิดมากกว่านั้น น่ะครับ

 

 

ผม คิดว่า จะลอง ไปหา สรุป การแก้ไข ปัญหา ของเกมนี้ ให้ได้ก่อน แล้วจึงคิดว่า

 

จะสั่งให้ มันหา ตาเดิน อย่างไร ครับ พอดี ช่วงนี้ ผมไข้ขึ้น เลย ต้องรอไปก่อน

 

แต่ จะพยายาม ทีหลังครับ ขอบคุณ สำหรับ คำแนะนำครับ
 

 

เพิ่มเติม หน่อยครับ ต้องขอโทษ คุณ เคนอิจิ อย่างสูง

 

ผมผิดพลาด ไปหน่อยครับ ที่ ดู ระดับความยาก ของการหา solution ผิดไป

 

คือ ใน web เขา บอกความยากที่ระดับ 1 ผมก็นึกว่า มันเป็นระดับเริ่มต้น

 

แต่ตรงข้ามครับ มันเป็น ระดับ ยากสุดของเขาเลย

 

ผมถึงบางอ้อ เลยครับ ว่า เมื่อวาน ทำไม ผมนั่งลองเล่น อยู่พักหนึ่ง ถึงได้ เล่นไม่จบสักที

 

ตาเดินมันจะตัน พอไปถึง กลางตาราง ตลอดเลย ครับ พอไม่มีตาเดิน while ลูป เลยจบไม่ได้

 

ขนาดลองเล่น แบบ ปกติ ใช้หัวคิด ไปตายตอนเหลือ หมุด (peg) 5 ตัว ทุกทีเลย

 

สุดท้าย ผม เลยได้รู้ว่า เขาบอกให้ใช้ วิธี bruce force attack แบบ ที่หา password ของ rar file นั่นละครับ

 

ให้ process ไล่หา ทางไปทีละอัน จนหาเจอ

 

แต่การ เขียน code แบบนี้ ไม่มีในหัว ผมเลย มันเลย เป็นการข้ามขั้น ของผมเอง

 

ต้องขอโทษ จริง ๆ ครับ ที่ดูระดับ ความยาก ผิดไป

 

นี่อะ ที่มาครับ

 

 

http://www.home.hs-k...en/en/java.html

 

ผมเลือก อันนี้

 

http://www.home.hs-k....html#solitaire


Edited by ทรงธรรม, 11 กุมภาพันธ์ พ.ศ. 2556 - 08:50.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#12 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 09:21

อ้อ .. มันเป็นอย่างนี้นะครับ

อย่างที่ผมบอก หากคุณอยากทำ rpg ต้องศึกษาเรื่อง animation ก่อน
แบบดราก้อนบอล คุณรู้แล้ว ว่ามันเป็น frame หลายๆภาพมาต่อกันจนวิ่งได้
แต่ 3d คือลายเส้น ที่ถุกดึงไปดึงมา จนภาพมันหมุนได้ และทุกองประกอบรือ object


เหมือนการทำเกมส์ ชนิดพัซเซิล
คุณต้องเริ่มจากการเอารูปมาต่อกันก่อน
แต่ก่อนหน้านั้น คุณต้องรู้ว่ามันจะจบอย่างไร
มันมีวิธีทำ และวิธีจบอย่างไร

เช่น หากคุณจะทำ solitair 10 ชั้น ต้อง่รู้ว่า แก้ 3 ชั้นต้องทำไง
แก้ 4 ชั้น 5 ชั้น 6 ชั้น ทำไง
ถ้าหาจุดร่วมของมันได้ คุณก็จะได้ 7 8 9 10 ชั้นเอง ถูกไหม
แต่ถ้าแก้ 2 ชั้น 3 ชั้น 4 ชั้น ยังห่วิธีเดิมๆ ทำซ้ำๆ ไม่ได้
logic เปลี่ยนไปเรื่อย ก็จะไม่สามารถคาดเดา ชั้นที่ 5 6 7 8 9 ได้ จริงป่ะ

คำว่า ตรรกะ หมายถึง

ผมให้โจทย์ ถ้าต้องการเอาช้างใส่ตู้เย็น ต้องทำอย่างไร
1. เปิดตู้เย็น
2. เอาช้างใส่
3. ปิดตู้เย็น

แล้วถ้าเอา แรด ใส่ตู้ล่ะ? เหมือนกันไหม?
(ให้เวลาคิด)













































. คำตอบคือ 1. เปิดตู้เย็น 2. เอาช้างออก 3. เอาแรดใส่ 4.ปิดตู้เย็น

แล้วถ้าจะเอาไดโนเสาร์เข้าตู้ล่ะ? เหมือนเดิมไหม?

แล้วถ้าจะเอาโน่นนี่ล่ะ
นี่คือการหา จุดสิ้นสุด ของโปรแกรม

ในเมื่อเราได้ 4 สเตปนี้แล้ว อะไรมา เราก็ใส่ได้หมด

การหา solution ของ puzzle ก็ทำนองเดียวกัน
พวกนี้ มักมีคนหาข้อสรุปออกมาแล้ว
เราแค่นำมาใช้
ส่วนการเขียน code ขึ้นอยู่กับใครจะเขียนให้มันทำงานเร็วกว่า และข้อบกพร่องน้อยกว่า
ผมถึงบอกว่า ไม่ค้องคิดเอง ไปหาสูตรมาก่อน


logic ที่ถูกใช้มาก ในการเขียน puzzle คือ recursive
คุณต้องไปศึกษาเรื่องนี้ก่อนนะ จะเข้าใจมากขึ้น
มันคือการทำซ้ำๆๆๆๆๆ จนกว่าจะถึงจุดสิ้นสุด

puzzle ยอดฮิต ที่ทุกคนต้องทำได้คือ tower of hanoi
ลองค้นดูครับ แล้วจะสนุกขึ้นอีก puzzle ง่ายๆ แต่อธิบายทุกอย่าง

มีอีกอันคือ rubic
แต่ text mode มันเล่นยาก

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#13 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 09:35

อย่างการหาจุดจบของเกมส์นี้ ต้องทำให้มัน recursive ได้ด้วย
สมมุติ แต้มทุกตาเป็น n (number) ไม่ว่าจะหยิบตัวไหน ก็นับไป n+1 n+2 .. ไปเรื่อยๆ
เหมือนทำ loop i ใน array แหละคับ
อย่าง ของจริงมีกี่ array
สุตรของคุณ จะเอาแถวพวกนี้ ไปเก็บเป็น array อย่างไร

ผมว่า สูตรที่เขาคิด มันยังไม่ถูกซะทีเดียวนะ
มันเหมือนทำเสร็จทีละข้าง (มี 4ข้าง)
พอเสร็จข้างนึงแล้ว เริ่มอีกข้างนึงไม่ได้
เพราะรูโบว๋ มันไม่กลับไปที่ตรงกลาง
เพื่อให้ข้างอื่นมีตาเดิน

เก็จปะ?

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#14 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 10:01

ตอบตามตรง เลยนะครับ

 

คือ ผมยัง ไม่ค่อยเข้าใจ เท่าไหร่

 

อย่างที่ผม กำหนด จุดจบ ให้มัน คือ ทำ array ที่เป็น ผลลัพธ์ตอนจบ(ภาพ array ที่มี X อยู่ตรงกลาง นอกนั้น เป็น O) แล้ว ใช้ Array.equals ทดสอบ ผลลัพธ์ กับ array ที่เปลี่ยนไปเรื่อย ๆ ตาม การเดิน จนกว่า จะเป็น array เดียวกัน

 

ผมคิดแบบ ซื่อ ๆ ว่า มันน่าจะใช้ได้ แต่จริง ๆ ผม ก็ยังไม่แน่ใจว่าจะใช้ได้ หรือเปล่า น่ะครับ

 

ส่วนการ recursive ผม พอรู้ว่า มัน ใช้ method ของตัวเอง ยังไง คือ ทำไปแล้ว 1 ชั้น มันจะวนกลับไปทำขั้นตอน เดิม อีก 1 ชั้น แต่ ปกติ การ recursive จะมี จำกัด ชั้น ที่ให้ recursive

 

เพราะผมเคย เปลี่ยน code ของชาวบ้าน จน มัน recursive ไม่สิ้นสุด จนมันขึ้น stack overflow มาแล้ว

 

 

แต่ถ้าถาม ว่า ผมสามารถ นำมันมาปรับใช้ได้หรือยัง คำตอบคือ ยัง ครับ เพราะ ผมยัง ไม่ได้ใช้มัน มากนัก

 

จะว่าไป เคยใช้ครั้งเดียว ตอน ผม ทำ class บัญชี เบื้องต้นของตัวเอง แต่ก็ recursive แค่ 1 ชั้น เท่านั้นเอง แหะ ๆ


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#15 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 10:03



package phase10;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class led00 {
	String led;
	List<Integer> left = new ArrayList<Integer>();
	List<Integer> right = new ArrayList<Integer>();
	List<Object[]> sum = new ArrayList<Object[]>();
	public led00(String input) {
		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			input = bufferedReader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		led = input;
	}

	public boolean testForName(String input) {

		return (input.equals(led));
	}

	public void addListLeft(int b1, boolean en) {
		if (en)
			left.add(b1);
	}

	public void addListRight(int b1, boolean en) {
		if (en)
			right.add(b1);
	}
	public int takeBF(int index){
		int suml = 0;
		int sumr = 0;
		int sumb = 0;
		suml = left.get(index);
		sumr = right.get(index);
		if(index<=0){
			sumb = 0;
		}else if(index>0){
		sumb = takeBF(index-1);
		}
		return (suml - sumr + sumb);
	
	}

	public int takeBalance(int index,int sumb) {

		int suml = 0;
		int sumr = 0;
		
		suml = left.get(index);
		sumr = right.get(index);
		return (suml - sumr + sumb);
	}

	public void showLedgerLine(int index) {
		
		int suml = 0;
		int sumr = 0;
		suml = left.get(index);
			System.out.print(suml + "    ");
		sumr = right.get(index);
		
			System.out.print(sumr + "    ");
		int result = (index==0)?0:takeBF(index-1);
		System.out.println(takeBalance(index,result));
	}

	public String toString() {
		return led;
	}

	public Object[] passLedger(boolean en, Object[] l,Object[] inv) {
		Object [] sum = null;
		if (en) {
			boolean ensure = testForName((String) l[0]);
			addListLeft((Integer) l[1], ensure);
			addListRight((Integer) l[2], ensure);
			sum = new Object[l.length+inv.length];
			System.arraycopy(inv, 0, sum, 0, inv.length);
			System.arraycopy(l, 0, sum, inv.length, l.length);
		}
		return sum;
	}
	public void addSum(Object []o){
		sum.add(o);
	}
	public void showSum(){
		for (Iterator<Object[]> it = sum.iterator(); it.hasNext(); ){
			Object[] temp = it.next();
			for(int i = 0;i<temp.length;i++){
				System.out.print(temp[i] + "  ");
			}
		}
	}
	public void showInvoice(Object [] o){
		for(int i = 0;i<o.length;i++ )
		System.out.print(o[i] + "  ");
	}
	public void showLedgerAll(){
		System.out.println(toString());
		Object[] temp = left.toArray();
		for(int i =0;i<temp.length;i++){
			Object[] obtem = sum.get(i);
			showInvoice(obtem);
			showLedgerLine(i);
		}
	}
	

}

 

เอ่อ method takeBF นั่นละครับ เป็นการใช้ recursive ครั้งแรก และครั้งเดียว ของผม

 

เพราะผมยัง ไม่ค่อยเคยชิน กับการใช้มันเลย

 

อันนี้ เป็น class บัญชีแยกประเภทครับ เป็น หนึ่งใน ชุด class ที่ผม ตั้งใจว่าจะทำ โปรแกรม บัญชีเบื้องต้น

 

ไว้ใช้เอง เนื่องจากผม ทำบัญชี อยู่ (แต่เงินเดือนน้อย ๆ เพราะผมจบแค่ ปวส)

 

 

แต่ผมกะว่า จะลงมือทำมันอีกที ตอนผมใช้ swing เออ graphic user interface ให้ได้ก่อนนะครับ

 

เรื่องนี้ ใน tutorial ยาวมาก ผมอ่าน ไปยังไม่ถึงครึ่ง ของ เนื่อหา มันเลย ไม่ค่อยเข้าใจ ตรง event เท่าไหร่ (ยังเรียนไปไม่ถึีง แหะ ๆ) แต่คิดว่า น่าจะเกี่ยวกับ logic code ที่ผม เขียนล่วงหน้าไว้ก่อน

 

ผมกะว่าจะปรับ ให้มัน เข้ากันได้ทีหลัง คงต้อง แก้อีกจมเลย

 

 

 

จริง ๆ puzzle นี่ ก็น่าทำเหมือนกันนะครับ tower of hanoi นี่มันไม่ยากใช่ไหมครับ

 

เดี๋ยวผมจะลองทำดู ไว้ อาการไข้ดีขึ้นอีกหน่อย จะทำครับ เพราะมันต้องใช้ สมองมากเลย

 

คือ ผม เป็นคน หัวสมอง ระดับ กลาง ๆ เท่านั้นเอง จำเป็นต้องใช้สมาธิ และให้เวลากับมันมาก ๆ


Edited by ทรงธรรม, 11 กุมภาพันธ์ พ.ศ. 2556 - 10:15.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#16 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 11:32

อยากบอกว่า มันไม่ยากครับ แค่มีหัวใสๆโล่งๆ คิดไปไกลๆหน่อย
ตรงจุดนี้ ตอนผมเรียน ครูบอกว่า ภาษ c ใช้ บรรทัดเดียว
ถ้าเขียนเป็น loop จะใช้หลายบรรทัดครับ)
คิดให้สมองแตก คิดไม่ออก
นั่งคิดบรรถเมล์ จนเครียด เมารถหลับไปเลย
ตื่นขึ้นมา ดันนึกได้ขึ้นมาเฉยๆ ซะงั้น ^^
recusive เป็นการทำ loop แบบ ลดรูปครับ
ขั้นแรกต้องทำ loop ให้ได้ก่อน
แล้วถึงจะทำ recursive ได้ อย่าเพิ่งข้ามขั้นครับ มันจะไปตันเอาตอนพีคๆ

ผมสอนทำ recursive ง่ายๆ ให้ printf ดูที่ console แล้วกันนะ
ไม่ตรงตาม coding language นะครับ ตอนนี้ ผมไม่มี programming studio อะไรเลย
โพสบน มือถือครับ :)
เขาเรียก pseudo code (สือโด โค้ด)
คือ คล้าย programming lang แต่ไม่ใช่
เอาไว้ให้ โปรอกรมเม่อ คนละภาษาคุยกัน
เวลาก้อบไปใช้จะ รันไม่ได้ ต้องเอาไปแปลงเป็น programing code เอง


main []
{
fowardrecusive(10);
backrecursive(10);
}

int forwardrecursive(int i)
{
printout("forward {o}", i);
if i ==0
return i;
else
return forwardrecursive(i--);

}

backrecursuve(int i)
{
if i ==0
return i;
backrecursuve(i--);
printout("forward {o}", i);
return i;

}


จะเห็นว่า recursuve คืิการทำซ้ำจนจบ
forwardrecursive จะทำงานก่อน ค่อยทำลูปถัดไป
backwardrecursive คือการ วนลูปก่อนค่อยทำงานทีหลัง

ถ้าเปรียบเทียบกับตาเดินของหมาก
การให้ค่า i =10 คือการเดินสิบครั้ง
fc คือการเลื่อนอันแรก ไปทีละอัน
bc คือการ นับไปข้างหน้า 10 อันแล้วค่อยเลื่อนทีละเม็ด



เด็กเกียรตินิยม จำได้แต่หลักการ ให้คิดแทบตายก็คิดไม่ออกครับ
ไม่เหมือนพวกปฏิบัติ มือพาไปเอง ไม่ต้องผ่านกระบวนความคิด
จะมาทางนี้ ขอแค่ขยัน ไม่คิดว่ารู้แล้ว ไม่อายครู (free source)
ก็ไปได้ไกลครับ
copy ไม่ใช่ไม่ดี แต่ก้อบแล้วต้องเข้าใจ เท่านั้นเอง

Edited by เคนอิจิ, 11 กุมภาพันธ์ พ.ศ. 2556 - 11:33.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#17 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 11:43

รูปใหม่ครับ

Attached Images

  • CYMERA_20130211_111753-1.jpg
  • CYMERA_20130211_111753-2.jpg

Edited by เคนอิจิ, 11 กุมภาพันธ์ พ.ศ. 2556 - 11:44.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#18 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 12:04

สมมติ ว่าหมากตั้งต้น เป็นแบบนี้ O คือหมาก X คือ ตาเดินที่ว่าง

 

O  O  O  O 

  O  O  O  O

X   X   X   X

   X   X   X   X

X   X   X   X

   X   X   X   X

X   X   X   X

   X   X   X   X

 

forward คือ แบบนี้ ใช่ไหมครับ

 

X   X   X   X

   X   X   X   X

O  O  O  O 

  O  O  O  O

X   X   X   X

   X   X   X   X

X   X   X   X

   X   X   X   X

 

แล้ว backward คือ แบบนี้ ใช่ไหมครับ

 

O  O  O  O 

  O  O  O   X

X   X   X   1

   X   10  2   X

X   X    9    3

   X   X   8    4

X   X    X   5,7

   X   X   X    6

 

1-10 แทน การเดินทีละตา แต่เป็นการเดิน ด้วยหมากอันเดียว แบบนี้ หรือเปล่าครับ


Edited by ทรงธรรม, 11 กุมภาพันธ์ พ.ศ. 2556 - 12:07.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#19 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 12:34

ขอโทษทีครับ
คุณโพสแล้วมันดูไม่ออก เดี๋ยวขอทำความเข้าใจนิดนึง

อันนี้ จะมองง่ายกว่า เป็นคอนเซปครับ
พยายาม apply เอา

recursive คือต้องทำทั้งหมด
ถ้าทำหมดไม่ได้ มันจะ หยุดไม่ลง อย่างที่เป็นอยู่ล่ะครับ

นั่นหมายถึง อาจต้องทำ condition เพิ่ม

ถ้าคุณทำได้ถึง 5 แปลว่า หลังจาก 5 ตัวขึ้นไป ต้อวเปลี่ยน condition
แต่ต้องรู้ก่อนว่า สเตปถัดไป จะ move หมากตัวไหน

Attached Images

  • CYMERA_20130211_123040.jpg

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#20 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 13:16

คือ ยังไม่เข้าใจหรอก นะครับ

 

แต่ อยากจะถาม ว่า เวลาที่เรา ตั้งใจจะหา solution นี่ เรา เลือกใช้

 

วิธี recursive แบบใด แบบหนึ่ง เช่น ถ้าใช้ forward ก็ใช้อย่างเดียว

 

และ backward ก็ใช้ แบบเดียว แล้วแต่ แบบใด จะเหมาะสม กับ เกม ๆ นั้น

 

ใช่ไหมครับ เป็นไปได้หรือเปล่า ว่า บางเกม ต้องใช้ ถึง 2 แบบ พร้อมกัน

 

 

 

คือ ตามความเข้าใจผม เบื้องต้น ตอนนี้ ก็คือ ผมนึกถึง  recursive แบบ ตุ๊กตารัสเซีย อะครับ คือ เข้าใจว่า ต้องทำในชั้นที่ลึกที่สุดก่อน

 

แล้ว ค่อยทำชั้นที่อยู่ถัดไป ด้วยวิธีการเดียวกัน เรื่อย ๆ มาจนถึง ชั้นที่ห่อหุ้ม ข้างบนสุด จึงเป็น ตุ๊กตารัสเซีย เสร็จหนึ่งตัว

 

หรือ อีกแบบหนึ่ง คือ การที่เราต้องทำ นาฬิกา ซึ่งเป็นงาน ประดิษฐ์ ต้องทำทั้งเข็ม และหน้าปัด วงจร ซึ่งจะมีข้อแม้ว่า ต้องใช้กลไกของ นาฬิกาอีกเรือน ซึ่งซ้อนอยู่ แต่เล็กกว่า แต่วิธีการทำนาฬิกา ที่เล็กว่านั้นต้องทำแบบเดียวกัน คือ มีทั้งเข็ม และหน้าปัด วงจร 


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#21 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 13:38

เออ มีอีกคำถามหนึ่งครับ

 

คือ กรณี หมากฮอส ถ้า กรณีที่เราเริ่ม เดิน จากหมาก มุม ซ้ายสุด บน ไป เรียกว่าเป็นตาแรก ซึ่งเป็น หนึ่ง ใน สี่ตัว ของหมาก ที่เราจะเดิน (ตาแรก เดินได้ 4 ตัวบน)

 

จะทำให้ตา ที่สอง ของเรา ที่จะเดิน ต้องพึ่งพิง การเดินของตาแรก(มุมซ้ายสุด) และ จะจำกัด การเดิน ในตา ต่อ ๆ ไป ด้วย การเดินของตาแรก และ ตาที่สอง ไปจน จบเกม

 

 

 

ลักษณะ ที่เป็นแบบนี้ คือ recursive แบบไหนครับ ใช่ forward ไหม

 

เพิ่มเติมครับแล้ว ลักษณะ ตาเดิน ที่แตกออก คล้ายกิ่งก้านที่เพิ่มขึ้น อย่างเช่น เมื่อเดินตาแรก

 

                                               1a                                 

             2aa            2ab                2ac              2ad

  3aaa...3aad  3aba..3abd     3aca...3acd     3ada.........3add

 

ลักษณะว่า จะขยายทางเลือก ออกไปเรื่อย ๆ จนไปค่อย ๆ ลดตาเดินลง เมื่อหมาก เริ่ม ลดลงไปเรื่อย ๆ

 

หรือ กรณี ของ peg solitaier คือตาเดิน จะขยายไปเรื่อย ๆ และไปลดลง เมื่อ หมุด ลดจำนวนลงเรื่อย ๆ 

 

แบบนี้ คือ forward ใช่ไหมครับ

 

จุดที่ ตาเดิน ขยายทางเลือก ไปจนสูงสุด (โดยมาก คือ กลาง ๆ ของเกม) คือ จุดพีค ที่ คุณเคนอิจิ บอกหรือเปล่าครับ


Edited by ทรงธรรม, 11 กุมภาพันธ์ พ.ศ. 2556 - 13:58.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#22 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 13:42

และ ใน merge sort ที่ทำการแบ่ง ข้อมูล การ sort ออกเป็นจาก

 

เริ่มต้น มี 8 ตัว

 

4    5    3    2    7   1   6   8

 

แล้วแบ่งเป็น

 

4    5    3    2  หนึ่งชุด   7   1   6   8

 

แล้วแบ่งเป็น

 

4    5  หนึ่งชุด   3    2   หนึ่งชุด   7    1   หนึ่งชุด   6    8

 

แล้วทำการเรียงของแต่ละชุด

 

4    5  --------    2    3  ---------   1      7 ---------   6      8

 

และรวบ

 

4     5  กับ    2     3  เข้าด้วยกัน  รวบ  1    7  กับ  6    8 เข้าด้วยกัน

 

แล้ว เรียงเป็น

 

2     3    4    5  ----------   1    6    7    8

 

แล้วสุดท้าย ค่อยรวบ เข้าด้วยกันทั้งหมด แล้วเรียงเป็น

 

1    2    3    4    5    6   7   8

 

คือ เรียงจาก ชุดที่เล็กที่สุดก่อน มาจนถึงชุดสุดท้ายที่ใหญ่ที่สุด

 

อันนี้ ใช่ backward หรือเปล่าครับ

 

เพิ่มเติมอีกนิด ครับ ผมเคยอ่านมาว่า ลักษณะที่ merge sort ทำคือเป็น recursive นั้นช่วยให้ เป็น วิธี sort ที่ถ้าไม่ใช่อันดับหนึ่ง ก็อันดับสอง แต่เห็นว่า เสถียรที่สุดด้วย

 

เป็นเพราะ recursive เป็นการคำนวน ที่ ใช้ process น้อยกว่า แบบอื่น ใช่หรือไม่ครับ คือตามความเข้าใจผม นะ ที่ทำให้การคำนวน เยอะ คือ บรรทัด หรือ statement ของ class ใช่หรือเปล่าครับ


Edited by ทรงธรรม, 11 กุมภาพันธ์ พ.ศ. 2556 - 14:04.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#23 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 14:26

#21 #22 เขาเรียกว่า binary sort คือการแยก array เป็นสองข้าง แล้วค่อยๆทำทีละข้าง

ลอง,search google หา binary sort
คุณจะเจอ วิธีการใช้ for loop ก็ได้ หรือ recursive ก็ได้

เช่น ตัวอย่างที่ผมให้ไป เขียนเป็น for loop ได้นะ
ลองเขียนให้ผมดูได้ไหม :)

เอาง่ายๆ เป็น pseudo ไม่ต้องรันจริงก็ได้


การทำ recursive คือการบอกว่า ทุกคนต้องทำเหมือนกัน แต่จะทำอะไร ยังไม่รู้
ทำไมไม่รู้? ก็เพราะค่า n มันไม่ตายตัว condition ขึ้นอยู่อาศรมกับหมไป
เช่น คุณเดินตามผม ถ้าผมเลี้ยวซ้าย คุณก็ต้องเลี้ยวซ้ายตาม
ถ้าผมทางตัน ก็ต้องดันคุณออกไป
บางที ถ้ามี solution ในการ back step ก็จะมี ทั้ง fwd,และ back
แต่การแก้ puzzle ส่วนใหญ่จะไม่มี เพรามันต้องแก้จนสำเร็จเท่านั้น ไม่มีเดินกลับ


forward เช่น
.คนยืนเรียงแถว 10 คน ผมเป็นหัวแถว คุณอยู่ทางซ้าย
เมื่อขยับขวา 1ก้าว ทุกคนก็ขยับตามมา คนละ ก้าว

backward คือ คุณอยู่ทางซ้ายของผม และผมยืนล้ำเส้น
ผมต้องให้คุณขยับไปทางซ้าย แต่คุณก็ติดอีกคน
คุณก็บอกต่อๆกัน ไปถึงคนสุดท้าย เขาก้าวซ้ายไป 1ก้าว
คนถัดมาจึงมีที่เดินซ้ายคนละก้าว จนกลับมาถึงคุณ และผมคนสุดท้าย

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#24 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 14:30

18 ตัวอย่าง 1
ผมยังหา recursive ไม่เจอ
fwd bwdเดินทีละตาทั้งคู่ครับ
ลอง wiki ดู tower of hanoi ก่อน
จะมองได้ลึกอีกนิด

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#25 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 15:05

เออ forward ก็เขียนเป็น loop

 

for( int i = 10 ; i >= 0 ; i--) 

 

System.out.print( "  " + i);

 

 

ถ้าเป็น backward ก็

 

for( int i = 10 ; i >= 0; --i)

 

System.out.print ("  " + (10-i));

 

ใช่ หรือเปล่าครับ


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#26 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 11 กุมภาพันธ์ พ.ศ. 2556 - 18:27

ใช่ครับ
สังเกตุไหมว่า มันง่ายๆ ทำไมต้องใช้ recursive ให้มากความ?


ปล. เพิ่มให้นิด

ถ้าเริ่มจาก 10 fwd จะเป็น 10 9 8 7 6 5...
bwd ก็จะเป็น 1 2 3 4 5 6 .....

ถ้าเริ่มจาก 1 มันก็คือ 1 2 3 4 5 6.......
bwd จะเป็น 10 9 8 7 6 5 4.......

ถ้า fwd คือ

for i=0 : i < n : i ++
print(i)

bwd ก็ต้องเป็น

for i=0 : i < n : i ++
print(n-i)


ตกลง ลอง printf debug ค่าดูรึยัง
ให้ put ใส่ไฟล์ไว้ก็ดีระ จะได้ก้อบมาให้ดูได้
ต้องอาศัยการ dubug ครับ ไม่งั้นการทำลูป มันหาข้อผิดพลาดยาก

Edited by เคนอิจิ, 12 กุมภาพันธ์ พ.ศ. 2556 - 06:44.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#27 Gop

Gop

    สมาชิกขั้นสูง

  • Members
  • PipPipPipPip
  • 4,450 posts

ตอบ 12 กุมภาพันธ์ พ.ศ. 2556 - 10:51

แวะมาให้กำลังใจทั้งศิษย์ และอาจารย์ครับ


หลักฐานไม่เคยโกหก (Gilbert Grissom C.S.I.)<p>Beneath this mask there is more than flesh. Beneath this mask there is an idea, Mr. Creedy, and ideas are bulletproof.

 


#28 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 06:43

คือ จะอวด คุณเคนอิจิ อะครับ ไม่ใช่อะไรหรอก

 

เมื่อวาน ผมไปทำ tower of hanoi มาแล้วล่ะ มี 2 แบบ

 

แบบเล่นเอง กับ แบบ recursive

 

import java.util.Arrays;

public class Tower {
	static String e = "       ";
	static String[][] hanoi = { { "small  ", e, e }, { "middle ", e, e },
			{ "big    ", e, e }, { "biggest", e, e } };
	static Dimen[] solution = new Dimen[15];

	public static void main(String[] args) {
		for (int i = 0; i < solution.length; i++) {
			solution[i] = new Dimen();
		}
		showArray();
		if (findSolution(0)) {
			printSolution();
		} else {
			System.out.println("No solution found!?");
		}

	}

	public static boolean findSolution(int move) {
		int one = 0;
		int two = 0;
		int three = 0;
		int four = 0;
		
		for (one = 0;  one < hanoi.length; one++) {
			
			for (two = 0; two < hanoi[one].length; two++) {
				
				if (canMove(one, two)) {
					for (three = 0; move<=14 &&three < hanoi.length; three++) {
						
						for (four = 0; four < hanoi[three].length; four++) {
							
							if (canMoveTo(three, four)) {
								moveTo(one, two, three, four);
								if (except(three, four)) {
									
									copyArray(solution[move]);
									if (!(end(hanoi) && (move >= 14))) {
										if (findSolution(move+1)) {
											return true;
										} else {
											moveBack(three, four, one, two);
										}
									} else {
										return true;
									}

									
								} else {
									
									moveBack(three, four, one, two);
								}

							} else {

							}
						}
					}
				} else {

				}
			}
		}
		return false;
	}

	public static Dimen copyArray(Dimen result) {

		for (int i = 0; i < hanoi.length; i++) {
			for (int j = 0; j < hanoi[0].length; j++) {
				result.temp[i][j] = hanoi[i][j];
			}
		}

		return result;
	}

	public static void printSolution() {
		for (int z = 0; z < solution.length; z++) {
			solution[z].print();
			System.out.println("");
		}
	}

	public static void showArray() {
		for (int i = 0; i < hanoi.length; i++) {
			for (int j = 0; j < hanoi[0].length; j++) {
				System.out.print(hanoi[i][j] + " | ");
			}
			System.out.println("");
		}
	}

	public static boolean canMove(int i, int j) {
		boolean tem = false;
		if ((!(i < 0)) && (!(i > 3)) && (!(j < 0)) && (!(j > 2))) {

			if (hanoi[i][j].equals(e)) {
				tem = false;
			} else if (!(hanoi[i][j].equals(e))) {
				if ((i == 0) || hanoi[i - 1][j].equals(e)) {
					tem = true;
				} else {
					tem = false;
				}
			}
		} else {
			tem = false;
		}
		return tem;
	}

	

	public static boolean canMoveTo(int i, int j) {
		boolean tem = false;
		if ((!(i < 0)) && (!(i > 3)) && (!(j < 0)) && (!(j > 2))) {
			if (hanoi[i][j].equals(e)) {
				tem = true;
			} else {
				tem = false;
			}
		} else {
			tem = false;
		}
		return tem;
	}

	public static void moveTo(int i, int j, int k, int l) {
		String result = null;
		result = hanoi[i][j];
		hanoi[i][j] = e;
		hanoi[k][l] = result;
	}

	public static void moveBack(int k, int l, int i, int j) {
		String result = null;
		result = hanoi[k][l];
		hanoi[k][l] = e;
		hanoi[i][j] = result;
	}

	public static boolean except(int i, int j) {
		boolean tem = false;
		if (exceptSmall(i, j) && exceptMiddle(i, j) && exceptBig(i, j)
				&& exceptBiggest(i, j)) {
			tem = true;
		} else {
			tem = false;
		}
		return tem;
	}

	public static boolean exceptSmall(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("small  ")) {
			if (i == 3) {
				if (hanoi[i - 1][j].equals(e) && hanoi[i - 2][j].equals(e)
						&& hanoi[i - 3][j].equals(e)) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 2) {
				if ((!(hanoi[i + 1][j].equals(e))) && hanoi[i - 1][j].equals(e)
						&& hanoi[i - 2][j].equals(e)) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 1) {
				if ((!(hanoi[i + 2][j].equals(e)))
						&& (!(hanoi[i + 1][j].equals(e)))
						&& hanoi[i - 1][j].equals(e)) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 0) {
				if ((!(hanoi[i + 3][j].equals(e)))
						&& (!(hanoi[i + 2][j].equals(e)))
						&& (!(hanoi[i + 1][j].equals(e)))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		} else {
			tem = true;
		}
		return tem;
	}

	public static boolean exceptMiddle(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("middle ")) {
			if (i < 1) {
				tem = false;
			} else if (i == 3) {
				if (hanoi[i - 1][j].equals(e)
						|| hanoi[i - 1][j].equals("small  ")
						&& (hanoi[i - 2][j].equals(e))
						&& (hanoi[i - 3][j].equals(e))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 2) {
				if ((!(hanoi[i + 1][j].equals(e) || hanoi[i + 1][j]
						.equals("small  ")))
						&& (hanoi[i - 1][j].equals(e) || hanoi[i - 1][j]
								.equals("small  "))
						&& (hanoi[i - 2][j].equals(e))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 1) {
				if (hanoi[i + 2][j].equals("biggest")
						&& hanoi[i + 1][j].equals("big    ")
						&& (hanoi[i - 1][j].equals(e) || hanoi[i - 1][j]
								.equals("small  "))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		} else {
			tem = true;
		}
		return tem;
	}

	public static boolean exceptBig(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("big    ")) {
			if (i < 2) {
				tem = false;
			} else if (i == 2) {
				if (hanoi[i + 1][j].equals("biggest")
						&& (!(hanoi[i - 1][j].equals("biggest")))
						&& (!(hanoi[i - 2][j].equals("biggest")))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 3) {
				if ((!(hanoi[i - 1][j].equals("biggest")))
						&& (!(hanoi[i - 2][j].equals("biggest")))
						&& (!(hanoi[i - 3][j].equals("biggest")))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		} else {
			tem = true;
		}
		return tem;
	}

	public static boolean exceptBiggest(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("biggest")) {
			if (i == 3)
				tem = true;
			else
				tem = false;
		} else {
			tem = true;
		}
		return tem;
	}

	public static boolean end(String[][] temp) {

		String[][] result1 = { { e, "small  ", e }, { e, "middle ", e },
				{ e, "big    ", e }, { e, "biggest", e } };
		String[][] result2 = { { e, e, "small  " }, { e, e, "middle " },
				{ e, e, "big    " }, { e, e, "biggest" } };
		if ((Arrays.deepEquals(result1, temp))
				|| (Arrays.deepEquals(result2, temp))) {
			return true;

		} else {
			return false;
		}
	}

	public static void parseOne() {

	}

	public static void parseTwo() {

	}
}

 

อันนี้ แบบ recursive เทสต์แล้ว ได้ผลด้วยล่ะ


Edited by ทรงธรรม, 13 กุมภาพันธ์ พ.ศ. 2556 - 06:46.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#29 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 06:47

public class Dimen {
	String [][] temp =new String[4][3];
	
	
	public void print(){
		for (int i = 0; i < temp.length; i++) {
			for (int j = 0; j < temp[0].length; j++) {
				System.out.print(temp[i][j] + " | ");
			}
			System.out.println("");
		}
	}
}

อันนี้ เป็น class เล็ก ๆ ประกอบ การทำ class แบบ recursive ครับ


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#30 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 06:49

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Tower {
	static String[][] hanoi = { { "small  ", "", "" }, { "middle ", "", "" },
			{ "big    ", "", "" }, { "biggest", "", "" } };

	public static void main(String[] args) {
		
		showArray();
		int one = 0;
		int two = 0;
		int three = 0;
		int four = 0;
		int move = 0;
		do{
		one = parseOne();
		two = parseTwo();
		if(canMove(one,two)){
			three = parseOne();
			four = parseTwo();
			if(canMoveTo(three,four)){
				moveTo(one,two,three,four);
				if(except(three,four)){
					System.out.println("look good");
					System.out.println("count move  "+ (++move));
				}else{
					moveBack(three,four,one,two);
					System.out.println("cant fill");
				}
				
			}else{
				System.out.println("cant move to");
			}
			
		}else{
			System.out.println("cant move");
		}
			
		showArray();
		}while(move<30);
		showArray();
		System.out.println("you are genious guy");
	}
	public static void showArray(){
		for (int i = 0; i < hanoi.length; i++) {
			for (int j = 0; j < hanoi[0].length; j++) {
				System.out.print(hanoi[i][j] + "  |  ");
			}
			System.out.println("");
		}
	}
	public static boolean canMove(int i, int j) {
		boolean tem = false;
		if ((!(i < 0)) && (!(i > 3)) && (!(j < 0)) && (!(j > 2))) {

			if (hanoi[i][j].equals("")) {
				tem = false;
			} else if (!(hanoi[i][j].equals(""))) {
				if ((i==0)||hanoi[i - 1][j].equals("")) {
					tem = true;
				} else {
					tem = false;
				}
			}
		} else {
			tem = false;
		}
		return tem;
	}

	public static String moveSize(int i, int j) {
		String result = null;

		result = hanoi[i][j];

		return result;
	}

	public static boolean canMoveTo(int i, int j) {
		boolean tem = false;
		if ((!(i < 0)) && (!(i > 3)) && (!(j < 0)) && (!(j > 2))) {
			if (hanoi[i][j].equals("")) {
				tem = true;
			} else {
				tem = false;
			}
		} else {
			tem = false;
		}
		return tem;
	}

	public static void moveTo(int i, int j, int k, int l) {
		String result = null;
		result = moveSize(i, j);
		hanoi[i][j] = "";
		hanoi[k][l] = result;
	}

	public static void moveBack(int k, int l, int i, int j) {
		String result = null;
		result = moveSize(k, l);
		hanoi[k][l] = "";
		hanoi[i][j] = result;
	}

	public static boolean except(int i, int j) {
		boolean tem = false;
		if (exceptSmall(i, j) && exceptMiddle(i, j) && exceptBig(i, j)
				&& exceptBiggest(i, j)) {
			tem = true;
		} else {
			tem = false;
		}
		return tem;
	}

	public static boolean exceptSmall(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("small  ")) {
			if (i == 3) {
				if (hanoi[i - 1][j].equals("") && hanoi[i - 2][j].equals("")
						&& hanoi[i - 3][j].equals("")) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 2) {
				if ((!(hanoi[i + 1][j].equals("")))
						&& hanoi[i - 1][j].equals("")
						&& hanoi[i - 2][j].equals("")) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 1) {
				if ((!(hanoi[i + 2][j].equals("")))
						&& (!(hanoi[i + 1][j].equals("")))
						&& hanoi[i - 1][j].equals("")) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 0) {
				if ((!(hanoi[i + 3][j].equals("")))
						&& (!(hanoi[i + 2][j].equals("")))
						&& (!(hanoi[i + 1][j].equals("")))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		}else{
			tem = true;
		}
		return tem;
	}

	public static boolean exceptMiddle(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("middle ")) {
			if (i < 1) {
				tem = false;
			} else if (i == 3) {
				if (hanoi[i - 1][j].equals("")
						|| hanoi[i - 1][j].equals("small  ")
						&& (hanoi[i - 2][j].equals(""))
						&& (hanoi[i - 3][j].equals(""))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 2) {
				if ((!(hanoi[i + 1][j].equals("") || hanoi[i + 1][j]
						.equals("small  ")))
						&& (hanoi[i - 1][j].equals("") || hanoi[i - 1][j]
								.equals("small  "))
						&& (hanoi[i - 2][j].equals(""))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 1) {
				if (hanoi[i + 2][j].equals("biggest")
						&& hanoi[i + 1][j].equals("big    ")
						&& (hanoi[i - 1][j].equals("") || hanoi[i - 1][j]
								.equals("small  "))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		}else{
			tem = true;
		}
		return tem;
	}

	public static boolean exceptBig(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("big    ")) {
			if (i < 2) {
				tem = false;
			} else if (i == 2) {
				if (hanoi[i + 1][j].equals("biggest")
						&& (!(hanoi[i - 1][j].equals("biggest")))
						&& (!(hanoi[i - 2][j].equals("biggest")))) {
					tem = true;
				} else {
					tem = false;
				}
			} else if (i == 3) {
				if ((!(hanoi[i - 1][j].equals("biggest")))
						&& (!(hanoi[i - 2][j].equals("biggest")))
						&& (!(hanoi[i - 3][j].equals("biggest")))) {
					tem = true;
				} else {
					tem = false;
				}
			}
		}else{
			tem = true;
		}
		return tem;
	}

	public static boolean exceptBiggest(int i, int j) {
		boolean tem = false;
		if (hanoi[i][j].equals("biggest")) {
			if (i == 3)
				tem = true;
			else
				tem = false;
		}else{
			tem = true;
		}
		return tem;
	}
	public static int parseOne(){
		String s2 = null;
		int i1 = 0;
		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			s2 = bufferedReader.readLine();
			i1 = Integer.parseInt(s2);
		} catch (NumberFormatException ex) {
			System.out.println("Not a number !");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return i1;
	}

	public static int parseTwo() {
		String s3 = null;

		int i2 = 0;

		try {
			BufferedReader bufferedReader = new BufferedReader(
					new InputStreamReader(System.in));
			s3 = bufferedReader.readLine();
			i2 = Integer.parseInt(s3);
		} catch (NumberFormatException ex) {
			System.out.println("Not a number !");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return i2;
	
	}
}

 

อันนี้ เป็นแบบ ให้เล่น โดยผ่าน command line ครับ ใช้ system in ช่วย


ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#31 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 06:56

คือ จะบอกว่า ผม copy วิธีการ มาจาก การแก้ Peg solitaire ของ ชาวเยอรมัน ที่ ผม ไปเอา แบบฝึกหัด น่ะแหละครับ

 

แต่จะบอกว่า ผม copy แต่ผม เข้าใจวิธีการมันแล้วนะ

 

คือจากการอธิบายของคุณ เคนอิจิ ด้วยอะครับ

 

เพราะ เมื่อวานนี้ กว่าผมจะทำเสร็จ ทั้งสองอัน ใช้เวลาร่วม 12 ชั่วโมง แน่ะครับ

 

โดยเฉพาะอัน recursive ใช้เวลามากเป็น 2 เท่า

 

 

เพราะจุดที่ผมติด และ ไม่ยอมผ่านตั้งนาน คือ ทีแรก

 

ผมไม่เข้าใจว่า ทำไม ต้อง moveBack ตาหมาก ที่เดินไปแล้ว (ในจุดที่ หลังจาก if statement ด้านในสุดของ method findSolution) เลยไม่ยอมใส่ในทีแรก

 

พอคล้อยหลังมาจึงเข้าใจว่า

 

dimension array ของผม มันเปลี่ยนรูป ไปแล้ว หลังจาก recursive ไปจนถึง ชั้นในสุด

 

ตัว hanoi [] [] ของผม มันจะเปลี่ยนรูป ไปแบบ มโหฬาร เลย 

 

ถ้าไม่มี moveBack มาคอยเปลี่ยนกลับ ไปทีละชั้น ๆ จนมาสู่ ตาแรก ก่อนจะเดิน

 

ถึง วน for loop ใหม่ แต่ ตาเดิน ตอนเดิน ตาแรก จะไม่ใช่ ตอนที่ hanoi [] [] มัน initialized

 

มันเลยทำให้ผิดพลาด

 

 

ผมว่า Peg solitaire ของผม มันก็เพราะเหตุผลนี้ด้วยเหมือนกันครับ


Edited by ทรงธรรม, 13 กุมภาพันธ์ พ.ศ. 2556 - 07:22.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#32 ทรงธรรม

ทรงธรรม

    ต่อให้ต้องเรียนจนแก่ ก็จะเรียนต่อไป คนเราพัฒนาได้ทุกคน

  • Members
  • PipPipPip
  • 2,157 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 07:17




ตกลง ลอง printf debug ค่าดูรึยัง
ให้ put ใส่ไฟล์ไว้ก็ดีระ จะได้ก้อบมาให้ดูได้
ต้องอาศัยการ dubug ครับ ไม่งั้นการทำลูป มันหาข้อผิดพลาดยาก

ยังไม่ได้ทำเลยครับ คือ ตรงส่วน debug นี่ ต้องใส่ไว้ ตรงไหนของ loop หรือเปล่าครับ

 

คือ ผมมีตั้ง 4  for loop มันต้องใส่ไว้ตรงไหนอะครับ

 

คือ มันมี body ของ ทั้ง loop และ if statement ด้วยอะครับ

 

แล้วการเขียน มันจะเป็นแบบเดียวกันไหมครับ ทั้ง c++ และ java 

 

คือ 

 

 

 

print("loop methodA {0}", z++)
เพื่อคุณจะได้รู้ว่า ลูบไหน ที่เป็นปัญหา


print("loop methodA {0} i={1} j={2}", z++,i,j)
เพื่อ echo ค่าของ i และ j
จะได้รู้ว่า มันลูปไปเกิน หรือออกนอกช่วงที่คุณตั้งไว้
หรือคุณลืม ++ ที่ไหนไปรึเปล่า

 

 

ที่คุณเคนอิจิบอกไว้

 

ลักษณะนี้ มันไม่ใช่ syntax ของ java อะครับ ผมเลย งง ๆ ค่อนข้างเยอะ

 

ว่าจะเรียน c++ เหมือนกัน แต่ java มันมโหฬารมากเลย คงอีกนานกว่าจะจบ

 

แล้วอีกอย่างคือ ผมเขียน แบบ psuedo code ไม่เป็นด้วยอะครับ

 

เลยไม่รู้ จะเขียน code แบบ กลาง ๆ ยังไง


Edited by ทรงธรรม, 13 กุมภาพันธ์ พ.ศ. 2556 - 07:20.

ขอให้พวกเรา ชาวหลากสี และพันธมิตร จงมีชีวิตรอด จากภาวะเศรษฐกิจตกต่ำ ฝีมือปูนา ไปตลอดรอดฝั่งด้วยครับ

 

PEMDAS ย่อมาจาก ลำดับการคำนวณ Parentheses , Exponentials , Multiply , Divide , Add , Subtract

 

FWGHSO ย่อมาจาก ลำดับการประเมินผลของ query  FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY


#33 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 09:00






ตกลง ลอง printf debug ค่าดูรึยัง
ให้ put ใส่ไฟล์ไว้ก็ดีระ จะได้ก้อบมาให้ดูได้
ต้องอาศัยการ dubug ครับ ไม่งั้นการทำลูป มันหาข้อผิดพลาดยาก

ยังไม่ได้ทำเลยครับ คือ ตรงส่วน debug นี่ ต้องใส่ไว้ ตรงไหนของ loop หรือเปล่าครับ

คือ ผมมีตั้ง 4 for loop มันต้องใส่ไว้ตรงไหนอะครับ

คือ มันมี body ของ ทั้ง loop และ if statement ด้วยอะครับ

แล้วการเขียน มันจะเป็นแบบเดียวกันไหมครับ ทั้ง c++ และ java

คือ



print("loop methodA {0}", z++)
เพื่อคุณจะได้รู้ว่า ลูบไหน ที่เป็นปัญหา


print("loop methodA {0} i={1} j={2}", z++,i,j)
เพื่อ echo ค่าของ i และ j
จะได้รู้ว่า มันลูปไปเกิน หรือออกนอกช่วงที่คุณตั้งไว้
หรือคุณลืม ++ ที่ไหนไปรึเปล่า


ที่คุณเคนอิจิบอกไว้

ลักษณะนี้ มันไม่ใช่ syntax ของ java อะครับ ผมเลย งง ๆ ค่อนข้างเยอะ

ว่าจะเรียน c++ เหมือนกัน แต่ java มันมโหฬารมากเลย คงอีกนานกว่าจะจบ

แล้วอีกอย่างคือ ผมเขียน แบบ psuedo code ไม่เป็นด้วยอะครับ

เลยไม่รู้ จะเขียน code แบบ กลาง ๆ ยังไง

ดีใจด้วย ที่หลายปม ถูกแก้ไขได้แล้ว เช่น recursive และการ move back

tower of hanoi ถ้าลองเปลี่ยนเป็น 10 ชั้น จะมองได้ลึกซึ้งบิ่งขึ้นนะครับ
มองมันทำงานไปเรื่อยๆๆๆ แล้วมันจะนึกภาพออกเอง

การทำ puzzle มันไม่ฉลาดเหมือนสมองมนุษย์ แต่มันแม่นยำกว่าด้วยสูตร
เช่น ถ้าคุณใช้ binary search หาทางเขาวงกต (maze) จะเห็นว่า ถ้าคุณเลือก จุดยืนว่า ลองไปซ้ายก่อนเสมอ เมื่อถึงทางตัน ก็จะต้องเดินถอยมาถึงทางแยกก่อนหน้า แล้วไปทางใหม่
(ลองหา maze algorithm ดูครับ)
แต่ถ้ามองด้วยตา คุณจะเห็นว่า แยกนี้ต้องเลี้ยวขวา ตะหาก เสียเวลาไปซ้าย



ผมไม่ได้ใช้ จาวาเหมือนกัน
แต่ statement (1 line of code) ของ c กับ java จะคล้ายกัน แค่เขียนต่างกัน

java เป็น object จะเห็นว่ามี xx.xx.xx() เยอะ เขาเรียกว่าคลาส
แต่ c++ ก็เหมือน object c แต่โดย nature แล้ว มันคือชุดคำสั่ง หนึ่งๆนั่นเอง
ดังนั้น การเขียน สือโด ก็ไม่ยาก ตัดความเป็น object ออกไป
ถนัดภาษาอะไร ก็เขียน คร่าวๆ ออกไปเลย

มันเป็นประสบการณ์ ค่อยๆ เรียนรู้ไปครับ
บางทีฝรั่ง ที่เขาเขียนอธิบาย algorithm ตามเวบ ก็เขียนเป็น สือโดเหมือนกัน
คุณจะงงว่า ทำไม เหมือนเป็น code แต่รันจริงไม่ได้


ผมคงไม่สามารถ review code ให้ได้ เพราะมันยาวมาก! และไม่มีที่ให้รันนะครับ
แต่จะแนะให้ คือ ถ้าผมจะดีบัก ให้คุณผมจะทำอย่างไร เผื่อคุณจะดีบักเองเป็น
เป็นสิ่งสำคัญ ของโปรแกรมเม่อ ที่จะต้องดีบัก เป็นครับ เพราะคุณจะรู้เองได้ไวกว่าคนอื่นอยู่แล้ว

ถ้าคุณ มี 4 loop ให่ใส่ทีละลูป ก็ได้ เอาที่ใกล้กับปัญหาก่อน เช่น



{


}
while (condition) // ดูว่า condition คือตัวแปลอะไร

(!end total) คือปัญหาที่เราอยากรู้ว่า ทำไม มันไม่ end สักที
ก็เข้าไป debug ตรงนั้นเลย


วิธี debug เอาแบบโค่ดจะคร่าว ก็คือ

public boolean end(array i)
{
print(i) //แสดงค่าที่ได้มาจากด้านนอกก่อนทำงาน ถ้าเป็น array ก็สร้าง function print array ขึ้นมาเลยครับ
..
..

//สุดท้าย print อีกที ก่อนจะ return ค่าการทำงาน
print (array1);
print(array2);
readline();

if (array1 = array2) return true
else return false

}

การแสดงผล จริง มันจะเละๆ ช่างมัน
อ้อ ผมเตือนว่า ควรจะใส่ readline () เข้าไปด้วย เพราะ คุณมองมันไม่ทันหรอก

พอเห็นค่าทั้งหมดแล้ว คุณจะรู้ว่า เขาเดินหมากด้วยวิธีไหน
และมันถึงจุดที่ ไม่ยอมจบเมื่อไหร่

ผมเข้าใจว่า คำว่าหมดตาเดินคือ array ที่เข้ามามีค่าเป็น null
มันถึง return false ออกไปตลอด

ถ้าใช่ ต้องมาหาทางแก้ ซึ่งขึ้นกับ logic ไม่ใช่ syntax นะครับ

logic คือวิธีแก้ปัญหา
syntax คือ วิธีเขียน code

Edited by เคนอิจิ, 13 กุมภาพันธ์ พ.ศ. 2556 - 09:02.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#34 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 13 กุมภาพันธ์ พ.ศ. 2556 - 20:07

คุณ เป็นคนที่ใฝ่รู้มากๆ 

ของแบบนี้ ไม่ใช่บอกกันเฉยๆแล้วจะรู้เรื่องหรอกนะ 

 

แต่... คุณเรียนจบ data structure ส่วนที่ยากที่สุดของปี 2 แล้วล่ะครับ :) 

 

พยายามถาม และหา solution แบบนี้ล่ะครับ 

 

 

เมื่อไหร่ อยากทำแอพบนมือถือล่ะก็ บอกนะครับ 

ไม่มีอะไรจะสอน เพราะยังทำไม่เป็น 

แต่อาจจะให้คุณสอนแทนก็เป็นได้ ;) 

หรือไม่ อาจจะมาช่วยกัน ผม ออกแบบ คุณเขียน คุณไม่เอาตัง ผมเอา สบายแฮ.. 

5555 


ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#35 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 21 กุมภาพันธ์ พ.ศ. 2556 - 09:44

เดาแล้วไม่ผิดเลย พวกแอฟบนมือถือของแบงค์ เน็ตโปรแกรมเมอร์ AS400 พวกนี้เงินเดือนสูง ไม่ใช่โปรแกรมเมอร์ทั่วไปแน่นอน

 

ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม  CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ

 

เอาคนใช้ภาษาโคบอลล์มาแนะนำ ภาษา OOP มันคนละแนวเลยครับ


Edited by Stargate-1, 21 กุมภาพันธ์ พ.ศ. 2556 - 16:22.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#36 webody

webody

    น้องใหม่

  • Members
  • Pip
  • 5 posts

ตอบ 23 กุมภาพันธ์ พ.ศ. 2556 - 10:14

ทำให้ผมได้รู้ว่า ในบอร์ดนี้มีคนเก่าจาวา ด้วยแหะ ผมจบ it มาจาวาก็แบบงูๆ ปลา 


อาหารเสริม คืออะไร? และวิตามินมีความจำเป็นต่อร่างกายเราหรือไม่


#37 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 16:10

เดาแล้วไม่ผิดเลย พวกแอฟบนมือถือของแบงค์ เน็ตโปรแกรมเมอร์ AS400 พวกนี้เงินเดือนสูง ไม่ใช่โปรแกรมเมอร์ทั่วไปแน่นอน

ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ

เอาคนใช้ภาษาโคบอลล์มาแนะนำ ภาษา OOP มันคนละแนวเลยครับ


เดาแล้วไม่ผิดเลย พวกแอฟบนมือถือของแบงค์ เน็ตโปรแกรมเมอร์ AS400 พวกนี้เงินเดือนสูง ไม่ใช่โปรแกรมเมอร์ทั่วไปแน่นอน

ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ

เอาคนใช้ภาษาโคบอลล์มาแนะนำ ภาษา OOP มันคนละแนวเลยครับ


งี่เง่าไม่เปลี่ยนแปลงครับ
recursive - cobol?
ภาพนี้ เขียนสดๆ จากคำถามของ จขกท

cobol?

อยากจะขำ ให้ดิ้นตายเหอะ

คำว่า oop และหรือ java เอง คุณรู้จักแค่ไหนครับ?

ยังดีที่รู้จักบ้าง
แต่อย่าคิดว่ารู้ดีที่สุดครับ
มันเผยความกระจอก ของตัวคุณเอง


รู้น้อยว่ารู้มาก เริงใจ
กลกบ เกิดอยู่ในสระจ้อย .....

Attached Images

  • CYMERA_20130211_111753-1.jpg

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#38 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 16:27

ก็นั่งเขียนโปรแกรมอยู่นี่ จะให้เรียกว่าอะไร? งี่เง่าไม่เปลี่ยนแปลงครับ  ถ่ายรูปอะไรมา
 

cobal.JPG

 

"ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ"      

ม่ลองเข้าไปในกูเกิ้ลว่า Headquaters อยู่ที่ไหน
 

 

แน่จริงก็บอกมาซิว่าใช้ภาษาอะไรในการโปรแกรมอยู่ ไม่ใช่แปะโน้นแปะนี้ ให้คนเข้าใจเอาเอง นึกเอาเอง ว่าใช้ภาษาโน้นภาษานี้อยู่ เสียดายตอนนั้นเพื่อนผมกำลังพัฒนาภาษานี้อยู่ ภาษา JAVA ยังไม่เกิด   เขาพัฒนาภาษา JAVA มาจากภาษาอะไร

 

http://alice.odessa....on in cobol.pdf

 

Function backRecursive() ไม่บอกว่าเอามาจาก libs.ของภาษาอะไร ให้เดาผิดเดาถูกกันอีก จะได้หลอกด่ากันอีก

 

ผมมันพวกโปรแกรมบน UNIX  ไม่ใช่พวก PC หรือ IBM AS/400 หรือ บนมือถือ


Edited by Stargate-1, 24 กุมภาพันธ์ พ.ศ. 2556 - 23:17.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#39 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 17:30

http://danzig.jct.ac.../recursion.html

 

Introduction to Computer Science - Java Recursion

Simply put, recursion is when a function calls itself. That is, in the course of the function definition there is a call to that very same function. At first this may seem like a never ending loop, or like a dog chasing its tail. It can never catch it. So too it seems our method will never finish. This might be true is some cases, but in practise we can check to see if a certain condition is true and in that case exit (return from) our method. The case in which we end our recursion is called a base case . Additionally, just as in a loop, we must change some value and incremently advance closer to our base case.
 

Consider this function.
void myMethod( int counter)
{
if(counter == 0)
     return;
else
       {
       System.out.println(""+counter);
       myMethod(--counter);
       return;
       }
}


 

This recursion is not infinite, assuming the method is passed a positive integer value. What will the output be?
Consider this method:


 

void myMethod( int counter)
{
if(counter == 0)
     return;
else
       {
       System.out.println("hello" + counter);
       myMethod(--counter);
       System.out.println(""+counter);
       return;
       }
}
If the method is called with the value 4, what will the output be? Explain.
The above recursion is essentially a loop like a for loop or a while loop. When do we prefer recursion to an iterative loop? We use recursion when we can see that our problem can be reduced to a simpler problem that can be solved after further reduction.


 

Every recursion should have the following characteristics.


 

  1.  
  2. A simple base case which we have a solution for and a return value.
  3.  
  4. A way of getting our problem closer to the base case. I.e. a way to chop out part of the problem to get a somewhat simpler problem.
  5.  
  6. A recursive call which passes the simpler problem back into the method.


 

The key to thinking recursively is to see the solution to the problem as a smaller version of the same problem. The key to solving recursive programming requirements is to imagine that your method does what its name says it does even before you have actually finish writing it. You must pretend the method does its job and then use it to solve the more complex cases. Here is how.


 

Identify the base case(s) and what the base case(s) do. A base case is the simplest possible problem (or case) your method could be passed. Return the correct value for the base case. Your recursive method will then be comprised of an if-else statement where the base case returns one value and the non-base case(s) recursively call(s) the same method with a smaller parameter or set of data. Thus you decompose your problem into two parts: (1) The simplest possible case which you can answer (and return for), and (2) all other more complex cases which you will solve by returning the result of a second calling of your method. This second calling of your method ( recursion ) will pass on the complex problem but reduced by one increment. This decomposition of the problem will actually be a complete, accurate solution for the problem for all cases other than the base case. Thus, the code of the method actually has the solution on the first recursion.
Let's consider writing a method to find the factorial of an integer. For example 7! equals 7*6*5*4*3*2*1 .
But we are also correct if we say 7! equals 7*6!.
In seeing the factorial of 7 in this second way we have gained a valuable insight. We now can see our problem in terms of a simpler version of our problem and we even know how to make our problem progressively more simple. We have also defined our problem in terms of itself. I.e. we defined 7! in terms of 6!. This is the essence of recursive problem solving. Now all we have left to do is decide what the base case is. What is the simplest factorial? 1!. 1! equals 1.


 

Let's write the factorial function recursively.


 

int myFactorial( int integer)
{
if( integer == 1)
     return 1;
else
       {
       return(integer*(myFactorial(integer-1);
       }
}


 

Note that the base case ( the factorial of 1 ) is solved and the return value is given. Now let us imagine that our method actually works. If it works we can use it to give the result of more complex cases. If our number is 7 we will simply return 7 * the result of factorial of 6. So we actaully have the exact answer for all cases in the top level recursion. Our problem is getting smaller on each recursive call because each time we call the method we give it a smaller number. Try running this program in your head with the number 2. Does it give the right value? If it works for 1 then it must work for two since 2 merely returns 2 * factorial of 1. Now will it work for 3? Well, 3 must return 3 * factorial of 2. Now since we know that factorial of 2 works, factorial of 3 also works. We can prove that 4 works in the same way, and so on and so on.
Food for thought: ask yourself, could this be written iteratively?
Note: make it your habit of writing the base case in the method as the first statement.


 

Note: Forgetting the base case leads to infinite recursion.
However, in fact, your code won't run forever like an infinite loop, instead, you will eventually run out of stack space (memory) and get a run-time error or exception called a stack overflow. There are several significant problems with recursion. Mostly it is hard (especially for inexperienced programmers) to think recursively, though many AI specialists claim that in reality recursion is closer to basic human thought processes than other programming methods (such as iteration). There also exists the problem of stack overflow when using some forms of recursion (head recursion.) The other main problem with recursion is that it can be slower to run than simple iteration. Then why use it? It seems that there is always an iterative solution to any problem that can be solved recursively. Is there a difference in computational complexity? No.
Is there a difference in the efficiency of execution? Yes, in fact, the recursive version is usually less efficient because of having to push and and pop recursions on and off the run-time stack, so iteration is quicker. On the other hand, you might notice that the recursive versions use fewer or no local variables.


 

So why use recursion? The answer to our question is predominantly because it is easier to code a recursive solution once one is able to identify that solution. The recursive code is usually smaller, more concise, more elegant, possibly even easier to understand, though that depends on ones thinking style. But also, there are some problems that are very difficult to solve without recursion. Those problems that require backtracking such as searching a maze for a path to an exit or tree based operations (which we will see in semester 2) are best solved recursively. There are also some interesting sorting algorithms that use recursion.


 

Towers of Hanoi


 

This problem comes from history, monks in Vietnam were asked to carry 64 gold disks from one tower (stack) to another. Each disk is of a different size. There are 3 stacks, a source stack, a destination stack and an intermediate stack. A disk is placed on one of three stacks but no disk can be placed on top of a smaller disk. The source tower holds 64 disks. How will the monks solve this problem? How long will it take them?


 

The easiest solution is a recursive one. The key to the solution is to notice that to move any disk, we must first move the smaller disks off of it, thus a recursive definition. Another way to look at it is this, if we had a method to move the top three disks to the middle position, we could put the biggest disk in its place. All we need to do is assume we have this method and then call it.


 

Lets start with 1 disk (our base case): Move 1 disk from start tower to destination tower and we are done.
To move 2 disks:
Move smaller disk from start tower to intermediate tower, move larger disk from start tower to final tower, move smaller disk from intermediate tower to final tower and we are done.
To move n disks (or think of, say, 3 disks):
Solve the problem for n - 1 disks (i.e. 2 disks) using the intermediate tower instead of the final tower (i.e. get 2 disks onto the intermediate tower). Then , move the biggest disk from start tower to final tower. Then again solve the problem for n - 1 disks but use the intermediate tower instead of the start tower (i.e. get the 2 disks onto the final tower using the start tower as the intermediate tower).




 

Tail Recursion


 

Tail recursion is defined as occuring when the recursive call is at the end of the recursive instruction. This is not the case with my factorial solution above. It is useful to notice when ones algorithm uses tail recursion because in such a case, the algorithm can usually be rewritten to use iteration instead. In fact, the compiler will (or at least should) convert the recursive program into an iterative one. This eliminates the potential problem of stack overflow.


 

This is not the case with head recursion, or when the function calls itself recursively in different places like in the Towers of Hanoi solution. Of course, even in these cases we could also remove recursion by using our own stack and essentially simulating how recursion would work.


 

In my example of factorial above the compiler will have to call the recursive function before doing the multiplication because it has to resolve the (return) value of the function before it can complete the multiplication. So the order of execution will be "head" recursion, i.e. recursion occurs before other operations.


 

To convert this to tail recursion we need to get all the multiplication finished and resolved before recursively calling the function. We need to force the order of operation so that we are not waiting on multiplication before returning. If we do this the stack frame can be freed up.


 

The proper way to do a tail-recursive factorial is this:

int factorial(int number) {

    if(number == 0) {

           return 1;

        }

        factorial_i(number, 1);

}



int factorial_i(int currentNumber, int sum) {

    if(currentNumber == 1) {

        return sum;

    } else {

        return factorial_i(currentNumber - 1, sum*currentNumber);

    }

}

Notice that in the call return factorial_i(currentNumber - 1, sum*currentNumber); both parameters are immediately resolvable. We can compute what each parameter is without waiting for a recursive function call to return. This is not the case with the previous version of factorial. This streamlining enables the compiler to minimize stack use as explained above. Thanks to Jon Bartlett for the example.
 

Some definitions ( types of recursion ):


 

  •  
  • Tail Recursion: A call is tail-recursive if nothing has to be done after the call returns. I.e. when the call returns, the returned value is immediately returned from the calling function. More simply, tail recursion is when the recursive call is the last statement in the function. See Tail Recursion.
  •  
  • Head Recursion: A call is head-recursive when the first statement of the function is the recursive call.
  •  
  • Middle or Multi Recursion: A call is mid-recursive when the recursive call occurs in the middle of the function. I.e. there are other statements before and after the recursive call. If one or more of these statements is another recursive call, then the function is multi-recursive. There is no essential difference between Head Recursion, Middle Recursion and Multi Recursion from the standpoint of efficiency and algorithm theory.
  •  
  • Mutual Recursion: Function X and Y are called mutually-recursive if function X calls function Y and function Y in turn calls function X. This is also called indirect recursion because the recursion occurs in two steps instead of directly. See Mutual Recursion.


 

Some Links

More explanations about recursion, Towers of Hanoi, etc.


Edited by Stargate-1, 24 กุมภาพันธ์ พ.ศ. 2556 - 17:33.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#40 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 17:40

http://www.narisa.co...showtopic=18338

การเขียนโปรแกรมวน loop แบบ recursive vs. Iteration

 

http://www.java-samp...?tutorialid=151

Recursion in java

http://community.tha...nction-aeeuoan/

ช่วยเขียนฟังก์ชันแบบเรียกตัวเอง !! (Recursive Function) ให้ดูทีครับ ช่วยทีคับ จนปัญญาแล้ว
 

http://www.toves.org...urex/index.html

Programming via Java: Recursion examples

Edited by Stargate-1, 24 กุมภาพันธ์ พ.ศ. 2556 - 17:41.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#41 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 17:46

Howto: javascript objects with public and private data and functions

Submitted by Andy Idsinga (Intel) on

Wed, 11/25/2009 - 16:18
I've been coding like mad lately - pulling together code in Javascript, HTML and C++ for the web APIs that we're working on.
See my other posts: here and here for more context.

One thing that had been nagging me about my own practice coding in javascript is that I still hadn't started implementing javascript objects with private data and functions. I knew it was possible but since the actual code layout was not obvious (at least as obvious as in C++) I procrastinated.

I'm happy to say I'm now creating my objects with private data and functions. I learned how to do this by reading this page by Douglas Crockford and by practicing the technique in a real project I'm working on.

Why do I want private data and methods in javascript?
I want them because I want to hide internal data and functions that implement the core functionality of my object behind a clean public interface. I want to disallow other code from changing my object's internal implementation except for the cases that have been explicitly allowed *through a public interface*.

I believe this also helps improve security because although a malicious script can change a public function of an object by assigning a different one to the same name; it can't change private functions and the private data and private function references they use.

I can always learn more about both javascript and security, so please feel free to help me along - especially with tips and tricks about defensive programming in javascript and web apps.

So, without further ado, here is some example code. This is a javascript object that includes both public functions and private functions and data:

FYI - I've updated this code based on Ruud's comment below and the link with Chris Heilmann's solution.




/* CODE START - spell checker off :) ---------------------------------------*/



/*  ObjectWithPrivates


    A javascript object with public and private data and functions */
function ObjectWithPrivates(){

  /* assign 'this' to 'that' so private functions can access this as that.


     Confusing? just remember: "this, that it's all the same!" :) 


     From Doug Crockford's page:


     This is a workaround for an error in the ECMAScript Language 


     Specification which causes this to be set incorrectly for inner 


     functions. 


     Note that I don't actually use the 'that' variable in


     the code below because my private functions use the privfuncs, privdata


     and pubfuncs containers to get at stuff. In any case, its a good 


     convention to follow so that private functions can access 'this'


     through 'that' */  
var that = this;

  /* container for private data - organizational thing -


     remember, since variables are scoped to the function block in 


     javascript all inner functions inside this function, our object's 


     constructor, have access to it. the outside world does not.


     tada private data! */
var privdata = {


    'data1':'this is some private data - data1',


    'data2':'some more private data - data2'


  };

  /* private function container 


     mainly for code organization and readability */
var privfuncs = {};

  /* public function container 


     we want private functions to be able to call public


     functions, but they should only do this through this container


     because the container can't be modified by the outside world directly!



     Note below we can pick and choose which funcs from pubfuncs we


     reveal through the array that we return.


  */
var pubfuncs = {};

  /* public shared data container. 


    This seems to be needed so that both internal and external code can modify shared


    data and see each other's changes. I've found that just using non array/object


    types doesn't work. This is sort of redundant becuase all of this data could


    just be revealed through this, but returning it through the array below


    makes it much more clear what the public interface is ..and that is a good thing*/
var pubdata = {};

  /* a private function - just displays a message */


  privfuncs.priv_func_1 = function(){


    alert("look everyone, this object has privates! - priv_func_1");


  }

  /* another private function - calls a public function


     through the pubfuncs container. 


     This will call the correct pub_func_2() even if some other code 


     changes this.pub_func_2 from outside. Cool eh? */


  privfuncs.priv_func_2 = function(){



    /* always call the correct pub_func_2() */


    pubfuncs.pub_func_2();


  }

  /* a public function - just calls some private functions */


  pubfuncs.pub_func_1 = function(){


    privfuncs.priv_func_1();


    privfuncs.priv_func_2();


  }

  /* second public function - displays a message */


  pubfuncs.pub_func_2 = function(){


    alert("I'm the original pub_func_2() - private data: " + privdata['data1']);


  }

  /* Now for the public interface. 


     Return an array that reveals the public interface - nice and obvious what is public*/


  return {


    pub_func_1:pubfuncs.pub_func_1,


    pub_func_2:pubfuncs.pub_func_2,


    shdata:pubdata


  }


}

/* Lets play with our object and its privates...


   Be sure to look at 'obWithPrivs' in a dom inspector tool like the 


   one that comes with firebug. Wow, no public data members, just the


   public functions! */
var obWithPrivs = new ObjectWithPrivates();

/* cheezy way to inspect the members of the object without 


   a proper dom inspector tool*/


for (var membr in obWithPrivs){


  alert("found: obWithPriv." + membr);


}

/* call a public function */


obWithPrivs.pub_func_1();

/* okay - be evil and and install a new pub_func_2 from the outside


   then call pub_func_1() again ...becuase we know it calls private code


   that calls pub_func_2 internally */


obWithPrivs.pub_func_2 = function(){


  alert("I'm the evil pub_func_2");


}

/* the new, evil, pub_func_2() will NOT be called from


   the private code becuase the private code still references 


   the original pub_func_2()*/


obWithPrivs.pub_func_1();

/* the new, evil, pub_func_2() can still be called from the outside - but


   it wasn't able to chain itself to the private functionality ! */


//alert("calling pub_func_2 directly...");


//obWithPrivs.pub_func_2();

/* CODE END ------------------------------------------------------------*/



Edited by Stargate-1, 24 กุมภาพันธ์ พ.ศ. 2556 - 17:48.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#42 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 18:00

Reverse a string using a recursive void method

So I'm trying to write a method that reverses a given string but the catch is that it has to be a void method rather than a return method which is making this difficult. My code seems logical to me but it doesn't work so I'm hoping someone can help me figure out where I'm going wrong.

public class Reverser {



public String text, revText;



/**

 * @param args

 */

public static void main(String[] args) {

    Reverser greeting = new Reverser("Buildings");

    greeting.reverse();

    System.out.println(greeting.getText());



}



public Reverser(String _text){

    text = _text;

}



public void reverse(){

    int len = text.length();

    if(len >= 1){

        String last = text.substring(text.length() - 1, text.length());

        revText += last;

        text = text.substring(0, text.length() - 1);

        Reverser loop = new Reverser(text);     

        loop.reverse();         

    }

}



public String getText(){



    return revText; 

}



}


 

 
 




1 down vote accepted



Here's an idea:

public class Reverser {



    private int idx;

    private String text, revText;



    public static void main(String[] args) {

        Reverser greeting = new Reverser("Buildings");

        greeting.reverse();

        System.out.println(greeting.getText());

    }



    public void reverse() {

        if (idx == text.length())

            return;

        revText = text.charAt(idx) + revText;

        idx++;

        reverse();

    }



    public Reverser(String _text) {

        idx = 0;

        text = _text;

        revText = "";

    }



    public String getText() {

        return revText; 

    }



}

The fundamental difference with respect to your answer, is that I'm using an index attribute to keep track of where exactly I am in the recursion. In that way, I don't have to modify the original text attribute.


Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#43 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 24 กุมภาพันธ์ พ.ศ. 2556 - 19:00

How to implement a Computer Game? Computer Games need to be fast at least 60 image per second (the monitor refresh rate) You need an efficient programming language You have to learn C++ You cannot use Java, Visual Basic, C# for critical routines. Note: A mixture of languages can be used but right now the performance critical parts are dominated by C++ in the industry Efficient Programming Language is not enough We need an efficient architecture Regular Intel / AMD CPU is too slow Peter Wonka, ASU 101 4

 

http://www.docslide....computer-games/


Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#44 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 26 กุมภาพันธ์ พ.ศ. 2556 - 11:00

http://www.youtube.com/watch?v=6PJylQILyN4&list=UUnniqWGq9lOqYd5sGWxVi7w&index=1

 

คมชัดลึก 25-02-56 ตอน ปล้น...ออนไลน์ ? ผู้ร่วมรายการ รศ.ยุทธพร อิสรชัย "เหยื่อ" ภัยธุรกรรมการเงินออนไลน์, ปริญญา หอมเอนก ประธานและผู้ก่อตั้ง ACIS Professionnal Center, นิพนธ์ นาซิน ผู้อำนวยการฝ่ายบริการที่ปรึกษา ACIS Professionnal Center
 


Edited by Stargate-1, 3 มีนาคม พ.ศ. 2556 - 01:21.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#45 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 18:16

ทำไมต้องบอกคุณว่า เขียนภาษาอะไร 

ไม่รู้ ก็ไม่ต้องสะเออะ บอกว่ารู้ 

 

google เก่ง ก็ได้แค่งาน operation 

ใช้ unix แต่ไม่ใช้ ansi C 

เอาอะไรมาอวด รู้ตัวหรือเปล่าเนี่ย? 

 

เป็นแต่ google ถึงได้ตอบคำถาม จขกท ไม่ได้

 

เขาแก้ไขงานตัวเองไปได้ถึงไหนแล้ว 

ตัวเองยังมาวนลูบ reverse string อยู่เลย  :huh:

 

นี่แหละน้า 

ไม่ใช่ของจริง ก็เอาแต่ น้ำท่วมทุ่ง ไม่ได้ใจความ ไม่ได้ประเด็น และแก้ไขปัญหาไม่ได้ 

เตะสะเปะสะปะ ไร้ประโยชน์ เป็นแต่อวด 


ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#46 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 18:32

ก็นั่งเขียนโปรแกรมอยู่นี่ จะให้เรียกว่าอะไร? งี่เง่าไม่เปลี่ยนแปลงครับ  ถ่ายรูปอะไรมา
 

attachicon.gifcobal.JPG

 

"ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ"      

ม่ลองเข้าไปในกูเกิ้ลว่า Headquaters อยู่ที่ไหน
 

 

แน่จริงก็บอกมาซิว่าใช้ภาษาอะไรในการโปรแกรมอยู่ ไม่ใช่แปะโน้นแปะนี้ ให้คนเข้าใจเอาเอง นึกเอาเอง ว่าใช้ภาษาโน้นภาษานี้อยู่ เสียดายตอนนั้นเพื่อนผมกำลังพัฒนาภาษานี้อยู่ ภาษา JAVA ยังไม่เกิด   เขาพัฒนาภาษา JAVA มาจากภาษาอะไร

 

http://alice.odessa....on in cobol.pdf

 

Function backRecursive() ไม่บอกว่าเอามาจาก libs.ของภาษาอะไร ให้เดาผิดเดาถูกกันอีก จะได้หลอกด่ากันอีก

 

ผมมันพวกโปรแกรมบน UNIX  ไม่ใช่พวก PC หรือ IBM AS/400 หรือ บนมือถือ

 

ก็เขียนเองทั้งหมด อยู่ในนั้น 

ไม่ได้เอามาจาก lib ไหน 

นั่นแหละ เรียกว่า recursive 

 

 

int backRecursive(int i)

{

   if (i=0)

      return i;

   backRecursive(i-1);

}

 

ดูไม่ออก อยากให้สอน ก็บอกตรงๆ จะสอนให้ 

ไม่ใช่ทำเป็น อวดเก่ง อวดดี 

แต่บ่มิไก๊ 

 

 

จขกท ใช้ Java แต่ไม่เขียนเป็น object หรือ oop 

เพราะการเดินหมาก มีแต่ method ไม่มี entity 

เลยไม่อยากพูดถึง lib หรือ method ให้วุ่นวาย 

และมันไม่ได้ช่วยอะไร

 

การที่คุณใช้คำว่า method คุณเข้าใจมันไหม?

 

 

 

เดาแล้วไม่ผิดเลย พวกแอฟบนมือถือของแบงค์ เน็ตโปรแกรมเมอร์ AS400 พวกนี้เงินเดือนสูง ไม่ใช่โปรแกรมเมอร์ทั่วไปแน่นอน

 

ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม  CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ

 

เอาคนใช้ภาษาโคบอลล์มาแนะนำ ภาษา OOP มันคนละแนวเลยครับ

 

คุณไปเอารูป โคบอล มาจากไหนครับ 

กระทู้นี้ มันอันนี้ครับ  อย่ามาซึน

 

กระทู้นี้ มันรูปนี้นะ 

รูปใหม่ครับ

http://webboard.seri...attach_id=14794

 

เป็นข้อพิสูจน์ว่า คุณเป็นคนชอบจับแพะชนแกะ

 

อันตรายมาก เพราะไม่รู้ว่า 

ข้อมูลทางการเมือง ที่คุณโพสๆ ออกมานั้น เป็นการจับแพะชนแกะด้วยหรือไม่ 

อย่างเรื่องน้ำมัน หรือ ปตท 

แรกๆ ก็ยังตามดูอยู่บ้าง แต่ไม่ได้คิดอะไร 

แต่ตอนนี้ เริ่มคิดละ 

ว่า .. แพะกี่ตัว แกะกี่ตัว 


Edited by นามิ, 2 มีนาคม พ.ศ. 2556 - 21:08.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#47 Stargate-1

Stargate-1

    SG-1

  • Members
  • PipPipPipPipPip
  • 8,578 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 21:03

คุณไปเอารูป โคบอล มาจากไหนครับ

เป็นข้อพิสูจน์ว่า คุณเป็นคนชอบจับแพะชนแกะ

อันตรายมาก เพราะไม่รู้ว่า
ข้อมูลทางการเมือง ที่คุณโพสๆ ออกมานั้น เป็นการจับแพะชนแกะด้วยหรือไม่
อย่างเรื่องน้ำมัน หรือ ปตท
แรกๆ ก็ยังตามดูอยู่บ้าง แต่ไม่ได้คิดอะไร
แต่ตอนนี้ เริ่มคิดละ
ว่า .. แพะกี่ตัว แกะกี่ตัว

โกหกจนไม่รู้ว่าโกหกอะไรไว้ ถ่ายรูปที่ไหนมาโพสต์ แล้วบอกว่ากำลังเขียนโปรแกรมอยู่
 
ไม่ใช้ libs แล้วไม่บอก เอามาจาก Function อะไร มั่วสุดๆ Function ของเขาก็มีอยู่แล้ว ใน libs ไมใช้ เอาของภาษาอะไรมาไม่รู้
 
ภาษา JAVA เขาเริ่มมาจาก UNIX-C script ภาษาก็บอกที่มาแล้วว่าเป็นพวก OOP ไม่ใช่ Structure Program แบบ Pascal
 
เห็นเพื่อนทำโปรเจ็คให้อ.ที่ทำงานอยู่กับ SUN  บอกว่ากำลังประดิษฐ์ภาษาใหม่ ชื่อ JAVA อยู่
ต่อมาคนนี้เรียนจบก็เข้าทำงานที่ ซันไมโครซิสเต็มส์  http://th.wikipedia....นไมโครซิสเต็มส์
(Sun's headquarters campus in Santa Clara University) แล้วมีคนไปดูถูกว่าเป็นแค่อาจารย์มหาวิทยาลัย ที่โน้นมันไม่เหมือนที่นี่ครับ 
 
การเชียนโปรแกรม ของ SW.Eng. เขาไม่ใช้ Flow Chart แล้ว เขาใช้  Logic Diagram แล้วมี Tools แปลงเป็น Code ได้เลย ส่วนพวก UNIX ใช้ Script ไม่ใช่ Program   UNIX ใช้ Ansi C ฮ่า ๆ ๆ ๆ UNIX มี 2 สองค่าย ใหญ่ๆ  เท่านั้น  AT&T และ SCO      อย่ามาอวดรู้เลย ไม่ได้อะไรหรอก  

ถ้าอยากรู้เรื่อง ปตท.จริงๆก็โทร.ไปคุยกับทีมงานอ.ประสิทธิ์เลยก็ได้ เบอร์ 084-559-3305
เพราะที่ผมหามาเองก็บอกที่มาที่ไปไว้แล้ว ส่วนที่ไม่มีที่มาที่ไปก็ของอ.ประสิทธิ์  ที่ให้ถามเพราะอ.รู้ที่มาที่ไปของข้อมูลนั้นๆ


เสื้อแดงเริ่มสนใจปากท้องตัวเองแล้ว

เพื่อนๆเสรีไทย พอจะทราบไหมวันที่26 มี.ค.2013 คนเสื้อเเดง นปช. จะเข้าพบ รมต.พลังงานเรื่อง นำ้มันเเพง พลังงานเเพง จะมีการปิดถนนประท้วงใหญ่
โดย mr.patton, วันนี้, 21:02


Edited by Stargate-1, 3 มีนาคม พ.ศ. 2556 - 00:57.

Tam-mic-ra ฟันธง!  คำว่า "โดนพริกไทยมั๊ง" น่ะ แค่นี่เอามาเป็นหลักฐาน ได้ยังไงครับ .....  คิดครับคิด  :lol:   จากกระทู้แก้ข่าวหน้า 2 qoute #96  ใครยิงวสันต์-ภู่ทอง   แอลพีจีทำมาจากซี2ซี3


#48 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 22:03

คุณไปเอารูป โคบอล มาจากไหนครับ

เป็นข้อพิสูจน์ว่า คุณเป็นคนชอบจับแพะชนแกะ

อันตรายมาก เพราะไม่รู้ว่า
ข้อมูลทางการเมือง ที่คุณโพสๆ ออกมานั้น เป็นการจับแพะชนแกะด้วยหรือไม่
อย่างเรื่องน้ำมัน หรือ ปตท
แรกๆ ก็ยังตามดูอยู่บ้าง แต่ไม่ได้คิดอะไร
แต่ตอนนี้ เริ่มคิดละ
ว่า .. แพะกี่ตัว แกะกี่ตัว

โกหกจนไม่รู้ว่าโกหกอะไรไว้ ถ่ายรูปที่ไหนมาโพสต์ แล้วบอกว่ากำลังเขียนโปรแกรมอยู่
 
ไม่ใช้ libs แล้วไม่บอก เอามาจาก Function อะไร มั่วสุดๆ Function ของเขาก็มีอยู่แล้ว ใน libs ไมใช้ เอาของภาษาอะไรมาไม่รู้
 
ภาษา JAVA เขาเริ่มมาจาก UNIX-C script ภาษาก็บอกที่มาแล้วว่าเป็นพวก OOP ไม่ใช่ Structure Program แบบ Pascal
 
เห็นเพื่อนทำโปรเจ็คให้อ.ที่ทำงานอยู่กับ SUN  บอกว่ากำลังประดิษฐ์ภาษาใหม่ ชื่อ JAVA อยู่
ต่อมาคนนี้เรียนจบก็เข้าทำงานที่ ซันไมโครซิสเต็มส์  http://th.wikipedia....นไมโครซิสเต็มส์
(Sun's headquarters campus in Santa Clara University) แล้วมีคนไปดูถูกว่าเป็นอาจารย์มหาวิทยาลัย ที่โน้นมันไม่เหมือนที่นี่ครับ 
 
การเชียนโปรแกรม ของ SW.Eng. เขาไม่ใช้ Flow Chart แล้ว เขาใช้  Logic Diagram แล้วมี Tools แปลงเป็น Code ได้เลย ส่วนพวก UNIX ใช้ Script ไม่ใช่ Program   UNIX ใช้ Ansi C ฮ่า ๆ ๆ ๆ UNIX มี 2 สองค่าย ใหญ่ๆ  เท่านั้น  AT&T และ SCO      อย่ามาอวดรู้เลย ไม่ได้อะไรหรอก  

ถ้าอยากรู้เรื่อง ปตท.จริงๆก็โทร.ไปคุยกับทีมงานอ.ประสิทธิ์เลยก็ได้ เบอร์ 084-559-3305

คุณยังจะแถอีก 

เรื่อง cobol เป็นกระทู้อื่น ดันเอามารวมกับ oop และ java ที่นี่ ยังสติดีอยู่ป่าว? 

 

เป็นใครใน SUN แล้วไง? มันใช่คุณไหมล่ะ คุณรู้ดีเท่าใครไหมล่ะ? 

 

สรุปว่า คน background ดีๆ เป็นเพื่อนตัวเอง หมดเลย ทำยังกะตัวเองรู้เท่าเขา 

ก้ากกกๆๆๆ  :lol:

 

รู้จักคำว่า lib หรือเปล่า เอามาใช้เรื่อยเปื่อย 

เขาทำ pegging อยู่ใน lib ไหนไม่ทราบ? 

 

อ่านไม่ออกดูไม่เป็น เลยคิดว่า เราจะทำ reverse string??? โถ น่าขำ  :lol:

 

อธิบายไป ก็เหมือนพูดกับลิง 

พอดีกว่า ชาวบ้านเห็นอยุ่แล้วว่า ใครของจริง ใครป่วย

 

 

สรุปว่า ปตท ก็ไม่กล้าตอบเอง แต่ต้องไปถามคนอื่น 

เออ เจริญ!!!!!

<_<

 

 

แล้วใครพูดถึง Flow chart สติแตกแล้วนาย สตุ๊ดการ์ด :D

พูดถึง ANSI C ดันไปอ้าง AT&T ฮ่าๆๆๆๆๆ ขำ  :lol:  :lol:


Edited by นามิ, 3 มีนาคม พ.ศ. 2556 - 00:25.

ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#49 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 22:08

โกหกจนไม่รู้ว่าโกหกอะไรไว้ ถ่ายรูปที่ไหนมาโพสต์ แล้วบอกว่ากำลังเขียนโปรแกรมอยู่

ปัญญาอ่อนนะ 

 

เราน่ะรู้อยู่แล้วว่าเราถ่ายมาจากไหน และตอบไว้ที่ไหน 

แต่นายน่ะมันมั่ว เอาเรื่อง cobol มาตอบใน java

แล้วมาหาว่าเราเขียนไม่เป็น

ตลกกาก มาก

 

เดาแล้วไม่ผิดเลย พวกแอฟบนมือถือของแบงค์ เน็ตโปรแกรมเมอร์ AS400 พวกนี้เงินเดือนสูง ไม่ใช่โปรแกรมเมอร์ทั่วไปแน่นอน

 

ภาษา JAVA กำเนิดมาจาก บ.ซัน ไมโครซิมเต็ม  CA, USA . โดยเพื่อนผมและอาจารย์เป็นผู้สร้างมันขึ้นมาครับ

 

เอาคนใช้ภาษาโคบอลล์มาแนะนำ ภาษา OOP มันคนละแนวเลยครับ

 

 คนละแนว แค่นายน่ะ มันสติแตก 

 

รู้ COBOL รู้ pascal รู้ UNIX รู้ .NET รู้ JAVA C++ CBuilder rational rose และอีกต่างๆมากมาย 

 

ในคนเดียว ไม่ได้เหรจ๊ะ 

อย่ามาอิจฉา..... เลยนะ นะ นะ 

:lol:

 

รู้จักแต่ c script ดันมาอวดวิจารณ์ JAVA 

นี่คงหลบเลี่ยงไม่พูดถึง ANSI C เพราะไม่รู้จัก 

เพราะคนไทย ไม่มีคำแปล พยายามอ่าน wiki แล้วก็คงไม่เข้าใจสิแนะ 

คริคริ 

 

แล้วบอกว่า ทำงาน UNIX เหอะ!!!!

 

<_<


ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 


#50 เคนอิจิ-นามิ

เคนอิจิ-นามิ

    สมาชิกขั้นสูง

  • Banned
  • PipPipPipPip
  • 4,447 posts

ตอบ 2 มีนาคม พ.ศ. 2556 - 22:14

การเชียนโปรแกรม ของ SW.Eng. เขาไม่ใช้ Flow Chart แล้ว เขาใช้  Logic Diagram แล้วมี Tools แปลงเป็น Code ได้เลย ส่วนพวก UNIX ใช้ Script ไม่ใช่ Program   UNIX ใช้ Ansi C ฮ่า ๆ ๆ ๆ UNIX มี 2 สองค่าย ใหญ่ๆ  เท่านั้น  AT&T และ SCO      อย่ามาอวดรู้เลย ไม่ได้อะไรหรอก  

 

5555555

ยิ่งขำ ใช้ SW Eng ทำโปรแกรม 

5555 ขำยังไงดี ให้ฟันหลุด!!

 

รู้จัก Software Engineer ไหม  :lol:

อ่ะ จะถามทำไม ไม่รู้จักสิแนะ 

 

 

คิดว่า ANSI C คือโปรแกรม????? และ UNIX เป็น script!!!!!!!!

โอ้...... core shell มันเป็น C จะต้องใช้โปรแกรมอะไร่ะจ๊าาาาา 

แล้วใช้เป๋นแต่ script เลยคิดว่า มันทำได้แค่ script สิแนะๆๆๆๆ 

 

เออ มีเพื่อนดี เก่ง ทำไม ไม่ปรึกษาเพื่อนก่อนจะมาตอบเราล่ะ? 

ทำเป็นเบ่ง 

เราอาจจะยอมแพ้เพื่อนคุณ 

แต่...กะคุณน่ะ... บ่มิไก๊ 

จริงๆแนะ 

ซอรี่ ที่ต้องพูดออกมา  ;)


ตรรกของผมที่แตกต่างจากสมาชิกคนอื่นใน สรท นิ๊ดเดียว  :D http://webboard.seri...e-3#entry634878

รอแมงวันหน้าสันขวานดิ้นดุ๊กดิ้กมาขอขมาอยู่นะ http://webboard.seri...-แวร์/?p=609037

ความตอแหลขอไอ้แมงวัน  http://webboard.seri...-แวร์/?p=609177

 





ผู้ใช้ 0 ท่านกำลังอ่านกระทู้นี้

สมาชิก 0 ท่าน, ผู้เยี่ยมชมทั่วไป 0 ท่าน และไม่เปิดเผยตัวตน 0 ท่าน