//
// main.m
// C6_结构体
//
// Created by YIem on 15/11/17.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <Foundation/Foundation.h>

// 结构体变量类型声明
// struct 结构体标识
// person 结构体类型名
struct person// 一般使用小写字母
{

// 成员变量
// 类型 变量名;
char name[20];
char sex;
int age;

};

typedef struct person Person;// 重定义为大写Person
// 类型 重定义
// 给一个已经存在的类型 起新的名字
typedef int NewInt;

typedef struct computer {

char brand[20];
char type[20];
float price;

}Computer;// 重定义 为Computer

struct student {

char name[20];
char sex;
int age;
int number;

};
typedef struct student Student;// 重新定义 常用

struct point {

float x;
float y;

};
typedef struct point MyPoint;

// 尺寸结构体
struct size{

float width;
float height;

};
typedef struct size MySize;

// 矩形结构体

struct rect {

MyPoint origin;
MySize size;

};
typedef struct rect MyRect;

// 匿名结构体
struct {

int a;
int b;

}
s1 = {1, 2},
s2 = {3, 4};

//Legend
struct legend {

/// 血量
int hp;
int mp;/**<魔法值*/
int attackDemage;/**<物理伤害*/
int abilityPower;/**<魔法伤害*/

};
typedef struct legend Legend;

int main(int argc, const char * argv[]) {

/*


// 结构体
// 构造类型 用来保存不同类型的数据
    // 结构体三要素: 声明(结构体类型)     定义(结构体变量)        使用(结构体变量中的成员变量)




// 结构体变量定义

// 类型          变量名  初值
int               a  = 100;
NewInt            b  = 100;
struct person marry  = {"Maryy", 'm', 18};
Person        suibian = {"aa", 'f', 200};


struct computer macbook = {"Apple", "laptop"
    , 5000};

struct student ace = {"bianyi", 'm', 10, 30};
struct student m = {"姜泉", 'm', 63, 29};
struct student h = {"姜欢", 'm', 63, 27};

Student bb = {"jj", 'm', 22, 33};
// 结构体的使用
// 结构体变量名.成员变量名 访问每一个数据
strcpy(bb.name, "gg");// 修改 姓名
printf("%s\n", bb.name);// 访问姓名

bb.number = 100;// 修改学号
printf("%d\n", bb.number);// 访问学号

MyRect r1 = {0, 0, 100, 100};
MyRect r2 = {{0, 0}, {100, 100}};
// 访问形式


// 结构体的 整体赋值
// 数组不能整体赋值 可以吧数组放在结构体中 通过结构体整体赋值

Person dawa = {"大娃", 'f', 16};
Person dawa2 = dawa;
int c = 100;
int d = c;
printf("%s\n", dawa2.name);

*/


Legend Garan = {500, 0, 60, 0};
printf("%d", Garan.hp);





return 0;

}