package z_exam;
import java.util.Scanner;
public class sukjae {
public static void main(String[] args) {
//숙제1 : 4-7번 그대로 출력하기
for(int i = 1; i<11; i++){
if(i==1){System.out.print(i);}else{ //i가 1이면 여는괄호 없이
System.out.print("+("); //그외에는 뭉치 시작할때 +( 붙이고
for(int k = 1; k<i+1;k++){ //한뭉치 시작 , k가 1이상뭉치숫자+1미만까지
if(k<i){ //k가 뭉치값미만이면
System.out.print(k+"+"); //k값더해줌
}else{ //k가 뭉치값과 같으면 즉 뭉치를 다 끝내고 나갈때가 되면
System.out.print(k+")"); //k와 닫는괄호 치고 나가줌
}
}
}//if
}
System.out.println();
//숙제2 : 숫자 받아서 거꾸로 돌려도 같은지 확인하고 true false값 내보내기
/*되긴 하는 데 아닌것같은 풀이
* Scanner sc = new Scanner(System.in);
System.out.println("숫자를 입력하세요 : ");
int a = sc.nextInt();
//숫자를 받아서 a에 넣음 //만약 12345였다 >> 54321 되어야함
int b,c = 0;
int d = 10000; //받은 a의 자릿수*10하고싶은데..
int save = a;
while(a!=0){
b = a%10;
c = c+b*d;
a = a/10;
d = d/10; //10000이 줄어들어야
}
if(save==c){
System.out.println("앞뒤가 똑같은 숫자가 맞습니다.");
}else{
System.out.println("앞뒤가 다른 숫자입니다.");
}
*/
Scanner sc = new Scanner(System.in);
System.out.println("숫자를 입력하세요 : ");
int a = sc.nextInt();
int b,c = 0;
int save = a;
//int length=(int)(Math.log10(a)+1);
int length;
//System.out.println("길이:"+length);
//int c=0;
/* do{
b = a%10;
c = c+b;
a = a/10;
ss= b*10+b;
System.out.print(b);
}while(a!=0);*/
while(a!=0){
length=(int)(Math.log10(a)+1); //길이는 입력받은 숫자의 자릿수를 먼저 센다
b = a%10; //입력받은 숫자를 10으로 나눈 나머지를 b에 담아 일의자리를 담고
//c = c+b; //최종값 c에 += 한다
c= c+(int)(b*Math.pow(10,length-1));
a = a/10; //일의자리는 0일테니 다음 반복을 위해서 10으로 나눠준다.
//ss= b*10+b;
//System.out.println(b);
//save2= save2+(int)(b*Math.pow(10,length-1));
//System.out.println(save2);
}
if(save==c){
System.out.println("앞뒤가 똑같은 숫자가 맞습니다.");
}else{
System.out.println("앞뒤가 다른 숫자입니다.");
}
/*반복문
b = a%10; // 받은 a값을 10으로 나눠 나머지 일의자리 > 즉 일의자리수를 b에 넣는다.
c = b*10000; // 일의 자릿수인 b값을 맨 앞으로 보내줘야 하므로 처음받은 a의 자릿수만큼 10 곱해줌
a = a/10; //원본a에서 일의자리수얻었으니 10으로 나눠서 0도 떨궈낸다
System.out.println(c);
b = a%10;
c = c+b*1000;
a = a/10;
System.out.println(c);
b = a%10;
c = c+b*100;
a = a/10;
System.out.println(c);
b = a%10;
c = c+b*10;
a = a/10;
System.out.println(c);
b = a%10;
c = c+b;
a = a/10;
System.out.println(c);
*/
//몇자리 입력할줄 모르니까 while로 a가 0일 될떄까지
}
}