From f89d9051c71a5b5c0aebebec36dcc7cc63042b48 Mon Sep 17 00:00:00 2001 From: harjot3200 Date: Sun, 1 Oct 2017 12:47:28 +0530 Subject: [PATCH 1/3] Solver for sudoku --- Backtracking/sudoku_solve.cpp | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 Backtracking/sudoku_solve.cpp diff --git a/Backtracking/sudoku_solve.cpp b/Backtracking/sudoku_solve.cpp new file mode 100644 index 000000000..e1e008a91 --- /dev/null +++ b/Backtracking/sudoku_solve.cpp @@ -0,0 +1,102 @@ +#include +using namespace std; +///N=9; +int n=9; + + +bool isPossible(int mat[][9],int i,int j,int no){ + ///Row or col nahin hona chahiye + for(int x=0;x Date: Sun, 8 Oct 2017 11:52:46 +0530 Subject: [PATCH 2/3] CODE for Spiral printing of an array --- spiral_print.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 spiral_print.cpp diff --git a/spiral_print.cpp b/spiral_print.cpp new file mode 100644 index 000000000..03ea074e9 --- /dev/null +++ b/spiral_print.cpp @@ -0,0 +1,68 @@ +#include +using namespace std; + +void genArray(int a[][10],int r,int c){ + + int value=1; + for(int i=0;i=startCol;i--,cnt++){ + cout<=startRow;i--,cnt++){ + cout<>r>>c; + genArray(a,r,c); + spiralPrint(a,r,c); + + +return 0; +} From 515e70a579f025c7403ecdd5985568fb5382e2db Mon Sep 17 00:00:00 2001 From: harjot3200 Date: Sun, 8 Oct 2017 20:08:04 +0530 Subject: [PATCH 3/3] sleep sort via c --- sleep sort.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sleep sort.c diff --git a/sleep sort.c b/sleep sort.c new file mode 100644 index 000000000..e0217ca25 --- /dev/null +++ b/sleep sort.c @@ -0,0 +1,41 @@ +#include +#include +#include + +void routine(void *a) +{ + int n = *(int *) a; // typecasting from void to int + + // Sleeping time is proportional to the number + // More precisely this thread sleep for 'n' milliseconds + Sleep(n); + + // After the sleep, print the number + printf("%d ", n); + +void sleepSort(int arr[], int n) +{ + // An array of threads, one for each of the elements + // in the input array + HANDLE threads[n]; + + // Create the threads for each of the input array elements + for (int i = 0; i < n; i++) + threads[i] = (HANDLE)_beginthread(&routine, 0, &arr[i]); + + // Process these threads + WaitForMultipleObjects(n, threads, TRUE, INFINITE); + return; +} + +// Driver program to test above functions +int main() +{ + // Doesn't work for negative numbers + int arr[] = {34, 23, 122, 9}; + int n = sizeof(arr) / sizeof(arr[0]); + + sleepSort (arr, n); + + return(0); +} \ No newline at end of file