结构体

/* Note:Your choice is C IDE */
#include "stdio.h"
#include "string.h"
/*define a struct type */
struct student {
	int no;     
	int age;      /*结构体类型的定义*/
	int score;
	};
main()
{ 
   int i;
   int age[3]={17,18,19};
   int *pi;
   
   
   struct student info13[45];
   struct student *stu;
   
   pi=ages;
   stu=info13;
   
   
   
   
   printf("%d\n",ages[1]);
   printf("%d\n",*(pi+1));
   
   
   for(i=0;i<45;i++){
      info13[i].no=i+1;
      info13[i].age=ages[i%3];
   }
   printf("no1: %d\n",info13[0].no);
   printf("no1: %d\n",(*stu).no);
   printf("no1: %d\n",stu-> no);
}
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "string.h"
/*define a struct type */
struct student {
	int no;     
	int age;      /*结构体类型的定义*/
	int score;
	};
main()
{ 
   int i;
   int age[3]={17,18,19};
   
   struct student info13[45];
   
   for(i=0;i<45;i++){
      info13[i].no=i+1;
      info13[i].age=ages[i%3];
   }
   for(i=0;i<45;I++){
   	printf("%d-no:%d-age:%d\n",i,info13[i].no,info13[i].age);
   
}

/* Note:Your choice is C IDE */
#include "stdio.h"
#include "string.h"
/*define a struct type */
struct student {
	int no;     
	int age;      /*结构体类型的定义*/
	int score;
	};
main()
{
  struct student cc;   /*变量的定义*/
  cc.no=20;
  cc.age=19;           /*变量的赋值*/
  cc.score=100;
  
  printf("cc: %d %d %d \n",cc.no,cc.age,cc.score);  
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值