Programming

Image Rotate를 위한 간단한 코드

Ronie.Kang 2008. 6. 23. 13:24
다들 업무로 인해서 머리가 잘 안돌아 가나 봅니다.
간단하게 prototype를 작성 해보았습니다.

O(N^2) 수행 시간입니다. 최적화가 필요하심 ~


// Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE)
// for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as
// it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler.


#include <cstdlib>
#include <iostream>

using namespace std;


int Src[3][5] = {
   {1, 2, 3, 4, 5},
   {6, 7, 8, 9, 10},
   {11, 12, 13, 14, 15} };
               
int dest[5][3] = { 0 };

int main(int argc, char *argv[])
{
   int k = 0;
   cout << "ORG buffer\n";
   for( int i = 0; i < 3; i ++ )
   {
        for( int j = 0, k = 4 ; j < 5; j++,k--)
        {
            dest[k][i] = Src[i][j];
            cout <<  dest[k][i] << "  ";
         }
         cout  << " " << "\n";
   }
   cout << "\n" << "\n";
   
   // roniekang ---- display
   cout << "Result \n";    
   for( int i = 0; i < 5; i ++ )
   {
       for(int j = 0; j < 3; j++)
       {
               cout <<  dest[i][j] << "  ";
       }
       cout << " " << "\n";              
   }
   
   system("PAUSE");
   return EXIT_SUCCESS;
}

이미지를 로테이트 시키기 위해서 잠시 작성..