数据结构D1作业

#include<stdio.h>

#include<string.h>

typedef struct stu

{

char name20;

double height;

int score;

}stu,*stu_p;

int main(int argc, const char *argv\[\])

{

int i=0;

int j=0;

char temp_name20="";

int temp_score=0;

double temp_height=0;

stu arr7={};

stu_p p=arr;

for(i=0;i<7;i++)

{

printf("请输入学生姓名>>");

scanf("%s",(p+i)->name);

printf("请输入学生身高>>");

scanf("%lf",&((p+i)->height));

printf("请输入学生成绩>>");

scanf("%d",&((arr+i)->score));

}

for(i=0;i<6;i++)

{

for(j=0;j<6-i;j++)

{

if((*(p+j)).score>(*(p+j+1)).score)

{

temp_score=(*(p+j)).score;

(*(p+j)).score=(*(p+j+1)).score;

(*(p+j+1)).score=temp_score;

temp_height=(*(p+j)).height;

(*(p+j)).height=(*(p+j+1)).height;

(*(p+j+1)).height=temp_height;

strcpy(temp_name,(p+j)->name);

strcpy((p+j)->name,(p+j+1)->name);

strcpy((p+j+1)->name,temp_name);

}

}

}

for(i=0;i<7;i++)

{

printf("%d\t",(*(p+i)).score);

}

printf("\n");

return 0;

}

相关推荐
nhdh7 小时前
B+树揭秘:MySQL索引核心原理全解析
数据结构·b树·mysql
蛋蛋的就会顺顺的13 小时前
hot100——矩阵
java·数据结构·算法·leetcode·力扣
学代码的CJY14 小时前
从代码出发理解时间复杂度与空间复杂度
数据结构·算法
字节跳动的猫15 小时前
LikeShop 积分体系全链路改造:获取规则、订单抵扣与积分商品兑换二开
运维·数据结构
上位机妹子16 小时前
C 语言 数组删除指定元素(快慢指针法)
c语言·数据结构·算法
C++ 老炮儿的技术栈18 小时前
有符号变量与无符号变量的区别
服务器·开发语言·前端·数据结构·c++·算法·c
keyipatience19 小时前
跳表详细解析
开发语言·数据结构·c++·算法·跳表
小小、码农20 小时前
〖Linux文件系统〗:彻底打通文件 IO 全链路
linux·开发语言·数据结构·c++·系统
INGNIGHT21 小时前
1897 · 会议室 3(扫描线)
数据结构·算法
All for pursuit.21 小时前
【贪心-2】253.会议室 II
数据结构·c++·算法·leetcode