diff --git a/C++/ComparingTwoFractions.cpp b/C++/ComparingTwoFractions.cpp new file mode 100644 index 00000000..700442b1 --- /dev/null +++ b/C++/ComparingTwoFractions.cpp @@ -0,0 +1,31 @@ +// fikriks + +#include + +using namespace std; + +int main() +{ + int pecahan_pembilang1, pecahan_penyebut1, pecahan_pembilang2, pecahan_penyebut2; + float hasil1, hasil2; + + printf("%s\n", "Membandingkan Dua Bilangan Pecahan"); + printf("Masukan Bilangan Pecahan Ke-1 (Format Input = 1/2) = "); + scanf("%i/%i", &pecahan_pembilang1, &pecahan_penyebut1); + + printf("Masukan Bilangan Pecahan Ke-2 (Format Input = 1/2) = "); + scanf("%i/%i", &pecahan_pembilang2, &pecahan_penyebut2); + + hasil1 = (float) pecahan_pembilang1 / pecahan_penyebut1; + hasil2 = (float) pecahan_pembilang2 / pecahan_penyebut2; + + if(hasil1 == hasil2){ + printf("Pecahan Ke-1 (%i/%i) Sama Dengan Pecahan Ke-2 (%i/%i)", pecahan_pembilang1, pecahan_penyebut1, pecahan_pembilang2, pecahan_penyebut2); + }else if(hasil1 < hasil2){ + printf("Pecahan Ke-1 (%i/%i) Lebih Kecil Dari Pecahan Ke-2 (%i/%i)", pecahan_pembilang1, pecahan_penyebut1, pecahan_pembilang2, pecahan_penyebut2); + }else if(hasil1 > hasil2){ + printf("Pecahan Ke-1 (%i/%i) Lebih Besar Dari Pecahan Ke-2 (%i/%i)", pecahan_pembilang1, pecahan_penyebut1, pecahan_pembilang2, pecahan_penyebut2); + } + + return 0; +} diff --git a/C++/Connected_components.cpp b/C++/Connected_components.cpp new file mode 100644 index 00000000..51dec77e --- /dev/null +++ b/C++/Connected_components.cpp @@ -0,0 +1,77 @@ +/* +░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░ +░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░ +░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░ +░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░ +░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░ +░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░ +░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░ +░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░ +░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░ +░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░ +▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░ +▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌ +▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░ +░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░ +░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░ +░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░ +░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░ +░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░ +░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░ +*/ + +// Github: GarvitV957 + +#include +using namespace std; +#define ll long long +#define lli long long int +#define vi vector +#define vvi vector +#define vll vector +#define vb vector +#define pb push_back +#define pii pair +#define all(x) x.begin(),x.end() + +int N=1e6 +1; +vvi adj(N); +vi vis(N,0); + +vvi cc; +vi current_comp; + +void dfs(int i){ + vis[i]=1; + current_comp.pb(i); + for(auto v:adj[i]){ + if(!vis[v]){ + dfs(v); + } + } +} + +int main(){ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + int n,e; + cin>>n>>e; + for(int i=0;i>x>>y; + adj[x].pb(y),adj[y].pb(x); + } + int c=0; + for(int i=1;i<=n;i++){ + if(!vis[i]){ + current_comp.clear(); + dfs(i); + cc.pb(current_comp); + c++; + } + } + cout< +#include +using namespace std; +#define RANGE 200 + +// The main function that sort +// the given string arr[] in +// alphabetical order +void countSort(char arr[]) +{ + // The output character array + // that will have sorted arr + char output[strlen(arr)]; + + // Create a count array to store count of individual + // characters and initialize count array as 0 + int count[RANGE + 1], i; + memset(count, 0, sizeof(count)); + + // Store count of each character + for (i = 0; arr[i]; ++i) + ++count[arr[i]]; + + // Change count[i] so that count[i] now contains actual + // position of this character in output array + for (i = 1; i <= RANGE; ++i) + count[i] += count[i - 1]; + + // Build the output character array + for (i = 0; arr[i]; ++i) { + output[count[arr[i]] - 1] = arr[i]; + --count[arr[i]]; + } + + /* + For Stable algorithm + for (i = sizeof(arr)-1; i>=0; --i) + { + output[count[arr[i]]-1] = arr[i]; + --count[arr[i]]; + } + + For Logic : See implementation + */ + + // Copy the output array to arr, so that arr now + // contains sorted characters + for (i = 0; arr[i]; ++i) + arr[i] = output[i]; +} + +// Driver code +int main() +{ + char arr[] = "countingsortincpp"; + + countSort(arr); + + cout << "Sorted character array is " << arr; + return 0; +} +//github : atinder11 + + diff --git a/C++/Merge_sort.cpp b/C++/Merge_sort.cpp new file mode 100644 index 00000000..3d6eef25 --- /dev/null +++ b/C++/Merge_sort.cpp @@ -0,0 +1,61 @@ +/* +chiragchandnani10 +https://github.com/chiragchandnani10 +*/ + +#include +using namespace std; +void merging(int input[],int start,int end){ + int mid = (start+end)/2; + int i=start, j=mid+1, k=start; + int ans[end+1]; + while(i<=mid&&j<=end){ + if(input[i]=end){ + return; + } + int mid = ((start+end)/2); + merge_sort(input,start,mid); + merge_sort(input,mid+1,end); + merging(input,start,end); + + +} + + + +void mergeSort(int input[], int size){ + // Write your code here + + merge_sort(input,0,size-1); + + + +} + diff --git a/C++/bucketSort.cpp b/C++/bucketSort.cpp new file mode 100644 index 00000000..27105e33 --- /dev/null +++ b/C++/bucketSort.cpp @@ -0,0 +1,50 @@ +/* + Authors Name : Utkarsh Tyagi + Date Modified: 1 October, 2022 +*/ +// C++ program to sort an +// array using bucket sort +#include +#include +#include +using namespace std; + +// Function to sort arr[] of +// size n using bucket sort +void bucketSort(float arr[], int n) +{ + + // 1) Create n empty buckets + vector b[n]; + + // 2) Put array elements + // in different buckets + for (int i = 0; i < n; i++) { + int bi = n * arr[i]; // Index in bucket + b[bi].push_back(arr[i]); + } + + // 3) Sort individual buckets + for (int i = 0; i < n; i++) + sort(b[i].begin(), b[i].end()); + + // 4) Concatenate all buckets into arr[] + int index = 0; + for (int i = 0; i < n; i++) + for (int j = 0; j < b[i].size(); j++) + arr[index++] = b[i][j]; +} + +/* Driver program to test above function */ +int main() +{ + float arr[] + = { 0.897, 0.565, 0.656, 0.1234, 0.665, 0.3434 }; + int n = sizeof(arr) / sizeof(arr[0]); + bucketSort(arr, n); + + cout << "Sorted array is \n"; + for (int i = 0; i < n; i++) + cout << arr[i] << " "; + return 0; +} diff --git a/C++/divisible_subarrays_using_pigeon_hole_principle.cpp b/C++/divisible_subarrays_using_pigeon_hole_principle.cpp new file mode 100644 index 00000000..a2e46679 --- /dev/null +++ b/C++/divisible_subarrays_using_pigeon_hole_principle.cpp @@ -0,0 +1,53 @@ +// Github : vinaypathak07 +// Pigeonhole Principle +// Divisible SubArrays +#include +#include + +using namespace std; + +#define lol long + +lol a[1000005], frequency[1000005]; + +int main() { + + // #ifndef ONLINE_JUDGE + // freopen("input.txt", "r", stdin); + // freopen("output.txt", "w", stdout); + // #endif + + int t; + cin >> t; + + while (t--) { + int n; + cin >> n; + + memset(frequency, 0, sizeof(frequency)); + frequency[0] = 1; + + lol sum = 0; + + for (int i = 0; i < n; i++) { + cin >> a[i]; + + sum += a[i]; + sum %= n; + sum = (sum + n) % n; // sum+n because if we encountered negative value + frequency[sum] += 1; + } + + lol ans = 0; + + for (int i = 0; i < n; i++) { + if (frequency[i] > 1) { + lol m = frequency[i]; + ans += (m * (m - 1)) / 2; + } + } + cout << ans << endl; + } + + return 0; +} diff --git a/C++/factorialprogram.cpp b/C++/factorialprogram.cpp new file mode 100644 index 00000000..992da77a --- /dev/null +++ b/C++/factorialprogram.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +// github username navdeepk037 https://github.com/navdeepk037 +int fact(int n) +{ + int factorial=1; + for(int i=n;i>=1;i--) + factorial=factorial*i; + return factorial; +} +int main(){ + int n; + cout<<"enter the number "; + cin>>n; + cout<<"the factorial of the number is "< + +void printArray(int *A,int n) +{ + for(int i=0;i A[j+1]) + { + temp = A[j]; + A[j] = A[j+1]; + A[j+1] = temp; + } + } + } +} + +int main() +{ + int A[] = {5,7,3,1,2}; + int n = 5; + printArray(A,n); + BubbleSort(A,n); + printArray(A,n); + +} + diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 59c1ebd0..f3226313 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -3,9 +3,10 @@ # Message

Enter your Name, Github Link & Your E-Mail Address in the given format. Don't try to change anything else!!!

-| Name | Github Link | E-Mail Address | +| Name | Github Link | E-Mail Address | # List of Contributors +

[*] Make sure you have updated your Name, Github link & E-Mail Id (enter your e-mail just after mailto:)!!!


@@ -29,15 +30,51 @@ | Aditya Wadkar | Aditya Wadkar | E-Mail | | Rahul Jangle | Ronny | E-Mail | | Anurag Vats | Anurag Vats | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Vinay Pathak | Vinay Pathak | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Aakash Jha | Aakash Jha | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Atinder Kumar | Atinder Kumar | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Shobhit Tiwari | Shobhit Tiwari | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Aritroo Chowdhury | Aritroo Chowdhury | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Kartikey Singh | Kartikey Singh | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Pradeep Khatri | Pradeep Khatri | E-Mail | | Apurva Dubey | umbridge | E-Mail | -| Daksh Kesarwani | Daksh kesaarwani | E-Mail | -| Shivam Jaiswal | Shivam Jaiswal | E-mail | -| Ashish Kushwaha | Ashish Kushwaha | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Fikri Khairul Shaleh | Fikri Khairul Shaleh | E-Mail | +| Shivam Jaiswal | Shivam Jaiswal | E-mail | +| Ashish Kushwaha | Ashish Kushwaha | E-Mail | +| Daksh Kesarwani | Daksh kesaarwani | E-Mail | +| Chirag Chandnani | Chirag Chandnani | E-Mail | +| Shivam Jaiswal | Shivam Jaiswal | E-mail | +| Ashish Kushwaha | Ashish Kushwaha | E-Mail | | Dhruv Arora | Dhruv Arora | E-Mail | -| Tharindu Sooriyaarchchi | E-Mail | -| Samriddh Prasad | Samriddh Prasad | E-Mail | -| Edgar Gonzalez | Edgar Gonzalez | E-Mail | - | Amisha Rani | Amisha Rani | E-Mail | +| Tharindu Sooriyaarchchi | E-Mail | +| Samriddh Prasad | Samriddh Prasad | E-Mail | +| Edgar Gonzalez | Edgar Gonzalez | E-Mail | +| Amisha Rani | Amisha Rani | E-Mail | +| Tharindu Sooriyaarchchi | E-Mail | +| Samriddh Prasad | Samriddh Prasad | E-Mail | +| Edgar Gonzalez | Edgar Gonzalez | E-Mail | +| Sneha Chaudhary | Sneha Chaudhary | E-Mail | +| Tharindu Sooriyaarchchi | E-Mail | +| Samriddh Prasad | Samriddh Prasad | E-Mail | +| Edgar Gonzalez | Edgar Gonzalez | E-Mail | + + + + + + + + + + diff --git a/Python/character_pattern.py b/Python/character_pattern.py new file mode 100644 index 00000000..523a86ab --- /dev/null +++ b/Python/character_pattern.py @@ -0,0 +1,32 @@ +# Python program to generate a character pattern + +# Github Username : aritroo + +#Example Output is given below :- +# Enter the number of rows : 5 +# A +# B B +# C C C +# D D D D +# E E E E E + + + +def character(n): + + num = 65 + + for i in range(0, n): + + for j in range(0, i+1): + + ch = chr(num) + + print(ch, end=" ") + + num = num + 1 + + print("\r") + +n = int(input("Enter the number of rows : ")) +character(n) diff --git a/Python/hourglass_pattern.py b/Python/hourglass_pattern.py new file mode 100644 index 00000000..bc293550 --- /dev/null +++ b/Python/hourglass_pattern.py @@ -0,0 +1,18 @@ +### Github Username - SanBuilds (https://github.com/SanBuilds) +### Hourglass pattern in python + +rows = int(input("Enter the rows(height) of the hourglass: ")) + +for i in range(rows): + for j in range(i): + print('', end = ' ') + for k in range(i,rows): + print('*', end = ' ') + print() + +for i in range(rows,-1,-1): + for j in range(i): + print('', end = ' ') + for k in range(i,rows): + print('*', end = ' ') + print() diff --git a/README.md b/README.md index 36aaab20..3fa1e539 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ✨Hacktoberfest 2022✨ +# ✨#Hacktoberfest 2022✨ A Simple😉 beginner friendly😊 Repo for all programmers and coders. All contributors are requested to star🌟this repo and and folllllow me. Contribute to start your journey with hacktoberfest and python. Happy Hacking💻!!! (*Required) @@ -6,40 +6,52 @@ Contribute to start your journey with hacktoberfest and python. Happy Hacking # 🌟Languages - 💻 C - 💻 C++ -- 💻 HTML - 💻 PHP - 💻 Python - 💻 Java - 💻 Javascript -- 💻 Dart + +# 🛡Rules to Contribute +- ⚓Star this repo to get latest updates. +- ⚓Give your file a proper extension according to language. Ex. .py, .java, .js. html etc. +- ⚓Name your file related to your topic. +- ⚓Put your files in correct folder like .py in Python, .js in Javascript etc. +- ⚓Make sure you have entered your github - username, aim and date in your file as a comment. +- ⚓Make sure you have entered your name in CONTRIBUTORS.md file as mentioned (It's your responsibility) (optional). +- ⚓You can follow ME😁. + +# ❄Format of 5th line in rules +
// Github username: Your Username
+// Aim: Your Repo aim according to your program
+// Date: Date of Coding
+
+// start coding
+
+
+ +### ⚡If your program have class try to use your class with its objects + +### ⚡If you are creating any PR then Add your name in CONTRIBUTORS.md file + +## 🛡Follow rules strictly for successful merged PR!!! # ❄Prgrams +- ⚡Create any pattern +- ⚡Make any algorithm (exclude calculator or related to it) - ⚡Print 1 to 100 without using numbers - ⚡Make calculator without using operators in program -- ⚡Create any pattern -- ⚡Make any algorithm -- ⚡Add webpage parts. - ⚡Calculate fibonacci series with classes - ⚡Calculate factorial with classes - ⚡Print IP Address and Hostname -- ⚡Any Game -## Don't forget to read the contributing rules mentioned below to be successfully merged your PR and get rewards!!! -## If you are using class, don't forget to implement it with it's objects +## Don't forget to read the contributing rules above to be successfully merged your PR and get rewards!!! 🏹 Visit Hacktoberfest to get more information about Hacktoberfest 2022!!! ✈ Visit Hacktoberfest-swag to know more about your swags and rewards!!! -# 🛡Rules to Contribute -- ⚓Star this repo to get latest updates. -- ⚓Give your file a proper extension according to language. Ex. .py, .java, .js. html etc. -- ⚓Name your file related to your topic. -- ⚓Put your files in correct folder like .py in Python, .js in Javascript etc. -- ⚓Make sure you have entered your github - username in your file as a comment. -- ⚓Make sure you have entered your name in CONTRIBUTORS.md file as mentioned (It's your responsibility). -- ⚓You can follow ME😁. +# 🛡 Strictly follow rules to contribute for successful merged PR!!! # Note All contributors who have followed the rules to contribute get successfully merged PR. Don't forget to follow!!!