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

Collapse funcion makes 2 or more vertices as one. And attach function makes 2 or more objects as one. So I made 2 hand modelings and attached them with Human body modeling which is posted before, then I collapsed couple of vertices. Faces that will be attached should have same number of vertices.



BTW, there was a problem that some veritces are not collapsed. I don't know why..

This was my second assignment of 3d Modeling course in Univ. Sample professor showed us was more simple but I just wanted do more in detail.


It was made 1 cube and I used connect, inset, extrude, and mirror functions in 3ds Max.


I wanted to express muscles, but it was not easy. Just tried to make curved surfaces as many as possible.


It was first assignment of my 3D Modeling course in University. It's a character in movie "Big Hero" series.


These are images that I saw when I made the 3d model.



My work consists of few basic spheres.





For eyes, I made like these pictures below. 2 very low cylinders and 1 torus.




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

2016.07.04

+ Recent posts