阅读程序 · 答案 It has 18 lowercases · 考点:输入输出、位运算、分支结构、循环结构、字符串(string)
← 整套速查表 NOIP 普及组初赛 全部真题阅读程序写结果:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
int i;
int count; count = 0;
getline( cin, str );
for ( i = 0; i < str.length(); i++ )
if ( str[i] >= 'a' && str[i] <= 'z' )
count++;
cout << "It has " << count << " lowercases" << endl; return(0);
}输入:NOI2016 will be held in Mian Yang. 输出:_______
看到统计小写字母 → 只数 a~z,忽略大小写、数字、标点。
别把大写字母或数字误判;输出格式固定,只填中间数字。
考点:字符串遍历|字符范围判断
读取一行文本,逐个字符判断是否属于小写字母(a~z),统计数量后按固定格式输出。