第一道题:疫苗接种 AC
#include <iostream>
#include <algorithm>
using namespace std;
int a, b, c;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
scanf("%d-%d-%d", &a, &b, &c);
if (a%4==0&&a%100!=0 || a%400==0) days[2] = 29;
c += 14;
if (c > days[b]) c -= days[b], b++;
if (b > 12) b = 1, a += 1;
printf("%d-%d-%d", a, b, c);
return 0;
}
第二道题:空心正方形 AC
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i==1 || i==n || j==1 || j==n) printf("*");
else printf(" ");
}
puts("");
}
return 0;
}