Rank

Rank

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4818 Accepted Submission(s): 1364
 
Problem Description
Jackson wants to know his rank in the class. The professor has posted a list of student numbers and marks. Compute Jackson’s rank in class; that is, if he has the top mark(or is tied for the top mark) his rank is 1; if he has the second best mark(or is tied) his rank is 2, and so on.
 
Input
The input consist of several test cases. Each case begins with the student number of Jackson, an integer between 10000000 and 99999999. Following the student number are several lines, each containing a student number between 10000000 and 99999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number.
 
Output
For each test case, output a line giving Jackson’s rank in the class.
 
Sample Input
20070101
20070102 100
20070101 33
20070103 22
20070106 33
0 0
 
Sample Output
2
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct Node
{
    int number;
    int grade;
    Node(){
        number = 0;
        grade = 0;
    }
};
int n;

bool cmp(Node a,Node b)
{
    return a.grade > b.grade;
}

int main()
{
    while (cin >> n) {
        int a,b;
        vector<Node> v1;
        int score;
        while( scanf("%d",&a) && scanf("%d",&b) ){
            if (a == 0 && b == 0) break;
            Node node;
            node.number = a;
            node.grade = b;
            if (a == n) {
                score = b;
            }
            v1.push_back(node);
        }
        sort(v1.begin(),v1.end(),cmp);
        for(int i=0;i<v1.size();i++){
            if(v1[i].grade==score){
                cout<<i+1;break;
            }
        }
        cout<<endl;
    }


    return 0;
}

在IT领域,“rank”有多种含义,以下是一些常见的解释: ### 矩阵的秩 在数学和计算机科学中,特别是在线性代数里,矩阵的秩是矩阵的一个重要属性。矩阵的秩表示矩阵中线性无关的行或列的最大数量。它在解决线性方程组、矩阵分解等问中有着重要应用。例如,在Python的NumPy库中,可以使用`numpy.linalg.matrix_rank()`函数来计算矩阵的秩。 ```python import numpy as np # 创建一个矩阵 matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) # 计算矩阵的秩 rank = np.linalg.matrix_rank(matrix) print("矩阵的秩:", rank) ``` ### 搜索引擎排序 在搜索引擎技术中,“rank”常用来表示网页的排名。搜索引擎会根据一系列算法(如PageRank算法)对网页进行评估和排序,以确定在搜索结果中展示的顺序。PageRank算法由谷歌的创始人拉里·佩奇和谢尔盖·布林提出,它基于网页之间的链接关系来评估网页的重要性。一个网页被其他重要网页链接得越多,它的PageRank值就越高,在搜索结果中的排名可能就越靠前。 ### 数据库排序 在数据库中,“rank”通常用于对查询结果进行排名。例如,在SQL中,可以使用`RANK()`函数为查询结果集中的每一行分配一个排名。以下是一个简单的SQL示例,展示了如何使用`RANK()`函数对学生成绩进行排名: ```sql -- 创建一个示例表 CREATE TABLE students ( id INT, name VARCHAR(50), score INT ); -- 插入示例数据 INSERT INTO students (id, name, score) VALUES (1, 'Alice', 85), (2, 'Bob', 92), (3, 'Charlie', 78), (4, 'David', 92); -- 使用RANK()函数对学生成绩进行排名 SELECT id, name, score, RANK() OVER (ORDER BY score DESC) as ranking FROM students; ``` ### 图论中的节点排名 在图论中,也会涉及到节点的排名。例如,在社交网络分析中,需要对用户节点的重要性进行排名,以找出网络中的关键人物。可以使用一些算法(如HITS算法)来计算节点的权威值和中心值,从而对节点进行排名。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值