//递归函数
/*
int remul(int num){
if (num<=1) {
return 1;
}
else{
return num*remul(num-1);
}
}
*/
//这就是一个结构体
//这只是一个类型
/*
struct point{
float x;//x轴
float y;//y轴
};
*/
//矩形
/*
struct rect{
float x;
float y;
float length;
float width;
};
struct student{
char name[20];
int age;
char sex[4];
char number[40];
};
//给数据类型起名字.
typedef int age;
typedef float num1;
typedef double num2;
typedef char name;
//简化结构体
typedef struct student stu;
//简化数组定义
typedef char array[10];
**/
/*
struct student1{
char name[20];
int fen;
int age;
};
typedef struct student1 sstu;
typedef int fenshu;
typedef int nianling;
*/
/*
struct test{
int a;
int b;
char c;
char d;
char e;
char f;
char r;
double k;
};
*/
/*
struct point {
float a;
float b;
};
typedef struct point point;
struct kg{
float x;
float y;
};
typedef struct kg kuangao;
struct juxing{
point p;
kuangao kgao;
};
*/
//学生机构体
/*
struct student{
char name[20];
int age;
// char sex[5];
};
typedef struct student std;
*/
/*
struct student{
char name [20];
int fenshu;
};
typedef struct student student;
*/
//赋初值
struct point p={10.0,20.0};
//修改值
p.x=30.0;
p.y=40.0;
printf("x=%f,y=%f",p.x,p.y);
unsigned long i=sizeof(struct test);
printf("%ld",i);
*/
/*
//赋初值的语法.如果赋完初值,就不可以再用这种语法
point p={10.0,20.0};
kuangao s={10.0,22.0};
//嵌套结构体的初始化方式,第一种
// struct juxing r={{10.0,20.0},{11.0,23.0}};
//第二种
struct juxing r1={p,s};
r1.p.a=10.0;
r1.p.b=12.0;
r1.kgao.x=13.0;
r1.kgao.y=15.0;
//折半查找
/*
int a[10]={1,3,5,7,9,11,13,15,17,19};
int first=0;
int last=9;
int mid=(first+last)/2;
int temp=19;
while (first<=last) {
if (a[mid]==temp) {
printf("找到了,第%d位置",mid);
break;
}
else{
if (temp<a[mid]) {
last=mid-1;
mid=(first+last)/2;
}
if (temp>a[mid]) {
first=mid+1;
mid=(first+last)/2;
}
}
}
if (first>last) {
printf("sorry,i can't find it");
}
*/