2010年9月27日 星期一

PHP與好朋友HTML的簡單??關係


<?php
 echo '<a href="http://www.google.com.tw/">Gooele</a>';
 /***********超連結語法************
 <a href="網址">連結顯示的文字</a>
 ********************************/
 
 echo '<br />';
 /************換行語法************
 <br />
 ********************************/
 
 $word = '身體';
 
 echo '<br />'.$word;
 echo '<br />頭'.'手'.$word.'膀胱'.'腳<br />';
 echo $word.'<br />';
 /***********文字連接符號*********
 '文字'點$word
 $word點'文字'
 '文字'點$word點'文字'
 ********************************/
 
 echo '<input type="text" />';
 /************表單語法************
 <form action="test.php" method="post">
  <input type="text" />
 </form>
 
 其中text可改成
 text  文字框
 password 密碼框
 button  一般按鈕
 reset  清除按鈕
 submit  送出按鈕
 file  檔案按鈕
 checkbox 核取方塊
 hidden  隱藏變數(可用來傳遞隱藏的變數)
 ********************************/
?>



後記:
聽說是今天在程式語言(一)上課時,
某個來討債的學弟一問(咦!?

2010年9月17日 星期五

除去虛擬硬碟


執行『cmd』進入命令提示字元鍵入:『subst z: /d』

2010年5月28日 星期五

GD_week14

HTML的部份:

零件編號: 設計者姓名: 零件長度: 零件寬度:
PHP的部份:
<?php
// week14_action.php
// 處理 week14_form.htm 所送回來的表單資料,並藉以直接顯示出對應的圖檔

// 取得表單傳回來的變數值
$number = $_POST["number"];
$name = $_POST["name"];
$length = $_POST["length"];
$width = $_POST["width"];

// 以下開始根據所取得的表單資料 show 出圖檔
    /*由於處理程式,直接假設取值不會有問題,因此不使用任何 echo 指令,傳送文字檔資料,
      因此 output buffer 中不會有資料,因此無需使用 ob_clean()進行清除*/
    header("Content-type: image/png");
//1.設定圖片大小 --------------------------------------------------------//
    $im = imagecreatetruecolor($length,$width);
    //$bgcolor = ImageColorAllocate ($im, Red(0~255), Green(0~255), Blue(0~255));
//2.設定背景顏色填入淺藍色底色 ------------------------------------------//
    $bgcolor = ImageColorAllocate ($im, 153, 204, 255);
    imagefill($im, 0, 0, $bgcolor);
    
//3.用線來畫邊框 --------------------------------------------------------//
    $black = ImageColorAllocate ($im, 0, 0, 0);
    // 畫框的一些參數
    $thick = 20;
    $margin = 40;
    // 畫最上方平行線
    $startx = 0 + $margin;
    $starty = 0 + $margin;
    $endx = $length - $margin;
    $endy = $starty;
    //imagelinethick($image,x1,y1,x2,y2,顏色,粗細);
    imagelinethick($im,$startx,$starty,$endx,$endy,$black,$thick);
    
//4.寫上編號與姓名 ------------------------------------------------------//
    $string = "Number:".$number."\nName:".$name;
    $font = "fireflysung.ttf";
    //imagettftext(resource $image,大小,角度,X座標,Y座標,顏色,字型,文字)
    ImageTTFText($im, 20, 0, ($length/2)-40,($width/2)-10, $black, $font, $string);
    
//5.畫箭頭 --------------------------------------------------------------//
    $red = ImageColorAllocate ($im, 255, 0, 0);
    //arrow($image,x1,y1,x2,y2,箭頭長度,箭頭寬度,顏色);
    arrow($im, 150,150, 350,150, $length/50, $width/50, $red);
    
//6.結束繪圖 ------------------------------------------------------------//
    imagepng($im);
    imagedestroy($im);

//-----------------------------------------------------------------------

//以下函式直接取自 http://www.php.net/manual/en/function.imageline.php
function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1)
{
    if ($thick == 1) {
        return imageline($image, $x1, $y1, $x2, $y2, $color);
    }
    $t = $thick / 2 - 0.5;
    if ($x1 == $x2 || $y1 == $y2) {
        return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
    }
    $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
    $a = $t / sqrt(1 + pow($k, 2));
    $points = array(
        round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a),
        round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a),
        round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a),
        round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a),
    );
    imagefilledpolygon($image, $points, 4, $color);
    return imagepolygon($image, $points, 4, $color);
}

// 以下函式直接取自 http://php.net/manual/en/function.imageline.php
function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {
    $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
    $dx = $x2 + ($x1 - $x2) * $alength / $distance;
    $dy = $y2 + ($y1 - $y2) * $alength / $distance;
    $k = $awidth / $alength;
    $x2o = $x2 - $dx;
    $y2o = $dy - $y2;
    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;
    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;
    imagelinethick($im, $x1, $y1, $dx, $dy, $color,3);
    imagefilledpolygon($im, array($x2, $y2, $x3, $y3, $x4, $y4), 3, $color);
}
?>

2010年5月18日 星期二

河內塔(Hanoi tower)

不知道河內塔是什麼嗎?請點我

遊戲規則:
1.每次只能移動一個盤子
2.大盤子不可以在小盤子的上面

程式碼:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

void HNTower(int,char,char,char);
int main() {
    int n;
    char A = 'A',B = 'B',C = 'C';
    scanf("%d",&n);
    HNTower(n,A,B,C);
    system("PAUSE");
    return 0;
}
void HNTower(int n,char a,char b,char c) {
    if(n == 1)
        printf("Move dish no.1 from %c to %c\n",a,c);
    else{
        HNTower(n - 1,a,c,b);
        printf("Move dish no.%d from %c to %c\n",n,a,c);
        HNTower(n - 1,b,a,c);
    }
}
參考看看吧。

 

2010年5月13日 星期四

簡易不弱格貼紙製造機

這程式沒有寫得很好僅供參考,

這個程式已經改好了=w=+

附加檔案:這裡

簡易不弱格貼紙製造機原始碼:

HTM部分:

<!--程式名稱:index.htm-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><!--宣告文件型態為萬國碼-->
<form method="GET" action="gd_change.php" enctype="multipart/form-data">
<!--文字輸入框-->
輸入一個字:<input name="word" type="text"
style="text-align:center; border-top-style:none; border-right-style:none; border-left-style:none;"
value="傻" size="1" /><br />
<!--size="1" 指定要多大的框框-->
<!--text-align:center; 文字置中-->
<!--border-top-style:none; 隱藏框框的上面的線-->
<!--border-right-style:none; 隱藏右邊的線-->
<!--border-left-style:none; 隱藏左邊的線-->

<!--下拉式選單-->
請選擇顏色:
<select name="color"><!--下拉式選單的名稱-->
<option value="r_eye">紅色</option><!--選項們-->
<option value="b_eye">藍色</option>
<option value="g_eye">綠色</option>
<option value="y_eye">棕色</option>
<option value="bk_eye">黑色</option>
</select>
<input type="hidden" name="action" value="1">
<!--送出按鈕-->
<input type="submit" value="送出"></form>


PHP部分:

<?php
//程式名稱:gd_change.php
$act = $_GET["action"];
$color = $_GET["color"];//讀進顏色
$string = $_GET["word"];//讀進文字
if($act && $color && $string) {
 header("Content-type: image/jpeg");//宣告文件型態
 $im = imagecreatefromjpeg($color.".jpg");//圖片檔案
 $fontsize = 8;//文字大小
 $angle = 0;//文字角度
 $x = 35;//文字X座標
 $y = 26;//文字Y座標
 $color = imagecolorallocate($im, 255, 255, 255);//文字顏色
 $font = "../fonts/fireflysung.ttf";//文字TTF字型
 ImageTTFText($im, $fontsize, $angle, $x, $y, $color, $font, $string);//輸出文字
 imagejpeg($im);//輸出圖形
 imagedestroy($im);//結束圖形編輯
}
?>

2010年5月6日 星期四

atoi整數轉換+強制轉換成int型態

//下面是範例程式

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

int main()
{
    int intnum;
    double doublenum;
    char word[30]; //最多只能讀30個字母組成的單字
    while(1)
    {
        printf("\nEnter any number:");
        scanf("%s",word);
        // 呼叫 atoi()將字串轉為整數,掃到非數字值即終止
        // 如輸入『123abc456』則會輸出『123』
        doublenum = atoi(word);
        // 強制轉換成int
        intnum = (int)doublenum;
        if(intnum<=50 && intnum>0)
        {
            printf("%d is >0 and <= 50",intnum);
        }
        else if(intnum == 0)
        {
            break;
        }
        else
        {
            printf("%d is <=0 or not integer",intnum);
        }
    }
    return 0;
}

GDpng程式

<?php
//程式名稱:gdpngtext.php
header("Content-type: image/png");

$im = imagecreatefrompng("test.png");//圖片檔案
$fontsize = 14;//文字大小
$angle = 0;//文字角度
$x = 25;//文字X座標
$y = 80;//文字Y座標
$color = imagecolorallocate($im, 255, 255, 255);//文字顏色
$font = "fireflysung.ttf";//文字TTF字型
$string = "國立虎尾科技大學";//文字

ImageTTFText($im, $fontsize, $angle, $x, $y, $color, $font, $string);//輸出文字
ImagePng($im);//輸出圖形
ImageDestroy($im);//結束圖形編輯
?>

2010年4月1日 星期四

簡單html語法

請寫在<body>與</body>之內~


<img src="http://l.yimg.com/f/i/tw/hp/mh/09purple.gif" />

超連結語法
<a href="http://tw.yahoo.com/">雅虎</a>

超連結開新頁面語法
<a target="_blank" href="http://www.google.com/">估狗</a>

刪除線語法
<s>丁丁</s>

粗體字
<b>拉拉</b>

斜體字
<i>迪西</i>

底線字
<u>小波</u>

2010年3月18日 星期四

速食店點快餐

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

int main(void)
{
    int meal,dollar,num,anser,keepon;
    anser=0;
    printf("歡迎光臨!請問要點幾號餐?");
    while(1)
    {
        meal=0;
        dollar=0;
        scanf("%d",&meal);
        if(meal==1)
        {
            printf("您點的是一號!新台幣一百元\n");
            dollar=100;
        }
        else if(meal==2)
        {
            printf("您點的是二號!新台幣一百二十元\n");
            dollar=120;
        }
        else
        {
            printf("我們不提供%d號,請重新輸入:\n",meal);
            continue;
        }
        num=0;
        printf("您要幾份套餐?");
        scanf("%d",&num);
        anser+=dollar*num;
        keepon=0;
        printf("是否還要續點(Yes=1,No=2)?");
        scanf("%d",&keepon);
        if(keepon==1)
        {
            printf("請問您要續點幾號餐?");
            continue;
        }
        else
        {
            break;
        }
    }
    printf("總共是%d元",anser);
    return 0;
}

2010年3月11日 星期四

HTML網頁基本架構

1.
要寫網頁之前一定要先了解網址:
例如本站網址:『http://nfuc.blogspot.com/』,
事實上這個網址省略了一個『index.html』,
正確來說完整的網址應該是『http://nfuc.blogspot.com/index.html』,
再拆開這個這個『index.html』由檔名『index』與『html』組成,
其中『index』是由自己設定的名稱,
而『html』則是為了能在網頁瀏覽器中看到資訊所設計的一種標示語言,
另外我們還會在網路上看到『htm』這種副檔名,
這兩種文件基本上內容沒有區別,
講簡單來說習慣上首頁檔我們會用『html』而子頁面我們則會用『htm』,
因此剛剛的例子才會採用『html』,
又系統內定默認『index.html』為烘培雞(Homepage)因此網址可以省略,
所以要做一個簡單的網站會包括一個『html』檔案再加上許多『htm』,
那麼該如何做呢?

2.
既然網址已經知道是怎麼一回事了,
那麼接下來就是要知道如何去寫這個名為『index.html』的檔案,
他的基本架構如下:

文件類型定義Html屬性標頭網頁說明網頁標題網頁內容


ps:這個『<br />』 是換行語法
---------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>賣火柴的小女孩</title>

</head>

<body>
我是賣火柴的小女孩這樣,<br />
我是妳爸,去賣火柴。
</body>

</html>

---------------------------------------------------------------
圖形表示:


所以最陽春的網頁就出現了...
有沒有寫教學很花時間的八卦(小聲...噓

2010年3月8日 星期一

水仙花數

在數論中,水仙花數是指這樣一個數,其各個數之立方和等於該數。

例如: 13+53+33=153

那麼如何利用程式算出100~999裡頭有哪些數字是水仙花數呢=w=?

如果你現在覺得閒閒沒事的可以寫寫看~

2010年3月4日 星期四

DiaPortable0.97.1-1



軟體名稱:DiaPortable0.97.1-1
軟體性質:免費軟體
軟體語言:多國(含繁體中文)
軟體載點:本站下載官方下載
軟體功能:繪製程式流程圖...等

網路上似乎很多人反應沒有辦法輸入繁體中文,
甚至有人非常克難的使用複製貼上的方式...~"~
在這裡教你遇到DIA無法輸入繁體中文的時候你可以試試:


另外當你遇到打不開軟體的時候,
你可以檢查看看你軟體放置的路徑是否有中文字存在,
因為DIA不允許安裝路徑有中文字出現。

2010年3月1日 星期一

程式語言(二)

課程網址:http://kmol1.mde.nfu.edu.tw/course/c2/

問:考題是不是你出的?
答:我不知道...看老師心情。

問:我會不會過?
答:施主...這要問您自己阿。

問:我什麼都不會耶!
答:那你來做什麼的...
好吧...你可以先自己看看部落格文章,
不懂的可以在8:00~10:00來學生宿舍三舍的資源中心找我,
我不是老師可以放輕鬆點學習。

2010年1月10日 星期日

第二次考試成績

成績公開結束。

有人帳號密碼那題程式的密碼是學號,
而且那學號還不是他的學號,
帶回家寫的連參考同學答案都不會參考,
更不用說真的會寫程式了。

像上面這類答案搞笑過頭的,
我們已經記錄在心中,但不會送上名單,
可是下學期如果還是我們改考卷,
再看到心中名單內重複搞笑過頭的我們不會客氣了,
這樣應該不過分吧?