Skip to content

Instantly share code, notes, and snippets.

View ronsc's full-sized avatar

Ronnakorn Jannnalao ronsc

View GitHub Profile
@ronsc
ronsc / Ball.java
Created December 21, 2013 13:57
ข้อสอบข้อที่ 1 -------------------------------------------- ผลการรัน -------------------------------------------- Anonymous moves. Nike moves Nike rolls
public class Ball implements Movable {
protected String name;
public Ball(){}
public Ball(String name){
this.name = name;
}
@Override
public void move(){
@ronsc
ronsc / Exam2.c
Created December 19, 2013 13:26
2. จงเขียน function (ในรูปของ program ภาษา C/C++ หรือ JAVA) ในการเพิ่มโหนดใน link list โดยโหนดที่เพิ่มเข้าไปใหม่ต้องอยู่ก่อนโหนดท้ายสุด (โหนดtail) เสมอ
#include<stdio.h>
typedef struct nd{
char ch;
struct nd *next;
}node;
node *head = NULL;
node *tail = NULL;
node *prev = NULL;
int count = 0;
@ronsc
ronsc / Exam1.c
Created December 19, 2013 12:15
1. จงเขียน function (ในรูปของ program ภาษา C/C++ หรือ JAVA) ในการเพิ่มโหนดใน link list โดยโหนดที่เพิ่มเข้าไปใหม่ต้องต่อท้ายโหนดแรกสุด (โหนด head) เสมอ
#include<stdio.h>
typedef struct nd{
char ch;
struct nd *next;
}node;
node *head = NULL;
int count = 0;
void add(char c){
node *n = malloc(sizeof(node));
@ronsc
ronsc / Answer.c
Last active December 30, 2015 18:39
Enter a number (1-10) : 11
Enter a number (1-10) : 399
Enter a number (1-10) : 6
6 is even number
Enter a number (1-10) : 40
Enter a number (1-10) : -9
Enter a number (1-10) : 3
3 is odd number
@ronsc
ronsc / Ex10.c
Last active December 29, 2015 21:39
แบบสวยงาม -=-
#include<stdio.h>
void main(){
int i, n, sum = 0;
do{
printf("Enter a Number (5-20) : ");
__fpurge(stdin);
scanf("%d", &n);
if(n < 5 || n > 20)
printf("ERROR!!!\n");
@ronsc
ronsc / T3.java
Created November 26, 2013 16:12
แบบฝึกหัดหน้า 121 ข้อ 3
public class T3 {
public static void main(String[] args){
String s = "ABCATACATBDMCATX";
String tmp = s;
String key = "CAT";
String result = "";
while(tmp.indexOf(key) != -1){
result += tmp.substring(0, tmp.indexOf(key));
tmp = tmp.substring(tmp.indexOf(key)+3);
@ronsc
ronsc / T1.java
Created November 26, 2013 15:00
แบบฝึกหัดหน้า 120 ข้อ 1
public class T1 {
public static void main(String[] args){
String s = "ant:bat:cat:dog:horse:elephant";
for(int i = 0; i < s.length(); i++){
if(s.charAt(i) == ':'){
System.out.println();
}else{
System.out.print(s.charAt(i));
@ronsc
ronsc / Student.java
Created November 26, 2013 14:52
แบบฝึกหัดหน้า 121 ข้อ 4
public class Student {
private String name;
private String value;
private int subject;
private float gpa;
public Student(String name, String value){
this.name = name;
this.value = value;
}
@ronsc
ronsc / T2.java
Created November 26, 2013 13:57
แบบฝึกหัดหน้า 121 ข้อ 2
public class T2 {
public static void main(String[] args){
String s = "AB1.2C5.1DEF3.08";
// ทำการ loop เพื่อหาจำนวนของเลขทศนิยมว่ามีกี่ตัว
int SIZE = 0;
for(int i = 0; i < s.length(); i++){
if(s.charAt(i) == '.'){
SIZE++;
}
@ronsc
ronsc / Ball.java
Last active December 28, 2015 19:19
แบบฝึกหัดข้อ 3 หน้า 105
public abstract class Ball implements Rollable, Bouncable{
public abstract void inflate(double volume);
public void bounce(float bf){
}
public void roll(){
}