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 +#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 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; +}