#include <stdio.h>
#include <string.h>
struct Student
{
int no;
char *name;
char sex;
float score;
};
struct Teacher
{
int no;
char *name;
float salary;
} t1, t2;
struct
{
char *plate_no;
char *brand;
float price;
} car1, car2;
typedef struct OrderEntry
{
int order_no;
int total;
float price;
} order;
struct Date
{
int day;
int month;
int year;
};
struct Person
{
char name[50];
struct Date birthday;
};
int main(int argc, const char *argv[])
{
printf("--------students---------\n");
struct Student stu1;
stu1.no = 1;
stu1.name = "steve";
stu1.sex = 'M';
stu1.score = 100;
printf("no = %d, name = %s, sex = %c, score = %.2f\n", stu1.no, stu1.name, stu1.sex, stu1.score);
printf("--------teachers---------\n");
t1.name = "bob";
t1.no = 1001;
t1.salary = 10000;
t2.name = "lisi";
t2.no = 1002;
t2.salary = 20005;
printf("no = %d, name = %s, salary = %.2f\n", t1.no, t1.name, t1.salary);
printf("no = %d, name = %s, salary = %.2f\n", t2.no, t2.name, t2.salary);
printf("--------cars---------\n");
car1.plate_no = "晋A69888";
car1.brand = "BMW";
car1.price = 598700;
car2.plate_no = "京A88888";
car2.brand = "Mercedes-Benz";
car2.price = 1500000;
printf("plate_no = %s, brand = %s, price = %.2f\n", car1.plate_no, car1.brand, car1.price);
printf("plate_no = %s, brand = %s, price = %.2f\n", car2.plate_no, car2.brand, car2.price);
printf("--------orders---------\n");
order ord1;
ord1.order_no = 9001;
ord1.total = 100;
ord1.price = 900000;
printf("order_no = %d, total = %d, price = %.2f\n", ord1.order_no, ord1.total, ord1.price);
printf("--------people---------\n");
struct Person p1;
strcpy(p1.name, "张三");
p1.birthday.year = 2005;
p1.birthday.month = 9;
p1.birthday.day = 20;
printf("name = %s, birthday = %4d-%02d-%2d\n", p1.name, p1.birthday.year, p1.birthday.month, p1.birthday.day);
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)