hanayo和米饭暴力破解
hanayo和米饭
http://www.nowcoder.com/questionTerminal/5acdfa892af147c6b12a3808d7657686
#include <iostream> using namespace std; void solve() { int n; //碗数量 cin >> n; int* container = new int[n + 1]; //存储米饭粒数的容器 for (int i = 0; i < n + 1; i++) container[i] = i; //对容器赋值,第n个碗装了n粒米 //将输入数据排除(置0) int temp; for (int i = 0; i < n - 1; i++) { cin >> temp; container[temp] = 0; } //遍历容器,不为0的就是拿走的碗里的米饭数量 for (int i = 1; i < n; i++) if (container[i] != 0) cout << container[i]; } int main() { solve(); }