static void Main(string[] args)
  {
   //BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
   //System.out.print("홀수를 입력하세요 : ");
   //int odd=Integer.parseInt(buf.readLine());
   Console.Write("홀수를 입력하쇼...");
   int odd;
   odd = Console.Read() - 48;
   //int odd = 5;
   if((odd%2)!=0)
   {
    int[,] arr=new int[odd,odd];
    arr[0,odd/2]=1;
    int x=0;
    int y=odd/2;
    for(int i=2;i<=(odd*odd);i++)
    {
     if(x-1<0 && y+1<odd)  //위로 벗어날 때
     {
      arr[odd-1,y+1]=i;
      x=odd-1;
      y=y+1;
     }
     else if(x-1>=0 && y+1>=odd)  //오른쪽으로 벗어날 때
     {
      arr[x-1,0]=i;
      x=x-1;
      y=0;
     }
     else if(x-1<0 && y+1>=odd)  //위와 오른쪽으로 벗어날 때
     {
      arr[x+1,y]=i;
      x=x+1;
     }
     else if(x-1>=0 && y+1<odd)  //벗어나지 않을 때
     {
      if(arr[x-1,y+1]==0)  //배열이 비어있으면
      {
       arr[x-1,y+1]=i;
       x=x-1;
       y=y+1;
      }
      else if(arr[x-1,y+1]!=0)  //배열에 값이 들어있으면
      {
       arr[x+1,y]=i;
       x=x+1;
      }
     }
    }
    for(int i=0;i<odd;i++)
    {
     for(int j=0;j<odd;j++)
     {
      if(arr[i,j]>9)
       Console.Write(arr[i,j]+" ");
      else
       Console.Write(" "+arr[i,j]+" ");
     }
     Console.WriteLine();
    }
 
   }
   else
   {
    Console.Write("짝수를 입력하셨습니다.");
   }
 
  } //main
닷넷으로 오라클연결예제

한글 비주얼 스튜디오 2005 익스프레스 무료 다운로드

(Visual Studio 2005 Express Download, Korean version) :

- 패키지에 포함된 개발 툴:

  . 비주얼 베이직 (Visual Basic)

  . 비주얼 씨샵 (Visual C#)

  . 비주얼 제이샵 (Visual J#)

  . 비주얼 웹 디벨로퍼 (Visual Web Developer)

  . 비주얼 씨 플러스 플러스 (Visual C++)

- 온라인 설치

http://www.microsoft.com/korea/msdn/vstudio/express/visualcsharp/default.aspx 

- 수동 설치(.ISO 다운로드 후)

http://www.microsoft.com/korea/msdn/vstudio/express/support/install/

FAQ: http://msdn.microsoft.com/vstudio/express/support/faq/

C#을 이용한 테트리스 프로그래밍

+ Recent posts