This commit is contained in:
2025-04-21 20:10:45 +08:00
parent 849819dff3
commit 9a7e511c12
7 changed files with 209 additions and 7 deletions
+29
View File
@@ -0,0 +1,29 @@
#include <stdio.h>
#define INT32_MIN (-2147483647 - 1)
#define for_i(i, range, inner) \
{ \
int i; \
for (i = 0; i < range; i++) \
inner; \
}
typedef struct {
int x;
int y;
int z;
} Point3D;
int main() {
Point3D max = {INT32_MIN, INT32_MIN, INT32_MIN};
Point3D input;
int n = 0;
scanf("%d", &n);
for_i(i, n, {
scanf("%d %d %d", &input.x, &input.y, &input.z);
if (input.z > max.z) {
max = input;
}
});
printf("%d %d %d\n", max.x, max.y, max.z);
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
#include <string.h>
#include <stdio.h>
typedef struct {
char areaCode[10];
char exchangeCode[40];
} PhoneNumber;
int main() {
PhoneNumber a, b;
scanf("%s %s", a.areaCode, a.exchangeCode);
scanf("%s %s", b.areaCode, b.exchangeCode);
if (strcmp(a.areaCode, b.areaCode) == 0) {
printf("%s", b.exchangeCode);
} else {
printf("%s%s", b.areaCode, b.exchangeCode);
}
return 0;
}
+70
View File
@@ -0,0 +1,70 @@
#include <stdio.h>
#define for_i(i, range, inner) \
{ \
int i; \
for (i = 0; i < range; i++) \
inner; \
}
typedef struct {
int year;
int month;
int day;
} Date;
int is_leap_year(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
return 1;
} else {
return 0;
}
}
int get_day_of_month(int year, int month) {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
return is_leap_year(year) ? 29 : 28;
default:
return -1;
}
}
int main() {
Date date1, date2;
int diff = 0;
scanf("%d %d %d", &date1.year, &date1.month, &date1.day);
scanf("%d %d %d", &date2.year, &date2.month, &date2.day);
for_i(i, date1.month - 1, { diff += get_day_of_month(date1.year, i + 1); })
diff += date1.day - 1;
for_i(i, date2.month - 1, { diff -= get_day_of_month(date2.year, i + 1); })
diff -= date2.day - 1;
{
int year_max = date1.year > date2.year ? date1.year : date2.year;
int year_min = date1.year < date2.year ? date1.year : date2.year;
int sign = date1.year > date2.year ? 1 : -1;
int i;
for (i = year_min; i < year_max; i++) {
diff += sign * (is_leap_year(i) ? 366 : 365);
}
}
if (diff < 0) {
diff = -diff;
}
printf("%d\n", diff);
return 0;
}