2012年9月6日

枚举

摘要: 1//枚举就是把一个事物所有的取值给一一列举出来2#include<stdio.h>3//只定义了一个数据类型,并没有定义变量,该数据类型的名字是enumWeekDay4enumWeekDay5{6Monday,TuseDay,WednesDay,ThusDay,FriDay,SaturDay,SunDay7};89voidf(enumWeekDayi)10{11switch(i)12{13case0:14printf("周一\n");15break;16case1:17printf("周二\n");18break;19case2:20pri 阅读全文

posted @ 2012-09-06 16:52 Your Song 阅读(132) 评论(0) 推荐(0) 编辑

动态构造存放学生信息的结构体数组,按分数排序输出

摘要: 1/*2动态构造存放学生信息的结构体数组,按分数排序输出3*/4#include<stdio.h>5#include<malloc.h>67structStudent8{9intage;10floatscore;11charname[100];1213};1415intmain(void)16{17inti,j;18intlen;19structStudent*pArr;20structStudentt;//临时变量要定义成structStudentt2122printf("请输入学生的个数:\n");23printf("len=" 阅读全文

posted @ 2012-09-06 14:21 Your Song 阅读(2306) 评论(0) 推荐(0) 编辑

冒泡排序

摘要: /*冒泡排序*/# include <stdio.h>void sort(int * pArr, int len){ int i, j, t; for(i=0; i<len-1; i++) { for(j=0; j<len-1-i; j++) //要弄懂流程,用一个例子来理解。 { if(pArr[j] > pArr[j+1]) { t = pArr[j]; pArr[j] = pArr[j+1]; pArr[j+1]=t; } } } }int main(void){ int a[6] = {10, 2, -4 , 11, 12, 0}; int... 阅读全文

posted @ 2012-09-06 13:39 Your Song 阅读(139) 评论(0) 推荐(0) 编辑

导航