Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i had finished all my 31 december code #74

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1f8129c
Add files via upload
Surendersahk Dec 8, 2023
60e7392
Add files via upload
Surendersahk Dec 8, 2023
33de2bf
Add files via upload
Surendersahk Dec 10, 2023
da55c12
Add files via upload
Surendersahk Dec 10, 2023
6ea2fcb
Add files via upload
Surendersahk Dec 10, 2023
e750c8e
Update C++_Surendersahk_Peaky Blinders.cpp
Surendersahk Dec 10, 2023
d8768db
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 11, 2023
34e0949
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 12, 2023
858fad1
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 13, 2023
bfbb321
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 22, 2023
61240a3
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 24, 2023
b98ccdc
Add files via upload
Surendersahk Dec 24, 2023
8103fab
Add files via upload
Surendersahk Dec 24, 2023
fd4c032
Add files via upload
Surendersahk Dec 24, 2023
8441e8f
Add files via upload
Surendersahk Dec 24, 2023
1a94976
Add files via upload
Surendersahk Dec 24, 2023
3d50af1
Add files via upload
Surendersahk Dec 24, 2023
06af80d
Add files via upload
Surendersahk Dec 24, 2023
9b04515
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 24, 2023
32ac054
Add files via upload
Surendersahk Dec 25, 2023
42a2938
Add files via upload
Surendersahk Dec 25, 2023
7bedd28
Add files via upload
Surendersahk Dec 25, 2023
3d00776
Add files via upload
Surendersahk Dec 25, 2023
b208b43
Add files via upload
Surendersahk Dec 25, 2023
089eafe
Add files via upload
Surendersahk Dec 25, 2023
05eaa7e
Add files via upload
Surendersahk Dec 25, 2023
f128999
Add files via upload
Surendersahk Dec 25, 2023
5d2b8bd
Add files via upload
Surendersahk Dec 25, 2023
6a6857e
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 28, 2023
08c07fc
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 29, 2023
4ab3123
Add files via upload
Surendersahk Dec 29, 2023
c8c24f4
Add files via upload
Surendersahk Dec 29, 2023
d47fa0d
Add files via upload
Surendersahk Dec 29, 2023
b5e916e
Add files via upload
Surendersahk Dec 29, 2023
f43ef22
Add files via upload
Surendersahk Dec 29, 2023
f17d57b
Add files via upload
Surendersahk Dec 29, 2023
46eb816
Add files via upload
Surendersahk Dec 29, 2023
a8cf73f
Add files via upload
Surendersahk Dec 29, 2023
c56ed0f
Add files via upload
Surendersahk Dec 29, 2023
6adb52d
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 30, 2023
209ae76
Add files via upload
Surendersahk Dec 30, 2023
d2e8027
Merge branch 'SVCE-ACM:master' into master
Surendersahk Dec 31, 2023
c6d4c63
Add files via upload
Surendersahk Dec 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions December 01/c++_Surendersahk_Cricmetric.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//There are five batsmen in the match. Their runs are 20, 35, 40, 15, and 25. The total runs scored by the team are 135. Batsman number 3 (index 2) scored the highest number of runs, which is 40.

#include<iostream>

using namespace std;

int main(){
int n,arr[100],sum=0;
cout << "Enter How many batsmen in the match :\n"<< endl;
cin >>n;

cout << "Enter the runs :\n"<< endl;

for(int i=0;i<n;i++){
cin >> arr[i];
}

for(int i=0;i<n;i++){
sum +=arr[i];
}

cout << "Total runs scored by the team : "<<sum << endl;

int max=arr[0],index;
for(int i=0;i<n;i++){
if(arr[i]>max){
max=arr[i];
index = i;

}
}
cout << "\nThe batsman at index "<< index <<" scored the highest number of runs , which is "<<max << endl;



}
32 changes: 32 additions & 0 deletions December 02/c++_Surendersahk_shopper's choice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include <vector>

int main() {
std::vector<int> array = {2, 4, 5, 2, 6, 7, 2, 8, 2};
int size = array.size();

int numCount;
std::cout << "Enter the number of values you want to find frequencies for: ";
std::cin >> numCount;

std::vector<int> numbersToFind(numCount);
std::cout << "Enter the values you want to find frequencies for, separated by spaces: ";
for (int i = 0; i < numCount; ++i) {
std::cin >> numbersToFind[i];
}

for (int i = 0; i < numCount; ++i) {
int frequency = 0;
int num = numbersToFind[i];

for (int j = 0; j < size; ++j) {
if (array[j] == num) {
frequency++;
}
}

std::cout << "The frequency of " << num << " is: " << frequency << std::endl;
}

return 0;
}
30 changes: 30 additions & 0 deletions December 03/C++_Surendersahk_Sunburnt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include<iostream>

using namespace std;

int main(){
int h[10],n;
int max= 0;

cout <<"\nEnter how many elements(buildings)"<< endl;
cin>>n;

cout << "\nEnter the height of the buildings"<< endl;
for(int i=0;i<n;i++){
cin>>h[i];

}
for(int i=0;i<n;i++){
if(h[i]>max){
max=h[i];

}
cout <<"max:"<< max<< endl;
}

int size = sizeof(max);

cout << "size is :"<< size << endl;


}
40 changes: 40 additions & 0 deletions December 04/C++_Surendersahk_Mirror Magic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <string>

bool isPalindrome(const std::string& str) {
int left = 0;
int right = str.length() - 1;

while (left < right) {
if (str[left] != str[right]) {
return false;
}
left++;
right--;
}

return true;
}

void extractPalindromes(const std::string& input) {
std::cout << "Palindromic substrings in '" << input << "':\n";

for (size_t i = 0; i < input.length(); ++i) {
for (size_t j = i + 1; j <= input.length(); ++j) {
std::string substring = input.substr(i, j - i);
if (isPalindrome(substring) && substring.length() > 1) {
std::cout << substring << std::endl;
}
}
}
}

int main() {
std::string input;
std::cout << "Enter a string: ";
std::cin >> input;

extractPalindromes(input);

return 0;
}
31 changes: 31 additions & 0 deletions December 05/C++_Surendersahk_Peaky Blinders.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<iostream>
using namespace std;

int main(){
int arr[10],n,sum=0,res,avg_ans;

cout << "Enter how many elements :"<< endl;
cin>>n;
cout <<"Enter the elements in the array "<< endl;
for(int i=0;i<n;i++){
cin>>arr[i];
sum +=arr[i];
}

res = sum/n;
cout << "res:"<<res <<endl;

for(int i=0;i<n;i++){
if(res<=arr[i]){
res=arr[i];
avg_ans+=arr[i];
}


}

cout << "The sum is "<<avg_ans << endl;



}
88 changes: 88 additions & 0 deletions December 06/C++_Surendersahk_The Lost Algorithm Scrolls.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

// Function to check if two words differ by only one character
bool isAdjacent(const string& a, const string& b) {
int diffCount = 0;
for (size_t i = 0; i < a.length(); ++i) {
if (a[i] != b[i]) {
if (++diffCount > 1) {
return false;
}
}
}
return diffCount == 1;
}

// Perform BFS to find the shortest path
vector<string> findOptimalSequence(const vector<string>& words, const string& start, const string& end) {
unordered_map<string, vector<string>> adjList;

// Create adjacency list
for (size_t i = 0; i < words.size(); ++i) {
for (size_t j = i + 1; j < words.size(); ++j) {
if (isAdjacent(words[i], words[j])) {
adjList[words[i]].push_back(words[j]);
adjList[words[j]].push_back(words[i]);
}
}
}

unordered_map<string, string> parent;
queue<string> q;
q.push(start);
parent[start] = "";

while (!q.empty()) {
string current = q.front();
q.pop();

if (current == end) {
break;
}

for (const string& neighbor : adjList[current]) {
if (parent.find(neighbor) == parent.end()) {
parent[neighbor] = current;
q.push(neighbor);
}
}
}

// Reconstruct the optimal sequence
vector<string> sequence;
string current = end;
while (current != "") {
sequence.push_back(current);
current = parent[current];
}

reverse(sequence.begin(), sequence.end());
return sequence;
}

int main() {
vector<string> encodedWords = {"co", "cade", "cade", "cate", "cart", "mart"};
string startWord = "code";
string endWord = "mart";

vector<string> sequence = findOptimalSequence(encodedWords, startWord, endWord);

if (sequence.empty() || sequence[0] != startWord || sequence.back() != endWord) {
cout << "No valid sequence found." << endl;
} else {
cout << "Optimal Sequence:" << endl;
for (const string& word : sequence) {
cout << word << " ";
}
cout << endl;
}

return 0;
}
36 changes: 36 additions & 0 deletions December 07/C++_Surendersahk_Babyblocks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
#include<math.h>
using namespace std;

int main (){

int diagonal,diameter,width ,height,rad_of_circle,square;

cout <<"Enter the value of width :";
cin>>width;

cout <<"\nEnter the value of height :";
cin>>height;

square= pow(width,2)+pow(height,2);

diagonal=sqrt(square);

cout << diagonal<< endl;

cout <<"\nEnter the value of radius of the circle :";
cin>>rad_of_circle;

diameter=rad_of_circle*2;

if(diagonal<=diameter){
cout<< "true"<< endl;

}
else{
cout << "false" << endl;
}



}
22 changes: 22 additions & 0 deletions December 08/C++_Surendersahk_The Enchanted Forest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>
#include<cstring>
#include<cctype>

using namespace std;

int main(){

string s;

cout << "Enter the string :";
cin>>s;

for(size_t i=0;i<s.length();i++){



}



}
25 changes: 25 additions & 0 deletions December 09/C++_Surendersahk_Camels on a String!.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){

string s;
int count=0;

cout << "ENter the string s : ";
cin>>s;



for( char str : s){
if(isupper(str)){

}
count++;
}
cout << "The letter is " << count<< endl;


}
35 changes: 35 additions & 0 deletions December 10/C++_Surendersahk_Forgotpassword.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <string>
#include <vector>


int main() {
// Sample data representing empname column values
std::string name;
std::vector<std::string> empnames;
std::cout << "Enter the string names :"<< std::endl;
for(size_t i=0;i<3;i++){

std::cin>>name;
empnames.push_back(name);

}
int start,end;
std::cout << "Start :";
std::cin>>start;

std::cout << "end:";
std::cin>>end;
// Retrieve substring from empname column for each row
for (const std::string& empname : empnames) {
if (empname.length() >= 3) { // Check if the string length is at least 3 to avoid out-of-range issues

std::string substring = empname.substr(start,end); // Extract two characters starting from the second character
std::cout << "Substring for " << empname << ": " << substring << std::endl;
} else {
std::cout << "Substring for " << empname << ": String too short" << std::endl;
}
}

return 0;
}
Loading