mのn次の方(大きい数)を求めます

1206 ワード

import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		//  50 
		int[] nums = new int[50]; // ( 0,1,2.... , , )
		int k = 0;
		int m = 0;
		int n = 0;
		int count = 0;
		int z = 0;
		String num = "";
		System.out.println(" m^n ");
		System.out.print(" m:");
		m = in.nextInt();
		System.out.print(" n:");
		n = in.nextInt();
		z = m;
		while(z>0) //  m 
		{
			nums[count++] = z%10;
			z /= 10;
		}
		System.out.printf("%d %d :",m,n);
		if(n==0)
		{
			System.out.println(1);
		}
		else if(n>0)
		{
			for(int i=0;i= 10) //  10 
					{
						sum = nums[j]/10;
						nums[j] %= 10;
					}
					if(sum != 0) //  
					{
					    //  
						j++;
						nums[j] *= m;
						nums[j] += sum;
					}
				}
			}
			for(int i=nums.length-1;i>=0;i--) //  , 
			{
				if(nums[i] != 0)
				{
					k = i;
					break;
				}
			}
			for(int i=k;i>=0;i--)
			{
				num += nums[i];
			}
			System.out.println(num);
		}
		in.close();
	}
	
}