/
ch-1.cpp
executable file
·34 lines (33 loc) · 922 Bytes
/
ch-1.cpp
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
#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>
#include <vector>
int main( ) {
std::cout << "Enter a word!\n" ;
std::string word ;
std::cin >> word ;
std::vector<char> uppers ;
std::copy_if( word.begin( ) , word.end( ) , std::back_inserter(
uppers ) , []( char c ) {return std::isupper( c ) ; } ) ;
if ( uppers.size( ) > 0 ) {
std::vector<char> selected ;
for ( auto it = uppers.begin( ) ; it != uppers.end( ) ; it++ ) {
if ( word.find( std::tolower( *it ) ) != std::string::npos ) {
selected.push_back( *it ) ;
}
}
if ( selected.size( ) > 0 ) {
std::sort( selected.begin( ) , selected.end( ) , []( char a ,
char b ) { return a > b ; } ) ;
std::cout << selected[0] << '\n' ;
}
else {
std::cout << "''\n" ;
}
}
else {
std::cout << "''\n" ;
}
return 0 ;
}