ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 수뒤집기
    과거...../icpc 문제 2010. 5. 11. 13:22

    문 제


    중요 함수 정리

     Integer.toString
    a1.toString().substring


    소 스 1

    import java.util.Scanner;


    public class su_kind {

     public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      
      int f_value,s_value,final_value;
      int bi1,bi2;
      int flag=0;
      String bande,bande_c;
      String a1,a1_c,al_c2;
      System.out.print("숫자를 입력하세요:");
      f_value = input.nextInt();
      
      
      for(bi1=0;bi1<f_value;bi1++){
       s_value = input.nextInt();
       bande=Integer.toString(s_value);
       bande_c ="";
       for(bi2 =0; bi2< bande.toString().length();bi2++){
        bande_c = bande_c + bande.toString().substring(bande.toString().length()-bi2-1, bande.toString().length()-bi2);
       }
       final_value = s_value + Integer.parseInt(bande_c);
       a1=Integer.toString(final_value);
       a1_c="";
       al_c2="";
       for(bi2 =0; bi2< a1.toString().length()-1;bi2++){
        if(a1.toString().length()/2-1 > bi2 ){
         al_c2 = al_c2 + a1.toString().substring(a1.toString().length()-bi2-1, a1.toString().length()-bi2);     
        }else if(a1.toString().length()/2-1 < bi2){
         a1_c = a1_c + a1.toString().substring(bi2+1, bi2+2); 
         System.out.print(Integer.toString(bi2+2));
        }    
       }   
       if(a1_c.equals(al_c2)){
        System.out.print("YES");        
       }else{
        System.out.print("No");
       }    
      }  
     }


    소 스 2

     
    import java.util.Scanner;

    public class ain {

     
     public static void main(String[] args) {
     
      Scanner A = new Scanner(System.in);
     
      StringBuffer B = new StringBuffer(10);
      StringBuffer C = new StringBuffer(10);
     
      int i=0;
      int j=0;
     
      String reverse_input2;
      int input = A.nextInt();
     
      for(i=0;i<input;i++){
      
       reverse_input2 = null;
      
       String input2 = A.next();
       B.delete(0,10);
       B.append(input2);
       B.reverse();
       reverse_input2 = B.toString();
      
       int int_in = Integer.parseInt(input2);
       int int_in2 = Integer.parseInt(reverse_input2);
      
       //System.out.println(int_in2);
      
       int all_sum = int_in + int_in2;
      
       String aaa = Integer.toString(all_sum);
      
       C.delete(0, 10);
       C.append(all_sum);
       C.reverse();
       String bbb = C.toString();
      
       if(aaa.equalsIgnoreCase(bbb)){
       
        System.out.println("YES");
       
       }else
        System.out.println("NO");
      
      }

     }

    }



Designed by Tistory.