....

2014年5月29日 星期四

[長知識] Android 利用SQLite語法找出兩個日期內的資料 (SQLite Manager)

再查詢資料庫前
我們必須要有資料庫存在
而這邊我也有存了資料進去
最後才能進行語法搜尋


首先
要能夠看到資料庫裏面的欄位以及資料
我是使用Firefox的外掛程式 --> SQLite Manager
點選設定裡面的外掛程式 搜尋 即可以下載

2014年5月27日 星期二

2014年5月26日 星期一

[長知識] Android 多個 DatePickerDialog 在同一個Activity

今天在寫datePickerDialog的時候發現的小小幫助,希望可以幫助大家:)
當我們發現在同一個Activity下需要寫兩個以上的datePickerDialog,可能會需要switch case來幫忙






[食記] 台中 高町平價日本料理

用餐時間 : 2014.5.24 晚上

先來個讓人流口水的照片> <



2014年5月25日 星期日

[長知識] C語言 - 新手篇章 - 結構struct

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
// 結構struct
//  自訂的變數型態,結構變數

//可以存放多個不同型態的變數 ex. 裡面有19個int, 12個double,...

[長知識] C語言 - 新手篇章 - 字串、指標應用

#include <stdio.h>
#include <stdlib.h>
#define MAX 1024 

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
//  字串、指標應用
//  java的String 是假字串,都是用字元陣列接的
int i;
char str[MAX];
printf("請輸入一段文字吧~");
gets(str);

[長知識] C語言 - 新手篇章 - 字串

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
// 字串String 為 字元陣列

char str[] = "Hello!";

[長知識] C語言 - 新手篇章 - 動態配置記憶體空間

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
//動態配置一塊記憶體空間,以byte為單位
// int *ptr = (int*)malloc(?byte);
int amount;
int i;

printf("輸入幾個int?");
scanf("%i", &amount);

[長知識] C語言 - 新手篇章 - 指標陣列的應用

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

//宣告很長一段的陣列
//陣列唯一連續的記憶體空間
//指標指向陣列第一個位置,是否能透過指標把陣列值讀出來


int main(int argc, char *argv[]) {

int ary[] ={17, 56, 56, 13, 64};
//取得第一個(7)記憶體空間
int *ptr = &ary[0];
int i;
int len = sizeof(ary)/sizeof(ary[0]);

[長知識] C語言 - 新手篇章 - 透過傳值傳址互換記憶體

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

//兩數交換
void changeByValue(int a, int b){
//a, b為方法內的區域變數
//傳值交換

printf("a的記憶體位置:%d,值:%d\n", &a, a);
  printf("b的記憶體位置:%d,值:%d\n", &b, b);
 
  int temp = a;
  a = b;
  b = temp;
 
  printf("a的記憶體位置:%d,值:%d\n", &a, a);
  printf("b的記憶體位置:%d,值:%d\n", &b, b);
 
}

//兩數交換
void changeByAddress(int *a, int *b){
//a, b為方法內的區域變數
//傳址交換

printf("a的記憶體位置:%d,值:%d\n", &a, *a);
  printf("b的記憶體位置:%d,值:%d\n", &b, *b);
 
  int temp = *a;
  *a = *b;
  *b = temp;
 
  printf("a的記憶體位置:%d,值:%d\n", &a, *a);
  printf("b的記憶體位置:%d,值:%d\n", &b, *b);
}

int main(int argc, char *argv[]) {

int a = 10, b = 20;
printf("changeByValue------------------------------------\n");
printf("--a的記憶體位置:%d,值:%d\n", &a, a);
printf("--b的記憶體位置:%d,值:%d\n", &b, b);

changeByValue(a, b); //a:20, b=10
printf("--a透過傳值方法,運算後記憶體位置為:%d,值為:%d\n", &a, a); //a=10, b=20
printf("--b透過傳值方法,運算後記憶體位置為:%d,值為:%d\n", &b, b);

printf("changeByAddress-----------------------------------\n");

printf("--a的記憶體位置:%d,值:%d\n", &a, a);
printf("--b的記憶體位置:%d,值:%d\n", &b, b);
//要傳值給他,可是他只吃址
//所以給址(&a)
changeByAddress(&a, &b);
printf("--a透過傳值方法,運算後記憶體位置為:%d,值為:%d\n", &a, a);
printf("--b透過傳值方法,運算後記憶體位置為:%d,值為:%d\n", &b, b);

return 0;
}

2014年5月23日 星期五

[長知識] C語言 - 新手篇章 - 指標轉換應用

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

int a=10, b=20, c=30;
int *ptr, *ptr_2;

ptr = &a;

printf("a的記憶體本身位置%i,指向的位置%i\n", &a, a);
printf("b的記憶體本身位置%d,指向的位置%d\n", &b, b);
printf("b的記憶體本身位置%d,指向的位置%d\n", &c, c);

//指標本身減2個單位(int = 4 byte),所以就是ptr退8個byte
//最後指標指到c的位置
ptr -=2;
printf("ptr的記憶體本身位置%d,指向的位置%d,內容%d\n", &ptr, ptr, *ptr);

//指標指到b的位置
ptr +=1;
printf("ptr的記憶體本身位置%d,指向的位置%d,內容%d\n", &ptr, ptr, *ptr);

//兩個指標指向同一個位置
ptr_2 = ptr;
printf("ptr的記憶體本身位置%d,指向的位置%d,內容%d\n", &ptr, ptr, *ptr);
printf("ptr_2的記憶體本身位置%d,指向的位置%d,內容%d\n", &ptr_2, ptr_2, *ptr_2);

return 0;

}

[長知識] C語言 - 新手篇章 - 指標應用

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
//Pointer 指標
//所有變數都是記憶體的一個空間
//一塊記憶體可以在不同的地方取用

int a=10, b=20;
//宣告一個指標可以指向int,0byte
//*取值,&取址
// a: int , ptr: int的記憶體位置

int* ptr;
ptr = &a;

printf("%i\n", a);
printf("%i\n", *ptr);

printf("a的記憶體本身位置%i,值為%i\n", &a, a);
printf("b的記憶體本身位置%d,值為%d\n", &b, b);
printf("ptr的記憶體本身位置%d,值為%d,內容為%d\n", &ptr, ptr, *ptr);

//透過ptr把b的值變成10
b = *ptr;
printf("b的記憶體本身位置%d,值為%d\n", &b, b);



*ptr = 100;
printf("a的記憶體本身位置%i,值為%i\n", &a, a);
printf("ptr的記憶體本身位置%d,值為%d,內容為%d\n", &ptr, ptr, *ptr);





return 0;

}

[長知識] C語言 - 新手篇章 - 遞迴三

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int sum(int s, int e){
//遞增,s是定值
if(s==e){
return e;
}else{

// 2 ->3 ->4 ->5
return sum(s+1, e)+s;
}

}


int main(int argc, char *argv[]) {
int start, end;
printf("輸入start:");
scanf("%i", &start);

printf("輸入end:");
scanf("%i", &end);

printf("%i", sum(start, end) );

return 0;

return 0;
}

[長知識] C語言 - 新手篇章 - 遞迴二

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int sum(int s, int e){

if(s==e){
return s;
}else{
//      s=3 e=5
// 5 ->4 ->3
//      sum(s, e-1)+e  "+e"是重點
return sum(s, e-1)+e;
}

}


int main(int argc, char *argv[]) {

int start, end;
printf("輸入start:");
scanf("%i", &start);

printf("輸入end:");
scanf("%i", &end);

printf("%i", sum(start, end) );

return 0;
}

[長知識] C語言 - 新手篇章 - 遞迴

#include <stdio.h>
#include <stdlib.h>

int sum(int n){
//都任何值進去,都會做1加到 n
if(n == 1){
return 1;
}else{
//呼叫自己 sum(n-1)+n,+n被斷開欠著
// 丟5,sum(4)+5, +5欠著去堆疊 ...      
//  5 --> 4 --> 3 --> 2 --> 1
//  5 <-- 4 <-- 3 <-- 2 <-- 1
//  15   10     6     3
// 遞迴是一直往上堆疊,有上限
return sum(n-1)+n;
}

}

int main(int argc, char *argv[]) {
//遞迴
int a;

printf("輸入數字由1加到x \nx=");
scanf("%i", &a);

printf("%i", sum(a));

return 0;

}

[長知識] C語言 - 新手篇章 - 輸入起始值和終點值相加

#include <stdio.h>
#include <stdlib.h>


//輸入起始值和終點值相加,印出結果
int countResult(int start, int end){
int i, sum=0;
for(i=start ; i<=end; i++){
sum += i;
}
return sum;
}

int main(int argc, char *argv[]) {

int start, end;

printf("給我兩個數字,我來做相加吧~\n");
printf("請輸入起始值");
scanf("%i", &start);
printf("請輸入終點值");
scanf("%i", &end);

int result = countResult(start, end);
printf("總和為:%i", result);

return 0;
}

[長知識] C語言 - 新手篇章 - 利用方法將ID搜尋的獎金列出

#include <stdio.h>
#include <stdlib.h>


//怕main在使用getLottery()的時候不認識,所以寫在main上面
int getLottery(int id);

int main(int argc, char *argv[]) {

int id;
printf("請輸入ID!");
scanf("%i", &id);

int award = getLottery(id);
if(award <= 0){
printf("銘謝惠顧!");
}else{
printf("YOUR AWARD:%i" ,award);
}



}

int getLottery(int id){

switch(id%5){
case 0:
return 10000;
case 1:
return 20000;
case 2:
return 30000;
case 3:
return 40000;
}
//default 其他回傳0
return 0;
}


[長知識] C語言 - 新手篇章 - 方法 - 有無回傳值

#include <stdio.h>
#include <stdlib.h>

//方法,就是叫程式幫你做事情
//void: 沒有回傳值

int main(int argc, char *argv[]) {


return 0;

}

//沒有回傳值
void 去掃地 (掃把 a, 拖把 b){
//a, b作為參數來傳遞用,為此方法內的變數
}

//有回傳值
帳單 去存錢 (錢 a){

return 帳單;
}

int saveMoney(int money){
int total

return total;
}

2014年5月20日 星期二

[長知識] C語言 - 新手篇章 - 方法 - 幾的幾次方

#include <stdio.h>
#include <stdlib.h>


//function
void countPow(int x, int p);

int main(int argc, char *argv[]) {
//2的20次方
countPow(2,20);

return 0;
}

[長知識] C語言 - 新手篇章 - 排序法 - 氣泡排序法

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

//排序法 - 氣泡排序法

int num[] = {2, 8,7,30, 14, 66, 95,100, 1};
int sortsize = sizeof(num)/sizeof(int);
int i, j, k;

[長知識] C語言 - 新手篇章 - 二維陣列介紹

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
//二維陣列

int ary[][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};

//第0維,第0個,為1
//第0維,第1個,為2
//第0維,第2個,為3

[長知識] C語言 - 新手篇章 - 陣列介紹

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//陣列(Array)
//ary[3] 表示 陣列大小為3 (ary[0], ary[1], ary[2])

 int ary[];
ary[0] =5;
ary[1] =10;
ary[2] =15;
printf("總和:%i\n", ary[0]+ary[1]+ary[2]);

[長知識] C語言 - 新手篇章 - for和if應用 - 電梯程式

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
//電梯 break, continue

int floor=101;
int i, find;

printf("先生請問幾樓?");
scanf("%i", &find);

[長知識] C語言 - 新手篇章 - 巢狀for迴圈的應用 - 9x9乘法表

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//巢狀for迴圈 - 9x9乘法表
//2x1=2   3x1=3   4x1=4   5x1=5   6x1=6   7x1=7   8x1=8   9x1=9
//2x2=4   3x2=6   4x2=8   5x2=10  6x2=12  7x2=14  8x2=16  9x2=18
//2x3=6   3x3=9   4x3=12  5x3=15  6x3=18  7x3=21  8x3=24  9x3=27

2014年5月19日 星期一

[遊記] 苗栗南庄民宿 橄欖樹 2014.01.23

這張民宿晚上的美圖就當作文章進入點吧~

[食記] 台中甜點 - 七個醫師的咖啡 - 試吃會心得

HI~大家好!!
我是小藍

2014.05.17 晚上六點

受到我的室友邀約
得到這個試吃會的機會

七個醫師的咖啡
01

02  

店長的名字很特別唷~
是道地的日本人!!!!

名片上的地址是他們的工作室

( 401 台中市東區振興路275號 )
我們也是在這邊進行試吃活動

2014年5月17日 星期六

[長知識] C語言 - 新手篇章 - 利用do while迴圈做出倒數計時

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int i=10;

[長知識] C語言 - 新手篇章 - 前置遞增&後置遞增

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
//    do-while loop
// 無論如何先做一次內容再做判斷
//   do{      }while();
// do無論如何都會先做一圈

  int i=0, sum=0;

[長知識] C語言 - 新手篇章 - do while迴圈

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
//    do-while loop

// 無論如何先做一次內容再做判斷 
//  do{      }while();

  int i=0, sum=0;

[長知識] C語言 - 新手篇章 - while迴圈相加總合以及while迴圈病毒

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
// while迴圈
// while(B),B表示判斷式 

// 印出0到9

int i=0;

[長知識] C語言 - 新手篇章 - for迴圈相加總合以及for迴圈病毒

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
//Loop迴圈
// for(A ;B ;C ){}
// A:初始式, B:判斷式, C:運算式, {}:在{}內重複執行,AC可以不寫,B一定要寫 
// i++, i=i+1, i+=1 三個一樣

int i, sum=0;

[長知識] C語言 - 新手篇章 - switch case && if 銀行開戶問題

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

int money;
char bankID;

[長知識] C語言 - 新手篇章 - switch case 用字元判斷

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//背後執行的是ASCII碼
char input;

printf("嗨!請問你要去哪個國家?\n (A)美國\n (B)中國\n (C)日本\n");

[長知識] C語言 - 新手篇章 - switch case自訂範圍

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int score;

printf("阿呆,你考幾分?");
scanf("%i", &score);

2014年5月15日 星期四

[長知識] C語言 - 新手篇章 - 條件判斷式(switch case )

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {

srand(time(NULL));
int a = rand()%9+1;

[長知識] C語言 - 新手篇章 - 條件判斷式(猜數字遊戲)

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int userinput;

//共取一個亂數庫,否則遊戲會失去平衡機制
srand(time(NULL));
//rand()產生 0~32767 其中一個數字
int answer = rand()%9+1;  //1~9亂數產生

[長知識] C語言 - 新手篇章 - 條件判斷式(三個數字比大小)

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int num1, num2, num3;
int max;

printf("輸入三個數字比大小");
scanf("%i%i%i", &num1, &num2, &num3);

[長知識] C語言 - 新手篇章 - 條件判斷式,年紀判斷

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int age;

printf("請輸入您的年紀:");
scanf("%i", &age);

[長知識] C語言 - 新手篇章 - 條件判斷式,判斷奇數或偶數

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//條件判斷式 if else, while, ...

int input;

printf("請輸入一個整數:");
scanf("%i", &input);

2014年5月13日 星期二

[長知識] C語言 - 新手篇章 - 邏輯運算子

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int a=1, b=2, c=3;

//a < b --> output=0 表示 錯誤
//a < b --> output=1 表示 正確
printf( " %i < %i ? %i \n " , a, b, a<b );  // 1 
printf( " %i < %i ? %i \n" , a, b, a>=b);  // 0

[長知識] C語言 - 新手篇章 - 華氏溫度轉攝氏溫度

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

//華氏溫度
int Fah;
        //攝氏溫度
float Cel;

[長知識] C語言 - 新手篇章 - 老闆請問打幾折

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int price;
float discounts, total;

printf("老闆請問多少錢?\n");

[長知識] C語言 - 新手篇章 - &怎麼用

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

int enter;

//請求輸入-->轉譯 -->放入記憶體位置
printf("input:\n");

//記憶體取 &enter值,丟到 %i
//&是取得記憶體空間的意思
scanf("%i", &enter);

2014年5月5日 星期一

[長知識] Java 文字操作小小整理

1. 大量的文字操作,StringBuilder類別最快。
2. FileWriter類別是寫入字元檔案較便捷。
3. BufferedReader類別具有緩衝能力,提升讀取檔案的效率。

4. 讀取檔案 InputStreamReader ,再用FileWriter將讀取的內容寫入硬碟檔案。
5. StringBuffer是避免檔案的多次寫入(也就是實現了可變字串)。
6. BufferedWriter類別將文字寫入字元輸出流,緩衝各個字元,進一步提供單一字元、陣列和字串的高效率寫入。  BufferedReader 是高效率寫出。