您的位置:首页 > 其它

sdut1959简单枚举类型——植物与颜色

2016-11-06 14:58 399 查看
#include <stdio.h>
#include <string.h>
int main()
{
char str[20];
enum color{red,orange,yellow,green,blue,violet};
while (gets(str)!=NULL)
{
if(strcmp(str,"red")==0)
printf("Rose are red.\n");
else if(strcmp(str,"orange")==0)
printf("Poppies are orange.\n");
else if(strcmp(str,"yellow")==0)
printf("Sunflower are yellow.\n");
else if(strcmp(str,"green")==0)
printf("Grass are green.\n");
else if(strcmp(str,"blue")==0)
printf("Bluebells are blue.\n");
else if(strcmp(str,"violet")==0)
printf("Violets are violet.\n");
else
printf("I don't know about the color %s.\n",str);

}
return 0;
}

/***************************************************
User name: TJRAC6015203228魏杰
Result: Accepted
Take time: 0ms
Take Memory: 108KB
Submit time: 2016-10-31 22:04:22
****************************************************/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: