问题及代码
Description
输出n个字符串,把其中以字母A打头的字符串输出。
Input
第一行 n
第二行到第n+1行,每行一个字符串
Output
A打头的字符串
Sample Input
3
Ada
Bob
Alice
Sample Output
Ada
Alice
/*烟台大学计算机学院 2016
作者: 马春澎
完成日期:2016年12月23日 */
#include <stdio.h>
#include <stdlib.h>
int main()
{
char s[80][80];
int i,n,j;
scanf("%d",&n);
for(i=0; i<n; i++)
scanf("%s",s[i]);
for(i=0; i<n; i++)
{
for(j=0; s[i][j]!='\0'; j++)
{
if(s[i][0]=='A'||s[i][0]=='a')
{
printf("%s\n",s[i]);
break;
}
}
}
return 0;
}
运算结果
知识点总结
字符串的应用
学习心得
这道题目与以前做的输出带有B的字符串十分相似,不过做题时要看清题目,这是很关键的。