문제는 두수 a,b를 입력해서 a와b 사이에 숫자를 호수일경우 3n+1을하고 짝수일 경우 n/2를 한다.
그래서 가장 큰 수를 뽑아내는 알고리즘이다.

<<<소스>>>
#include<stdio.h>
#include<stdlib.h>

void main()
{
 int i;
 int one,two;
 int max=0;
 int count=0;
 int n=0;

 printf("첫번째 : ");
 scanf("%d",&one);

 printf("두번째 : ");
 scanf("%d",&two);

 for(i=one;i<two;i++)
 {
  max=i;
  count=0;
  while(1)
  {   
   if(max==1)
   {
    break;
   }
   else if(max%2==0)//짝수
   {
    max/=2;
   }
   else//홀수
   {
    max=3*max+1;
   } 
   count++; 
  // printf("%d : %d\n",count,max);
  }  
  if(n<=count)
  {
   n=count;
  }
  
  printf("%d : %d\n",i,n);
 }
 printf("최대 횟수 : %d\n",n);
 scanf("%d",max);
}


타이틀바 없애기
requestWindowFeature(Window.FEATURE_NO_TITLE);
인디케이터 없애기
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

'IT 공부 > 안드로이드' 카테고리의 다른 글

XML을 활용한 RSS리더기  (1) 2012.02.25
파서(Get)  (1) 2012.02.25
Animation effect  (1) 2011.11.03
화면 변화  (1) 2011.11.02
자유곡선  (2) 2011.11.02
애니메이션 효과는 크게 2가지 있다.
1. Tweended animation : 뷰를 회전, 크기변경, 투명조절등의 에니메이션 방법
2. Frame-by-frame-animation :  연속된 이미지를 표시하는 에니메이션 방법

ALPHA = fromAlpha toAlpha – 0에서 1사이의 부동 소수

SCALE = fromXScale/toXScale - 0에서 1사이의 부동 소수

fromYScale/toYScale - 0에서 1사이의 부동 소수

pivotX/pivotY – 그림의 폭/높이는 0%에서 100%사이의 백분율로 나타낸 문자열

TRANSLATE = fromX/fromY - 0에서 1사이의 부동 소수

toX/toY - 0에서 1사이의 부동 소수

ROTATE = fromDegrees/toDegrees – 0에서 360 사이의 부동 소수

AnimationSet은 여러 animation을 쓰고자 할떄 쓴다.

ex)
public static void setLayoutAnim_slidedownfromtop(ViewGroup panel,int a) {

       AnimationSet set = new AnimationSet(true);

       Animation animation = new AlphaAnimation(0.0f, 1.0f);
       animation.setDuration(1000);
       set.addAnimation(animation);
      
       if(a==1){
       animation = new TranslateAnimation(
           Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
           Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f
       );
       }
       else{
        animation = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f
            );
       }
       animation.setDuration(1000);
       set.addAnimation(animation);
       /*
       ScaleAnimation scale = new ScaleAnimation(-1, 1, -1, 1,
         ScaleAnimation.RELATIVE_TO_SELF, 1f,
         ScaleAnimation.RELATIVE_TO_SELF, 1f);
       set.addAnimation(scale);
       */
       panel.startAnimation(set);
    }

'IT 공부 > 안드로이드' 카테고리의 다른 글

파서(Get)  (1) 2012.02.25
Activity 화면창  (3) 2011.11.03
화면 변화  (1) 2011.11.02
자유곡선  (2) 2011.11.02
단어 정리  (2) 2011.08.12

+ Recent posts