其他分享
首页 > 其他分享> > 实验11-1-3 查找星期 (15 分)

实验11-1-3 查找星期 (15 分)

作者:互联网

#include <stdio.h>
#include <string.h>

#define MAXS 80

int getindex(char *s);

int main()
{
    int n;
    char s[MAXS];

    scanf("%s", s);
    n = getindex(s);
    if (n == -1) printf("wrong input!\n");
    else printf("%d\n", n);

    system("pause");
    return 0;
}

/* 你的代码将被嵌在这里 */
int getindex(char *s) {
    char *days[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    for (int i = 0; i < 7; i++)
        if (strcmp(s, days[i]) == 0)
            return i;
    return -1;
}

 

标签:11,getindex,15,int,char,查找,printf,return,include
来源: https://www.cnblogs.com/Robert-De-Niro/p/15979115.html