#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
struct students
{
char name[21];
unsigned int age;
char tel[16];
float scores[3];
char sex;
}stu;
int main1(void)
{
char arr[10] = "abc";
//struct students stu = { "aaa", 20, "13111111111", 100.0f, 200, 300, 'M' };
//struct students stu = { .name = "aaa", .age = 20, .tel = "13111111111", .scores[0] = 100.0f, .scores[1] = 200, .scores[2] = 300, .sex= 'M' };
struct students stu1;
//stu.name = "奸恶蝌蚪";
strcpy(stu.name, "奸恶蝌蚪");
stu.age = 25;
strcpy(stu.tel, "13111111111");
stu.scores[0] = 90;
stu.scores[1] = 91;
stu.scores[2] = 92;
stu.sex = 'M';
printf("姓名:%s\n", stu.name);
printf("年龄;%d\n", stu.age);
printf("电话:%s\n", stu.tel);
printf("成绩:%.1f, %.1f,%f\n", stu.scores[0], stu.scores[1], stu.scores[2]);
printf("性别:%s\n", stu.sex == 'M' ? "男":"女");
/*
姓名:aaa
年龄;20
电话:13111111111
成绩:100.0, 200.0,300.000000
性别:女
请按任意键继续. . .
*/
system("pause");
return EXIT_SUCCESS;
}
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
struct stu1
{
char name[21];
float scores[3];
};
int main2(void)
{
struct stu1 s[3];
for (int i = 0; i < 3; i++)
{
printf("请输入学生姓名 成绩 \n");
scanf("%s%f%f%f", s[i].name, &s[i].scores[0], &s[i].scores[1], &s[i].scores[2]);
}
for (int i = 0; i < 3; i++)
{
printf("排序前%s %.1f %.1f %.1f\n", s[i].name, s[i].scores[0], s[i].scores[1], s[i].scores[2]);
}
/*
请输入学生姓名 成绩
a 10 20 30
请输入学生姓名 成绩
a1 20 30 40
请输入学生姓名 成绩
a2 30 40 50
a 10.0 20.0 30.0
a1 20.0 30.0 40.0
a2 30.0 40.0 50.0
请按任意键继续. . .
*/
for (int i = 0; i < 3-1; i++)
{
for (int j = 0; j < 3 - i - 1; j++)
{
int sum1 = s[j].scores[0]