#S0011. 电子宠物
电子宠物
1. Description
Create a virtual pet simulator. Input a series of commands (feed/play/clean/check), update pet status and output results. Initial status:
- Hunger:50 (0-100, higher means hungrier)
- Happiness:50 (0-100)
- Cleanliness:50 (0-100)
Rules:
feed N: Reduce hunger by N (min 0), cleanliness -5play N: Increase happiness by N (max 100), hunger +10clean N: Increase cleanliness by N (max 100)check: Output current status (format: Hunger:{},Happiness:{},Cleanliness:{})
Output "Invalid command" for invalid inputs (negative numbers or unknown commands)
2. Input & Output
Input:
- Multiple commands separated by semicolons
commands = input().split(';')
Output:
- Output status for each
checkcommand, errors for invalid commands
输入输出示例
# 输入:
feed 20;play 5;check
# 输出:
饥饿值:40,快乐值:55,清洁度:45
# 输入:
clean 10;feed -5
# 输出:
指令错误