A - Word
Problem Link: [Codeforces 59A##link##]
- [tab]
- C++
#include <iostream> #include <string> #include <cstdlib> #include <ctime> #include <random> #include <cmath> using namespace std; int main() { int n=0; string word; cin >> word; for(char c: word) { if (islower(c)) n++; else n--; } for(char c : word) { if(n>=0) cout << (char)tolower(c); else cout << (char)toupper(c); } }
- Python3
word = input() lower = 0 upper = 0 for char in word: if char.isupper(): upper += 1 else: lower += 1 if upper > lower: word = word.upper() else: word = word.lower() print(word)
- JAVA
import java.util.*; public class JavaApplication70 { public static void main(String[] args) { Scanner in=new Scanner(System.in); String s=in.next(); char[]a=s.toCharArray(); int count=0,cou=0; for (int i = 0; i < a.length; i++) { if(a[i]>=65&&a[i]<=90) count++; else if(a[i]>=97&&a[i]<=122) cou++; } if(count>cou) System.out.println(s.toUpperCase()); else System.out.println(s.toLowerCase()); } }