aboutsummaryrefslogtreecommitdiff
path: root/challenge-190/ulrich-rieke/cpp/ch-1.cpp
blob: c013223bfe91945ba1778ced733595f1bbe20122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

int main( ) {
  std::cout << "Please enter a word!\n" ;
  std::string line ;
  std::cin >> line ;
  if ( (std::isupper( static_cast<int>( line[0] )) &&
    std::all_of( line.begin( ) + 1 , line.end( ) , []( char c )
      {return std::islower( static_cast<int>( c )) ; } )) ||
    std::all_of( line.begin( ) , line.end( ) , []( char c )
        { return std::isupper( static_cast<int>( c )) ; }) ||
    std::all_of( line.begin( ) , line.end( ) , []( char c )
        { return std::islower( static_cast<int>( c )) ; }) )
    std::cout << 1 ;
  else
      std::cout << 0 ;
  std::cout << std::endl ;
  return 0 ;
}