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

}

相关推荐
旖旎夜光2 小时前
LeetCode 11:盛最多水的容器(双指针问题) —— 题解
数据结构·c++·算法·leetcode·双指针
不一样的故事1264 小时前
芯片设计是一个高度复杂、分工精细的系统工程
数据结构·经验分享
梁辰兴5 小时前
软件工程:面向数据结构的设计方法
数据结构·软件工程·梁辰兴·面向数据结构的设计方法·jackson方法·warnier方法·方法比较
白狐_7985 小时前
408数据结构第7章:查找②——顺序、折半、分块查找秒杀 + 真题
数据结构·算法
hold?fish:palm6 小时前
链表的基本原理和实现(C++版本)
数据结构·c++·链表
码完就睡7 小时前
数据结构——树、二叉树基础概念
数据结构·算法
疯狂打码的少年8 小时前
【数据结构】栈:定义、顺序栈与链式栈
数据结构·笔记
wabs6669 小时前
关于图论【最短路径之Bellman_ford 算法|卡码网94.城市间货物运输的思考】
数据结构·算法·图论·卡码网·bellman_ford·求最短路径
今日无bug9 小时前
JS 数据类型 + 内存分配:从 8 种类型到栈堆模型
javascript·数据结构
wabs6669 小时前
关于哈希表【力扣454.四数相加II的思考】
数据结构·算法·leetcode·散列表