수정할 것 (재귀함수 호출 공부 코드); 계속해서 갱신해볼 것
package shift;
import java.util.Scanner;
public class stu4 {
public static int test=0;
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int arr_3[] = new int[3];
for(int i=0; i<3; i++)
{
System.out.printf("[%d]번째 데이터 입력: ", i+1);
arr_3[i] = input.nextInt();
if(arr_3[i] == 0)
{
while(true)
{
System.out.print("0은 입력할 수 없습니다. 다시 입력해주세요: ");
arr_3[i] = input.nextInt();
if(arr_3[i] == 0)
{
}
}
}
}
test(arr_3,0,1,2);
}
public static void test(int arr[],int start, int end, int remaind)
{
int temp;
if((arr[start]+arr[end])>arr[remaind])
{
System.out.println(test);
System.out.printf("%d 와 (과) %d 에 의해 삼각형이 형성됩니다.\n"
, arr[start],arr[end]);
return;
}
else
{
if(test == 7)
{
System.out.println(test);
System.out.printf("삼각형이 형성될 수 없는 조건 입니다.\n");
return;
}
temp = end;
end = remaind;
remaind = temp;
test = test+1;
test(arr,start,end,remaind);
}
}
}
'언어 > java' 카테고리의 다른 글
2016 01 18 (0) | 2016.01.18 |
---|---|
(java) 삼각형 형성조건 (0) | 2016.01.18 |
2016-01-18 (0) | 2016.01.18 |
2016-01-18 (0) | 2016.01.18 |
st1 (0) | 2015.10.26 |