javait
sharing java programming experience
BlogJava
首頁
新隨筆
聯系
聚合
管理
隨筆 - 5 文章 - 0 trackbacks - 0
<
2025年6月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
常用鏈接
我的隨筆
我的評論
我的參與
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆分類
tc_exercise(5)
隨筆檔案
2009年4月 (2)
2009年3月 (3)
文章分類
tc_exercise
搜索
最新評論
閱讀排行榜
1.?SRM 149 FormatAmt(121)
2.?SRM 148 DivisorDigits(121)
3.?SRM 147 CCipher(118)
4.?SRM 145 ImageDithering(93)
5.?SRM 144 Time(88)
評論排行榜
1.?SRM 147 CCipher(0)
2.?SRM 149 FormatAmt(0)
3.?SRM 148 DivisorDigits(0)
4.?SRM 145 ImageDithering(0)
5.?SRM 144 Time(0)
2009年4月5日
SRM 147 CCipher
1
import
java.lang.
*
;
2
import
java.util.
*
;
3
4
public
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)
|
編輯
收藏
SRM 149 FormatAmt
1
import
java.util.
*
;
2
import
java.lang.
*
;
3
4
public
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)
|
編輯
收藏
2009年3月21日
SRM 148 DivisorDigits
1
import
java.util.
*
;
2
import
java.lang.
*
;
3
4
public
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)
|
編輯
收藏
SRM 145 ImageDithering
1
import
java.util.
*
;
2
3
public
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 閱讀(93) |
評論 (0)
|
編輯
收藏
SRM 144 Time
1
public
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 閱讀(88) |
評論 (0)
|
編輯
收藏
僅列出標題
Copyright ©2025 edwing Powered by:
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
河池市
|
大新县
|
瓦房店市
|
厦门市
|
额敏县
|
万载县
|
恭城
|
汽车
|
南汇区
|
明光市
|
繁昌县
|
新民市
|
崇信县
|
安阳市
|
冀州市
|
巴塘县
|
韶山市
|
永福县
|
南乐县
|
渝北区
|
东台市
|
米林县
|
通化市
|
佛冈县
|
静海县
|
黄浦区
|
东光县
|
郓城县
|
河池市
|
桐梓县
|
乌苏市
|
白朗县
|
合阳县
|
峨山
|
大化
|
金乡县
|
遂昌县
|
桐庐县
|
吉木萨尔县
|
九江市
|
西乌珠穆沁旗
|