C数据结构

 

#include 
#include 
#include 
//堆区申请6个int类型空间存放6名学生成绩
//使用函数实现申请空间,输入输出成绩,对其进行升降序,释放空间。
int *neicun(int num)
{
	int *p=(int*)malloc(sizeof(int)*num);
	if(NULL == p){
		printf("卒");
		return NULL;
	}else{
	
		printf("666\n");
		return p;
	}
}
void intput(int *a ,int b){
	int i = 0;
	if(NULL != a){
	
		for(i=0;i*(a+j+1))
			{
				temp = *(a+j);
				*(a+j) = *(a+j+1);
				*(a+j+1) = temp;
			}
		}
	
	}
	printf("排序完成\n");

}
void shuchu(int *a,int b){
	int i = 0;
	for(i=0;i
#include 
#include 
#include 

int *dizhifanhui(){

 	static int a = 666;
	return &a;
		
}



int zhifanhui(){

	int a = 10;
	return a;

}

void dizhichuandi(int *a,int *b){

	int * temp;
	temp = *a;
	*a = *b;
	*b = temp;

}


void zhi111111(int *p,int *q){
	int *temp;
	temp = p;
	p = q;
	q = temp;


}
void zhi(int m,int n){
	int temp;
	temp = m;
	m = n;
	n = temp;

}
int main(int argc, const char *argv[])
{
	int num = 520;
	int mun = 1314;
	zhi(num,mun);
	printf("调用zhi传递函数后主函数中num=%d,mun=%d\n",num,mun);
	zhi111111(&num,&mun);
	printf("调用zhi111111传递函数后主函数中num=%d,mun=%d\n",num,mun);
	dizhichuandi(&num,&mun);
	printf("调用地址传递传递函数后主函数中num=%d,mun=%d\n",num,mun);
	int a = zhifanhui();
	printf("调用值返回%d\n",a);
	printf("值返回%d\n",zhifanhui());
	int *p = dizhifanhui();
	*dizhifanhui() = 777;
	printf("地址返回%d\n",*dizhifanhui());
	return 0;
}
#include 
#include 
#include 
int main(int argc, const char *argv[])
{
	//申请int类型大小
	int *p = (int *)malloc(int);
	//申请int类型大小
	int *p1 =(int *)malloc(sizeof(int));
	//连续申请五个int类型的大小
	int *p2 = (int *)malloc(sizeof(int)*5);

	//释放
	free(p);
		p = NULL;
	free(p1);
		p1 = NULL;
	free(p2);
		p2 = NULL;
	return 0;
}

你可能感兴趣的:(数据结构)