import java

Document technical information

Format doc
Size 29.2 kB
First found May 22, 2018

Document content analysis

Category Also themed
Language
Type
not defined
Concepts
no text concepts found

Persons

Organizations

Places

Transcript

import java.io.*;
public class P8 {
/**
* @param args
*/
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
String str;
String[]table={"個","十","百","千","萬","十萬","百萬","千萬","億","
十億"};
for(;;){
System.out.print("INPUT==>");
str=br.readLine();
if(str.equals("0"))return;
System.out.println("OUTPUT:");
if(str.length()>10){
System.out.println("輸入數字超過十位數請重新輸入");
continue;
}
char max='0';
for(int i=0;i<str.length();i++){
if(str.charAt(i)!='0'){
System.out.println(table[str.length()-1-i]+"位為
"+str.charAt(i));
if(str.charAt(i)>max)max=str.charAt(i);
}
}
System.out.println("\n最大為"+max);
System.out.print("反轉輸出");
boolean nz=false;
for(int i=str.length()-1;i>=0;i--){
if(str.charAt(i)!='0'){
nz=true;
}
if(nz){
System.out.print(str.charAt(i));
}
}
System.out.println();
}
}
}

Similar documents

×

Report this document