数据结构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;

}

相关推荐
yi0116 小时前
LeetCode 219:存在重复元素 II——哈希表记录“最近一次出现的位置”
数据结构·人工智能·笔记·python·算法·leetcode·哈希表
禾小西9 小时前
Redis 数据结构:快速的 Redis 有哪些慢操作?
数据结构·数据库·redis
H.莓飛9 小时前
【数据结构】二叉树_OJ题
linux·开发语言·数据结构·算法
好想像大佬一样能够ak所有10 小时前
Leetcode35.搜索插入位置
数据结构·算法·leetcode
chenbingjie_c11 小时前
C++ STL 适配器:stack & queue,从 vector/list 到 deque 深度解析
数据结构·c++
垆边人似月.14 小时前
华为OD算法题:查找众数及中位数
数据结构·算法·leetcode
CoderYanger14 小时前
一轮复习——F.动态规划模型总结(入门篇)
java·开发语言·数据结构·算法·leetcode·职场和发展·动态规划
一只旭宝15 小时前
数据结构与算法复习手册:从写过,到讲清楚
开发语言·数据结构·c++·算法
All for pursuit.16 小时前
【动态规划-1】121.买卖股票的最佳时机
数据结构·c++·算法·leetcode·动态规划
Logic10117 小时前
C语言/数据结构位运算题解:异或XOR找出优秀项目组中的“独特编号“——只出现一次的数字
c语言·数据结构·数组·位运算·时间复杂度·算法题·异或性质