From a7484f8c27961c3fce23974d51bf4e6c69178dbf Mon Sep 17 00:00:00 2001 From: p62jhspgx <2736273201@qq.com> Date: Mon, 13 Nov 2023 21:19:07 +0800 Subject: [PATCH] Delete 't4.c' --- t4.c | 74 ------------------------------------------------------------ 1 file changed, 74 deletions(-) delete mode 100644 t4.c diff --git a/t4.c b/t4.c deleted file mode 100644 index 4d12658..0000000 --- a/t4.c +++ /dev/null @@ -1,74 +0,0 @@ -#include -int num[4], Class[4]; -float Maths[4], Physics[4], English[4], sum[4]; -void Swap(int k); -void insert_array(); -int main() -{ - insert_array(); -} -void insert_array() -{ - for (int i = 0; i < 3; i++) - { - scanf("%d%d%f%f%f\n", &num[i], &Class[i], &Maths[i], &Physics[i], &English[i]); - sum[i] = Maths[i] + Physics[i] + English[i]; - } - scanf("%d%d%f%f%f", &num[3], &Class[3], &Maths[3], &Physics[3], &English[3]); - for (int i = 0; i < 3; i++) - { - if (num[i] == num[3]) - { - printf("The student's info has already existed!\n"); - return; - } - } - int inserted_num = num[3]; - sum[3] = Maths[3] + Physics[3] + English[3]; - for (int i = 0; i < 4; i++) - { - for (int j = 3; j > i; j--) - { - if (Class[j] < Class[j - 1]) - { - Swap(j); - } - else if (Class[j] == Class[j - 1]) - { - if (sum[j] > sum[j - 1]) - { - Swap(j); - } - } - } - } - for (int i = 0; i < 4; i++) - { - if (num[i] == inserted_num) - { - printf("%d %d %.1f %.1f %.1f", num[i], Class[i], Maths[i], Physics[i], English[i]); - printf(" inserted\n"); - } - else - { - printf("%d %d %.1f %.1f %.1f\n", num[i], Class[i], Maths[i], Physics[i], English[i]); - } - } -} -void Swap(int k) -{ - int num0 = num[k], Class0 = Class[k]; - float Maths0 = Maths[k], Physics0 = Physics[k], English0 = English[k], sum0 = sum[k]; - num[k] = num[k - 1]; - Class[k] = Class[k - 1]; - Maths[k] = Maths[k - 1]; - Physics[k] = Physics[k - 1]; - English[k] = English[k - 1]; - sum[k] = sum[k - 1]; - num[k - 1] = num0; - Class[k - 1] = Class0; - Maths[k - 1] = Maths0; - Physics[k - 1] = Physics0; - English[k - 1] = English0; - sum[k - 1] = sum0; -} \ No newline at end of file