zoukankan      html  css  js  c++  java
  • 数数

    数数

    时间限制:3000 ms  |  内存限制:65535 KB
    难度:2
    描述

    我们平时数数都是喜欢从左向右数的,但是我们的小白同学最近听说德国人数数和我们有些不同,他们正好和我们相反,是从右向左数的。因此当他看到123时会说“321”。

    现在有一位德国来的教授在郑州大学进行关于ACM的讲座。现在他聘请你来担任他的助理,他给你一些资料让你找到这些资料在书中的页数。现在你已经找到了对应的页码,要用英文把页码告诉他。

    为了简化我们的问题,你只需要返回单词的大写的首字母。(数字0读成字母O)

    注意:每个数字式单独读取的,因此不会出现11读成double one的情况。

    输入
    输入分两部分:
    第一部分:一个整数T(1<=T<=1000)
    第二部分:一共T行,每行为一个数字。每个数的长度不超过10位。
    输出
    每组输出单独占一行,输出对应的返回给德国教授的页码缩写。
    样例输入
    2
    12
    1234
    
    样例输出
    TO
    FTTO

    import java.util.Scanner;
    
    
    public class Main30 {
    
    	public static void main(String[] args) {
    		Scanner input = new Scanner(System.in);
    		int number = input.nextInt();
    		for (int i = 0;i<number;i++) {
    			int n = input.nextInt();
    			String result = solove(n);
    			System.out.println(result);
    		}
    	}
    
    	private static String solove(int n) {
    		String result = String.valueOf(n);
    		StringBuffer sb = new StringBuffer(result);
    		StringBuffer temp = new StringBuffer();
    		sb.reverse();
    		result = sb.reverse().toString();
    		char [] array = result.toCharArray();
    		for (int i = array.length-1;i>=0;i--) {
    			if (array[i] == '0'){
    				temp.append("O");
    			} else if (array[i] == '1') {
    				temp.append("O");
    			} else if (array[i] == '2') {
    				temp.append("T");
    			} else if (array[i] == '3') {
    				temp.append("T");
    			} else if (array[i] == '4') {
    				temp.append("F");
    			} else if (array[i] == '5') {
    				temp.append("F");
    			} else if (array[i] == '6') {
    				temp.append("S");
    			} else if (array[i] == '7') {
    				temp.append("S");
    			} else if (array[i] == '8') {
    				temp.append("E");
    			} else if (array[i] == '9') {
    				temp.append("N");
    			}
    		}
    		
    		return temp.toString();
    	}
    	
    }
    
  • 相关阅读:
    eclipse rcp 获取工程项目路径
    Eclipse RCP中添加第三方jar包的办法
    eclipse content assist 代码提示功能失效解决办法
    lwuit更改字体大小
    lwuit调整滚动条灵敏度值
    AWTEvent
    IE7 IE6去掉关闭提示框的解决方案
    jQuery多库共存最优解决方案
    电子商务网站 数据库产品表设计方案
    javascript操作cookie
  • 原文地址:https://www.cnblogs.com/airycode/p/5491991.html
Copyright © 2011-2022 走看看