隨筆 - 5  文章 - 0  trackbacks - 0
          <2009年4月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章分類

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

           1import java.lang.*;
           2import java.util.*;
           3
           4public class CCipher {
           5    public String decode(String cipherText, int shift) {
           6        
           7        StringBuffer ans = new StringBuffer();
           8        for (int i = 0; i < cipherText.length(); ++i) {
           9            char ch = cipherText.charAt(i);
          10            if (ch - 'A' - shift < 0{
          11                ch += 26 - shift;
          12            }
           else {
          13                ch -= shift;
          14            }

          15            ans.append(ch);
          16        }

          17        return ans.toString();
          18        
          19    }

          20}
          posted @ 2009-04-05 20:09 edwing 閱讀(118) | 評論 (0)編輯 收藏
           1import java.util.*;
           2import java.lang.*;
           3
           4public class FormatAmt {
           5
           6    public String amount(int dollars, int cents) {
           7    
           8        String ans = "";
           9        String dollarsStr = String.valueOf(dollars);
          10        int n = dollarsStr.length();
          11        int begin = (3 - (n % 3)) % 3;
          12        for (int i = 0, j = begin; i < n; ++i, j = (++j) % 3{
          13            if (i != 0 && j == 0{
          14                ans += ",";
          15            }

          16            ans += dollarsStr.charAt(i);
          17        }

          18        ans = "$" + ans + ".";
          19        if (cents < 10{
          20            ans += "0" + cents;
          21        }
           else {
          22            ans += cents;
          23        }

          24        return ans;
          25        
          26    }

          27
          28}
          posted @ 2009-04-05 20:07 edwing 閱讀(121) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 和硕县| 长沙县| 靖江市| 基隆市| 桃源县| 鄂伦春自治旗| 东宁县| 永嘉县| 澎湖县| 儋州市| 江川县| 安化县| 黔西| 余江县| 阜阳市| 新田县| 衡阳县| 辉县市| 大新县| 从化市| 章丘市| 嵊州市| 银川市| 浦县| 磐石市| 穆棱市| 合水县| 青川县| 平遥县| 达州市| 苏尼特右旗| 阳江市| 金华市| 大方县| 临猗县| 常熟市| 武陟县| 永城市| 翁源县| 泗水县| 太康县|