-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path59A.c
More file actions
51 lines (45 loc) · 1.12 KB
/
59A.c
File metadata and controls
51 lines (45 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Codeforces link: https://codeforces.com/problemset/problem/59/A
#include <stdio.h>
int main()
{
char word[101];
printf("Enter a word: ");
scanf("%s", word);
int uppercaseCount = 0;
int lowercaseCount = 0;
// Count the number of uppercase and lowercase letters
for (int i = 0; word[i] != '\0'; i++)
{
if (word[i] >= 'A' && word[i] <= 'Z')
{
uppercaseCount++;
}
else if (word[i] >= 'a' && word[i] <= 'z')
{
lowercaseCount++;
}
}
// Determine the corrected word based on the counts
if (uppercaseCount > lowercaseCount)
{
for (int i = 0; word[i] != '\0'; i++)
{
if (word[i] >= 'a' && word[i] <= 'z')
{
word[i] -= 32; // Convert to uppercase using ASCII values
}
}
}
else
{
for (int i = 0; word[i] != '\0'; i++)
{
if (word[i] >= 'A' && word[i] <= 'Z')
{
word[i] += 32; // Convert to lowercase using ASCII values
}
}
}
printf("%s", word);
return 0;
}