PAT 甲级 1027 Colors in Mars(模拟)

 

1027 Colors in Mars (20)(20 分)

People in Mars represent the colors in their computers in a similar wayas the Earth people. That is, a color is represented by a 6-digitnumber, where the first 2 digits are for Red, the middle 2 digits forGreen, and the last 2 digits for Blue. The only difference is that theyuse radix 13 (0-9 and A-C) instead of 16. Now given a color in threedecimal numbers (each between 0 and 168), you are supposed to outputtheir Mars RGB values.

Input

Each input file contains one test case which occupies a line containingthe three decimal color values.

Output

For each test case you should output the Mars RGB value in the followingformat: first output "#", then followed by a 6-digit number where allthe English characters must be upper-cased. If a single color is only1-digit long, you must print a "0" to the left.

Sample Input

15 43 71

Sample Output

#123456

Analysis:

upper means "大写"。。。。

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream(""));
		BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
		String in[]=bufferedReader.readLine().split(" ");
		System.out.print("#");
		int i=0;
		while(i<3) {
			String rString=Integer.toString(Integer.parseInt(in[i]), 13);
			if(rString.length()==1)
				System.out.print("0");
			for(int j=0;j<rString.length();j++)
				if(rString.charAt(j)>='a'&&rString.charAt(j)<='z')
					System.out.print((char)(rString.charAt(j)-32));
				else {
					System.out.print(rString.charAt(j));
				}
			i++;
		}


	}

}

 


版权声明:本文为zpjlkjxy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。