1 /*
2 * Main.c
3 * E1-數組-01. 字符轉換
4 * Created on: 2014年8月20日
5 * Author: Boomkeeper
6 ******部分通過**********
7 */
8
9 #include <stdio.h>
10
11 int main(void) {
12
13 char str[80] = { -1 };
14
15 gets(str);
16
17 int i;
18 for (i = 0; i < 80; i++) {
19 if (str[i] >= '0' && str[i] <= '9')
20 putchar(str[i]);
21 }
22 putchar('\n');
23
24 return 0;
25 }

題目鏈接:
http://pat.zju.edu.cn/contests/basic-programming/%E6%95%B0%E7%BB%84-01
.
s.subString(0,2);
提取前兩位,然後把這個子串裝入數組即可
如果字符串有一定規律,如 s =“23-3-4-2”
可以按照String[] str = s.split("-");
這樣可以按照“-”拆分字符串成字符數組
用Convert.ToInt32("aa", 16);
轉化好的int型存到bytes數組裡就行了