switch和数组两种方法对不同输入做不同响应

#include<stdio.h>

int main(void)

{

    int i;

    scanf("%d",&i);

    switch(i)

        {

            case :

                printf("who\n");

                break;

            case :

                printf("what\n");

                break;

            case :

                printf("when\n");

                break;

            case :

                printf("where\n");

                break;

            case :

                printf("why\n");

                break;

            default:

                printf("don't know\n");

                break;

        }

    return ;

}
#include<stdio.h>

int main(void)

{

    int i;

    char *str[]={"who","what","when","where","why"};

    scanf("%d",&i);

    if(i<=&&i>=)

        printf("%s\n",str[i-]);

    else 

        printf("don't know");

    return ;

}
上一篇:Apache Nginx URL 地址 重写


下一篇:springboot中url地址重写(urlwrite)