Created
December 17, 2016 17:57
-
-
Save JoeUnsung/9ce7c4028ec15d5897455a2201c8c8d8 to your computer and use it in GitHub Desktop.
Check the number whether complete number or not.
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.*; | |
import java.io.*; | |
class Main { | |
public static int checkCompleteNum(int num){ | |
// 숫자가 완전제곱수인지를 체크하는 메서드 작성. | |
for(int i = 0 ; i < num ; i++){ | |
if ( num == i*i ){ | |
return 1; | |
} | |
} | |
return 0; | |
} | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
String num1 = sc.next(); | |
String num2 = sc.next(); | |
int a = Integer.parseInt(num1); | |
int b = Integer.parseInt(num2); | |
//System.out.println(num1 + " " + num2); // 입력 체크 | |
int cnt = 0; | |
for (int i = a ; i <= b ; i++){ | |
cnt += checkCompleteNum(i); | |
} | |
System.out.println(cnt); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment