2010年2月19日 星期五

SyntaxHighlighter 2.1 + 試用

SyntaxHighlighter 2.1 解決之前不能處理 <<>>的問題
(經我實測結果結果還是會有點問題........可以輸出<<>> 但<>後面接續字母的話,會被當作tag...)

程式碼寫在< pre class="brush: 程式語言 > 你的程式碼< / pre>

brush code
ActionScript3 as3, actionscript3
Bash/shell bash, shell
C# c-sharp, csharp
C++ cpp, c
CSS css
Delphi delphi, pas, pascal
JavaScript js, jscript, javascript
Java java shBrushJava.js
JavaFX jfx, javafx
Perl perl, pl
PHP php
Plain Text plain, text
PowerShell ps, powershell
Python py, python
Ruby rails, ror, ruby
Scala scala
SQL sql
Visual Basic vb, vbnet
XML xml, xhtml, xslt, html, xhtml

測試範例..之前寫的亂數產生座標點
#include < iostream> 
#include < stdlib.h>
#include < iomanip>
#include < fstream> 
#include < time.h>
using namespace std; 

int main() { 
 
 //亂數種子
 time_t t;
 srand((unsigned) time(&t));
 
 // 資料的範圍...10*10 
 int dataspaceX;
 int dataspaceY;
 dataspaceX = 10;
 dataspaceY = 10;
 
 // transaction 筆數...1000筆
 int notrans;
 notrans = 100;
 
 //transaction length.....2~7
 int len;
 
 //create output file stream
 ofstream fout("db.txt"); 
 if(!fout) { 
        cout << "無法寫入檔案\n"; 
        return 1; 
    } 

 for(int i=0;i< notrans;i++){>
  //亂數決定每一筆transaction長度
  len = 2 + (rand() % 7);
  cout<< len;
  cout << endl; 
  fout << i+1 << " ";
  //亂數產生點
  for(int j=0;j< len;j++){>
   //產生 x,y
   int tmpX = 1 + rand() % dataspaceX;
   int tmpY = 1 + rand() % dataspaceY;
   //產生0~10的浮點數  
   fout << tmpX << "," << tmpY << "," << fixed << setprecision(1) << (float)10*(rand())/RAND_MAX << " ";
   //fout  << " ("<< tmpX << "," << tmpY << "," << (float)10*(rand())/RAND_MAX << ")";
   
  }
  fout << endl;  
 }
 fout.close();
 //printf("%.1f\n",(float)10*(rand())/RAND_MAX);
 //printf("%f\n",(float)3.4);
 //printf("%f\n", (float)(rand() % dataspace)/10);
 //printf("%d\n", rand() % dataspace);

 system("pause");
 return 0; 
} 

沒有留言: