UVA 10101 Java

import java.util.*;

public class main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int count = 0;
    while(sc.hasNextLong())
    {
    	long num = sc.nextLong();
    	System.out.printf("%4d.", ++count);
    	if(num == 0)
    		System.out.print(" 0");
		else
			bangla(num);
    	System.out.println();
    }
  }
  
  public static void bangla(long num)
  {
  	    if(num >= 10000000)
    	{
    		bangla(num / 10000000);
    		System.out.print(" kuti");
    		num = num % 10000000;
    	}
    	if(num >= 100000)
   		{
   			bangla(num / 100000);
   			System.out.print(" lakh");
    		num = num % 100000;
    	}
    	if(num >= 1000)
    	{
    		bangla(num / 1000);
    		System.out.print(" hajar");
    		num = num % 1000;
    	}
    	if(num >= 100)
    	{
    		bangla(num / 100);
    		System.out.print(" shata");
    		num = num % 100;
    	}
    	if(num > 0)
    		System.out.printf(" %d", num);
  }
};

留言

這個網誌中的熱門文章

C# 井字遊戲