C语言习题 输出A打头的字符串

Description

输出n个字符串,把其中以字母A打头的字符串输出。

Input

第一行 n
第二行到第n+1行,每行一个字符串

Output

A打头的字符串

Sample Input

3
Ada
Bob
Alice

Sample Output

Ada
Alice


  1. #include
  2. int main()
  3. {
  4.     char a[999];
  5.     int n,i;
  6.     scanf("%d",&n); //输入要字符串的个数n
  7.     for(i=1;i<=n;i++)
  8.     {
  9.         scanf("%s",a); //输入字符串
  10.         if(a[0]=='A') //判断如果字符串的开头为‘A’ 则输出字符串
  11.         {
  12.             puts(a);
  13.         }
  14.   
  15.     }
  16.     return 0;

你可能感兴趣的:(计154第六次)