#include <string>
#include <cctype>
#include <iostream>
#include <algorithm>
int main( )
{
std:: string str = "loop through a string and uppercase each letter\n " ;
for ( char & c : str ) c = std:: toupper ( c) ; // 1
std:: cout << str ;
for ( std:: string :: iterator iter = str.begin ( ) ; iter ! = str.end ( ) ; ++ iter ) // 2
* iter = std:: tolower ( * iter ) ;
std:: cout << str ;
for ( std:: string :: size_type i = 0 ; i < str.size ( ) ; ++ i ) // 3
str[ i] = std:: toupper ( str[ i] ) ;
std:: cout << str ;
std:: transform ( str.begin ( ) , str.end ( ) , str.begin ( ) , ( int ( * ) ( int ) ) std:: tolower ) ; // 4
std:: cout << str ;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnN0cmluZyBzdHIgPSAibG9vcCB0aHJvdWdoIGEgc3RyaW5nIGFuZCB1cHBlcmNhc2UgZWFjaCBsZXR0ZXJcbiIgOwoKICAgIGZvciggY2hhciYgYyA6IHN0ciApIGMgPSBzdGQ6OnRvdXBwZXIoYykgOyAvLyAxCiAgICBzdGQ6OmNvdXQgPDwgc3RyIDsKCiAgICBmb3IoIHN0ZDo6c3RyaW5nOjppdGVyYXRvciBpdGVyID0gc3RyLmJlZ2luKCkgOyBpdGVyICE9IHN0ci5lbmQoKSA7ICsraXRlciApIC8vIDIKICAgICAgICAgICppdGVyID0gc3RkOjp0b2xvd2VyKCAqaXRlciApIDsKICAgIHN0ZDo6Y291dCA8PCBzdHIgOwoKICAgIGZvciggc3RkOjpzdHJpbmc6OnNpemVfdHlwZSBpID0gMCA7IGkgPCBzdHIuc2l6ZSgpIDsgKytpICkgLy8gMwogICAgICAgICAgc3RyW2ldID0gc3RkOjp0b3VwcGVyKHN0cltpXSkgOwogICAgc3RkOjpjb3V0IDw8IHN0ciA7CgogICAgc3RkOjp0cmFuc2Zvcm0oIHN0ci5iZWdpbigpLCBzdHIuZW5kKCksIHN0ci5iZWdpbigpLCAoIGludCgqKShpbnQpIClzdGQ6OnRvbG93ZXIgKSA7IC8vIDQKICAgIHN0ZDo6Y291dCA8PCBzdHIgOwp9Cg==