Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
請定義具有red, orange, yellow, green, blue, violet六種顏色的枚舉類型color,根據輸入的顏色名稱,輸出以下六種植物花朵的顏色:
Rose(red), Poppies(orange), Sunflower(yellow), Grass(green), Bluebells(blue), Violets(violet)。如果輸入的顏色名稱不在枚舉類型color中,例如輸入purple,請輸出I don't know about the color purple.
Input
輸入數據有多行,每行有一個字符串代表顏色名稱,顏色名稱最多30個字符,直到文件結束爲止。
Output
輸出對應顏色的植物名稱,例如:Bluebells are blue. 如果輸入的顏色名稱不在枚舉類型color中,例如purple, 請輸出I don't know about the color purple.
Example Input
Example Output
Bluebells are blue.
Sunflower are yellow.
I don't know about the color purple.
Hint
請用枚舉類型實現。
Author
lxh
參考代碼
#include<stdio.h>
int main()
{
char s[50];
while(~scanf("%s",s))
{
if( strcmp(s,"red") == 0 )
printf("Rose are red.\n");
else if( strcmp(s,"orange") == 0 )
printf("Poppies are orange.\n");
else if( strcmp(s,"yellow") == 0)
printf("Sunflower are yellow.\n");
else if( strcmp(s,"green") == 0 )
printf("Grass are green.\n");
else if( strcmp(s,"blue") == 0 )
printf("Bluebells are blue.\n");
else if( strcmp(s,"violet") == 0 )
printf("Violets are violet.\n");
else
printf("I don't know about the color %s.\n",s);
}
return 0;
}