数据结构D1作业

#include<stdio.h>

#include<string.h>

typedef struct stu

{

char name[20];

double height;

int score;

}stu,*stu_p;

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

{

int i=0;

int j=0;

char temp_name[20]="";

int temp_score=0;

double temp_height=0;

stu arr[7]={};

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;

}

相关推荐
睡不醒的kun1 小时前
leetcode算法刷题的第三十二天
数据结构·c++·算法·leetcode·职场和发展·贪心算法·动态规划
_OP_CHEN3 小时前
数据结构(C语言篇):(十二)实现顺序结构二叉树——堆
c语言·数据结构·算法·二叉树·学习笔记··顺序结构二叉树
cellurw5 小时前
EDID 数据结构解析与编辑工具:校验和计算、厂商/设备名编解码、物理地址读写、颜色与时序信息提取
数据结构
Pluchon6 小时前
硅基计划3.0 Map类&Set类
java·开发语言·数据结构·算法·哈希算法·散列表
重生之我是Java开发战士7 小时前
【数据结构】Java集合框架:List与ArrayList
java·数据结构·list
爱干饭的boy7 小时前
手写Spring底层机制的实现【初始化IOC容器+依赖注入+BeanPostProcesson机制+AOP】
java·数据结构·后端·算法·spring
躲在云朵里`8 小时前
Redis深度解析:核心数据结构、线程模型与高频面试题
数据结构·数据库·redis
wangwangblog10 小时前
LLVM 数据结构简介
开发语言·数据结构·c++
平平无奇。。。13 小时前
解密完全二叉树顺序存储之堆结构
c语言·数据结构·visual studio