结构体类型

//结构体类型

// 

#include<stdio.h>

#pragma warning(disable : 4996)

struct point  //声明结构类型
{
    int x;
    int y;
};

int main()
{
    struct date     //声明结构类型
    {
        int month;
        int day;
        int year;
    };

    struct date today;  //定义结构体变量

    today.month = 07;
    today.day = 31;
    today.year = 2021;


    struct point p1, p2;  //定义结构体变量
    p1.x = 3;
    p1.y = 6;
    p2.x = 2;
    p2.y = 4;

    printf("p1 x = %d\n", p1.x);
    printf("p1 y = %d\n", p1.y);
    printf("p2 x = %d\n", p2.x);
    printf("p2 x = %d\n", p2.y);

    printf("Today's date is %i-%i-%i.\n", today.day, today.month, today.year);
    return 0;

    
}

posted @ 2021-12-27 10:00  江南王小帅  阅读(111)  评论(0)    收藏  举报