为啥c语言一亚索就无法运行,蓝鸥C语言学习第十一天

#import

typedefstruct student{

char

name[30];

int age;

float

score;

float

height;

float

weight;

int

studentID;

char sex;

float

birthday;

}Student;

// 打印学生数组的方法

void printStudentArray(Student *p ,int

count)

{

printf("姓名\t年龄\t成绩\t\t身高\t\t体重\t\t学号\t\t性别\t\t生日\t\t\n");

for

(int i = 0; i < count;

i++) {

printf("%s\t%d\t%.2f\t\t%.2f\t\t%.2f\t\t%d\t\t%c\t\t%.2f\t\t\n"

, (p+i)->name , (p+i)->age ,

(p+i)->score , (p+i)->height ,

(p+i)->weight , (p+i)->studentID ,

(p+i)->sex , (p+i)->birthday);

}

}

//typedef int ThreeInt (int , int);

// 年龄

BOOL byAge(Student stu1 , Student stu2)

{

return  stu1.age >

stu2.age;

}

// 成绩

BOOL byScore(Student stu1 , Student stu2)

{

return

stu1.score > stu2.score;

}

// 身高

BOOL byHeight(Student stu1 , Student stu2)

{

return

stu1.height > stu2.height;

}

// 体重

BOOL byWeight(Student stu1 , Student stu2)

{

return

stu1.weight > stu2.weight;

}

// 学号

BOOL byStudentID(Student stu1 , Student stu2)

{

return

stu1.studentID > stu2.studentID;

}

// 生日

BOOL byBirthday(Student stu1 , Student stu2)

{

return

stu1.birthday > stu2.birthday;

}

typedef BOOL boolFunctionPoint

(Student , Student);

typedefstruct chieng{

char

hanzi[30];

boolFunctionPoint

*hanshudizhi;

}Chieng;

void sortedAll(Student *stus , int

count , char *name)

{

Chieng age =

{"年龄" , byAge};

Chieng height =

{"身高" , byHeight};

Chieng score =

{"成绩" , byScore};

Chieng studentID =

{"学号" , byStudentID};

Chieng weight =

{"体重" , byWeight};

Chieng birthday =

{"生日" , byBirthday};

Chieng jiegoutiArray[] =

{age , height , score , studentID , weight , birthday};

boolFunctionPoint *p =

nil;

for

(int i = 0; i <

6; i++) {

if (strcmp(name,

jiegoutiArray[i].hanzi) == 0) {

p =

jiegoutiArray[i].hanshudizhi;

break;

}

}

if (p !=

nil) {

for (int i =

0; i < count - 1; i++)

{

for (int j = 0; j

< count - 1 - i; j++) {

if (p(stus[j] ,

stus[j + 1])) {

Student temp;

temp = *(stus + j);

*(stus + j) = *(stus + j + 1);

*(stus + j + 1) = temp;

}

}

}

}

printStudentArray(stus, count);

}

int main(int argc, const

char * argv[]) {

// 准备好一个指针变量出来

Student stu1 =

{"蛮子" , 26 ,

34.6 , 174 , 68 ,

101 , 'm' , 10.12};

Student stu2 =

{"剑圣" , 24 ,

24.6 , 170 , 60 ,

102 , 'm' , 10.11};

Student stu3 =

{"亚索" , 27 ,

64.6 , 179 , 65 ,

125 , 'm' , 10.13};

Student stu4 =

{"薇恩" , 20 ,

84.6 , 171 , 48 ,

134 , 'f' , 10.16};

Student stu5 =

{"石头人" , 50 ,

74.6 , 180 , 100 ,

156 , 'm' , 10.14};

Student stu6 =

{"盖伦" , 29 ,

14.6 , 181 , 70 ,

178 , 'm' , 10.18};

Student stu7 =

{"赵信" , 22 ,

54.6 , 176 , 69 ,

189 , 'm' , 10.15};

Student stu8 =

{"崔斯特" , 30 ,

94.6 , 178 , 66 ,

196 , 'm' , 10.17};

Student students[] = {stu1

, stu2 , stu3 , stu4 , stu5 , stu6 , stu7 , stu8};

sortedAll(students,

8, "身高");

return

0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值