摘要: 1 /*编写一个学生成绩输出程序,要求:编写一个函数print,打印一个学生的成绩数组,该数组中有5个学生的数据记录,每个记录包括 2 num,name,score[3],主函数已有这些记录,用print函数输出这些记录。 3 */ 4 #include 5 void print(struct Student *p ); 6 struct Student 7 { 8 int num; 9 char name[20];10 float score[3];11 };12 int main(void)13 {14 struct Student stu[5]={101... 阅读全文
posted @ 2013-11-24 01:43 ASMLearner 阅读(799) 评论(0) 推荐(0)
摘要: 1、先用定义变量的方法给出定义体。2、将变量名换为新类型名。3、再用typedef定义新类型名。4、用新类型名去定义新变量。例:1、int a[10]; 2、int array[10]; 3、typedef int array[10]; 4、array n1;定义新结构体:1、先定义结构体struct date{ int year;int month;int day}d;2、定义新的结构变量struct date{ int year;int month;int day}DATE;3、typedef定义新的结构类型typedef struct date{ int year;int mont... 阅读全文
posted @ 2013-11-24 00:29 ASMLearner 阅读(949) 评论(0) 推荐(0)
摘要: 1 #include 2 int main(void) 3 { 4 enum Color {red,yellow,blue,white,black}; 5 int i,j,k; 6 int n=0,pri,loop; 7 for (i=red;i<=black;i++) 8 { 9 for (j=red;j<=black;j++)10 {11 if(i!=j)12 {13 for(k=red;k<=black;k++)14 ... 阅读全文
posted @ 2013-11-24 00:12 ASMLearner 阅读(5664) 评论(0) 推荐(0)
摘要: 1 /*动态链表的建立与输出*/ 2 #include 3 #include 4 #define N sizeof(struct Student) 5 struct Student 6 { 7 int num; 8 float score; 9 struct Student *next;10 };11 void print(struct Student *head);12 struct Student *creat(void);13 int main(void)14 {15 struct Student *pt;16 pt=creat();17 ... 阅读全文
posted @ 2013-11-22 00:16 ASMLearner 阅读(456) 评论(0) 推荐(0)
摘要: 1 #include 2 #define LEN sizeof(struct Student) 3 struct Student 4 { 5 int num; 6 float score; 7 struct Student *next; 8 }; 9 int n=0;10 struct Student *creat()11 {12 struct Student *p1,*p2,*head;13 p1=p2=(struct Student *)malloc(LEN);14 head=NULL;15 printf("请输入学生的学号和成绩,... 阅读全文
posted @ 2013-11-21 23:36 ASMLearner 阅读(275) 评论(0) 推荐(0)
摘要: 1 #include 2 struct Student 3 { 4 int num; 5 float score; 6 struct Student *next; 7 }; 8 int main() 9 {10 struct Student a,b,c,*head,*p;11 a.num=10101;a.score=89.5;12 b.num=10103;b.score=90;13 c.num=10107;c.score=85;14 head=&a;15 a.next=&b;16 b.next=&c;17 ... 阅读全文
posted @ 2013-11-21 20:46 ASMLearner 阅读(260) 评论(0) 推荐(0)
摘要: 1 /*有n个学生的信息(包括学号、姓名、成绩),要求按照成绩的高低顺序输出各学生的信息。*/ 2 #include 3 struct student 4 { 5 int number; 6 char name[20]; 7 int score; 8 }; 9 int main(void)10 { struct student stu[5]={001,"wang",80,002,"zhang",89,003,"wang",60,004,"zhao",97,005,"sun",100};11 st 阅读全文
posted @ 2013-11-21 01:45 ASMLearner 阅读(5549) 评论(0) 推荐(0)
摘要: 1 #include 2 struct leader 3 { 4 char name[20]; 5 int count; 6 }lead[]={"li",0,"wang",0,"zhao",0}; 7 void main(void) 8 { 9 int i,j; char lead1[20];10 printf("Please input the name with \"li\" and \"wang\" or \"zhao\"\n");11 for(i= 阅读全文
posted @ 2013-11-21 00:25 ASMLearner 阅读(445) 评论(0) 推荐(0)
摘要: 1 /*动态定义数组*/ 2 #include 3 #include 4 void main() 5 { 6 int i,n,*p; 7 printf("Please input n:\n"); 8 scanf("%d",&n); 9 p=(int *)malloc(n*sizeof(int));10 for(i=0;i<n;i++)11 p[i]=i*i;12 for(i=0;i<n;i++)13 printf("n=%d\t",p[i]);14 free(p);15 return 0;16 } 阅读全文
posted @ 2013-11-18 00:03 ASMLearner 阅读(202) 评论(0) 推荐(0)
摘要: 动态申请内存空间void malloc(unsigned int n),申请成功则返回空间首地址,反之返回NULL值;void calloc(unsigned int n,int size) 动态申请N个长度为size 的空间; void realloc(void *p,unsigned int size) 改变动态空间大小;释放空间函数free(void *p) 阅读全文
posted @ 2013-11-17 23:45 ASMLearner 阅读(194) 评论(0) 推荐(0)