⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program_4_10.cpp

📁 c++程序设计讲义 cppprograming 含源码
💻 CPP
字号:
// Program 4.10: Echo input to standard output
// converting uppercase to lowercase along the way
#include <iostream>
#include <string>
using namespace std;
int main() {
    // prepare for processing text
    bool MoreLinesToProcess = true;
    while (MoreLinesToProcess) {
        // process next line
        bool MoreCharactersOnCurrentLine = true;
        cout << "Please type a line of text: ";
        while (MoreCharactersOnCurrentLine) {
            // process next character on current line
            char CurrentCharacter;
            if (cin.get(CurrentCharacter)) {
                // process current character on current line
                if (CurrentCharacter == '\n') {
                    // found newline character that ends line
                    MoreCharactersOnCurrentLine = false;
                }
                else if ((CurrentCharacter >= 'A')
                          && (CurrentCharacter <= 'Z')) {
                    // CurrentCharacter is uppercase
                    CurrentCharacter = CurrentCharacter - 'A' + 'a';
                    cout << CurrentCharacter;
                }
                else {  // nonuppercase character
                    cout << CurrentCharacter;
                }
            }
            else { // no more characters
                MoreCharactersOnCurrentLine = false;
                MoreLinesToProcess = false;
            }
        }
        // finish processing of current line
        cout << endl;
    }
    // finish overall processing
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -