sdut-1959簡單列舉型別——植物與顏色
阿新 • • 發佈:2019-01-18
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
Example Input
blue yellow purple
Example Output
Bluebells are blue. Sunflower are yellow. I don't know about the color purple.
Hint
請用列舉型別實現。Author
lxh 一道水題。定義一個bool型變數f,賦值false,如果輸入的顏色與列舉的顏色相匹配,賦值true,最後判斷f的值,false時 輸出I don't know about the color....
01 |
#include
<iostream> |
02 |
#include<stdio.h> |
03 |
#include<string.h> |
04 |
using namespace std; |
05 |
enum color |
06 |
{ |
07 |
red,
orange, yellow, green, blue, violet |
08 |
}; |
09 |
char ch[100]; |
10 |
int main() |
11 |
{ |
12 |
13 |
while |