#include<stdio.h>
int *men(int num)
{
int *p=(int *)malloc(sizeof(int)*num);
}
void input(int *p,int n)
{
if(NULL!=p)
{
int i=0;
for(i=0;i<n;i++)
{
scanf("%d", p+i);
}
}
}
void output(int *p, int n)
{
int i = 0;
for(i=0;i<n;i++)
{
printf("%-4d", *(p+i));
}
}
void sort_(int *p, int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(*(p+j)>*(p+j+1))
{
temp = *(p+j);
*(p+j) = *(p+j+1);
*(p+j+1) = temp;
}
}
}
}
void FREE(int *p)
{
if(NULL != 0)
{
free(p);
p = NULL;
}
}
int main()
{
int *p=(mem);
input(p,6);
sort_(p,6);
output(p,6);
printf("\n");
FREE(p);
p = NULL;
return 0;
}
#include<stdio.h>
#include<string.h>
typedef unsigned short int uint16;
typedef int * Ptr_i;
typedef char String[10];
int main()
{
uint16 num=520;
printf("sizeof num=%d\n",sizeof(num));
printf("num=%d\n",num);
Ptr_i p;
printf("sizeof p=%ld\n", sizeof(p));
String s;
strcpy(s,"hello");
printf("s=%s\n", s);
printf("sizeof s=%ld\n",sizeof(s));
printf("strlen s=%ld\n",strlen(s));
return 0;
}
#include<stdio.h>
struct Hero
{
char name[20];
int Hp;
double speed;
char KDA;
}h3={"盖伦", 3500, 500, 5/3/1};
struct Goods
{
char name[30];
char position[30];
float price;
float weight;
};
int main()
{
struct Hero h1={"亚索", 594, 350, 0/8/0};
struct Hero h2={.Hp=2000, .speed=1000};
printf("h1.name=%s\n", h1.name);
printf("h1.Hp=%d\n", h1.Hp);
printf("h1.speed=%lf\n", h1.speed);
printf("h1.KDA=%s\n", h1.KDA);
struct Goods g2;
printf("请输入商品名称:");
gets(g2.name);
printf("请输入商品产地:");
gets(g2,position);
printf("请输入商品价格:");
scanf("%f", &g2.price);
printf("请输入商品重量:");
scanf("%f", &g2.weight);
printf("商品名称:=%s\n",g2.name);
printf("商品产地:=%s\n",g2.position);
printf("商品价格:=%f\n",g2.price);
printf("商品重量:=%f\n",g2.weight);
struct Hero *ptr = (struct Hero*)malloc(sizeof(struct Hero));
strcpy(ptr->name, "亚瑟");
ptr->Hp = 3000;
ptr->speed = 350;
ptr->KDA = 3/7/0;
printf("英雄信息为:%s %d %.2f %s\n", ptr->name, ptr->Hp, ptr=->speed, ptr->KDA);
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/9367ac2877fb4cc6867abc607a77f1d9.png#pic_center)