2009年10月7日 星期三

Java 安裝與環境設置

至 Java 官方網站下載 JDK 環境來安裝

選擇單純的

Java SE Development Kit (JDK)
JDK 6 Update 16
This special release provides a few key fixes.

來安裝即可,記得要先把舊版的 Java 都先移除乾淨。

接著再按照此網站來設定環境變數,便可在命令提示字元作編譯跟執行的動作。

以下是 TCP Socket 的 Java code... 其中 127.0.0.1 為本機位址,1234是隨便開的 port number

程式會將 Clinet 送過去的字串轉成大寫送回。

// Server端

import java.lang.*;
import java.io.*;
import java.net.*;

class Socket_Server
{
   public static void main(String args[]) throws Exception
   {
    String clientSentence; 
    String capitalizedSentence; 
    ServerSocket welcomeSocket = new ServerSocket(1234); 
    while(true)
    { 
     Socket connectionSocket = welcomeSocket.accept(); 
     BufferedReader inFromClient = new BufferedReader
         (new InputStreamReader(connectionSocket.getInputStream())); 
     DataOutputStream outToClient = new DataOutputStream
         (connectionSocket.getOutputStream()); 
     clientSentence = inFromClient.readLine(); 
     System.out.println("1234: " + clientSentence ); 
     capitalizedSentence = clientSentence.toUpperCase() + '\n'; 
     outToClient.writeBytes(capitalizedSentence); 
    }
   }
}

// Client端

import java.lang.*;
import java.io.*;
import java.net.*;

class Socket_Client
{
   public static void main(String args[]) throws Exception
   {
    String sentence;
    String modifiedSentence; 
    BufferedReader inFromUser = new BufferedReader
        (new InputStreamReader(System.in)); 
    Socket clientSocket = new Socket("127.0.0.1", 1234); 
    DataOutputStream outToServer = new DataOutputStream
      (clientSocket.getOutputStream()); 
    BufferedReader inFromServer = new BufferedReader
      (new InputStreamReader(clientSocket.getInputStream())); 
    sentence = inFromUser.readLine(); 
    outToServer.writeBytes(sentence + '\n'); 
    modifiedSentence = inFromServer.readLine(); 
    System.out.println("FROM SERVER: " + modifiedSentence); 
    clientSocket.close(); 
   }
}

2009年9月17日 星期四

修改開機選單

若是XP系統則可針對boot.ini檔案做修改

若是Vista則是在"控制台→系統管理工具→系統設定→開機"的地方選擇

也可以調整等待時間,

若是想重置開機選單則可在選擇登入OS的時候在Vista的選項按F8

接著進入"修復電腦→下一步→系統修復選項→命令提示字元"

輸入Bootrec.exe按下Enter

接著打入以下指令:

bcdedit /export C:\BCD_Backup
c:
cd boot
attrib bcd -s -h -r
ren c:\boot\bcd bcd.old
bootrec /RebuildBcd

就可以重製開機選單了,不過是英文介面。

以上是微軟公布的相關辦法

連結:

如何在 Windows 修復環境內使用 Bootrec.exe 工具,來疑難排解及修復 Windows Vista 中的啟動問題

2009年9月9日 星期三

Opera 在背景開新分頁

除了使用滑鼠中鍵之外,

在Opera網址列輸入 Opera:config

會進入"功能設定編輯器"

使用搜尋查到 "Open New Window in Background" 這項

打勾之後儲存便可以使新分頁都開啟在背景了~

Linkin Park - "New Divide"

2009年8月28日 星期五

2009年8月26日 星期三

Opera 10.0 Release Candidate

據說速度加速了40%

實際上與9.64版的比較感覺真的快超多 XD

而且會將上次瀏覽的網頁與現在新開的頁面做區隔!

多國語言版下載

以下是更動部分↓

Changelog:

User Interface:
New application icon(感覺以前的比較好看)
Fixed the new tab button on the sides(ctrl+tab間隔變大了,比較清楚)
Various small Visual Tabs fixes(以下我都不知道是殺毀= =")
Fixed a BitTorrent crash
Fix to jumping up/down of the new tab button while on the sides
Fixed Bug DSK-195906 (Opera error page selects URL field when displayed, also when focus is already inside URL field)
Fixed Bug DSK-257578 ("..." in site titles in some cases overlap the close button)
Fixed Bug DSK-258585 (Can't remove menu button when main menu is disabled): The menu button can be removed as any other toolbar button now (upgraders may have to reset the toolbar first)
Fixed Bug DSK-261205 (Strings don't fit in Preferences > Downloads [pl])
Fixed Bug DSK-261206 (Strings don't fit in Preferences > Programs [pl])
Fixed Bug DSK-261757 (Missing "splitter" in bookmark split view)
Fixed Bug DSK-261933 (Text cut off in startup dialog (Polish translation))
Fixed Bug DSK-261962 ("Reset Toolbar to Its Default" resets all toolbars, not just the current)
Fixed Bug DSK-262181 (Empty [dropdown widget] section added to custom shortcuts by update)
Fixed Bug DSK-262283 (Skin.ini section inconsistencies)

Core
Various crash fixes
Fixed Bug CORE-19376 (Crash navigating history)
Fixed Bug CORE-23125 (Adding IFRAME with javascript: src through DOM adds history entry (Yandex))

Opera Mail:
Fixed a crash
Fixed Bug DSK-245600 (Mail imported into account with no downloading of message bodies loses bodies)
Fixed Bug DSK-261035 (Crash when opening image attachments)
Fixed Bug DSK-261459 (Go to Unread View when requested, don't reuse a maximized mail view)

Windows
Crash Fix
Reverted Fix to Bug DSK-241262 (Error message when opening HTML files if Opera is not already running): This caused DSK-262363
Fixed Bug DSK-259756 (Installer removes icon pinned to the Windows 7 task bar)
Fixed Bug DSK-260498 (The list of closed tabs needs clicks to be shown)
Fixed Bug DSK-262363 (Other programs using the http protocol to open websites in Opera just open blank page in Windows Vista and Windows 7)
Fixed Bug DSK-259743 (Closed tabs and new tab buttons have non-native looks in native skin)
Fixed Bug DSK-262120 (Panel selector buttons in Native skin get Standard style when not on the left)
Fixed Bug DSK-262272 (Closed tabs and new tab positioned incorrectly when tabbar is placed on left or right side)

Mac
Fixed Bug DSK-261726 (Closed Tabs button overlaps tabs when set to right or left and new tab button is disabled)

Unix
Fixed Bug DSK-259575 (Dead keys don't seem to work on widgets)
Fixed Bug DSK-250495 (Spell checking not working for some UNIX users)

2009年8月22日 星期六

10000 - Longest Paths

Time limit: 3.000 seconds
                                      Longest Paths
It is a well known fact that some people do not have their social abilities completely enabled. One example is the lack of talent for calculating distances and intervals of time. This causes some people to always choose the longest way to go from one place to another, with the consequence that they are late to whatever appointments they have, including weddings and programming contests. This can be highly annoying for their friends.
César has this kind of problem. When he has to go from one point to another he realizes that he has to visit many people, and thus always chooses the longest path. One of César's friends, Felipe, has understood the nature of the problem. Felipe thinks that with the help of a computer he might be able to calculate the time that César is going to need to arrive to his destination. That way he could spend his time in something more enjoyable than waiting for César.

Your goal is to help Felipe developing a program that computes the length of the longest path that can be constructed in a given graph from a given starting point (César's residence). You can assume that the graph has no cycles (there is no path from any node to itself), so César will reach his destination in a finite time. In the same line of reasoning, nodes are not considered directly connected to themselves.
Input
The input consists of a number of cases. The first line on each case contains a positive number n ( ) that specifies the number of points that César might visit (i.e., the number of nodes in the graph).
A value of n = 0 indicates the end of the input.

After this, a second number s is provided, indicating the starting point in César's journey ( ). Then, you are given a list of pairs of places p and q, one pair per line, with the places on each line separated by white-space. The pair `` " indicates that César can visit q after p.
A pair of zeros (``0 0") indicates the end of the case.

As mentioned before, you can assume that the graphs provided will not be cyclic.
Output
For each test case you have to find the length of the longest path that begins at the starting place. You also have to print the number of the final place of such longest path. If there are several paths of maximum length, print the final place with smallest number.

Print a new line after each test case.

Sample Input
2
1
1 2
0 0
5
3
1 2
3 5
3 1
2 4
4 5
0 0
5
5
5 1
5 2
5 3
5 4
4 1
4 2
0 0
0

Sample Output
Case 1: The longest path from 1 has length 1, finishing at 2.

Case 2: The longest path from 3 has length 4, finishing at 5.

Case 3: The longest path from 5 has length 2, finishing at 1.

=====================================================

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

// function prototype
void DFS(int data_num, int from, int step);

// data structure
struct FromTo
{
 int p;
 int q;
};

struct FromTo FromTo[100];
int longest_path;
int finish_point;

int main()
{
 freopen("Input.txt", "r", stdin);
 freopen("Output.txt", "w", stdout);
   
 int start_point;
 int point_num;
 int p, q;
 int case_num = 1;
   
 while(1)
 {  
  int data_num = 0;
  scanf("%d", &point_num);
  if(!point_num)
   break;
  for(int i=0; i<100; i++)
   FromTo[i].p = FromTo[i].q = -1;
  scanf("%d", &start_point);
  for(int i=0; scanf("%d %d", &p, &q) == 2; i++)
  {
   if(!p && !q)
    break;
   FromTo[i].p = p;
   FromTo[i].q = q;
   data_num++;
  }
  longest_path = 0;
  DFS(data_num, start_point, 0);
   
  printf("Case %d: The longest path from %d has length %d, finishing at %d.\n\n",
      case_num++, start_point, longest_path, finish_point);
 }
   
 return 0;
}

void DFS(int data_num, int from, int step)
{
 for(int i=0; i<data_num; i++)
  if(FromTo[i].p == from)
  {
   if(++step > longest_path)
   {
    longest_path = step;
    finish_point = FromTo[i].q;
   }
   DFS(data_num, FromTo[i].q, step);
   --step;
  }
}

2009年7月31日 星期五

Meeting @ VPON

昨天去了新眾電腦股份有限公司
因為產學計畫所以要跟他們報告目前做了什麼
沒想到對方對這個很有興趣 XD" 大概剛好搭上潮流的順風車吧
不過也要努力開始做了 雖然能找到的論文好少 = =
好不容易看了一篇到最後又是似是而非 又是一篇地雷論文
硬著頭皮看第二篇... gogo QQ

開會的過程還好蠻輕鬆的
並沒有想像中的嚴肅
也真的體會到學界跟業界的差距
有些要求他們講的很簡單
我們要做出來卻有一定難度
不過也不好意思說甚麼 XD"
在一旁跟學長聊天偷笑 呵呵
不好意思最後是冠宇學長幫忙簽約
好像把你賣掉一樣 哈哈哈 XDDDDDDDDDDDD" 為了你要認真做!!

超狠的老爸XDDDDDDDDDDDDD

2009年7月18日 星期六

爆破狂:電話簿摩擦力



原來最大靜摩擦力可以這麼強 = =.... 太扯了

佩服那個實驗室的人 XD" 租來戰車耶!!

兩本書可以產生8000磅的作用力 媽呀 = =.....不可思議

人材再留失!! 體委會無能?! 17歲桌球冠軍遭挖角



本來很看好陳建安的說
去年三峽鎮長盃有看到他比賽XD 整個超猛的阿
積分260x排名第二名與第一名僅差了幾十分,可惜了
台灣真的很不重視運動員(怒ˋ ˊ )

2009年7月16日 星期四

牛寶@三峽

一家新開的牛肉麵館,位於北大正門直走一段的右手處,
半筋半肉很好吃,不過刀切面有點硬,細麵下次再試試看,
湯頭也不錯,缺點就是出餐速度太慢,還頻頻送錯,
也有漏煮的錯誤,昨天去吃還有一個死小孩一直吵,
人少的時候可去吃,有無限紅茶。評價中。

Ps. 隔壁要開麻辣燙,期待ing

雙打積分賽@淡水新興國小

第一次參加積分賽,雖然是雙打且不會算上積分,
卻是難忘的經驗阿,早上7:30就在北車淡水線集合,

可惡阿幹竟然差點遲到,還好最後有趕上比賽,雖然沒有暖身就上場了,
不過幸好對手都不強,還連贏兩組,雖然我們也打得很爛 = =

連贏兩組之後就連輸兩組了,輸給怪老伯伯的組合,
日直反面長顆不加海綿,打起來真是討厭 = = 而且老伯伯發球都不太拋球的啦
也不等對方準備好就直接發球,不喜歡 =3=

最後輸給兩個國小女生吧,不知道要怎麼打他們,不過大概也是最後一場沒力的關係吧,
也沒甚麼在攻擊就輸光光了XD" 還剛好被趕來的Angie看到 =..=

值得一提是離開前贏了彭大帥=.=+ 從2:0逆轉到2:3贏
打最開心的就這一場了吧 XD" 推 YE7 是好拍,打起來比70g的舊拍穩超多

打完之後吃了淡水阿給,覺得醬汁好鹹,不喜歡,不過感謝彭大帥的烤魷魚,
超美味的XD" 除了第一口會被粉嗆到之外 哈哈

總的來說是還不錯的經驗,期待下次單打的積分賽XD"...我應該有1400吧 哈哈
北大積分團GOGO~~~

Opera - 一款好用的瀏覽器

推薦一款好用的瀏覽器 Opera
雖然FireFox好用卻越包越多,大小越來越肥胖,
相較之下Opera速度依舊第一且體積更輕薄,
且有幾項方便的功能!

1. 可在網址列輸入 "g 關鍵字" 就會以google來搜尋關鍵字,
若是輸入 "y 關鍵字" 則會以yahoo來搜尋,
且搜尋引擎是可以自己設定的!!

2. 新增分頁那邊不會是空白頁,而是快速撥號頁,
如下圖,有九個快速頁面可以點選,
不需要在打網址而直接可連上最常使用的網頁!!












3. 下載檔案的視窗是單獨一個分頁,
不像是火狐還會跳一個小視窗出來很占位置。












如果google chrome分頁不是開process使電腦效能耗很大,
且論壇以及一些網站排版能正常顯示的話,
也不失為一款好的瀏覽器。速度也是很快的。

不過在google chrome改善以前還是首推Opera或是火狐:D