งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

pyramid มหาวิทยาลัยเนชั่น การโปรแกรมเชิงวัตถุด้วยภาษา JAVA

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "pyramid มหาวิทยาลัยเนชั่น การโปรแกรมเชิงวัตถุด้วยภาษา JAVA"— ใบสำเนางานนำเสนอ:

1 pyramid มหาวิทยาลัยเนชั่น การโปรแกรมเชิงวัตถุด้วยภาษา JAVA
บุรินทร์ รุจจนพันธุ์ . ปรับปรุง 22 มิถุนายน 2550

2 sharpen an anvil to create a pin
วัตถุประสงค์ ถ้ารักจะเป็นนักคอมพิวเตอร์ .. ต้องพยายามแบบ .. ฝนทั่งให้เป็นเข็ม sharpen an anvil to create a pin ข้อมูลจาก

3 ความเหมือนที่แตกต่าง
หลายครั้งที่ผมต้องเริ่มสอนเขียนโปรแกรม ให้นักเรียนกลุ่มใหม่ และก็ต้องบอกเล่า ด้วยประโยคเดิมทุกครั้งว่า "การเขียนโปรแกรม ทุกภาษานั้นเหมือนกัน" สิ่งที่แตกต่างกัน ของแต่ละภาษาคือ syntax แต่สิ่งที่เหมือนกันของทุกภาษาคือ การใช้ประสบการณ์จากภาษาหนึ่ง ไปใช้ในอีกภาษาหนึ่งได้ ด้วยการซึมซับ เรื่องของ Structure Programming จนเข้าใจ เพื่อควบคุมในสิ่งที่คล้าย ๆ กันคือ input, process และ output ซึ่งหมายความว่า ถ้าท่านเขียนโปรแกรมอะไร ในภาษาหนึ่งได้แล้ว การเขียนโปรแกรมแบบนั้น ในภาษาอื่นย่อมไม่ใช่เรื่องยากอีกต่อไป

4 เข้าทำงานใน for รอบเดียว
for (int i=1; i<=1; i++){ System.out.println(i); :: } 1

5 ไม่เข้าไปทำงานภายใน For
for (int i=1; i<=0; i++){ System.out.println(i); :: }

6 พิมพ์ 1 ถึง 2 อย่างง่าย for (int i=1; i<=2; i++){
System.out.println(i); :: } 1 2

7 พิมพ์ 5 ถึง 1 อย่างง่าย 5 4 3 2 1 1 1: class x {
1: class x { 2: public static void main(String args[]) { 3: for (int i=5;i>=1;i--) { 4: System.out.println(i); 5: } 6: } 7: } 1 1: class y { 2: public static void main(String args[]) { 3: for (int i=1;i<=5;i++) { 4: System.out.println(i % 2); 5: } 6: } 7: }

8 หลายบรรทัดใน for *1* *2* *3* 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=3;i++) { 4: System.out.print("*"); 5: System.out.print(i); 6: System.out.println("*"); 7: } 8: } 9: } *1* *2* *3*

9 ก่อน และหลัง for *123* 1: class y {
2: public static void main(String args[]) { 3: System.out.print("*"); 4: for (int i=1;i<=3;i++) { 5: System.out.print(i); 6: } 7: System.out.println("*"); 8: } 9: } *123*

10 For ซ้อน For (1/4) 1111 2222 3333 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=3;i++) { 4: for (int j=1;j<=4;j++) { 5: System.out.print( i ); 6: } 7: System.out.println(); 8: } 9: } 10:} 1111 2222 3333

11 For ซ้อน For (2/4) 1 12 123 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=3;i++) { 4: for (int j=1;j<=i;j++) { 5: System.out.print( j ); 6: } 7: System.out.println(); 8: } 9: } 10: } 1 12 123

12 For ซ้อน For (3/4) 1 22 333 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=3;i++) { 4: for (int j=1;j<=i;j++) { 5: System.out.print( i ); 6: } 7: System.out.println(); 8: } 9: } 10: } 1 22 333

13 For ซ้อน For (4/4) 1 123 12345 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=3;i++) { 4: for (int j=1;j<=(i*2)- 1;j++) { 5: System.out.print( j ); 6: } 7: System.out.println(); 8: } 9: } 10: } 1 123 12345

14 For ซ้อนหลาย For (1/4) 1 12 123 1234 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=4;i++) { 4: for (int j=1;j<=10 - i;j++) { 5: System.out.print(" "); 6: } 7: for (int k=1;k<=i;k++) { 8: System.out.print( k ); 9: } 10: System.out.println(); 11: } 12: } 13:} 1 12 123 1234

15 For ซ้อนหลาย For (2/4) 1 121 12321 1234321 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=4;i++) { 4: for (int j=1;j<=10 - i;j++) { 5: System.out.print(" "); 6: } 7: for (int k=1;k<=i;k++) { 8: System.out.print( k ); 9: } 10: for (int l=i - 1;l>=1;l--){ 11: System.out.print( l ); 12: } 13: System.out.println(); 14: } 15: } 16:} 1 121 12321

16 For ซ้อนหลาย For (3/4) 1234321 12321 121 1 1: class y {
2: public static void main(String args[]) { 3: for (int i=1;i<=4;i++) { 4: for (int j=1;j<=i;j++) { 5: System.out.print(" "); 6: } 7: for (int k=1;k<=5-i;k++){ 8: System.out.print( k ); 9: } 10: for (int l=4-i;l>=1;l--){ 11: System.out.print( l ); 12: } 13: System.out.println(); 14: } 15: } 16:} 12321 121 1

17 For ซ้อนหลาย For (4/4) 11***11 22**22 33*33 4444 1: class pyramid {
2: public static void main(String args[]) { 3: int k = 4; 4: for (int i=1;i<=k;i++) { 5: for (int j=2;j<=i;j++) { 6: System.out.print(" "); 7: } 8: System.out.print(i+""+i); 9: for (int j=k;j>=(i+1);j--){ 10: System.out.print("*"); 11: } 12: System.out.println(i+""+i); 13: } 14: } 15:} 11***11 22**22 33*33 4444


ดาวน์โหลด ppt pyramid มหาวิทยาลัยเนชั่น การโปรแกรมเชิงวัตถุด้วยภาษา JAVA

งานนำเสนอที่คล้ายกัน


Ads by Google