#include <Windows.h>

#include <tchar.h>


int WINAPI  WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR Ipcmdline, int nCmdShow)

{

MessageBox(NULL, _T("Hello World"), _T("메시지"), MB_OK);

//Null, 내용, 제목표시줄, 몰라

return 0;

}



this code will create window below:




So, There are WinMain() and WndProc() Functions


 WinMain( )
{
       윈도우 클래스 만들기 - (RegisterClass(...))

       윈도우 객체 생성하기 - (CreateWindow(...))

       윈도우 객체 화면에 띄우기 - (ShowWindow(...))

       메시지 루프 돌리기 - While(GetMessage(....))
}

 

WndProc( )
{
       전달된 메시지 처리하기
}


WinMain() function only create Window of program

WndProc() function manages Window messages



From: http://yyman.tistory.com/

'공부(Study)' 카테고리의 다른 글

Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day 2  (0) 2016.07.08
Sudoku Game with C++ - day1  (0) 2016.07.06
Java Study - day1  (0) 2016.07.06

After recovered from gouly arthritis, now I will study MFC for rest of vacation


Hope do not quit before end..!

'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day 2  (0) 2016.07.08
Sudoku Game with C++ - day1  (0) 2016.07.06
Java Study - day1  (0) 2016.07.06

I made 9 x 9 Matrix with all numbers allocated randomly. Then, I checked if all columns, rows, and 9 3by3 matrices have no repeated numbers.


However, this algorithm takes so much time to generate correct sudoku matrix. At first, I didn't realize how bad this is. So, I made 2 by 2 matrix with same algorithm, But It took so long time to find correct Matrix even it has only 4 numbers!!


Now, I think that it is because I made whole matrix and then judged if it is well made. So I would make another algorithm.

'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 2  (0) 2016.07.08
Sudoku Game with C++ - day1  (0) 2016.07.06
Java Study - day1  (0) 2016.07.06

I finally finished making 3 by 3 matrix which have 1 ~ 9 numbers in it.

These are results. There is no repeated number but 1 ~ 9 numbers with random arrangement







And this is the code

////////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <random>


using namespace std;


int num[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int arrNum[9];

int arr[3][3];


void createSudoku();
void printSudoku();
void bubbleSortArr();
void swap(double* a, double* b);
void printArrNum();
bool IsSame();


void main()
{
 createSudoku();
 printSudoku();
}


void createSudoku()
{
 while (1)
 {
  random_device rd;
  mt19937_64 rng(rd());

  uniform_int_distribution<__int64> dist1(1, 9);
  int k = 0;

  for (int i = 0; i < 3; i++)
  {
   for (int j = 0; j < 3; j++)
   {
    arr[i][j] = dist1(rng);
    arrNum[k] = arr[i][j];
    k++;
   }
  }
  bubbleSortArr();
  if (IsSame())
  {
   break;
  }
 }
}

void printSudoku()
{
 for (int i = 0; i < 3; i++)
 {
  for (int j = 0; j < 3; j++)
  {
   cout << arr[i][j] << " ";
  }
  cout << endl;
 }
}

void printArrNum()
{
 for (int i = 0; i < 9; i++)
 {
  cout << arrNum[i] << " ";
 }
}

void bubbleSortArr()
{
 for (int j = 0; j < 9; j++)
 {
  for (int k = 0; k < 9 - j - 1; k++)
  {
   if (arrNum[k] > arrNum[k + 1])
    swap(arrNum[k], arrNum[k + 1]);
  }
 }
}

void swap(double* a, double* b)
{
 double * temp;
 temp = a;
 a = b;
 b = temp;
}

//day1
bool IsSame()
{
 bool same = true;

  for (int i = 0; i < sizeof(num) / sizeof(int); i++)
  {
   if (num[i] != arrNum[i])
    same = false;
  } 

 return same;
}

////////////////////////////////////////////////////////////////////////////////////


Now, I will extend this to 9 by 9 Sudoku matrix

'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day1  (0) 2016.07.06
Java Study - day1  (0) 2016.07.06


This is first structure. With Random.h, created array of integers size 9 and printed it.

Result is below. array 'num' will be used judge if arr[3][3] is well created(if there is no repeated number)




Now, I added judgement if that 'arr' array is created well so there is no repeated number. So, I added array named 'arrNum' size 9, which will save created numbers.


   int arrNum[9];



and substituted created numbers in it



and rearranged arrNum by ascending order, using bubblesort algorithm



'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day 2  (0) 2016.07.08
Java Study - day1  (0) 2016.07.06

Install Eclipse

 

create package & class

 

Helloworld class

 

package org.buster.javatutorials.eclipse;

public class Helloworld {

 public static void main(String[] args) {
  System.out.println("Hello world!");
 }
}

 

String class

print string that includes ""

 

public class String {

 public static void main(java.lang.String[] args) {
  System.out.println("egoing said\n\"Welcome programming world\"");
 }
}

 

Variables

Using variables increases recyclability of the codes

For example,

 

System.out.println(100 + 10);
System.out.println((100 + 10) / 10);
System.out.println(((100 + 10) / 10) - 10);
System.out.println((((100 + 10) / 10) - 10) * 10);

 

If I want to change first number 100 to 1000, I have to change all 4 lines. However, if I used variable for 100, I have to change only 1 line. See the below

 

int a = 100;                    //chage to int a = 1000;
System.out.println(a + 10);
System.out.println((a+ 10) / 10);
System.out.println(((a + 10) / 10) - 10);
System.out.println((((a + 10) / 10) - 10) * 10);

 

So, using variables makes it easy for developer to maintenance the codes

'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day 2  (0) 2016.07.08
Sudoku Game with C++ - day1  (0) 2016.07.06

+ Recent posts