zoukankan      html  css  js  c++  java
  • uva 1203

    简单的优先队列的应用;

    代码:

     1 #include<queue>
     2 #include<cstdio>
     3 using namespace std;
     4 
     5 struct node
     6 {
     7     int num;
     8     int ti;
     9     int period;
    10     bool operator<(const node &t)const
    11     {
    12         if(ti==t.ti)return num>t.num;
    13         return ti>t.ti;
    14     }
    15 };
    16 priority_queue< node >q;
    17 char s[20];
    18 int main()
    19 {
    20     int m;
    21     node a;
    22     while(scanf("%s",&s)&&s[0]!='#')
    23     {
    24         scanf("%d%d",&a.num,&a.period);
    25         a.ti=a.period;
    26         q.push(a);
    27     }
    28     scanf("%d",&m);
    29     while(m--)
    30     {
    31         node k=q.top();
    32         q.pop();
    33         printf("%d
    ",k.num);
    34         k.ti+=k.period;
    35         q.push(k);
    36     }
    37     return 0;
    38 }
    View Code
  • 相关阅读:
    对象拷贝-深拷贝
    eclipse安装桌面快捷方式
    ajax 分页
    单例模式
    过滤器
    ajax参数详解
    json
    反射
    jdbc02
    jdbc --例子7
  • 原文地址:https://www.cnblogs.com/yours1103/p/3385446.html
Copyright © 2011-2022 走看看