知识库

C++语言开发示例:11. 条件语句

2025-02-01 20:28:27 李腾 1 次阅读

if.cpp

#include <iostream>

int main()
{
    using std::cin;
    using std::cout;
    char ch;
    int spaces = 0;
    int total = 0;
    cin.get(ch);
    while (ch != '.')
    {
        if (ch == ' ')
            ++spaces;
        ++total;
        cin.get(ch);
    }
    cout << spaces << " spaces, " << total;
    cout << " characters total in sentence\n";
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:11. 条件语句

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!