멍청이들

블로그 이미지
우린 멍청하니깐ㅋ
milang9

Article Category

분류 전체보기 (8)
멍청이들이란? (0)
오늘의 알고리즘 (1)
프로그래밍 참고 자료 (0)
진주의 배설물 (5)
교승이의 배설물 (1)
승하의 배설물 (1)

Recent Post

Recent Comment

Calendar

«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

Archive

My Link

  • Total
  • Today
  • Yesterday

문제 출처 : http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110101&format=html


문제 해석

min 값과 max 값을 받아옵니다.
min부터 max까지의 수가 1까지 도달하는 데의 cycle을 구합니다.
최대 cycle만 출력합니다.

1까지 도달하는데의 규칙
홀수일경우 - 3n+1
짝수일경우 - n/2

문제 해석이 이해 안가면 출처 가서 읽고오거나 덧글을 남겨주세요.

Sample Input

1 10
100 200
201 210
900 1000

Sample Output

1 10 20
100 200 125
201 210 89
900 1000 174


and

<?

  $ip = array

        (

            " ???.???.???.?? "           // 아이피 주소

        );

 

  $block_user=0;

        if(in_array($HTTP_SERVER_VARS["REMOTE_ADDER"],$ip))

       {

            $block_user=1;

       }

 

        if($block=="1")

       {

            exit;
       }

       else

       {

            echo("");                  // reroad

       }
?>


차단해야할 값을 미리 선언해놓고
if문을 이용하여 지금 현재 사용자의 값과 차단해야할 값이 같으면 차단(exit) 다르면 리로드합니다.

반대로 특정한 사람만 사용하고 싶다면 어떻게 해야할까요?

분홍색 부분의 소스만

        if($block=="1")

       {

            echo("");
       }

       else

       {

            exit;

       }


이렇게 바꿔주면 됩니다!
 
참 쉽죠? ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
and

Queue 란? FIFO(First In First Out) 형식을 가진 자료구조 형태입니다!

간단하게 소스한번 볼까요~? 

#include <stdio.h>

 

int ary[5]={0,};
int rear=-1;
int front=-1;

 

void init_Queue();
void InQueue();
void DeQueue();
void Print_Queue();
void All_Clear();

 

int main(void)
{
 int i;

 init_Queue();

 printf("Queue에 데이터를 입력합니다.\n");

//0~4까지 입력 

for(i=0; i<4; i++)
 {
  InQueue();
 }

 Print_Queue();

 printf("Queue에 데이터를 입력합니다.\n");

//5까지 입력, 오버플로우 확인 

 for(i=0; i<2; i++)
 {
  InQueue();
 }
 Print_Queue();

//0~4까지 삭제

 printf("Queue에 데이터를 삭제합니다.\n");

 for(i=0; i<4; i++)
 {
  DeQueue();
 }

 Print_Queue();

//5까지 삭제, 언더플로우 확인

 printf("Queue에 데이터를 삭제합니다.\n");

 for(i=0; i<2; i++)
 {
  DeQueue();
 }

 Print_Queue();

//스택 비움

 printf("Queue를 비웁니다..\n");

 All_Clear();

 Print_Queue();


 return 0;
}

 

 

void init_Queue()
{
 rear=-1;
 front=-1;
}

 

void InQueue()
{
 int num;
 rear+=1;

 if(rear>=5)
 {
  printf("Overflow!\n");
 }
 else
 {
 printf("Input : ");
 scanf("%d",&num);

 ary[rear]=num;
 }

}

 

void DeQueue()
{


 front+=1;

 if(front==rear)
 {
  printf("underflow!\n");
  All_Clear();
 }
 else{

 ary[front]=0;
 }

}


void Print_Queue()
{
 int i;

 for(i=0; i<5; i++)
 {
  printf("Queue Data : %3d\n",ary[i]);
 }
 printf("\n");
}

 

void All_Clear()
{
 int i;

 for(i=0; i<5; i++)
 {
  ary[i]=0;
 }

 init_Queue();

}


엄청나게 지저분한걸 보면 딱 제가 짠 소스라는걸 알수있습니다..
필요하다면 메인 부분만 수정해서 쓰시면 될 것 같네요.
 
 
and

Tag Cloud