隨筆 - 5  文章 - 0  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(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 閱讀(119) | 評論 (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 閱讀(122) | 評論 (0)編輯 收藏
           1import java.util.*;
           2import java.lang.*;
           3
           4public class DivisorDigits {
           5    public int howMany(int number) {
           6        
           7        int ans = 0;
           8        int n = number;
           9        while (n != 0{
          10            int n1 = n % 10;
          11            if (n1 != 0 && number % n1 == 0{
          12                ++ans;
          13            }

          14            n /= 10;
          15        }

          16        return ans;
          17        
          18    }

          19}
          posted @ 2009-03-21 10:27 edwing 閱讀(121) | 評論 (0)編輯 收藏
           1import java.util.*;
           2
           3public class ImageDithering {
           4    public int count(String dithered, String[] screen) {
           5        int ans = 0;
           6        for (int i = 0; i < screen.length; ++i) {
           7            for (int j = 0; j < screen[0].length(); ++j) {
           8                char ch = screen[i].charAt(j);
           9                if (dithered.indexOf(ch) != -1{
          10                    ++ans;
          11                }

          12            }

          13        }

          14        return ans;
          15    }

          16}
          posted @ 2009-03-21 10:21 edwing 閱讀(94) | 評論 (0)編輯 收藏
          1public class Time {
          2    public String whatTime(int seconds) {
          3        int h = seconds / 3600;
          4        int m = seconds / 60 % 60;
          5        int s = seconds % 60;
          6        return (h + ":" + m + ":" + s);
          7    }

          8}
          posted @ 2009-03-21 10:17 edwing 閱讀(89) | 評論 (0)編輯 收藏
          僅列出標題  
          主站蜘蛛池模板: 苍南县| 抚顺市| 罗甸县| 龙门县| 城口县| 靖州| 普兰店市| 浑源县| 重庆市| 敖汉旗| 拜城县| 岐山县| 社旗县| 中宁县| 石泉县| 扶风县| 勐海县| 新兴县| 三原县| 南城县| 山东省| 台湾省| 塔河县| 成都市| 霍州市| 雷州市| 鞍山市| 兴安县| 长白| 柘荣县| 丹巴县| 合水县| 罗平县| 嘉兴市| 隆安县| 耒阳市| 苍梧县| 湘乡市| 德州市| 昭平县| 贺州市|