1 条题解
-
0
Java :
import java.io.UnsupportedEncodingException; import java.util.Scanner; public class Main { public static void main(String[] args) throws UnsupportedEncodingException { int p[] = {0xB0C5,0xB2C1,0xB4EE,0xB6EA,0xB7A2,0xB8C1,0xB9FE,0xBBF7,0xBFA6,0xC0AC,0xC2E8,0xC4C3,0xC5B6,0xC5BE,0xC6DA,0xC8BB,0xC8F6,0xCBFA,0xCDDA,0xCEF4,0xD1B9,0xD4D1,0xFFFF}; String h="ABCDEFGHJKLMNOPQRSTWXYZ"; int i,j,k; Scanner sc=new Scanner(System.in); int n=Integer.parseInt(sc.nextLine()); for(k=0;k<n;k++) { String r=""; String s=sc.nextLine(); byte[] b=s.getBytes("GB2312"); for(i=0;i<b.length;i+=2)//针对每个汉字 { int t=(0xff00&b[i]<<8)+(0xff&b[i+1]);//位运算,把每个汉字转成整数 for(j=0;j<23;j++) { if(t<p[j]) { r+=h.charAt(j); break; } } } System.out.println(r); } } }
- 1
信息
- ID
- 858
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者