Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions December 01/c_balajisanthanam205_cricket
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>
int main()
{
int total=0,n,i,max,x;
printf("Enter total number of Players played:");
scanf("%d",&n);
int runs[n];
for (i=0;i<n;i++)
{
printf ("Enter the score of batsman %d:",i+1);
scanf("%d",&runs[i]);
}
for (i=0;i<n;i++)
{
total=total+runs[i];
}
max=runs[0];
x=0;
for (i=0;i<n;i++)
{
if (max<runs[i])
{
max=runs[i];
x=i;
}
}
printf ("The total runs scored by the team is %d\n", total );
printf ("The top scored batsman index is %d\nand he scored %d runs\n",x,max);
return 0;
}

45 changes: 45 additions & 0 deletions December 02/c_balajisanthanam_Shopper's Choice.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <stdio.h>

void generateFrequency(int productIDs[], int n, int frequency[]) {
for (int i = 0; i < n; i++) {
frequency[productIDs[i]]++;
}
}

int main() {
int n;

// Get the number of products
printf("Enter the number of products: ");
scanf("%d", &n);

int productIDs[n];

// Get the product IDs from the user
printf("Enter the product IDs should be below 1000 only:\n");
for (int i = 0; i < n; i++) {
scanf("%d", &productIDs[i]);
}

// Assuming product IDs are non-negative integers
int maxProductID = 1000; // Adjust this based on the maximum product ID in your dataset

// Initialize an array to store the frequency of each product
int frequency[maxProductID + 1]; // +1 to account for 0-based indexing
for (int i = 0; i <= maxProductID; i++) {
frequency[i] = 0;
}

// Generate the frequency array
generateFrequency(productIDs, n, frequency);

// Display the frequency of each product
printf("Product ID\tFrequency\n");
for (int i = 0; i <= maxProductID; i++) {
if (frequency[i] > 0) {
printf("%d\t\t%d\n", i, frequency[i]);
}
}

return 0;
}
22 changes: 22 additions & 0 deletions December 03/c_balajisanthanam205_Sunburnt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
int main ()
{
int n,max=0,x=0,i;
printf ("Enter the number of Building:");
scanf ("%d",&n);
int building[n];
for(i=0;i<n;i++)
{
printf ("Enter the High of the building %d:",i+1);
scanf ("%d",& building);
}
max=building[0];
for (i=0;i<n;i++)
{
if (max<building[i])
{
x++;
}
}
printf ("The number of Building which requires sun light:%d",x);
}
25 changes: 25 additions & 0 deletions December 05/c_balajisanthanam_Peaky Blinders.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <stdio.h>
int main ()
{
int n,i,avg=0,x=0,sum=0, size=0;
printf ("Enter the number of thief :");
scanf ("%d",&n);
int amount [n];
for(i=0;i<n;i++){
printf ("Enter the amount theft by the thief number %d:",i+1);
scanf ("%d",& amount[i]);
}
size =sizeof(amount)/sizeof(amount[0]);
for (i=0;i<n;i++)
{
sum=sum+amount [i];
}
avg=sum/size;
for(i=0;i<n;i++){
if (avg<=amount[i])
{
x=x+amount [i];
}
}
printf ("The total amount equal to and more than tha average:%d",x);
}
56 changes: 56 additions & 0 deletions December 06/c_balajisanthanam_ The Lost Algorithm Scrolls.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// Function to check if two words differ by exactly one character
int isOneCharDifference(char *word1, char *word2) {
int diffCount = 0;
int len1 = strlen(word1);
int len2 = strlen(word2);

if (len1 != len2)
return 0; // Words must have the same length

for (int i = 0; i < len1; i++) {
if (word1[i] != word2[i]) {
diffCount++;
if (diffCount > 1)
return 0; // More than one difference found
}
}

return diffCount == 1; // Return true if exactly one difference is found
}

// Function to find the optimal sequence of words
void findOptimalSequence(char **words, int n) {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (isOneCharDifference(words[i], words[j]))
printf("%s -> %s\n", words[i], words[j]);
}
}
}

int main() {
int numWords;
printf("Enter the number of encoded words: ");
scanf("%d", &numWords);

char **encodedWords = (char **)malloc(numWords * sizeof(char *));
printf("Enter the encoded words:\n");
for (int i = 0; i < numWords; i++) {
encodedWords[i] = (char *)malloc(50 * sizeof(char)); // Assuming a maximum word length of 50 characters
scanf("%s", encodedWords[i]);
}

findOptimalSequence(encodedWords, numWords);

// Free allocated memory
for (int i = 0; i < numWords; i++) {
free(encodedWords[i]);
}
free(encodedWords);

return 0;
}
34 changes: 34 additions & 0 deletions December 07/c_balajisanthanam205_Baby Blocks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdbool.h>
#include <math.h>

// Function to check if the rectangle can fit inside the circle
bool rectangleInCircle(int width, int height, int radius) {
// Calculate the diagonal of the rectangle using the Pythagorean theorem
double diagonal = sqrt(width * width + height * height);

// Check if the diagonal is less than or equal to the diameter of the circle (2 * radius)
return (diagonal <= 2 * radius);
}

int main() {
int rectangleWidth, rectangleHeight, circleRadius;

// Get input from the user
printf("Enter the width of the rectangle: ");
scanf("%d", &rectangleWidth);

printf("Enter the height of the rectangle: ");
scanf("%d", &rectangleHeight);

printf("Enter the radius of the circle: ");
scanf("%d", &circleRadius);

// Check if the rectangle can fit inside the circle
bool result = rectangleInCircle(rectangleWidth, rectangleHeight, circleRadius);

// Print the result
printf("Result: %s\n", result ? "true" : "false");

return 0;
}
65 changes: 65 additions & 0 deletions December 08/c_balajisanthanam205_The Enchanted Forest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <stdio.h>

// Function to find the magic square for the given odd integer 'n'
void findPath(int n) {
int magicSquare[n][n];

// Initialize the matrix with 0
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
magicSquare[i][j] = 0;

int i = n / 2;
int j = n - 1;

// Fill the matrix with numbers according to the rules
for (int num = 1; num <= n * n;) {
if (i == -1 && j == n) {
j = n - 2;
i = 0;
} else {
if (j == n)
j = 0;

if (i < 0)
i = n - 1;
}

if (magicSquare[i][j] != 0) {
j -= 2;
i++;
continue;
} else {
magicSquare[i][j] = num++;
}

j++;
i--;
}

// Print the magic square
for (int x = 0; x < n; x++) {
for (int y = 0; y < n; y++)
printf("%4d", magicSquare[x][y]);
printf("\n");
}
}

int main() {
int n;

// Get input from the user
printf("Enter an odd integer (3 <= n <= 15): ");
scanf("%d", &n);

if (n % 2 != 1 || n < 3 || n > 15) {
printf("Invalid input. Please enter an odd integer between 3 and 15.\n");
return 1;
}

// Call the function to find and print the magic square
findPath(n);

return 0;
}