【2015蓝桥杯省赛】C++ B组试题
1.奖券数目 作答:52488,正确 #include <iostream> using namespace std; bool check(int x) { int a[10] = { 0 }; while (x) { a[x % 10]++; x /= 10; } if (a[4] != 0)return false; return true; } int main() { int res = 0; for (int i = 10000; i <= 99999; i++) { if (check(i)) { res++; } } cout << res << endl; return 0; } View Code 2.星系炸弹 作答:2017-8-5,正确 算法基本功,日期判断 -_-。 #include <iostream> using namespace std; int main() { //根据2014年的来写的 int days[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 }; int year = 2014, month = 11, day = 9; for (int i = 0; i < 1000; i++) { cout << year << " " << month << " " << day << ": " <