diff --git a/【实践课内】16.结构体2/7-1 计算职工工资.c b/【实践课内】16.结构体2/7-1 计算职工工资.c new file mode 100644 index 0000000..5c535ce --- /dev/null +++ b/【实践课内】16.结构体2/7-1 计算职工工资.c @@ -0,0 +1,22 @@ +#include + +struct person { + char name[10]; + double basic, floating, outlay; +}; + +int n; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + struct person p; + + scanf("%s %lf %lf %lf", p.name, &p.basic, &p.floating, &p.outlay); + + printf("%s %.2lf\n", p.name, p.basic + p.floating - p.outlay); + } + + return 0; +} diff --git a/【实践课内】16.结构体2/7-1 计算职工工资.jpg b/【实践课内】16.结构体2/7-1 计算职工工资.jpg new file mode 100644 index 0000000..f912f6a Binary files /dev/null and b/【实践课内】16.结构体2/7-1 计算职工工资.jpg differ diff --git a/【实践课内】16.结构体2/7-2 计算平均成绩.c b/【实践课内】16.结构体2/7-2 计算平均成绩.c new file mode 100644 index 0000000..7a4cc9d --- /dev/null +++ b/【实践课内】16.结构体2/7-2 计算平均成绩.c @@ -0,0 +1,32 @@ +#include + +struct student { + char id[10], name[10]; + int score; +}; + +int n; +double avg; +struct student stu[10]; + +int main() { + scanf("%d", &n); + + for (int i = 0; i < n; i++) { + scanf("%s %s %d", stu[i].id, stu[i].name, &stu[i].score); + + avg += stu[i].score; + } + + avg /= n; + + printf("%.2lf\n", avg); + + for (int i = 0; i < n; i++) { + if (stu[i].score < avg) { + printf("%s %s\n", stu[i].name, stu[i].id); + } + } + + return 0; +} diff --git a/【实践课内】16.结构体2/7-2 计算平均成绩.jpg b/【实践课内】16.结构体2/7-2 计算平均成绩.jpg new file mode 100644 index 0000000..06299c6 Binary files /dev/null and b/【实践课内】16.结构体2/7-2 计算平均成绩.jpg differ diff --git a/【实践课内】16.结构体2/7-3 找出总分最高的学生.c b/【实践课内】16.结构体2/7-3 找出总分最高的学生.c new file mode 100644 index 0000000..7e48ba9 --- /dev/null +++ b/【实践课内】16.结构体2/7-3 找出总分最高的学生.c @@ -0,0 +1,34 @@ +#include + +struct student { + char id[10], name[10]; + int score[3]; + int sum_score; +}; + +int n, max_id; +struct student stu[10]; + +int main() { + scanf("%d", &n); + + for (int i = 0; i < n; i++) { + scanf("%s %s", stu[i].id, stu[i].name); + + for (int j = 0; j < 3; j++) { + scanf("%d", &stu[i].score[j]); + + stu[i].sum_score += stu[i].score[j]; + } + } + + for (int i = 1; i < n; i++) { + if (stu[i].sum_score > stu[max_id].sum_score) { + max_id = i; + } + } + + printf("%s %s %d\n", stu[max_id].name, stu[max_id].id, stu[max_id].sum_score); + + return 0; +} diff --git a/【实践课内】16.结构体2/7-3 找出总分最高的学生.jpg b/【实践课内】16.结构体2/7-3 找出总分最高的学生.jpg new file mode 100644 index 0000000..754871f Binary files /dev/null and b/【实践课内】16.结构体2/7-3 找出总分最高的学生.jpg differ diff --git a/【实践课内】16.结构体2/7-4 通讯录的录入与显示.c b/【实践课内】16.结构体2/7-4 通讯录的录入与显示.c new file mode 100644 index 0000000..c28be44 --- /dev/null +++ b/【实践课内】16.结构体2/7-4 通讯录的录入与显示.c @@ -0,0 +1,34 @@ +#include + +struct contact { + char name[15], birthday[15], gender, tel[20], phone[20]; +}; + +int n, k; +struct contact contacts[15]; + +int main() { + scanf("%d", &n); + + for (int i = 0; i < n; i++) { + scanf("%s %s %c %s %s\n", contacts[i].name, contacts[i].birthday, &contacts[i].gender, contacts[i].tel, contacts[i].phone); + } + + scanf("%d", &k); + + for (int i = 0; i < k; i++) { + int x; + + scanf("%d", &x); + + if (x < 0 || x >= n) { + printf("Not Found\n"); + + continue; + } + + printf("%s %s %s %c %s\n", contacts[x].name, contacts[x].tel, contacts[x].phone, contacts[x].gender, contacts[x].birthday); + } + + return 0; +} diff --git a/【实践课内】16.结构体2/7-4 通讯录的录入与显示.jpg b/【实践课内】16.结构体2/7-4 通讯录的录入与显示.jpg new file mode 100644 index 0000000..2981539 Binary files /dev/null and b/【实践课内】16.结构体2/7-4 通讯录的录入与显示.jpg differ