BC46-判断是元音还是辅音

目录

        1.思路解析

        2.代码实现

        3.实现知识


        1.思路解析

                首先,用一个数组来。接收判断信息(A,E,I,O,U,a,e,i,o,u),用循环实现连续输入

        (注意:输入的是字符所以要回车也会被当做字符接收进去)而后判断元音还是辅音

        2.代码实现

#include <stdio.h>
int main()
{
    char i = 0;
    char ch[] = { 'A','E','I','O','U','a','e','i','o','u' };
    
    while ((scanf("%c", &i)) != EOF)
    {
        while (1)
        {
           char b=getchar();
            break;
        }
        int a = 0;
        for (a = 0; a < 10; a++)
        {
        if (i == ch[a])
        {
            printf("元音\n");
            break;
        }

        }
        if (a == 10)
        {
        printf("辅音\n");
        }
    }
}

        3.实现知识

            判断语句

            for循环遍历数组的每一个数

        ​​​​​​​     通过循环来实现连续输入

        ​​​​​​​     getchar()读取最后'\n'的字符防止代码出错误

扫描二维码关注公众号,回复: 13302579 查看本文章

猜你喜欢

转载自blog.csdn.net/weixin_60359155/article/details/121398330