2024年java基础break和continue

java基础break和continueanimals c uses a switch statement include stdio h include ctype h int main void char ch printf Give me a letter of the alphabet and I will give printf an ctype h stdio h

大家好,我是讯享网,很高兴认识大家。



/* animals.c -- uses a switch statement */
#include <stdio.h>
#include <ctype.h>
int main(void)
{
    char ch;    
    printf("Give me a letter of the alphabet, and I will give ");
    printf("an animal name beginning with that letter. ");
    printf("Please type in a letter; type # to end my act. ");
    while ((ch = getchar()) != '#')
    {
        if(' ' == ch)
            continue;
        if (islower(ch))     /* lowercase only          */
            switch (ch)
        {
            case 'a' :
                printf("argali, a wild sheep of Asia ");
                break;
            case 'b' :
                printf("babirusa, a wild pig of Malay ");
                break;
            case 'c' :
                printf("coati, racoonlike mammal "); java基础break和continue
                break;
            case 'd' :
                printf("desman, aquatic, molelike critter ");
                break;
            case 'e' :
                printf("echidna, the spiny anteater ");
                break;
            case 'f' :
                printf("fisher, brownish marten ");
                break;
            default :
                printf("That's a stumper! ");
        }                /* end of switch           */
        else
            printf("I recognize only lowercase letters. ");
        while (getchar() != ' ')
            continue;      /* skip rest of input line */
        printf("Please type another letter or a #. ");
    }                        /* while loop end          */
    printf("Bye!
小讯
上一篇 2024-12-25 22:45
下一篇 2024-12-28 10:43

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/3732.html