#include<iostream>
#include<string>
using namespace std;
int main()
{
const int n = 4;
string str[n];
int i;
for (i = 0; i < n; i++)
cin >> str[i];
for (i = 0; i < n; i++)
if (str[i][0] == 'A')
cout << str[i] << " ";
return 0;
}
总结:字符串变量也有数组形式,且它的元素为一个字符串。
字符串数组也有二维数组形式,比如本代码中的str[i][0]表示第i个字符串中的第1个字符。