Sean's Note

2008年11月9日 星期日

貪食蛇 Snakii

Snakii V1.1 (235KB)

之前有做過 console 版本的, 不過 code 不見了 @@
所以這次又重寫了一個視窗版的.
畫面很陽春啦, 自己畫圖超累的 XD
Bug1. 因為障礙物是隨機產生的, 如果障礙把水果圍住, Snakii 就吃不到了.
雖然機率應該很低, 不過有空還是要解決一下這個問題.


V1.1 更新內容 :
1. 更新背景
2. 一開始不容易撞到石頭


V1.0 更新內容 :
1. 初版




2008年10月6日 星期一

Four Bits Adder

兩個 half adder 合成一個 full adder, 四個 full adder 合成一個 4 bits adder.

想畫美美的圖用 PhotoImpact 就對了, PhotoImpact 真好用阿. 

從國一用到現在的軟體, 作業報告網頁的圖片都靠它了.

要支持國產貨!  哈哈.


2008年8月28日 星期四

Where Are Windows Vista Cookies !?

The Enigmatic Cookies Folder In Vista
Type Cookies in Start Menu. and it may take you to C:\Users\Username\cookies folder. When you try to click on it, in all probability, you will be greeted with an Access Denied box. This path, however, is just a kind of a pointer.
To see where IE 7 stores its Cookies in Windows Vista :
Open Explorer > Organize > Folder Options > Views > Check 'Do not show hidden files and folders' and Uncheck 'Hide protected OS files' > Apply > OK.
Now you will be able to see the two real locations of Vista's Cookies folders.
C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies\Low
As mentioned elsewhere on this site, in Vista, processes run with integrity levels as defined by the Mandatory Integrity Control Feature. 'Protected Mode' Internet Explorer, runs as a 'Low Privilege' process. This prevents the Internet Explorer from writing to areas of the File System or the Registry that require a higher privilege! What happens, is that, Vista creates a set of folders and files, for use with Protected Mode' Internet Explorer. These folders and files share the same Low Privilege level as Internet Explorer.
One of these 4 'low privilege' folders, used by IE7 in Vista, in the course of daily operation, is Cookies, the other being Cache, History & Temp, and is located at:
%AppData%\Microsoft\Windows\Cookies\Low
With the IE 7 Protected Mode Turned On, the browser essentially runs as a low privilege process; as a result of which it can store / read / write cookies in the LOW version of the Cookies folder:
C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies\Low
But if you have turn UAC off or Disabled the Protected Mode in IE 7, in Windows Vista, they (like cache, temp & history) will mostly be stored in:
C:\Users\username\AppData\Roaming\Microsoft\Windows\Cookies
以上內容源自 : winvistaclub 

2008年8月2日 星期六

[PHP] 中文編碼 " 許功蓋 " 和 " ' "

如果有使用到讓使用者輸入文字的表格,

使用者輸入"許功蓋" 時, 資料庫裡存的會是"許\功\蓋\"

只要加上下面這一行就可以了.


$str = stripslashes($str);

另外使用者如果輸入 " ' " 的時候, PHP 的 query 會出現錯誤訊息,

將一個 '  取代成兩個 '' 就行了, 如下.


$str = str_replace("'", "''", $str);



2008年7月21日 星期一

[PHP] odbc_num_rows()

網路上看了一下, 取得的值不如預期, 大部分是因為 odbc 的 driver 不支援,

詳細我也不太清楚, 反正要取得 Total 有幾筆資料, 方法很多,

query 裡用 COUNT(*) 就行了.


2007年10月27日 星期六

[C/C++] ACM - 10539 - Almost Primes Numbers

這題的 long long 真是超級機車的, 遇到了一些奇怪的 coding 問題, submit 了大概快三十次才 AC 吧 = =

 
[問題一]
 
quicksort 裡的 compare function, 如果型態不是 long long,
 
以下兩種寫法都行, 只需對應參數的型態.
 
但如果是 long long 就只能用寫法二了, 真不知道為什麼? @@
 
寫法一 :
 int compare( const void *a, const void *b)
{  return (long long *)a - (long long*)b) ; }
 
寫法二 :
int compare(const void *a,const void *b)
{
   long long *c, *d;
   c=(long long *)a;
   d=(long long *)b;
  
   if(*c>*d)
      return 1;
   else if(*c==*d)
      return 0;
   else
      return -1;
} 
 
[問題二]
 
寫法一跟寫法二的意思是一樣的, 可是寫法一和寫法二 nonprime[] 裡存放的東西卻不一樣.
 
寫法一才是正確的, 寫法二卻不是?
 
寫法一:
long long temp;
long long nonprime[80080];
for (i = 0, k = 0; k < 80070; i++)
  {
  temp = prime[i];
  while ((temp *= prime[i]) <= 1e12)
    { nonprime[k++] = temp; }
  }
 
寫法二:
long long nonprime[80080];
for (i = 0, k = 0; k < 80070; i++)
  {
  nonprime[k] = prime[i]*prime[i];  // prime[i] * prime[i]  都會小於等於 1e12,  所以寫法一的迴圈也會跑  while (nonprimep[k] * prime[i] <= 1e12)
    {
    nonprime[k+1] = nonprime[k] * prime[k];
    k++; 
    }
   }
 
[心得]
 
突然發現 cout 可以正確的印出 long long 的值,
 
以後遇到 long long 的題目還是用 C++ 寫好了.