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

}

相关推荐
奋发向前wcx7 小时前
P2590 树的统计 题目解析
数据结构·算法·深度优先
额鹅恶饿呃9 小时前
C语言中的数据结构和变量
c语言·数据结构·算法
万法若空10 小时前
【数据结构-哈希表】哈希表原理
数据结构·算法·散列表
tachibana211 小时前
hot100 翻转二叉树(226)
java·数据结构·算法·leetcode
兰令水11 小时前
leecodecode【面试150】【2026.7.9打卡-java版本】
java·数据结构·leetcode·面试·职场和发展
A.零点13 小时前
期末复习,408考研数据结构:第一章绪论完整知识梳理与真题深度解读
c语言·数据结构·笔记·考研
阿文的代码库14 小时前
经典算法题剖析:按奇偶排序数组
数据结构·算法
玛卡巴卡ldf17 小时前
【LeetCode 手撕算法】(细节知识点总结)
java·数据结构·算法·leetcode·力扣
Yang_jie_0318 小时前
笔记:数据结构(链队列的相关判断条件)
数据结构·笔记
zmzb010320 小时前
C++课后习题训练记录Day154
数据结构·c++·算法