├── C-codes
├── Num Converters
│ ├── Bin2oct
│ │ └── bin2oct.c
│ ├── Dec2bin
│ │ └── dec2bi.c
│ ├── Dex2hex
│ │ └── dex2hex.c
│ └── Hex2bin
│ │ └── hex2bin.c
├── Readme.md
├── SchedulingAlgo
│ ├── RoundRobin.c
│ └── ShortestJobFirst.c
├── cyclically_rotate_an_array_by_one.c
├── gussthenum
│ └── command.c
├── important program
│ ├── armstrongNum.c
│ ├── palindrome.c
│ └── reverse number.c
├── merge2sortedArrays.c
├── mysql
│ └── mysql.c
├── simple programs
│ ├── Halfpyramid.c
│ ├── factorial.c
│ └── fibonacci.c
├── simpleinterest.c
├── sjf.c
└── socket
│ ├── client.c
│ └── server.c
├── Contribute.md
├── Images
├── Coded_logo.png
└── hacktoberfest.jpg
├── Java-codes
├── Area
│ ├── Rectangle.java
│ ├── Sphere.java
│ ├── Square.java
│ ├── circle.java
│ └── triangle.java
├── Bottom_view_of_binary_tree.java
├── LongestPalindromicSubstring.java
├── MedianofTwoSortedArrays.java
├── PalindromeNumber.java
├── Readme.md
├── RegularExpressionMatching.java
├── ReverseInteger.java
├── Sorting
│ ├── bubblesort.java
│ ├── heapsort.java
│ ├── quicksort.java
│ └── selectionsort.java
├── Stack_implementation_in.java
├── StringtoInteger(atoi).java
├── ZigzagConversion.java
├── dijkastra.java
├── huffman_Coding.java
├── impotant Programs
│ ├── BFS.java
│ ├── Binary_search_tree_in_java.java
│ ├── Concatenate.java
│ ├── FactorialofNum.java
│ ├── Fibonacci.java
│ ├── Top_view_of_binary_tree.java
│ ├── calculator.java
│ ├── checkPalindrome.java
│ ├── checkevenodd.java
│ ├── kadane’sAlgo.java
│ ├── prime-number.java
│ ├── rat_in_maze.java
│ └── swapping.java
├── kadanes_algorithm.java
├── matrixadd.java
├── reverse_the_array.java
└── timer.java
├── README.md
├── React
└── portfolio
│ └── package.json
├── VisualBasic
├── Readme.md
└── Simpleprograms
│ ├── Areaofparallelogram.vb
│ ├── Mathematicalcalculations.vb
│ └── typeconverison.vb
├── Web
├── Google
│ └── index1.html
├── Readme.md
├── THEME
│ ├── index.html
│ ├── index.js
│ └── style.css
├── calculator
│ ├── index.html
│ ├── script.js
│ └── style.css
├── loading.css
├── loading.html
├── loginpage
│ ├── 4.jpg
│ ├── loginpage.css
│ └── loginpage.html
├── skc group
│ ├── index.html
│ └── style.css
└── style1.css
├── c++
└── important programs
│ ├── Hosoya traingle
│ ├── Krukshal c++
│ ├── MyC++programs
│ ├── Reverseanumber.cpp
│ ├── armstrong.cpp
│ ├── factorialofnumber.cpp
│ └── palindrome or not.cpp
│ ├── Painting_fence_algorithm.cpp
│ ├── bubble sort
│ ├── dijkastra.cpp
│ ├── evenodd.cpp
│ ├── fcfs.cpp
│ ├── quicksort.cpp
│ ├── reverse.cpp
│ ├── sudoko
│ ├── unbounded_kanpsack.cpp
│ └── usefulprograms
│ ├── GCD.cpp
│ ├── LCM.cpp
│ ├── greatestnumberinarray.cpp
│ ├── matrixaddition.cpp
│ └── towerofhanoi.cpp
└── python
├── CardGame.py
├── bubble_sort.py
├── circular_queue.py
├── lcs.py
└── merge_sort.py
/C-codes/Num Converters/Bin2oct/bin2oct.c:
--------------------------------------------------------------------------------
1 | // Convert a binary number to octal number
2 | #include
3 |
4 | int main()
5 | {
6 | int binaryNumber = 0;
7 | int octalNumber = 0;
8 | int i = 1;
9 | int rem = 0;
10 |
11 | printf("Enter binary number: ");
12 | scanf("%d", &binaryNumber);
13 |
14 | while (binaryNumber != 0) {
15 | rem = binaryNumber % 10;
16 | octalNumber = octalNumber + rem * i;
17 |
18 | i = i * 2;
19 | binaryNumber = binaryNumber / 10;
20 | }
21 |
22 | printf("Octal Number: %o", octalNumber);
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/C-codes/Num Converters/Dec2bin/dec2bi.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 |
6 | void insert_binary(char *str,char d){
7 | int len = strlen(str);
8 | static pos = 0;
9 | if(pos == 4){
10 | memmove(&str[1],str,len+1);
11 | str[0] = ' ';
12 | pos = 0;
13 | }
14 |
15 | memmove(&str[1],str,len+1);
16 | str[0] = d;
17 | pos++;
18 | }
19 | int main(int argc,char *agrv[]){
20 | int i;
21 | char binary[1024];
22 | int n,r;
23 |
24 | if(argc<2){
25 | fprintf(stderr,"usages:%s number\n",agrv[0]);
26 | exit(0);
27 | }
28 | memset(binary,0,sizeof(binary));
29 | i = atoi(agrv[1]);
30 | do{
31 | r = i%2;
32 | n = i/2;
33 | /*insert degiit reminder to the leftmost*/
34 | insert_binary(binary,r?'1':'0');
35 | i = n;
36 | }while(i);
37 | printf("binayr : %s\n",binary);
38 |
39 | return 0;
40 | }
--------------------------------------------------------------------------------
/C-codes/Num Converters/Dex2hex/dex2hex.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main(int argc,char *argv[]){
6 | char h[17]="0123456789ABCDEF";
7 | int num;
8 | char hex[1024];
9 | int quo;
10 | int rem;
11 | int i;
12 |
13 | if (argc !=2){
14 | fprintf(stderr,"Usage: %s decimal_number\n",argv[0]);
15 | exit(1);
16 | }
17 | num = atoi(argv[1]);
18 | hex[0] = '\0';
19 |
20 | while(num != 0){
21 | quo = num / 16;
22 | rem = num % 16;
23 | memmove(&hex[1],hex,strlen(hex)+1);
24 | hex[0] = h[rem];
25 | num = quo;
26 | }
27 | printf("%d= 0x%s\n\n",atoi(argv[1]),hex);
28 | return 0;
29 | }
--------------------------------------------------------------------------------
/C-codes/Num Converters/Hex2bin/hex2bin.c:
--------------------------------------------------------------------------------
1 | // Convert a hexadecimal number to binary number
2 | #include
3 |
4 | int main()
5 | {
6 | char HexNum[32] = { 0 };
7 | int i = 0;
8 |
9 | printf("Enter the Hexadecimal number: ");
10 | scanf("%s", HexNum);
11 |
12 | printf("Binary Number: ");
13 |
14 | while (HexNum[i]) {
15 | switch (HexNum[i]) {
16 | case '0':
17 | printf("0000");
18 | break;
19 |
20 | case '1':
21 | printf("0001");
22 | break;
23 |
24 | case '2':
25 | printf("0010");
26 | break;
27 |
28 | case '3':
29 | printf("0011");
30 | break;
31 |
32 | case '4':
33 | printf("0100");
34 | break;
35 |
36 | case '5':
37 | printf("0101");
38 | break;
39 |
40 | case '6':
41 | printf("0110");
42 | break;
43 |
44 | case '7':
45 | printf("0111");
46 | break;
47 |
48 | case '8':
49 | printf("1000");
50 | break;
51 |
52 | case '9':
53 | printf("1001");
54 | break;
55 |
56 | case 'a':
57 | case 'A':
58 | printf("1010");
59 | break;
60 |
61 | case 'b':
62 | case 'B':
63 | printf("1011");
64 | break;
65 |
66 | case 'c':
67 | case 'C':
68 | printf("1100");
69 | break;
70 |
71 | case 'd':
72 | case 'D':
73 | printf("1101");
74 | break;
75 |
76 | case 'e':
77 | case 'E':
78 | printf("1110");
79 | break;
80 |
81 | case 'f':
82 | case 'F':
83 | printf("1111");
84 | break;
85 |
86 | default:
87 | printf("\nInvalid hexa digit: %c", HexNum[i]);
88 | return 0;
89 | }
90 | i++;
91 | }
92 | return 0;
93 | }
--------------------------------------------------------------------------------
/C-codes/Readme.md:
--------------------------------------------------------------------------------
1 | Here are c codes written for windows and linux systems.
2 |
--------------------------------------------------------------------------------
/C-codes/SchedulingAlgo/RoundRobin.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int i, limit, total = 0, x, counter = 0, time_quantum;
5 | int WT = 0, tat = 0, AT[10], BT[10], temp[10];
6 | float average_WT, average_tat;
7 | printf("\nEnter Total Number of Processes: ");
8 | scanf("%d", &limit);
9 | x = limit;
10 | for(i = 0; i < limit; i++)
11 | {
12 | printf("Enter Details of Process[%d]\n", i + 1);
13 | printf("Arrival Time:");
14 | scanf("%d", &AT[i]);
15 | printf("Burst Time:");
16 | scanf("%d", &BT[i]);
17 | temp[i] = BT[i];
18 | }
19 |
20 | printf("\nEnter Time Quantum:\t");
21 | scanf("%d", &time_quantum);
22 | printf("\nProcess\tBT\tTAT\tWT");
23 | for(total = 0, i = 0; x != 0;)
24 | {
25 | if(temp[i] <= time_quantum && temp[i] > 0)
26 | {
27 | total = total + temp[i];
28 | temp[i] = 0;
29 | counter = 1;
30 | }
31 | else if(temp[i] > 0)
32 | {
33 | temp[i] = temp[i] - time_quantum;
34 | total = total + time_quantum;
35 | }
36 | if(temp[i] == 0 && counter == 1)
37 | {
38 | x--;
39 | printf("\nP[%d]\t%d\t%d\t%d", i + 1, BT[i], total - AT[i], total - AT[i] - BT[i]);
40 | WT = WT + total - AT[i] - BT[i];
41 | tat = tat + total - AT[i];
42 | counter = 0;
43 | }
44 | if(i == limit - 1)
45 | {
46 | i = 0;
47 | }
48 | else if(AT[i + 1] <= total)
49 | {
50 | i++;
51 | }
52 | else
53 | {
54 | i = 0;
55 | }
56 | }
57 |
58 | average_WT = WT * 1.0 / limit;
59 | average_tat = tat * 1.0 / limit;
60 | printf("\nAverage Waiting Time:\t%f", average_WT);
61 | printf("\nAvg Turnaround Time:\t%f", average_tat);
62 | return 0;
63 | }
64 |
--------------------------------------------------------------------------------
/C-codes/SchedulingAlgo/ShortestJobFirst.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
5 | float avg_wt,avg_tat;
6 | printf("Enter number of process:");
7 | scanf("%d",&n);
8 |
9 | printf("\nEnter Burst Time:\n");
10 | for(i=0;i
2 |
3 |
4 |
5 | void rotate(int arr[], int n)
6 |
7 | {
8 |
9 | int x = arr[n-1], i;
10 |
11 | for (i = n-1; i > 0; i--)
12 |
13 | arr[i] = arr[i-1];
14 |
15 | arr[0] = x;
16 |
17 | }
18 |
19 |
20 |
21 | int main()
22 |
23 | {
24 |
25 | int arr[] = {1, 2, 3, 4, 5}, i;
26 |
27 | int n = sizeof(arr)/sizeof(arr[0]);
28 |
29 |
30 |
31 | printf("Given array is\n");
32 |
33 | for (i = 0; i < n; i++)
34 |
35 | printf("%d ", arr[i]);
36 |
37 |
38 |
39 | rotate(arr, n);
40 |
41 |
42 |
43 | printf("\nRotated array is\n");
44 |
45 | for (i = 0; i < n; i++)
46 |
47 | printf("%d ", arr[i]);
48 |
49 |
50 |
51 | return 0;
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/C-codes/gussthenum/command.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int
5 | randnum(int maxval)
6 | {
7 | /* pick a random number from 1 to maxval */
8 |
9 | int randval;
10 |
11 | getrandom(&randval, sizeof(int), GRND_NONBLOCK);
12 |
13 | /* could be negative, so ensure it's positive */
14 |
15 | if (randval < 0) {
16 | return (-1 * randval % maxval + 1);
17 | }
18 | else {
19 | return (randval % maxval + 1);
20 | }
21 | }
22 |
23 | int
24 | main(void)
25 | {
26 | int number;
27 | int guess;
28 |
29 | number = randnum(100);
30 |
31 | puts("Guess a number between 1 and 100");
32 |
33 | do {
34 | scanf("%d", &guess);
35 |
36 | if (guess < number) {
37 | puts("Too low");
38 | }
39 | else if (guess > number) {
40 | puts("Too high");
41 | }
42 | } while (guess != number);
43 |
44 | puts("That's right!");
45 |
46 | return 0;
47 | }
--------------------------------------------------------------------------------
/C-codes/important program/armstrongNum.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int num, originalNum, remainder, result = 0;
4 | printf("Enter a three-digit integer: ");
5 | scanf("%d", &num);
6 | originalNum = num;
7 |
8 | while (originalNum != 0) {
9 | // remainder contains the last digit
10 | remainder = originalNum % 10;
11 |
12 | result += remainder * remainder * remainder;
13 |
14 | // removing last digit from the orignal number
15 | originalNum /= 10;
16 | }
17 |
18 | if (result == num)
19 | printf("%d is an Armstrong number.", num);
20 | else
21 | printf("%d is not an Armstrong number.", num);
22 |
23 | return 0;
24 | }
25 |
--------------------------------------------------------------------------------
/C-codes/important program/palindrome.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int n, reversed = 0, remainder, original;
4 | printf("Enter an integer: ");
5 | scanf("%d", &n);
6 | original = n;
7 |
8 | // reversed integer is stored in reversed variable
9 | while (n != 0) {
10 | remainder = n % 10;
11 | reversed = reversed * 10 + remainder;
12 | n /= 10;
13 | }
14 |
15 | // palindrome if orignal and reversed are equal
16 | if (original == reversed)
17 | printf("%d is a palindrome.", original);
18 | else
19 | printf("%d is not a palindrome.", original);
20 |
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/C-codes/important program/reverse number.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main() {
4 |
5 | int n, reverse = 0, remainder;
6 |
7 | printf("Enter an integer: ");
8 | scanf("%d", &n);
9 |
10 | while (n != 0) {
11 | remainder = n % 10;
12 | reverse = reverse * 10 + remainder;
13 | n /= 10;
14 | }
15 |
16 | printf("Reversed number = %d", reverse);
17 |
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/C-codes/merge2sortedArrays.c:
--------------------------------------------------------------------------------
1 | // C program to merge two sorted arrays with O(1) extra
2 | // space.
3 | #include
4 |
5 | // Merge ar1[] and ar2[] with O(1) extra space
6 |
7 | void merge(int ar1[], int ar2[], int m, int n)
8 | {
9 |
10 | // Iterate through all elements
11 |
12 | // of ar2[] starting from the last element
13 |
14 | for (int i = n - 1; i >= 0; i--) {
15 |
16 | // Find the smallest element greater than ar2[i].
17 |
18 | // Move all elements one position ahead till the
19 |
20 | // smallest greater element is not found */
21 |
22 | int j, last = ar1[m - 1];
23 |
24 | for (j = m - 2; j >= 0 && ar1[j] > ar2[i]; j--)
25 |
26 | ar1[j + 1] = ar1[j];
27 |
28 |
29 | // If there was a greater element
30 |
31 | if (last > ar2[i]) {
32 |
33 | ar1[j + 1] = ar2[i];
34 |
35 | ar2[i] = last;
36 |
37 | }
38 |
39 | }
40 | }
41 |
42 | // Driver program
43 |
44 | int main()
45 | {
46 |
47 | int ar1[] = { 1, 5, 9, 10, 15, 20 };
48 |
49 | int ar2[] = { 2, 3, 8, 13 };
50 |
51 | int m = sizeof(ar1) / sizeof(ar1[0]);
52 |
53 | int n = sizeof(ar2) / sizeof(ar2[0]);
54 |
55 | merge(ar1, ar2, m, n);
56 |
57 |
58 | printf("After Merging \nFirst Array: ");
59 |
60 | for (int i = 0; i < m; i++)
61 |
62 | printf("%d ", ar1[i]);
63 |
64 | printf("\nSecond Array: ");
65 |
66 | for (int i = 0; i < n; i++)
67 |
68 | printf("%d ", ar2[i]);
69 |
70 | return 0;
71 | }
72 |
73 | // This code is contributed by Ramanujam
74 |
--------------------------------------------------------------------------------
/C-codes/mysql/mysql.c:
--------------------------------------------------------------------------------
1 | /* Simple C program that connects to MySQL Database server*/
2 | #include
3 | #include
4 |
5 | main() {
6 | MYSQL *conn;
7 | MYSQL_RES *res;
8 | MYSQL_ROW row;
9 |
10 | char *server = "localhost";
11 | char *user = "root";
12 | char *password = "PASSWORD"; /* set me first */
13 | char *database = "mysql";
14 |
15 | conn = mysql_init(NULL);
16 |
17 | /* Connect to database */
18 | if (!mysql_real_connect(conn, server,
19 | user, password, database, 0, NULL, 0)) {
20 | fprintf(stderr, "%s\n", mysql_error(conn));
21 | exit(1);
22 | }
23 |
24 | /* send SQL query */
25 | if (mysql_query(conn, "show tables")) {
26 | fprintf(stderr, "%s\n", mysql_error(conn));
27 | exit(1);
28 | }
29 |
30 | res = mysql_use_result(conn);
31 |
32 | /* output table name */
33 | printf("MySQL Tables in mysql database:\n");
34 | while ((row = mysql_fetch_row(res)) != NULL)
35 | printf("%s \n", row[0]);
36 |
37 | /* close connection */
38 | mysql_free_result(res);
39 | mysql_close(conn);
40 | }
--------------------------------------------------------------------------------
/C-codes/simple programs/Halfpyramid.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int i, j, rows;
4 | printf("Enter the number of rows: ");
5 | scanf("%d", &rows);
6 | for (i = 1; i <= rows; ++i) {
7 | for (j = 1; j <= i; ++j) {
8 | printf("* ");
9 | }
10 | printf("\n");
11 | }
12 | return 0;
13 | }
14 |
--------------------------------------------------------------------------------
/C-codes/simple programs/factorial.c:
--------------------------------------------------------------------------------
1 | #include
2 | long int multiplyNumbers(int n);
3 | int main() {
4 | int n;
5 | printf("Enter a positive integer: ");
6 | scanf("%d",&n);
7 | printf("Factorial of %d = %ld", n, multiplyNumbers(n));
8 | return 0;
9 | }
10 |
11 | long int multiplyNumbers(int n) {
12 | if (n>=1)
13 | return n*multiplyNumbers(n-1);
14 | else
15 | return 1;
16 | }
17 |
--------------------------------------------------------------------------------
/C-codes/simple programs/fibonacci.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 |
4 | int i, n;
5 |
6 | // initialize first and second terms
7 | int t1 = 0, t2 = 1;
8 |
9 | // initialize the next term (3rd term)
10 | int nextTerm = t1 + t2;
11 |
12 | // get no. of terms from user
13 | printf("Enter the number of terms: ");
14 | scanf("%d", &n);
15 |
16 | // print the first two terms t1 and t2
17 | printf("Fibonacci Series: %d, %d, ", t1, t2);
18 |
19 | // print 3rd to nth terms
20 | for (i = 3; i <= n; ++i) {
21 | printf("%d, ", nextTerm);
22 | t1 = t2;
23 | t2 = nextTerm;
24 | nextTerm = t1 + t2;
25 | }
26 |
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/C-codes/simpleinterest.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main()
4 | {
5 | float principle, time, rate, SI;
6 |
7 | /* Input principle, rate and time */
8 | printf("Enter principle (amount): ");
9 | scanf("%f", &principle);
10 |
11 | printf("Enter time: ");
12 | scanf("%f", &time);
13 |
14 | printf("Enter rate: ");
15 | scanf("%f", &rate);
16 |
17 | /* Calculate simple interest */
18 | SI = (principle * time * rate) / 100;
19 |
20 | /* Print the resultant value of SI */
21 | printf("Simple Interest = %f", SI);
22 |
23 | return 0;
24 | }
25 |
--------------------------------------------------------------------------------
/C-codes/sjf.c:
--------------------------------------------------------------------------------
1 | #include
2 | int main()
3 | {
4 | int A[100][4];
5 | int i, j, n, total = 0, index, temp;
6 | float avg_wt, avg_tat;
7 | printf("Enter number of process: ");
8 | scanf("%d", &n);
9 | printf("Enter Burst Time:\n");
10 | for (i = 0; i < n; i++) {
11 | printf("P%d: ", i + 1);
12 | scanf("%d", &A[i][1]);
13 | A[i][0] = i + 1;
14 | }
15 | for (i = 0; i < n; i++) {
16 | index = i;
17 | for (j = i + 1; j < n; j++)
18 | if (A[j][1] < A[index][1])
19 | index = j;
20 | temp = A[i][1];
21 | A[i][1] = A[index][1];
22 | A[index][1] = temp;
23 |
24 | temp = A[i][0];
25 | A[i][0] = A[index][0];
26 | A[index][0] = temp;
27 | }
28 | A[0][2] = 0;
29 | for (i = 1; i < n; i++) {
30 | A[i][2] = 0;
31 | for (j = 0; j < i; j++)
32 | A[i][2] += A[j][1];
33 | total += A[i][2];
34 | }
35 | avg_wt = (float)total / n;
36 | total = 0;
37 | printf("P BT WT TAT\n");
38 | for (i = 0; i < n; i++) {
39 | A[i][3] = A[i][1] + A[i][2];
40 | total += A[i][3];
41 | printf("P%d %d %d %d\n", A[i][0],
42 | A[i][1], A[i][2], A[i][3]);
43 | }
44 | avg_tat = (float)total / n;
45 | printf("Average Waiting Time= %f", avg_wt);
46 | printf("\nAverage Turnaround Time= %f", avg_tat);
47 | }
48 |
--------------------------------------------------------------------------------
/C-codes/socket/client.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #define NEXT "Hello World of sockets"
11 |
12 | int main(int argc, char *argv[]){
13 | int sock;
14 | struct sockaddr_in server;
15 | struct hostent *hp;
16 | char buffer[1024];
17 |
18 | sock = socket(AF_INET, SOCK_STREAM,0);
19 | if(sock < 0){
20 | perror("socket creation failed\n");
21 | exit(1);
22 | }
23 | server.sin_family = AF_INET;
24 | hp = gethostbyname (argv[1]);
25 | if(hp == 0){
26 | perror("hostname not found\n");
27 | close(sock);
28 | exit(1);
29 | }
30 | memcpy(&server.sin_addr, hp->h_addr, hp->h_length);
31 | server.sin_port = htons(5000);
32 |
33 | if(connect(sock, (struct sockaddr *)&server, sizeof(server)) < 0){
34 | perror("connect failed\n");
35 | exit(1);
36 | }
37 | if(send(sock, NEXT, sizeof(NEXT), 0) < 0){
38 | perror("send failed\n");
39 | close(sock);
40 | exit(1);
41 | }
42 | printf("sent %s\n",NEXT);
43 | close(sock);
44 | return 0;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/C-codes/socket/server.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | int main(int agrc,char *argv[]){
9 |
10 | /*variables*/
11 | int sock;
12 | struct sockaddr_in server;
13 | int mysock;
14 | char buffer[1024];
15 | int rval;
16 | /*Create shocket*/
17 | /*tcp--ip*/
18 | sock = socket(AF_INET, SOCK_STREAM,0);
19 | if(sock == 0){
20 | printf("socket creation failed\n");
21 | exit(1);
22 | }
23 | server.sin_family = AF_INET;
24 | server.sin_addr.s_addr = INADDR_ANY;
25 | server.sin_port = htons(5000);
26 |
27 | /*call bind*/
28 | if(bind(sock, (struct sockaddr *)&server, sizeof(server))<0){
29 | perror("bind failed\n");
30 | exit(1);
31 | }
32 |
33 | /*listen*/
34 | listen(sock, 5);
35 | //
36 | //printf("listening\n");
37 | // }
38 |
39 | /*accept*/
40 | /*Only only connectection doesnt need to optimized or creating
41 | another process for handeling is not required*/
42 | do{
43 | mysock = accept(sock, (struct sockaddr *) 0, 0);
44 | if(mysock == -1 ){
45 | perror("accept failed\n");
46 | }
47 | else{
48 | memset(buffer, 0, sizeof(buffer));
49 |
50 | if((rval=recv(mysock,buffer,sizeof(buffer),0))<0)
51 | perror("Reading steam message error");
52 | else if(rval == 0)
53 | printf("Client disconnected\n");
54 |
55 | else
56 | printf("Message received: %s\n",buffer);
57 | printf("Got the message(rval = %d) \n",rval);
58 | close(mysock);
59 |
60 | }
61 | } while(1);
62 |
63 |
64 | return 0;
65 | }
--------------------------------------------------------------------------------
/Contribute.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | HacktoberFest 2022 :fire:
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | >-The power of open source is power of people,the people rule.(Philippe)
12 | #### [hacktoberfest 2022](https://hacktoberfest.com/)
13 |
14 |
15 | ### Let's Contribute :+1:
16 | - **Step 1** - Fork this repository.
17 | - **Step 2** - Clone the repository to your local machine.
18 | - **Step 3** - Resolve the bugs, mentions provided in the Issues section of the repository. *Also add a description of what changes you have done*.
19 | - **Step 4** - Add the changes to your repository.
20 | - **Step 5** - Create a PULL Request. And that's all.
21 | - **NOTE** - Please start the filename with the platform name on which the problem was solved.
22 | ### What you can contribute in this repo? :punch:
23 | - You can add your own competitive programming solutions or coding related solution.
24 | - There are various topics like Recursion , Bits Manipulation, Graphs etc. ***You can contribute in them***
25 | - You can contribute some **Learning Resources** in the ***Readme.md*** File.
26 | - You can modify previous solutions if you feel like your solution has better ***Time or Space complexity.***
27 |
28 |
29 | ##### Let's Contribute :smiley:
30 |
--------------------------------------------------------------------------------
/Images/Coded_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codednepal/hacktober2022/8f64ced0fb555d6e1456228c0b73dd55068d67c7/Images/Coded_logo.png
--------------------------------------------------------------------------------
/Images/hacktoberfest.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codednepal/hacktober2022/8f64ced0fb555d6e1456228c0b73dd55068d67c7/Images/hacktoberfest.jpg
--------------------------------------------------------------------------------
/Java-codes/Area/Rectangle.java:
--------------------------------------------------------------------------------
1 | // a program to calculate area of Rectangle in Java
2 | import java.util.Scanner;
3 | class AreaOfRectangle
4 | {
5 | public static void main(String[] args) {
6 | Scanner s= new Scanner(System.in);
7 | System.out.println("Enter the length of the Triangle:");
8 | Double l= s.nextDouble();
9 |
10 | System.out.println("Enter the breadth of the Triangle:");
11 | Double b= s.nextDouble();
12 |
13 | //Area = ( length * breadth )
14 | double area=(l*b);
15 | System.out.println("Area of Rectangle is: " + area);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Java-codes/Area/Sphere.java:
--------------------------------------------------------------------------------
1 | // Java program to calculate area of a Sphere in java
2 |
3 | import java.util.Scanner;
4 | public class AreaOfSphere {
5 |
6 | public static void main(String[] args) {
7 | System.out.println("Enter radius of circle: ");
8 | Scanner sn = new Scanner(System.in);
9 | Double radius = sn.nextDouble();
10 |
11 | //area of sphere = 4*pi*r*r
12 | Double area = 4*Math.PI * radius * radius;
13 | System.out.println("Area of sphere = "+area);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Java-codes/Area/Square.java:
--------------------------------------------------------------------------------
1 |
2 | import java.util.Scanner;
3 | public class AreaOfSquare {
4 |
5 | public static void main(String[] args) {
6 | System.out.println("Enter side: ");
7 | Scanner sn = new Scanner(System.in);
8 | Double side = sn.nextDouble();
9 | //area of square= side*side
10 | Double area = side*side;
11 | System.out.println("Area of square = "+area);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Java-codes/Area/circle.java:
--------------------------------------------------------------------------------
1 | // Java program to calculate area of a circle in java
2 | import java.util.Scanner;
3 | public class AreaOfCircle {
4 | public static void main(String[] args) {
5 | System.out.println("Enter radius of circle: ");
6 | Scanner sn = new Scanner(System.in);
7 | Double radius = sn.nextDouble();
8 | //area of circle = pi*r*r
9 | Double area = Math.PI * radius * radius;
10 | System.out.println("Area of circle = "+area);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Java-codes/Area/triangle.java:
--------------------------------------------------------------------------------
1 |
2 | // a program to calculate area of triangle in Java
3 | import java.util.Scanner;
4 | class AreaOfTriangle
5 | {
6 | public static void main(String[] args) {
7 | Scanner s= new Scanner(System.in);
8 | System.out.println("Enter the breadth of the Triangle:");
9 | Double b= s.nextDouble();
10 |
11 | System.out.println("Enter the height of the Triangle:");
12 | Double h= s.nextDouble();
13 |
14 | //Area = ( breadth * height )/2
15 | double area=(b*h)/2;
16 | System.out.println("Area of Triangle is: " + area);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Java-codes/Bottom_view_of_binary_tree.java:
--------------------------------------------------------------------------------
1 | // Java Program to print Bottom View of Binary Tree
2 | import java.util.*;
3 | import java.util.Map.Entry;
4 |
5 | // Tree node class
6 | class Node
7 | {
8 | int data; //data of the node
9 | int hd; //horizontal distance of the node
10 | Node left, right; //left and right references
11 |
12 | // Constructor of tree node
13 | public Node(int key)
14 | {
15 | data = key;
16 | hd = Integer.MAX_VALUE;
17 | left = right = null;
18 | }
19 | }
20 |
21 | //Tree class
22 | class Tree
23 | {
24 | Node root; //root node of tree
25 |
26 | // Default constructor
27 | public Tree() {}
28 |
29 | // Parameterized tree constructor
30 | public Tree(Node node)
31 | {
32 | root = node;
33 | }
34 |
35 | // Method that prints the bottom view.
36 | public void bottomView()
37 | {
38 | if (root == null)
39 | return;
40 |
41 | // Initialize a variable 'hd' with 0 for the root element.
42 | int hd = 0;
43 |
44 | // TreeMap which stores key value pair sorted on key value
45 | Map map = new TreeMap<>();
46 |
47 | // Queue to store tree nodes in level order traversal
48 | Queue queue = new LinkedList();
49 |
50 | // Assign initialized horizontal distance value to root
51 | // node and add it to the queue.
52 | root.hd = hd;
53 | queue.add(root);
54 |
55 | // Loop until the queue is empty (standard level order loop)
56 | while (!queue.isEmpty())
57 | {
58 | Node temp = queue.remove();
59 |
60 | // Extract the horizontal distance value from the
61 | // dequeued tree node.
62 | hd = temp.hd;
63 |
64 | // Put the dequeued tree node to TreeMap having key
65 | // as horizontal distance. Every time we find a node
66 | // having same horizontal distance we need to replace
67 | // the data in the map.
68 | map.put(hd, temp.data);
69 |
70 | // If the dequeued node has a left child add it to the
71 | // queue with a horizontal distance hd-1.
72 | if (temp.left != null)
73 | {
74 | temp.left.hd = hd-1;
75 | queue.add(temp.left);
76 | }
77 | // If the dequeued node has a right child add it to the
78 | // queue with a horizontal distance hd+1.
79 | if (temp.right != null)
80 | {
81 | temp.right.hd = hd+1;
82 | queue.add(temp.right);
83 | }
84 | }
85 |
86 | // Extract the entries of map into a set to traverse
87 | // an iterator over that.
88 | Set> set = map.entrySet();
89 |
90 | // Make an iterator
91 | Iterator> iterator = set.iterator();
92 |
93 | // Traverse the map elements using the iterator.
94 | while (iterator.hasNext())
95 | {
96 | Map.Entry me = iterator.next();
97 | System.out.print(me.getValue()+" ");
98 | }
99 | }
100 | }
101 |
102 | // Main driver class
103 | public class BottomView
104 | {
105 | public static void main(String[] args)
106 | {
107 | Node root = new Node(20);
108 | root.left = new Node(8);
109 | root.right = new Node(22);
110 | root.left.left = new Node(5);
111 | root.left.right = new Node(3);
112 | root.right.left = new Node(4);
113 | root.right.right = new Node(25);
114 | root.left.right.left = new Node(10);
115 | root.left.right.right = new Node(14);
116 | Tree tree = new Tree(root);
117 | System.out.println("Bottom view of the given binary tree:");
118 | tree.bottomView();
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Java-codes/LongestPalindromicSubstring.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String longestPalindrome(String s) {
3 | if (s == null || s.length() < 1) return "";
4 | int start = 0, end = 0;
5 | for (int i = 0; i < s.length(); i++) {
6 | int len1 = expandAroundCenter(s, i, i);
7 | int len2 = expandAroundCenter(s, i, i + 1);
8 | int len = Math.max(len1, len2);
9 | if (len > end - start) {
10 | start = i - (len - 1) / 2;
11 | end = i + len / 2;
12 | }
13 | }
14 | return s.substring(start, end + 1);
15 | }
16 |
17 | private int expandAroundCenter(String s, int left, int right) {
18 | int L = left, R = right;
19 | while (L >= 0 && R < s.length() && s.charAt(L) == s.charAt(R)) {
20 | L--;
21 | R++;
22 | }
23 | return R - L - 1;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Java-codes/MedianofTwoSortedArrays.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public double findMedianSortedArrays(int[] nums1, int[] nums2) {
3 | int index1 = 0;
4 | int index2 = 0;
5 | int med1 = 0;
6 | int med2 = 0;
7 | for (int i=0; i<=(nums1.length+nums2.length)/2; i++) {
8 | med1 = med2;
9 |
10 | if (index1 == nums1.length)
11 | {
12 | med2 = nums2[index2];
13 | index2++;
14 | }
15 | else if (index2 == nums2.length) {
16 | med2 = nums1[index1];
17 | index1++;
18 | }
19 | else if (nums1[index1] < nums2[index2] ) {
20 | med2 = nums1[index1];
21 | index1++;
22 | }
23 | else {
24 | med2 = nums2[index2];
25 | index2++;
26 | }
27 | }
28 |
29 | if ((nums1.length+nums2.length)%2 == 0){
30 | return (float)(med1+med2)/2;
31 | }
32 | return med2;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Java-codes/PalindromeNumber.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public boolean isPalindrome(int x) {
3 | int i = x;
4 | int num = 0;
5 | while(i>=1) {
6 | int rem = i%10;
7 | num = num*10+rem;
8 | i=i/10;
9 | }
10 | return num==x;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Java-codes/Readme.md:
--------------------------------------------------------------------------------
1 | upload Your Java codes here
2 |
--------------------------------------------------------------------------------
/Java-codes/RegularExpressionMatching.java:
--------------------------------------------------------------------------------
1 | enum Result {
2 | TRUE, FALSE
3 | }
4 |
5 | class Solution {
6 | Result[][] memo;
7 |
8 | public boolean isMatch(String text, String pattern) {
9 | memo = new Result[text.length() + 1][pattern.length() + 1];
10 | return dp(0, 0, text, pattern);
11 | }
12 |
13 | public boolean dp(int i, int j, String text, String pattern) {
14 | if (memo[i][j] != null) {
15 | return memo[i][j] == Result.TRUE;
16 | }
17 | boolean ans;
18 | if (j == pattern.length()){
19 | ans = i == text.length();
20 | } else{
21 | boolean first_match = (i < text.length() &&
22 | (pattern.charAt(j) == text.charAt(i) ||
23 | pattern.charAt(j) == '.'));
24 |
25 | if (j + 1 < pattern.length() && pattern.charAt(j+1) == '*'){
26 | ans = (dp(i, j+2, text, pattern) ||
27 | first_match && dp(i+1, j, text, pattern));
28 | } else {
29 | ans = first_match && dp(i+1, j+1, text, pattern);
30 | }
31 | }
32 | memo[i][j] = ans ? Result.TRUE : Result.FALSE;
33 | return ans;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Java-codes/ReverseInteger.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public int reverse(int x) {
3 | int rev = 0;
4 | while (x != 0) {
5 | int pop = x % 10;
6 | x /= 10;
7 | if (rev > Integer.MAX_VALUE/10 || (rev == Integer.MAX_VALUE / 10 && pop > 7)) return 0;
8 | if (rev < Integer.MIN_VALUE/10 || (rev == Integer.MIN_VALUE / 10 && pop < -8)) return 0;
9 | rev = rev * 10 + pop;
10 | }
11 | return rev;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Java-codes/Sorting/bubblesort.java:
--------------------------------------------------------------------------------
1 | public class BubbleSortExample {
2 | static void bubbleSort(int[] arr) {
3 | int n = arr.length;
4 | int temp = 0;
5 | for(int i=0; i < n; i++){
6 | for(int j=1; j < (n-i); j++){
7 | if(arr[j-1] > arr[j]){
8 | //swap elements
9 | temp = arr[j-1];
10 | arr[j-1] = arr[j];
11 | arr[j] = temp;
12 | }
13 |
14 | }
15 | }
16 |
17 | }
18 | public static void main(String[] args) {
19 | int arr[] ={3,60,35,2,45,320,5};
20 |
21 | System.out.println("Array Before Bubble Sort");
22 | for(int i=0; i < arr.length; i++){
23 | System.out.print(arr[i] + " ");
24 | }
25 | System.out.println();
26 |
27 | bubbleSort(arr);//sorting array elements using bubble sort
28 |
29 | System.out.println("Array After Bubble Sort");
30 | for(int i=0; i < arr.length; i++){
31 | System.out.print(arr[i] + " ");
32 | }
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Java-codes/Sorting/heapsort.java:
--------------------------------------------------------------------------------
1 |
2 | // Java program for implementation of Heap Sort
3 | public class HeapSort
4 | {
5 | public void sort(int arr[])
6 | {
7 | int n = arr.length;
8 |
9 | // Build heap (rearrange array)
10 | for (int i = n / 2 - 1; i >= 0; i--)
11 | heapify(arr, n, i);
12 |
13 | // One by one extract an element from heap
14 | for (int i=n-1; i>=0; i--)
15 | {
16 | // Move current root to end
17 | int temp = arr[0];
18 | arr[0] = arr[i];
19 | arr[i] = temp;
20 |
21 | // call max heapify on the reduced heap
22 | heapify(arr, i, 0);
23 | }
24 | }
25 |
26 | // To heapify a subtree rooted with node i which is
27 | // an index in arr[]. n is size of heap
28 | void heapify(int arr[], int n, int i)
29 | {
30 | int largest = i; // Initialize largest as root
31 | int l = 2*i + 1; // left = 2*i + 1
32 | int r = 2*i + 2; // right = 2*i + 2
33 |
34 | // If left child is larger than root
35 | if (l < n && arr[l] > arr[largest])
36 | largest = l;
37 |
38 | // If right child is larger than largest so far
39 | if (r < n && arr[r] > arr[largest])
40 | largest = r;
41 |
42 | // If largest is not root
43 | if (largest != i)
44 | {
45 | int swap = arr[i];
46 | arr[i] = arr[largest];
47 | arr[largest] = swap;
48 |
49 | // Recursively heapify the affected sub-tree
50 | heapify(arr, n, largest);
51 | }
52 | }
53 |
54 | /* A utility function to print array of size n */
55 | static void printArray(int arr[])
56 | {
57 | int n = arr.length;
58 | for (int i=0; i MAX) return MAX; //likewise.
24 |
25 | i++;
26 | }
27 | return (int)ans*sign; //convert ans to integer and return.
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Java-codes/ZigzagConversion.java:
--------------------------------------------------------------------------------
1 | class Solution {
2 | public String convert(String s, int numRows) {
3 |
4 | if (numRows == 1) return s;
5 |
6 | StringBuilder ret = new StringBuilder();
7 | int n = s.length();
8 | int cycleLen = 2 * numRows - 2;
9 |
10 | for (int i = 0; i < numRows; i++) {
11 | for (int j = 0; j + i < n; j += cycleLen) {
12 | ret.append(s.charAt(j + i));
13 | if (i != 0 && i != numRows - 1 && j + cycleLen - i < n)
14 | ret.append(s.charAt(j + cycleLen - i));
15 | }
16 | }
17 | return ret.toString();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Java-codes/dijkastra.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | import java.io.*;
4 |
5 | class ShortestPath {
6 | // A utility function to find the vertex with minimum distance value,
7 | // from the set of vertices not yet included in shortest path tree
8 | static final int V = 9;
9 | int minDistance(int dist[], Boolean sptSet[])
10 | {
11 | // Initialize min value
12 | int min = Integer.MAX_VALUE, min_index = -1;
13 |
14 | for (int v = 0; v < V; v++)
15 | if (sptSet[v] == false && dist[v] <= min) {
16 | min = dist[v];
17 | min_index = v;
18 | }
19 |
20 | return min_index;
21 | }
22 |
23 | // A utility function to print the constructed distance array
24 | void printSolution(int dist[], int n)
25 | {
26 | System.out.println("Vertex Distance from Source");
27 | for (int i = 0; i < V; i++)
28 | System.out.println(i + " tt " + dist[i]);
29 | }
30 |
31 | // Function that implements Dijkstra's single source shortest path
32 | // algorithm for a graph represented using adjacency matrix
33 | // representation
34 | void dijkstra(int graph[][], int src)
35 | {
36 | int dist[] = new int[V]; // The output array. dist[i] will hold
37 | // the shortest distance from src to i
38 |
39 | // sptSet[i] will true if vertex i is included in shortest
40 | // path tree or shortest distance from src to i is finalized
41 | Boolean sptSet[] = new Boolean[V];
42 |
43 | // Initialize all distances as INFINITE and stpSet[] as false
44 | for (int i = 0; i < V; i++) {
45 | dist[i] = Integer.MAX_VALUE;
46 | sptSet[i] = false;
47 | }
48 |
49 | // Distance of source vertex from itself is always 0
50 | dist[src] = 0;
51 |
52 | // Find shortest path for all vertices
53 | for (int count = 0; count < V - 1; count++) {
54 | // Pick the minimum distance vertex from the set of vertices
55 | // not yet processed. u is always equal to src in first
56 | // iteration.
57 | int u = minDistance(dist, sptSet);
58 |
59 | // Mark the picked vertex as processed
60 | sptSet[u] = true;
61 |
62 | // Update dist value of the adjacent vertices of the
63 | // picked vertex.
64 | for (int v = 0; v < V; v++)
65 |
66 | // Update dist[v] only if is not in sptSet, there is an
67 | // edge from u to v, and total weight of path from src to
68 | // v through u is smaller than current value of dist[v]
69 | if (!sptSet[v] && graph[u][v] != 0 &&
70 | dist[u] != Integer.MAX_VALUE && dist[u] + graph[u][v] < dist[v])
71 | dist[v] = dist[u] + graph[u][v];
72 | }
73 |
74 | // print the constructed distance array
75 | printSolution(dist, V);
76 | }
77 |
78 | // Driver method
79 | public static void main(String[] args)
80 | {
81 | /* Let us create the example graph discussed above */
82 | int graph[][] = new int[][] { { 0, 4, 0, 0, 0, 0, 0, 8, 0 },
83 | { 4, 0, 8, 0, 0, 0, 0, 11, 0 },
84 | { 0, 8, 0, 7, 0, 4, 0, 0, 2 },
85 | { 0, 0, 7, 0, 9, 14, 0, 0, 0 },
86 | { 0, 0, 0, 9, 0, 10, 0, 0, 0 },
87 | { 0, 0, 4, 14, 10, 0, 2, 0, 0 },
88 | { 0, 0, 0, 0, 0, 2, 0, 1, 6 },
89 | { 8, 11, 0, 0, 0, 0, 1, 0, 7 },
90 | { 0, 0, 2, 0, 0, 0, 6, 7, 0 } };
91 | ShortestPath t = new ShortestPath();
92 | t.dijkstra(graph, 0);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Java-codes/huffman_Coding.java:
--------------------------------------------------------------------------------
1 | import java.util.PriorityQueue;
2 | import java.util.Scanner;
3 | import java.util.Comparator;
4 |
5 | class Huffman {
6 | public static void printCode(HuffmanNode root, String s)
7 | {
8 | if (root.left
9 | == null
10 | && root.right
11 | == null
12 | && Character.isLetter(root.c)) {
13 | System.out.println(root.c + ":" + s);
14 |
15 | return;
16 | }
17 | printCode(root.left, s + "0");
18 | printCode(root.right, s + "1");
19 | }
20 | public static void main(String[] args)
21 | {
22 | Scanner s = new Scanner(System.in);
23 | int n = 6;
24 | char[] charArray = { 'a', 'b', 'c', 'd', 'e', 'f' };
25 | int[] charfreq = { 5, 9, 12, 13, 16, 45 };
26 | PriorityQueue q
27 | = new PriorityQueue(n, new MyComparator());
28 |
29 | for (int i = 0; i < n; i++) {
30 | HuffmanNode hn = new HuffmanNode();
31 | hn.c = charArray[i];
32 | hn.data = charfreq[i];
33 | hn.left = null;
34 | hn.right = null;
35 | q.add(hn);
36 | }
37 | HuffmanNode root = null;
38 | while (q.size() > 1) {
39 | HuffmanNode x = q.peek();
40 | q.poll();
41 | HuffmanNode y = q.peek();
42 | q.poll();
43 | HuffmanNode f = new HuffmanNode();
44 | f.data = x.data + y.data;
45 | f.c = '-';
46 | f.left = x;
47 | f.right = y;
48 | root = f;
49 | q.add(f);
50 | }
51 | printCode(root, "");
52 | }
53 | }
54 | class HuffmanNode {
55 | int data;
56 | char c;
57 | HuffmanNode left;
58 | HuffmanNode right;
59 | }
60 | class MyComparator implements Comparator {
61 | public int compare(HuffmanNode x, HuffmanNode y)
62 | {
63 |
64 | return x.data - y.data;
65 | }
66 | }
67 |
68 | // This code is contributed by Nishant Choudhary
69 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/BFS.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | class Graph {
3 |
4 | private int V;
5 | private LinkedList adj[];
6 | Graph(int v) {
7 | V = v;
8 | adj = new LinkedList[v];
9 | for (int i = 0; i < v; ++i)
10 | adj[i] = new LinkedList();
11 | }
12 | void addEdge(int v, int w) {
13 | adj[v].add(w);
14 | }
15 | void BFS(int s) {
16 |
17 | boolean visited[] = new boolean[V];
18 |
19 | LinkedList queue = new LinkedList();
20 |
21 | visited[s] = true;
22 | queue.add(s);
23 |
24 | while (queue.size() != 0) {
25 | s = queue.poll();
26 | System.out.print(s + " ");
27 |
28 | Iterator i = adj[s].listIterator();
29 | while (i.hasNext()) {
30 | int n = i.next();
31 | if (!visited[n]) {
32 | visited[n] = true;
33 | queue.add(n);
34 | }
35 | }
36 | }
37 | }
38 |
39 | public static void main(String args[]) {
40 | Graph g = new Graph(4);
41 |
42 | g.addEdge(0, 1);
43 | g.addEdge(0, 2);
44 | g.addEdge(1, 2);
45 | g.addEdge(2, 0);
46 | g.addEdge(2, 3);
47 | g.addEdge(3, 3);
48 |
49 | System.out.println("Following is Breadth First Traversal " + "(starting from vertex 2)");
50 |
51 | g.BFS(2);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/Binary_search_tree_in_java.java:
--------------------------------------------------------------------------------
1 | class BST_class {
2 | //node class that defines BST node
3 | class Node {
4 | int key;
5 | Node left, right;
6 |
7 | public Node(int data){
8 | key = data;
9 | left = right = null;
10 | }
11 | }
12 | // BST root node
13 | Node root;
14 |
15 | // Constructor for BST =>initial empty tree
16 | BST_class(){
17 | root = null;
18 | }
19 | //delete a node from BST
20 | void deleteKey(int key) {
21 | root = delete_Recursive(root, key);
22 | }
23 |
24 | //recursive delete function
25 | Node delete_Recursive(Node root, int key) {
26 | //tree is empty
27 | if (root == null) return root;
28 |
29 | //traverse the tree
30 | if (key < root.key) //traverse left subtree
31 | root.left = delete_Recursive(root.left, key);
32 | else if (key > root.key) //traverse right subtree
33 | root.right = delete_Recursive(root.right, key);
34 | else {
35 | // node contains only one child
36 | if (root.left == null)
37 | return root.right;
38 | else if (root.right == null)
39 | return root.left;
40 |
41 | // node has two children;
42 | //get inorder successor (min value in the right subtree)
43 | root.key = minValue(root.right);
44 |
45 | // Delete the inorder successor
46 | root.right = delete_Recursive(root.right, root.key);
47 | }
48 | return root;
49 | }
50 |
51 | int minValue(Node root) {
52 | //initially minval = root
53 | int minval = root.key;
54 | //find minval
55 | while (root.left != null) {
56 | minval = root.left.key;
57 | root = root.left;
58 | }
59 | return minval;
60 | }
61 |
62 | // insert a node in BST
63 | void insert(int key) {
64 | root = insert_Recursive(root, key);
65 | }
66 |
67 | //recursive insert function
68 | Node insert_Recursive(Node root, int key) {
69 | //tree is empty
70 | if (root == null) {
71 | root = new Node(key);
72 | return root;
73 | }
74 | //traverse the tree
75 | if (key < root.key) //insert in the left subtree
76 | root.left = insert_Recursive(root.left, key);
77 | else if (key > root.key) //insert in the right subtree
78 | root.right = insert_Recursive(root.right, key);
79 | // return pointer
80 | return root;
81 | }
82 |
83 | // method for inorder traversal of BST
84 | void inorder() {
85 | inorder_Recursive(root);
86 | }
87 |
88 | // recursively traverse the BST
89 | void inorder_Recursive(Node root) {
90 | if (root != null) {
91 | inorder_Recursive(root.left);
92 | System.out.print(root.key + " ");
93 | inorder_Recursive(root.right);
94 | }
95 | }
96 |
97 | boolean search(int key) {
98 | root = search_Recursive(root, key);
99 | if (root!= null)
100 | return true;
101 | else
102 | return false;
103 | }
104 |
105 | //recursive insert function
106 | Node search_Recursive(Node root, int key) {
107 | // Base Cases: root is null or key is present at root
108 | if (root==null || root.key==key)
109 | return root;
110 | // val is greater than root's key
111 | if (root.key > key)
112 | return search_Recursive(root.left, key);
113 | // val is less than root's key
114 | return search_Recursive(root.right, key);
115 | }
116 | }
117 | class Main{
118 | public static void main(String[] args) {
119 | //create a BST object
120 | BST_class bst = new BST_class();
121 | /* BST tree example
122 | 45
123 | / \
124 | 10 90
125 | / \ /
126 | 7 12 50 */
127 | //insert data into BST
128 | bst.insert(45);
129 | bst.insert(10);
130 | bst.insert(7);
131 | bst.insert(12);
132 | bst.insert(90);
133 | bst.insert(50);
134 | //print the BST
135 | System.out.println("The BST Created with input data(Left-root-right):");
136 | bst.inorder();
137 |
138 | //delete leaf node
139 | System.out.println("\nThe BST after Delete 12(leaf node):");
140 | bst.deleteKey(12);
141 | bst.inorder();
142 | //delete the node with one child
143 | System.out.println("\nThe BST after Delete 90 (node with 1 child):");
144 | bst.deleteKey(90);
145 | bst.inorder();
146 |
147 | //delete node with two children
148 | System.out.println("\nThe BST after Delete 45 (Node with two children):");
149 | bst.deleteKey(45);
150 | bst.inorder();
151 | //search a key in the BST
152 | boolean ret_val = bst.search (50);
153 | System.out.println("\nKey 50 found in BST:" + ret_val );
154 | ret_val = bst.search (12);
155 | System.out.println("\nKey 12 found in BST:" + ret_val );
156 | }
157 | }
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/Concatenate.java:
--------------------------------------------------------------------------------
1 | class Concatenate
2 | {
3 | public static void main(String args[]){
4 |
5 | String s1="Sachin ";
6 | String s2="Tendulkar";
7 |
8 | String s3=s1.concat(s2);
9 |
10 | System.out.println(s3);//Sachin Tendulkar
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/FactorialofNum.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | public class Factorial
3 | {
4 | public static void main(String[] args)
5 | {
6 | Scanner in=new Scanner(System.in);
7 | System.out.println("Enter any number ");
8 | int num,i,f=1;
9 | num=in.nextInt();
10 | for ( i=1;i<=num;i++)
11 | {
12 | f=f*i;
13 | }
14 | if(num==0)
15 | System.out.println("factorial of given number is : 0 ");
16 | else
17 | System.out.println("factorial of given number is :"+f);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/Fibonacci.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | class Fibonacci
3 | {
4 | public static void main(String[] args)
5 | {
6 | Scanner in = new Scanner(System.in);
7 | int a,b=1,c=0,num;
8 | System.out.println("Enter how many number you want to print fibonacci series");
9 | num= in.nextInt();
10 | for(int i=1;i<=num;i++)
11 | {
12 | System.out.println(c+" ");
13 | a=b;
14 | b=c;
15 | c=a+b;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/Top_view_of_binary_tree.java:
--------------------------------------------------------------------------------
1 | // Java program to print top
2 | // view of binary tree
3 | import java.util.LinkedList;
4 | import java.util.Map;
5 | import java.util.Map.Entry;
6 | import java.util.Queue;
7 | import java.util.TreeMap;
8 |
9 | // class to create a node
10 | class Node {
11 | int data;
12 | Node left, right;
13 |
14 | public Node(int data)
15 | {
16 | this.data = data;
17 | left = right = null;
18 | }
19 | }
20 |
21 | // class of binary tree
22 | class BinaryTree {
23 | Node root;
24 |
25 | public BinaryTree() { root = null; }
26 |
27 | // function should print the topView of
28 | // the binary tree
29 | private void TopView(Node root)
30 | {
31 | class QueueObj {
32 | Node node;
33 | int hd;
34 |
35 | QueueObj(Node node, int hd)
36 | {
37 | this.node = node;
38 | this.hd = hd;
39 | }
40 | }
41 | Queue q = new LinkedList();
42 | Map topViewMap
43 | = new TreeMap();
44 |
45 | if (root == null) {
46 | return;
47 | }
48 | else {
49 | q.add(new QueueObj(root, 0));
50 | }
51 |
52 | System.out.println(
53 | "The top view of the tree is : ");
54 |
55 | // count function returns 1 if the container
56 | // contains an element whose key is equivalent
57 | // to hd, or returns zero otherwise.
58 | while (!q.isEmpty()) {
59 | QueueObj tmpNode = q.poll();
60 | if (!topViewMap.containsKey(tmpNode.hd)) {
61 | topViewMap.put(tmpNode.hd, tmpNode.node);
62 | }
63 |
64 | if (tmpNode.node.left != null) {
65 | q.add(new QueueObj(tmpNode.node.left,
66 | tmpNode.hd - 1));
67 | }
68 | if (tmpNode.node.right != null) {
69 | q.add(new QueueObj(tmpNode.node.right,
70 | tmpNode.hd + 1));
71 | }
72 | }
73 | for (Map.Entry entry :
74 | topViewMap.entrySet()) {
75 | System.out.print(entry.getValue().data + " ");
76 | }
77 | }
78 |
79 | // Driver Program to test above functions
80 | public static void main(String[] args)
81 | {
82 | /* Create following Binary Tree
83 | 1
84 | / \
85 | 2 3
86 | \
87 | 4
88 | \
89 | 5
90 | \
91 | 6
92 | */
93 | BinaryTree tree = new BinaryTree();
94 | tree.root = new Node(1);
95 | tree.root.left = new Node(2);
96 | tree.root.right = new Node(3);
97 | tree.root.left.right = new Node(4);
98 | tree.root.left.right.right = new Node(5);
99 | tree.root.left.right.right.right = new Node(6);
100 | System.out.println(
101 | "Following are nodes in top view of Binary Tree");
102 | tree.TopView(tree.root);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/calculator.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | class Main {
3 | public static void main(String[] args) {
4 | char operator;
5 | Double number1, number2, result;
6 | Scanner input = new Scanner(System.in);
7 | System.out.println("Choose an operator: +, -, *, or /");
8 | operator = input.next().charAt(0);
9 | System.out.println("Enter first number");
10 | number1 = input.nextDouble();
11 | System.out.println("Enter second number");
12 | number2 = input.nextDouble();
13 | switch (operator) {
14 | case '+':
15 | result = number1 + number2;
16 | System.out.println(number1 + " + " + number2 + " = " + result);
17 | break;
18 | case '-':
19 | result = number1 - number2;
20 | System.out.println(number1 + " - " + number2 + " = " + result);
21 | break;
22 | case '*':
23 | result = number1 * number2;
24 | System.out.println(number1 + " * " + number2 + " = " + result);
25 | break;
26 | case '/':
27 | result = number1 / number2;
28 | System.out.println(number1 + " / " + number2 + " = " + result);
29 | break;
30 | default:
31 | System.out.println("Invalid operator!");
32 | break;
33 | }
34 | input.close();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/checkPalindrome.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 | public class CheckPalindrome
3 | {
4 | public static void main(String[] args)
5 | {
6 | Scanner in = new Scanner(System.in);
7 | int num,b,cpy,rev=0;
8 | System.out.println("Enter any number ");
9 | num=in.nextInt();
10 | cpy=num;
11 | while(num!=0)
12 | {
13 | b=num%10;
14 | rev=rev*10+b;
15 | num=num/10;
16 | }
17 | if(cpy==rev)
18 | System.out.println("number is palindrome");
19 | else
20 | System.out.println("number is not palindrome");
21 | }
22 | }
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/checkevenodd.java:
--------------------------------------------------------------------------------
1 | //program to check number is even or odd
2 | import java.util.Scanner;
3 | class Check
4 | {
5 | public static void main(String[] args)
6 | {
7 | Scanner in= new Scanner(System.in);
8 | System.out.println("Enter any number");
9 | int num =in.nextInt();
10 | if(num%2==0)
11 | System.out.println("number is even");
12 | else
13 | System.out.println("numberis odd");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/kadane’sAlgo.java:
--------------------------------------------------------------------------------
1 | import java.util.*;
2 | import java.lang.*;
3 | import java.io.*;
4 | class Main {
5 | public static int maximumSubarraySum(int[] arr) {
6 | int n = arr.length;
7 | int maxSum = Integer.MIN_VALUE;
8 |
9 | for (int i = 0; i <= n - 1; i++) {
10 | int currSum = 0;
11 | for (int j = i; j <= n - 1; j++) {
12 | currSum += arr[j];
13 | if (currSum > maxSum) {
14 | maxSum = currSum;
15 | }
16 | }
17 | }
18 |
19 | return maxSum;
20 | }
21 | public static void main(String args[]) {
22 | // Your code goes here
23 | int a[] = {1, 3, 8, -2, 6, -8, 5};
24 | System.out.println(maximumSubarraySum(a));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/prime-number.java:
--------------------------------------------------------------------------------
1 | public class PrimeExample{
2 | public static void main(String args[]){
3 | int i,m=0,flag=0;
4 | int n=3;
5 | m=n/2;
6 | if(n==0||n==1){
7 | System.out.println(n+" is not prime number");
8 | }else{
9 | for(i=2;i<=m;i++){
10 | if(n%i==0){
11 | System.out.println(n+" is not prime number");
12 | flag=1;
13 | break;
14 | }
15 | }
16 | if(flag==0) { System.out.println(n+" is prime number"); }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/rat_in_maze.java:
--------------------------------------------------------------------------------
1 | /* Java program to solve Rat in
2 | a Maze problem using backtracking */
3 |
4 | public class RatMaze {
5 |
6 | // Size of the maze
7 | static int N;
8 |
9 | /* A utility function to print
10 | solution matrix sol[N][N] */
11 | void printSolution(int sol[][])
12 | {
13 | for (int i = 0; i < N; i++) {
14 | for (int j = 0; j < N; j++)
15 | System.out.print(
16 | " " + sol[i][j] + " ");
17 | System.out.println();
18 | }
19 | }
20 |
21 | /* A utility function to check
22 | if x, y is valid index for N*N maze */
23 | boolean isSafe(
24 | int maze[][], int x, int y)
25 | {
26 | // if (x, y outside maze) return false
27 | return (x >= 0 && x < N && y >= 0
28 | && y < N && maze[x][y] == 1);
29 | }
30 |
31 | /* This function solves the Maze problem using
32 | Backtracking. It mainly uses solveMazeUtil()
33 | to solve the problem. It returns false if no
34 | path is possible, otherwise return true and
35 | prints the path in the form of 1s. Please note
36 | that there may be more than one solutions, this
37 | function prints one of the feasible solutions.*/
38 | boolean solveMaze(int maze[][])
39 | {
40 | int sol[][] = new int[N][N];
41 |
42 | if (solveMazeUtil(maze, 0, 0, sol) == false) {
43 | System.out.print("Solution doesn't exist");
44 | return false;
45 | }
46 |
47 | printSolution(sol);
48 | return true;
49 | }
50 |
51 | /* A recursive utility function to solve Maze
52 | problem */
53 | boolean solveMazeUtil(int maze[][], int x, int y,
54 | int sol[][])
55 | {
56 | // if (x, y is goal) return true
57 | if (x == N - 1 && y == N - 1
58 | && maze[x][y] == 1) {
59 | sol[x][y] = 1;
60 | return true;
61 | }
62 |
63 | // Check if maze[x][y] is valid
64 | if (isSafe(maze, x, y) == true) {
65 | // Check if the current block is already part of solution path.
66 | if (sol[x][y] == 1)
67 | return false;
68 |
69 | // mark x, y as part of solution path
70 | sol[x][y] = 1;
71 |
72 | /* Move forward in x direction */
73 | if (solveMazeUtil(maze, x + 1, y, sol))
74 | return true;
75 |
76 | /* If moving in x direction doesn't give
77 | solution then Move down in y direction */
78 | if (solveMazeUtil(maze, x, y + 1, sol))
79 | return true;
80 |
81 | /* If none of the above movements works then
82 | BACKTRACK: unmark x, y as part of solution
83 | path */
84 | sol[x][y] = 0;
85 | return false;
86 | }
87 |
88 | return false;
89 | }
90 |
91 | public static void main(String args[])
92 | {
93 | RatMaze rat = new RatMaze();
94 | int maze[][] = { { 1, 0, 0, 0 },
95 | { 1, 1, 0, 1 },
96 | { 0, 1, 0, 0 },
97 | { 1, 1, 1, 1 } };
98 |
99 | N = maze.length;
100 | rat.solveMaze(maze);
101 | }
102 | }
103 | // This code is contributed by Abhishek Shankhadhar
104 |
--------------------------------------------------------------------------------
/Java-codes/impotant Programs/swapping.java:
--------------------------------------------------------------------------------
1 | public class Swapping {
2 |
3 | public static void main(String[] args) {
4 |
5 | float first = 13.0f, second = 23.4f;
6 |
7 | System.out.println("--Before swap--");
8 | System.out.println("First number = " + first);
9 | System.out.println("Second number = " + second);
10 |
11 | // Value of first is assigned to temporary
12 | float temporary = first;
13 |
14 | // Value of second is assigned to first
15 | first = second;
16 |
17 | // Value of temporary (which contains the initial value of first) is assigned to second
18 | second = temporary;
19 |
20 | System.out.println("--After swap--");
21 | System.out.println("First number = " + first);
22 | System.out.println("Second number = " + second);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Java-codes/kadanes_algorithm.java:
--------------------------------------------------------------------------------
1 | package me.company;
2 | import java.util.*;
3 | public class kadanes_algorithm
4 | {
5 | public static void main(String args[])
6 | {
7 | Scanner sc=new Scanner(System.in);
8 | System.out.println("Enter the no. of elements in array");
9 | int n=sc.nextInt();
10 | int a[]=new int[n];
11 | System.out.println("Enter the elements of the array : ");
12 | for(int i=0; i=0)
21 | curr_sum+=a[i];
22 | else
23 | curr_sum=a[i];
24 |
25 | if(curr_sum>total_sum)
26 | total_sum=curr_sum;
27 | }
28 | System.out.println("Maximum sum subarray is : "+total_sum);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Java-codes/matrixadd.java:
--------------------------------------------------------------------------------
1 | public class MatrixAdd{
2 | public static void main(String args[]){
3 | //creating two matrices
4 | int x[][]={{1,3,4},{2,4,3},{3,4,5}};
5 | int y[][]={{1,3,4},{2,4,3},{1,2,4}};
6 |
7 | //creating another matrix to store the sum of two matrices
8 | int z[][]=new int[2][2]; //2 rows and 2 columns
9 |
10 | //adding and printing addition of 2 matrices
11 | for(int i=0;i<2;i++){
12 | for(int j=0;j<2;j++){
13 | z[i][j]=x[i][j]+y[i][j]; //use - for subtraction
14 | System.out.print(z[i][j]+" ");
15 | }
16 | System.out.println();//new line
17 | }
18 | }}
19 |
--------------------------------------------------------------------------------
/Java-codes/reverse_the_array.java:
--------------------------------------------------------------------------------
1 | // Iterative java program to reverse an
2 |
3 | // array
4 |
5 | public class GFG {
6 |
7 | /* Function to reverse arr[] from
8 |
9 | start to end*/
10 |
11 | static void rvereseArray(int arr[],
12 |
13 | int start, int end)
14 |
15 | {
16 |
17 | int temp;
18 |
19 |
20 |
21 | while (start < end)
22 |
23 | {
24 |
25 | temp = arr[start];
26 |
27 | arr[start] = arr[end];
28 |
29 | arr[end] = temp;
30 |
31 | start++;
32 |
33 | end--;
34 |
35 | }
36 |
37 | }
38 |
39 |
40 |
41 | /* Utility that prints out an
42 |
43 | array on a line */
44 |
45 | static void printArray(int arr[],
46 |
47 | int size)
48 |
49 | {
50 |
51 | for (int i = 0; i < size; i++)
52 |
53 | System.out.print(arr[i] + " ");
54 |
55 |
56 |
57 | System.out.println();
58 |
59 | }
60 |
61 | // Driver code
62 |
63 | public static void main(String args[]) {
64 |
65 |
66 |
67 | int arr[] = {1, 2, 3, 4, 5, 6};
68 |
69 | printArray(arr, 6);
70 |
71 | rvereseArray(arr, 0, 5);
72 |
73 | System.out.print("Reversed array is \n");
74 |
75 | printArray(arr, 6);
76 |
77 |
78 |
79 | }
80 |
81 | }
82 |
83 | // This code is contributed by Mahesmati Maharana
84 |
--------------------------------------------------------------------------------
/Java-codes/timer.java:
--------------------------------------------------------------------------------
1 | import java.util.Calendar;
2 | import java.util.Timer;
3 | import java.util.TimerTask;
4 | public class ScheduleTimer
5 | {
6 | public static void main(String args[])
7 | {
8 | //instance of the Timer class
9 | Timer timer = new Timer();
10 | TimerTask task = new TimerTask()
11 | {
12 | //represent the time after which the task will begin to execute
13 | int i = 5;
14 | @Override
15 | public void run()
16 | {
17 | if(i>0)
18 | {
19 | System.out.println(i);
20 | i--;
21 | }
22 | else
23 | {
24 | System.out.println("Wish You Very Happy Birthday!!");
25 | //cancel the task once it is completed
26 | timer.cancel();
27 | }
28 | }
29 | };
30 | //creating an instance of the Calendar class
31 | Calendar date = Calendar.getInstance();
32 | //setting the date and time on which timer will begin
33 | date.set(2022, Calendar.MARCH, 30,23, 59, 54);
34 | //enables the counter to count at a rate of 1 second
35 | timer.scheduleAtFixedRate(task, date.getTime(), 1000);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hacktober Fest 2022
7 |
8 | Give a Star to This repo:fire::star:
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
Open source for everybody.
26 |
27 |
28 | ## Table of Contents
29 |
30 | - [C-Programming](/C-codes)
31 | - [C++-Programming](/c++)
32 | - [Java-Programming](/Java-codes)
33 | - [React](/React)
34 | - [Python Programming](/python)
35 | - [Web-Projects](/Web)
36 |
37 |
38 | ## Contributing
39 |
40 | Contributions are always welcome!
41 |
42 | See `contributing.md` for ways to get started.
43 |
44 | Add any Simple or Complex Program in any language you Like in this Repository by clicking "Add File -> Create new File".
45 |
46 |
47 | If you liked working on this project, please share this project as much as you can and star this project to help as many people in opensource as you can.
48 |
49 | ## Note:
50 |
51 | 1. Don't Create Pull Request to update "readme.md" File.
52 | 2. Upload or Create File in Specified Language Folder.
53 | 3. If Specified Language Folder not Found then Create Folder and then Upload or Create File.
54 |
--------------------------------------------------------------------------------
/React/portfolio/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "info",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.16.5",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "autoprefixer": "^10.4.8",
10 | "postcss": "^8.4.16",
11 | "react": "^18.2.0",
12 | "react-dom": "^18.2.0",
13 | "react-icons": "^4.4.0",
14 | "react-router-dom": "^6.3.0",
15 | "react-scripts": "5.0.1",
16 | "tailwindcss": "^3.1.8",
17 | "web-vitals": "^2.1.4"
18 | },
19 | "scripts": {
20 | "start": "react-scripts start",
21 | "build": "react-scripts build",
22 | "test": "react-scripts test",
23 | "eject": "react-scripts eject"
24 | },
25 | "eslintConfig": {
26 | "extends": [
27 | "react-app",
28 | "react-app/jest"
29 | ]
30 | },
31 | "browserslist": {
32 | "production": [
33 | ">0.2%",
34 | "not dead",
35 | "not op_mini all"
36 | ],
37 | "development": [
38 | "last 1 chrome version",
39 | "last 1 firefox version",
40 | "last 1 safari version"
41 | ]
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/VisualBasic/Readme.md:
--------------------------------------------------------------------------------
1 | Add your Vb code here.
2 |
--------------------------------------------------------------------------------
/VisualBasic/Simpleprograms/Areaofparallelogram.vb:
--------------------------------------------------------------------------------
1 | Module Program
2 | Public Sub main()
3 | Dim base As Integer
4 | Dim height As Integer
5 | Console.WriteLine("enter base")
6 | base = Console.ReadLine()
7 | Console.WriteLine("enter height")
8 | height = Console.ReadLine()
9 | Dim area As Integer
10 | area = base * height
11 | Console.WriteLine("Area of Parallelogram {0}", area)
12 | Console.ReadKey()
13 | End Sub
14 | End Module
15 |
--------------------------------------------------------------------------------
/VisualBasic/Simpleprograms/Mathematicalcalculations.vb:
--------------------------------------------------------------------------------
1 | Module Program
2 | Public Sub main()
3 | Dim a, b As Integer
4 | Dim add, diff, product, divide As Integer
5 | Console.WriteLine("enter first number")
6 | a = Console.ReadLine()
7 | Console.WriteLine("enter second number")
8 | b = Console.ReadLine()
9 |
10 | add = a + b
11 | diff = a - b
12 | product = a * b
13 | divide = a / b
14 | Console.WriteLine("Addition is {0}", add)
15 | Console.WriteLine("subraction is {0}", diff)
16 | Console.WriteLine("Product is {0}", product)
17 | Console.WriteLine("Division is {0}", divide)
18 | End Sub
19 | End Module
20 |
--------------------------------------------------------------------------------
/VisualBasic/Simpleprograms/typeconverison.vb:
--------------------------------------------------------------------------------
1 | Option Strict On
2 |
3 | Module Program
4 | Public Sub main()
5 | Dim n As Integer
6 | Dim da As Date
7 | Dim bl As Boolean = True
8 | n = 12345
9 | da = Today
10 | Console.WriteLine(bl)
11 | Console.WriteLine(CSByte(bl))
12 | Console.WriteLine(CStr(bl))
13 | Console.WriteLine(CChar(CStr(da)))
14 | Console.ReadKey()
15 | End Sub
16 | End Module
17 |
--------------------------------------------------------------------------------
/Web/Google/index1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Google Fieldset
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |

18 |
19 |
20 |
21 |
Sign in
22 |
Continue to Gmail
23 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Web/Readme.md:
--------------------------------------------------------------------------------
1 | WebProjects here.
2 |
--------------------------------------------------------------------------------
/Web/THEME/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Shikshya
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Coded
20 | >
21 |
22 | Blue
23 |
24 |
25 | Change the theme
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Web/THEME/index.js:
--------------------------------------------------------------------------------
1 | function changeTheme() {
2 | if (document.getElementById('button').innerHTML === 'Dark Theme') {
3 | document.body.style.background = '#555';
4 | document.body.style.color = 'white';
5 | document.getElementById('button').innerHTML = 'Light Theme';
6 | }
7 | else {
8 | document.body.style.background = 'white';
9 | document.body.style.color = '#555';
10 | document.getElementById('button').innerHTML = 'Dark Theme';
11 | }
12 | }
--------------------------------------------------------------------------------
/Web/THEME/style.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
2 | @import url('https://fonts.googleapis.com/css2?family=Advent+Pro&display=swap');
3 |
4 | html,
5 | button {
6 | font-family: Quicksand, sans-serif;
7 | }
8 |
9 | body {
10 | background: white;
11 | color: #555;
12 | text-align: center;
13 | }
14 |
15 | .logo {
16 | margin-top: 30%;
17 | font-size: 30px;
18 | font-weight: normal;
19 | }
20 |
21 | .brackets {
22 | font-family: Advent Pro, sans-serif;
23 | }
24 |
25 | .left {
26 | color: tomato;
27 | }
28 |
29 | .right {
30 | color: dodgerblue;
31 | }
32 |
33 | .sample {
34 | padding: 20px;
35 | font-size: 18px;
36 | background: inherit;
37 | color: inherit;
38 | }
39 |
40 | #button {
41 | margin-top: 10px;
42 | background: dodgerblue;
43 | color: white;
44 | width: 80%;
45 | height: 60px;
46 | font-size: 20px;
47 | outline: none;
48 | border: 5px solid deepskyblue;
49 | border-radius: 5px;
50 | }
51 |
52 | #button:active {
53 | transform: scale(0.95);
54 | }
--------------------------------------------------------------------------------
/Web/calculator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Calculator
8 |
9 |
10 |
11 |
44 |
45 |
46 |
47 |