PTA(3+2)专科段数据结构题 61-65

本文涵盖了PTA专科段数据结构的五道题目,包括懒虫小鑫问题、队列基本操作、One Way In, Two Ways Out、程序设计综合实践1.4以及先序和中序构造二叉树。每道题目都提供了相应的代码实现。" 133967587,8753399,PCL实战:点云不变估计算法实现,"['点云', '3D重建', '计算机视觉', '算法实现', 'PCL库']
摘要由CSDN通过智能技术生成

7-61  懒虫小鑫

代码:

正确代码:#include <stdio.h>
#include <stdlib.h>
struct node
{
    int x;
    int y;
}a[100100];
int sum;
int cmp(struct node* a,struct node* b)
{
    if(a->x==b->x)
    {
        return (*a).y<(*b).y?1:0;
    }
    else
    {
        return (*a).x>(*b).x?1:0;
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
    }
    qsort(a,n,sizeof(struct node),cmp);
    int sum=0;
    for(int i=0;i<m;i++)
    {
        sum+=a[i].y;
    }
    printf("%d",sum);
    return 0;
}


7-62 队的基本操作

代码:

#include<iostream>
using namespace std;
#define ERROR 0
#define OK 1
#define MAXQSIZE 10
typedef int QElemType;
typedef int Status;
typedef struct{
    QElemType *base;
    int rear;
    int front;
}SqQu
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值