public class idTest {
private static int x=0, y=0;//轉換英文代表的數字
public idTest(){
}
public static void main(String[] args) throws IOException {
String id;
char[] idChar;
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("請輸入身分證字號:");
id = buf.readLine();
if(id.length() != 10){
System.out.println("id長度錯誤。");
System.exit(0);
}
標籤
Android
(
1
)
DbVisualizer
(
2
)
html/javascript
(
1
)
java
(
11
)
MySQL
(
1
)
oracle
(
1
)
servlet&jsp
(
3
)
struts
(
2
)
2011年8月27日 星期六
2011年8月21日 星期日
sort排序 練習
//sort排序
int ary[] = {120,-10,-30,3,20,150,30,150};
String temp = "";
for(int i = 0;i <ary.length; i++){
temp += ary[i]+"\t";
}
System.out.println("排序前的ary : "+temp);
int ary[] = {120,-10,-30,3,20,150,30,150};
String temp = "";
for(int i = 0;i <ary.length; i++){
temp += ary[i]+"\t";
}
System.out.println("排序前的ary : "+temp);
氣泡排序 練習
//氣泡排序
int ary[] = {120,-10,-30,3,20,150,30,150};
int swap;
String temp = "";
for(int i = 0;i < ary.length;i++){
temp += ary[i]+"\t";
}
System.out.println("排序前的ary: "+temp);
temp="";
for(int i = 0;i < ary.length-1;i++){
if(ary[i] > ary[i+1]){
swap = ary [i];
int ary[] = {120,-10,-30,3,20,150,30,150};
int swap;
String temp = "";
for(int i = 0;i < ary.length;i++){
temp += ary[i]+"\t";
}
System.out.println("排序前的ary: "+temp);
temp="";
for(int i = 0;i < ary.length-1;i++){
if(ary[i] > ary[i+1]){
swap = ary [i];
陣列的複製 練習
//陣列的複製
char ary1[] = {'A','A','A','A'};
char ary2[] = {'B','C','D','E'};
String temp1 = "",temp2 = "";
for(int i = 0;i < 4;i++){
temp1 += ary1[i] + "\t";
temp2 += ary2[i] + "\t";
}
System.out.println("複製前的ary1 :"+temp1);
System.out.println("複製前的ary2 :"+temp2);
非對稱二維陣列 練習
public static void main(String[] args) {
//非對稱二維陣列
int[][] array = new int[4][];
array[0] = new int[]{1};
array[1] = new int[]{2,3};
array[2] = new int[]{4,5,6};
array[3] = new int[]{7,8,9,10};
System.out.println("非對稱二維陣列 : ");
// System.out.println(array[0][0]);
// System.out.println(array[1][0]+ " " +array[1][1]);
// System.out.println(array[2][0]+ " " +array[2][1]+ " " +array[2][2]);
// System.out.println(array[3][0]+ " " +array[3][1]+ " " +array[3][2]+ " " +array[3][3]);
//非對稱二維陣列
int[][] array = new int[4][];
array[0] = new int[]{1};
array[1] = new int[]{2,3};
array[2] = new int[]{4,5,6};
array[3] = new int[]{7,8,9,10};
System.out.println("非對稱二維陣列 : ");
// System.out.println(array[0][0]);
// System.out.println(array[1][0]+ " " +array[1][1]);
// System.out.println(array[2][0]+ " " +array[2][1]+ " " +array[2][2]);
// System.out.println(array[3][0]+ " " +array[3][1]+ " " +array[3][2]+ " " +array[3][3]);
2011年8月19日 星期五
簡易計算機 練習
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>簡易javascript計算機</title>
</head>
<body background="images/j007.jpg">
a + b: <input id='a' size="4"/> + <input id='b' size="4">
<button onclick="calc();" style="width: 40; height: 27">=</button>
<span id="result"> </span>
<script language="JavaScript">
2011年8月18日 星期四
鍵盤輸入 練習
public static void main(String[] args) throws IOException {
// TODO code application logic here
String str;
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("請輸入數字:");
str = buf.readLine();
System.out.println(Integer.parseInt(str));
}
九九乘法表 練習
for(int i = 1;i<=9;i++){
for(int j = 1;j <= 9;j++){
System.out.printf("%2d *%2d = %2d\t", j,i,(i*j));
// System.out.print(j+" * "+i+" = ");
// System.out.printf("%2d", (i * j));
// System.out.print("\t");
}
System.out.println();
}
2011年8月16日 星期二
MySQL連線 練習
import java.sql.*;
public class DBConnectionDemo {
public static void main(String[] args) {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/My108";
String user = "root";
String password = "1234";
Connection conn = null;
Statement stmt = null;
public class DBConnectionDemo {
public static void main(String[] args) {
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/My108";
String user = "root";
String password = "1234";
Connection conn = null;
Statement stmt = null;
BMI計算 練習
res\layout\main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:weightSum="1"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:text="" android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:weightSum="1"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:text="" android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
訂閱:
文章
(
Atom
)