2010년/30계단1~2단계

두현의 교착 구하기

뽀얀햄스터 2010. 3. 26. 11:31

두 개의 현이 주어질 때 이 현이 교차하는지 아닌지를 판단하는 프로그램을 작성하시오.

아래 그림은 두 현이 교차하는 경우의 예이다.

입력 형식

첫 줄에는 한 현의 정보가 다음 줄에는 다른 한 현의 정보가 입력된다. 숫자는 1 이상 100 이하인 서로 다른 자연수이다.

출력 형식

두 현이 교차하면 cross ,아니면 not cross 를 출력한다.

입출력 예

입력 

20 80
85 40

출력 

cross
---------------------------------
우헤헤헤헤 어렵게 풀었다 ㅠ
#include<stdio.h>
int
 main()
{
  int ione;
  int itwo;
  int ithree;
  int ifour;
  int icount=0;
  fprintf(stdout,"입력하세요\n");
  fscanf(stdin,"%d %d",&ione,&itwo);
  fscanf(stdin,"%d %d",&ithree,&ifour);
  if((ione<=ithree||itwo>=ithree))
  {
    if(ione>=ifour&&itwo<=ifour)
    {
      ++icount;
    }
  }
  if((ione>=ithree||itwo<=ithree))
  {
    if(ione<=ifour&&itwo>=ifour)
    {
      ++icount;
    }
  }
  if(1==icount)
  {
    printf("cross\n");
  }
  else
  {
    printf("nocross\n");
  }
  return 0;
}


생각보다 어렵게 풀었뜸 ㅠ