2008年8月4日

真正的代码高亮

不能写i<r0
其他直接贴上来。单独一贴说怎么配置


package 字符串操作;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/** 输入字符格式:
* 大小 字符1 字符2 ...
* 每两行,进行一次处理
* 比如:
* 2 1 3
* 4 9 19 29 0
* 排序后得到
* 6 0 1 3 9 19 29
* PS:baidu一贴,用c语言写了一天没写出来,很郁闷,字符串的处理,内存的管理烦死了
* 于是用java写了下,1个小时内吧,哎~~~
* @author gnuser
*
*
*/
class 输入字符串对 {
String[] r0;
String[] r1;
int[] result;

public 输入字符串对(String[] r0, String[] r1) {
super();
this.r0 = r0;
this.r1 = r1;
}
public 输入字符串对() {
}
/**
* 将r0,r1合并后,转换为整形数组
*/
public void changeMig() {
int[] s = new int[r0.length + r1.length];
for(int i=0; i < r0.length; i++)
{
s[i] = Integer.parseInt(r0[i]);
}

for(int i=0; i < r1.length; i++)
{
s[r0.length+i] = Integer.parseInt(r1[i]);
}
this.setResult(s);
}
/**
* 排序后打印
*/
public void printSorted() {
int[] rs = this.getResult();
Arrays.sort(rs);
System.out.print(rs.length + " ");
for(int i=0; i < rs.length; i++)
System.out.print(rs[i] + " ");
System.out.println();
}

public String[] getR0() {
return r0;
}
public void setR0(String[] r0) {
this.r0 = r0;
}
public String[] getR1() {
return r1;
}
public void setR1(String[] r1) {
this.r1 = r1;
}
public int[] getResult() {
return result;
}
public void setResult(int[] result) {
this.result = result;
}


}
public class 分割_排序_输入 {
输入字符串对 ip;

public 输入字符串对 getIp() {
return ip;
}

public void setIp(输入字符串对 ip) {
this.ip = ip;
}

public 分割_排序_输入() {
super();
ip = new 输入字符串对();
}

public void BOBO() throws IOException
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String s;
String[] r0 = null,r1 = null;
int row = 0;
while((s = stdin.readLine()) != null && s.length() != 0)
{
if(s.trim().equals("q"))
break;
if((row++) % 2 == 0)
r0 = s.substring(2).split(" ");
else
{
r1 = s.substring(2).split(" ");
ip.setR0(r0);
ip.setR1(r1);
ip.changeMig();
ip.printSorted();
}
}
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
分割_排序_输入 fps = new 分割_排序_输入();
fps.BOBO();
}

}




展开 Read More...

2008年4月10日

测试代码高亮

如果速度你可以忍受的话,可以试试!
别人写出来了,我就不改着名再写了


int main()
{
printf("hello, beauty!\n");
return 0;
}


比较


int main()
{
printf("hello, beauty!\n");
return 0;
}


展开 Read More...

本博客的模板代码

黑白永远是最提神的搭配.

round4的, 可以对比着改改,我刚弄, 没有改多少, 可以让你从不会到稍微会一点,
不需要多少知识,真的. 有一点注释(其实都没必要)
直接贴过去也可以, 注意贴过去就成我的标题了哦@_@


如下
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

<head>
<b:include data='blog' name='all-head-content'/>
<title><data:blog.pageTitle/></title>
<b:skin><![CDATA[/*
-----------------------------------------------
Blogger Template Style
Name: Rounders 4
Designer: Douglas Bowman
Modifier: 凡人
URL: www.stopdesign.com
Date: 27 Feb 2004
Updated by: Blogger Team
----------------------------------------------- */

/* Variable definitions
====================
<Variable name="mainBgColor" description="Main Background Color"
type="color" default="#466" value="#000000">
<Variable name="mainTextColor" description="Text Color" type="color"
default="#ced" value="#cceedd">
<Variable name="postTitleColor" description="Post Title Color" type="color"
default="#fff" value="#ffffff">
<Variable name="dateHeaderColor" description="Date Header Color"
type="color" default="#cf4" value="#ccff44">
<Variable name="borderColor" description="Post Border Color" type="color"
default="#bbb" value="#bbbbbb">


<Variable name="mainLinkColor" description="Link Color" type="color"
default="#fff" value="#ffffff">
<Variable name="mainVisitedLinkColor" description="Visited Link Color"
type="color" default="#fff" value="#ffffff">

<Variable name="titleTextColor" description="Blog Title Color"
type="color" default="#fff" value="#ffffff">

<Variable name="topSidebarHeaderColor"
description="Top Sidebar Title Color"
type="color" default="#fff" value="#ffffff">
<Variable name="topSidebarBgColor"
description="Top Sidebar Background Color"
type="color" default="#9b5" value="#000000">
<Variable name="topSidebarTextColor" description="Top Sidebar Text Color"
type="color" default="#fff" value="#ffffff">
<Variable name="topSidebarLinkColor" description="Top Sidebar Link Color"
type="color" default="#fff" value="#ffffff">
<Variable name="topSidebarVisitedLinkColor"
description="Top Sidebar Visited Link Color"
type="color" default="#eee" value="#eeeeee">

<Variable name="bottomSidebarBgColor"
description="Bottom Sidebar Background Color"
type="color" default="#fff" value="#ffffff">
<Variable name="bottomSidebarTextColor"
description="Bottom Sidebar Text Color"
type="color" default="#666" value="#666666">
<Variable name="bottomSidebarLinkColor"
description="Bottom Sidebar Link Color"
type="color" default="#475" value="#ffffff">
<Variable name="bottomSidebarVisitedLinkColor"
description="Bottom Sidebar Visited Link Color"
type="color" default="#798" value="#779988">

<Variable name="bodyFont" description="Text Font" type="font"
default="normal normal 100% 'Trebuchet MS',Verdana,Arial,Sans-serif" value="normal normal 100% 'Trebuchet MS',Verdana,Arial,Sans-serif">
<Variable name="pageTitleFont" description="Blog Title Font" type="font"
default="normal bold 300% 黑体" value="normal bold 300% 黑体">
<Variable name="descriptionFont" description="Description Font" type="font"
default="normal normal 100% 'Trebuchet MS',Verdana,Arial,Sans-serif" value="normal normal 100% 'Trebuchet MS',Verdana,Arial,Sans-serif">
<Variable name="headerFont" description="Sidebar Title Font" type="font"
default="normal bold 100% 'Trebuchet MS',Verdana,Arial,Sans-serif" value="normal bold 100% 'Trebuchet MS',Verdana,Arial,Sans-serif">
<Variable name="postTitleFont" description="Post Title Font" type="font"
default="normal bold 135% 'Trebuchet MS',Verdana,Arial,Sans-serif" value="normal bold 200% 黑体">
<Variable name="startSide" description="Start side in blog language"
type="automatic" default="left" value="left">
<Variable name="endSide" description="End side in blog language"
type="automatic" default="right" value="right">
*/

body {
background:#bca;
margin:0;
text-align:center;
line-height: 1.5em;
font: x-small Trebuchet MS, Verdana, Arial, Sans-serif;
color:$mainTextColor;
font-size/* */:/**/small;
font-size: /**/small;
}

/* 贴源代码用的 */
code {
display: block; /* fixes a strange ie margin bug */
font-family: Courier New;
font-size: 10pt;
overflow:auto;
background: #000000 left top repeat-y;
border: 1px solid #ccc;
padding: 10px 10px 10px 21px;
max-height:200px;
line-height: 1.2em;
}

/* Page Structure
----------------------------------------------- */
/* The images which help create rounded corners depend on the
following widths and measurements. If you want to change
these measurements, the images will also need to change.
*/

#outer-wrapper {
width:80%; /* 这些比例就是能缩小放大你的博客格局, 很多我手动调的 */
margin:0 auto;
text-align:$startSide;
font: $bodyFont;
}
#main-wrap1 {
width:70%;
float:$startSide;
background:$mainBgColor $startSide bottom; /* 记得把那些边框圆角图片去掉, 要不就露馅了*/
margin:15px 0 0;
padding:0 0 10px;
color:$mainTextColor;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}
#main-wrap2 {
float:$startSide;
width:100%;
padding:10px 0 0;
}
#main {
padding:0;
width:100%; /* 必须100% */
}
#sidebar-wrap {
background: #000 $startSide top;
width:26%;
float:$endSide;
margin:15px 0 0;
font-size:97%;
line-height:1.5em;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

.main .widget {
margin-top: 0;
margin-$endSide: 13px;
margin-bottom: 4px;
margin-$startSide: 13px;
}

.main .Blog {
margin: 0;
}

/* Links
----------------------------------------------- */
a:link {
color: $mainLinkColor;
}
a:visited {
color: $mainVisitedLinkColor;
}
a:hover {
color: $mainVisitedLinkColor;
}
a img {
border-width:0;
}


/* Blog Header
----------------------------------------------- */
#header-wrapper {
background: #000 $startSide top;
margin-top:22px;
margin-$endSide:0;
margin-bottom:0;
margin-$startSide:0;
padding-top:8px;
padding-$endSide:0;
padding-bottom:0;
padding-$startSide:0;
color:$titleTextColor;
}
#header {
text-align:center;
letter-spacing:20px;
background: no-repeat $startSide bottom;
padding:0 15px 8px;
}
#header h1 {
margin:0;
padding:10px 30px 5px;
line-height:1.2em;
font: $pageTitleFont;
}
#header a,
#header a:visited {
text-decoration:none;
color: $titleTextColor;
}
#header .description {
margin:0;
padding:5px 30px 10px;
line-height:1.5em;
font: $descriptionFont;
}

/* Posts
----------------------------------------------- */
h2.date-header {
margin-top:0;
margin-$endSide:28px;
margin-bottom:0;
margin-$startSide:43px;
font-size:85%;
line-height:2em;
text-transform:uppercase;
letter-spacing:.2em;
color:$dateHeaderColor;
}
.post {
margin:.3em 0 25px;
padding:0 13px;
border:1px dotted $borderColor;
border-width:1px 0;
}
.post h3 {
margin:0;
line-height:1.5em;
background:url("http://www.blogblog.com/rounders4/icon_arrow.gif") no-repeat 10px .5em;
display:block;
border:1px dotted $borderColor;
border-width:0 1px 1px;
padding-top:2px;
padding-$endSide:14px;
padding-bottom:2px;
padding-$startSide:29px;
color: $postTitleColor;
font: $postTitleFont;
}
.post h3 a, .post h3 a:visited {
text-decoration:none;
color: $postTitleColor;
}
.post h3 a:hover {
background-color: $borderColor;
color: $postTitleColor;
}
.post-body {
border:1px dotted $borderColor;
border-width:0 1px 1px;
border-bottom-color:$mainBgColor;
padding-top:10px;
padding-$endSide:14px;
padding-bottom:1px;
padding-$startSide:29px;
line-height: 25px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
html>body .post-body {
border-bottom-width:0;
}
.post p {
margin:0 0 .75em;
}

.post-footer {
background: #000;
margin:0;
padding-top:2px;
padding-$endSide:14px;
padding-bottom:2px;
padding-$startSide:29px;
border:1px dotted $borderColor;
border-width:1px;
font-size:100%;
line-height:1.5em;
color: #acb;
}

.post-footer p {
margin: 0;
}

html>body .post-footer {
border-bottom-color:transparent;
}

.uncustomized-post-template .post-footer {
text-align: $endSide;
}

.uncustomized-post-template .post-author,
.uncustomized-post-template .post-timestamp {
display: block;
float: $startSide;
text-align:$startSide;
margin-$endSide: 4px;
}

.post-footer a {
color: #fff;
}
.post-footer a:hover {
color: #eee;
}
a.comment-link {
/* IE5.0/Win doesn't apply padding to inline elements,
so we hide these two declarations from it */
background/* */:/**/url("http://www.blogblog.com/rounders4/icon_comment_$startSide.gif") no-repeat $startSide 45%;
padding-$startSide:14px;
}
html>body a.comment-link {
/* Respecified, for IE5/Mac's benefit */
background:url("http://www.blogblog.com/rounders4/icon_comment_$startSide.gif") no-repeat $startSide 45%;
padding-$startSide:14px;
}
.post img {
margin-top:0;
margin-$endSide:0;
margin-bottom:5px;
margin-$startSide:0;
padding:4px;
border:1px solid $borderColor;
}
blockquote {
margin:.75em 0;
border:1px dotted $borderColor;
border-width:1px 0;
padding:5px 15px;
color: $dateHeaderColor;
}
.post blockquote p {
margin:.5em 0;
}

#blog-pager-newer-link {
float: $startSide;
margin-$startSide: 13px;
}

#blog-pager-older-link {
float: $endSide;
margin-$endSide: 13px;
}

#blog-pager {
text-align: center;
}

.feed-links {
clear: both;
line-height: 2.5em;
margin-$startSide: 13px;
}

/* Comments
----------------------------------------------- */
#comments {
margin:-25px 13px 0;
border:1px dotted $borderColor;
border-width:0 1px 1px;
padding-top:20px;
padding-$endSide:0;
padding-bottom:15px;
padding-$startSide:0;
}
#comments h4 {
margin:0 0 10px;
padding-top:0;
padding-$endSide:14px;
padding-bottom:2px;
padding-$startSide:29px;
border-bottom:1px dotted $borderColor;
font-size:120%;
line-height:1.4em;
color:$postTitleColor;
}
#comments-block {
margin-top:0;
margin-$endSide:15px;
margin-bottom:0;
margin-$startSide:9px;
}
.comment-author {
background:url("http://www.blogblog.com/rounders4/icon_comment_$startSide.gif") no-repeat 2px .3em;
margin:.5em 0;
padding-top:0;
padding-$endSide:0;
padding-bottom:0;
padding-$startSide:20px;
font-weight:bold;
}
.comment-body {
margin:0 0 1.25em;
padding-top:0;
padding-$endSide:0;
padding-bottom:0;
padding-$startSide:20px;
}
.comment-body p {
margin:0 0 .5em;
}
.comment-footer {
margin:0 0 .5em;
padding-top:0;
padding-$endSide:0;
padding-bottom:.75em;
padding-$startSide:20px;
}
.comment-footer a:link {
color: #ced;
}
.deleted-comment {
font-style:italic;
color:gray;
}


/* Profile
----------------------------------------------- */
.profile-img {
float: $startSide;
margin-top: 5px;
margin-$endSide: 5px;
margin-bottom: 5px;
margin-$startSide: 0;
border: 4px solid $topSidebarTextColor;
}

.profile-datablock {
margin-top: 0;
margin-$endSide: 15px;
margin-bottom: .5em;
margin-$startSide: 0;
padding-top: 8px;
}

.profile-link {
background:url("http://www.blogblog.com/rounders4/icon_profile_$startSide.gif") no-repeat $startSide .1em;
padding-$startSide:15px;
font-weight:bold;
}

.profile-textblock {
clear: both;
margin: 0;
}

.sidebar .clear, .main .widget .clear {
clear: both;
}

#sidebartop-wrap {
background:$topSidebarBgColor no-repeat $startSide bottom;
margin:0px 0px 15px;
padding:0px 0px 10px;
color:$topSidebarTextColor;
}

#sidebartop-wrap2 {
background: $topSidebarBgColor no-repeat $startSide top;
padding: 10px 0 0;
margin:0;
border-width:0;
}

#sidebartop h2 {
line-height:1.5em;
color:$topSidebarHeaderColor;
border-bottom: 1px dotted $topSidebarHeaderColor;
font: $headerFont;
margin-bottom: 0.5em;
}

#sidebartop a {
color: $topSidebarLinkColor;
}

#sidebartop a:hover {
color: $topSidebarVisitedLinkColor;
}
#sidebartop a:visited {
color: $topSidebarVisitedLinkColor;
}
/* Sidebar Boxes
----------------------------------------------- */

.sidebar .widget {
margin:.5em 13px 1.25em;
padding:0 0px;
}

.widget-content {
margin-top: 0.5em;
}

#sidebarbottom-wrap1 {
margin:0 0 15px;
padding:10px 0 0;
color: $bottomSidebarTextColor;
}

#sidebarbottom-wrap2 {
background: no-repeat $startSide bottom;
padding:0 0 8px;
}


#sidebar {
color: $bottomSidebarTextColor;
}

#sidebar h2 {
color: $bottomSidebarTextColor;
border-bottom: 1px dotted $bottomSidebarTextColor;
margin-bottom: 0.5em;
}

#sidebar a {
color: $bottomSidebarLinkColor;
}
#sidebar a:hover,
#sidebar a:visited {
color: $bottomSidebarVisitedLinkColor;
}

.sidebar h2 {
margin:0;
padding:0 0 .2em;
line-height:1.5em;
font:$headerFont;
}

.sidebar ul {
list-style:none;
margin:0 0 1.25em;
padding:0;
}

.sidebar ul li {
background:url("http://www.blogblog.com/rounders4/icon_arrow_sm.gif") no-repeat 2px .25em;
margin:0;
padding-top:0;
padding-$endSide:0;
padding-bottom:3px;
padding-$startSide:16px;
margin-bottom:3px;
border-bottom:1px dotted $borderColor;
line-height:1.4em;
}
.sidebar p {
margin:0 0 .6em;
}

/* Footer
----------------------------------------------- */
#footer-wrap1 {
clear:both;
margin:0 0 10px;
padding:15px 0 0;
}
#footer-wrap2 {
background:#447766 $startSide top;
color:$titleTextColor;
}
#footer {
background: $startSide bottom;
padding:8px 15px;
}
#footer hr {display:none;}
#footer p {margin:0;}
#footer a {color:$titleTextColor;}
#footer .widget-content {
margin:0;
}

/** Page structure tweaks for layout editor wireframe */
body#layout #main-wrap1,
body#layout #sidebar-wrap,
body#layout #header-wrapper {
margin-top: 0;
}

body#layout #header, body#layout #header-wrapper,
body#layout #outer-wrapper {
margin-$startSide:0,
margin-$endSide: 0;
padding: 0;
}

body#layout #outer-wrapper {
width:%65;
}

body#layout #footer-wrap1 {
padding-top: 0;
}
]]></b:skin>
</head>

<body>
<div id='outer-wrapper'>

<div id='header-wrapper'>
<b:section class='header' id='header' maxwidgets='1'>
<b:widget id='Header1' locked='true' title='凡人凡居 (标题)' type='Header'/>
</b:section>
</div>

<div id='crosscol-wrapper' style='text-align:center'>
<b:section class='crosscol' id='crosscol' showaddelement='no'/>
</div>

<div id='main-wrap1'><div id='main-wrap2'>
<b:section class='main' id='main' showaddelement='no'>
<b:widget id='Blog1' locked='true' title='博客文章' type='Blog'/>
</b:section>
</div></div>

<div id='sidebar-wrap'>

<div id='sidebartop-wrap'><div id='sidebartop-wrap2'>
<b:section class='sidebar' id='sidebartop'>
<b:widget id='Profile1' locked='false' title='Host' type='Profile'/>
</b:section>
</div></div>

<div id='sidebarbottom-wrap1'><div id='sidebarbottom-wrap2'>
<b:section class='sidebar' id='sidebar' preferred='yes'>
<b:widget id='LinkList2' locked='false' title='Favorite area' type='LinkList'/>
<b:widget id='BlogArchive1' locked='false' title='博客归档' type='BlogArchive'/>
<b:widget id='LinkList1' locked='false' title='Links' type='LinkList'/>
</b:section>
</div></div>

</div>

<div id='footer-wrap1'><div id='footer-wrap2'>
<b:section class='footer' id='footer'/>
</div></div>

</div>
</body>
</html>

展开 Read More...

2008年4月7日

扩展发表文章(Expandable post summaries with Beta)

I came up with two better versions later. Use one of them instead of this older version.
1. One with which you can selectively make some of the old posts expandable i.e. only summaries will show up for them and clicking a "read more..." link will take you to the post page.
2. One that expands posts in the main page itself - Peekaboo style.]



Jornada left a comment in my blog that he found a blog which explained how to show expandable post summaries with Beta. Good thing about showing only post summary in the main page is that your readers can quickly find all that you have written about. Also, your blog gets an 'online journal'-like neat look. A "Read more" link is provided which takes them to the post page to read the entire post. Please note that you, as the author, have the flexibility to choose the portion of your post that appears as summary.


This hack is only an adaptation of Blogger's original instructions for expandable post summaries to Beta template. You can find Jornada's post about this here. I thought I will re-post the instructions with minor modifications for my readers.

<div class="post-header-line-1">

<div class="post-body">
<span style="font-weight: bold; color: rgb(255, 0, 0);">
<b:if cond="data:blog.pageType == "item"">
<style>.fullpost{display:inline;}</style>
</b:if><p><data:post.body></data:post.body></p>
<b:else>
<style>.fullpost{display:none;}</style>

</b:else><p><data:post.body></data:post.body></p>

<a style="color: rgb(255, 0, 0);" href="data:post.url">Read More......</a>

</span>
<div style="clear: both;"> <!-- clear for photos floats -->
</div>



Step 2. Goto Settings->Formatting and at the bottom, you will find the text box provided to specify the "Post template". Copy/paste these lines into that text box and save the settings.


Type your summary here
<span class="fullpost">
Type rest of the post here
</span>



If you create a new post now, it shows you clearly where to type the summary and where to add the rest of the post. Follow the format and only summary will show up in your main page. Please note that you also need to divide your old posts like this (atleast the ones showing up in main page) into summary and full portions by editing them.

展开 Read More...