Last active
          December 29, 2019 09:01 
        
      - 
      
- 
        Save dalcon10028/bac75d344ae3ac1404334bf341e92407 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.*; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int N = sc.nextInt(); // 자연수 | |
| sc.close(); | |
| for(int i=0; i<N; i++){ // 0부터 분해합 검사 | |
| int decompos=i; // 분해합이 될 변수 | |
| String numtoString = Integer.toString(i); // 각 자리수를 더하기 위해 N을 문자열로 바꿈 | |
| for(int j=0; j<numtoString.length(); j++){ | |
| decompos+=Character.getNumericValue(numtoString.charAt(j)); | |
| } | |
| if(N==decompos){ | |
| System.out.print(i); | |
| return ; | |
| } | |
| } | |
| System.out.print(0); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment