如何用学号去查找成绩

学号 成绩
students[1][1]=001 students[1][2]=78
students[2][1]=002 students[2][2]=65
students[3][1]=003 students[3][2]=23
students[4][1]=004 students[4][2]=34
students[5][1]=005 students[5][2]=56
students[6][1]=006 students[6][2]=87
以下students省略
007 90
008 99
009 45
010 88
011 54
012 95
013 63
014 66
015 89
016 54
017 64
018 77
019 63
020 56
021 5
022 86
023 97
024 94
025 30


#include <iostream>
#include <string>
using namespace std;
int main()
{
    //存储的学号和成绩
    string str[10][2]=
    {
        {"001","78"},
        {"002","65"},
        {"003","80"},
        {"004","78"},
        {"005","73"},
        {"006","75"},
        {"007","77"},
        {"008","69"},
        {"009","88"},
        {"010","99"},
    };
    cout << "请输入学号:" << endl;
    string strNum;
    cin >> strNum;

    for(int i = 0; i < 10; ++i)
    {
        if(str[i][0] == strNum)
        {
            cout << "该学生的成绩为:" << str[i][1] << endl;
            break;
        }
    }
    return 0;
}


你这是二维数组吧 int students[7][2]如果来存储你上面的结构的话,直接按照二维数组遍历后输出就好了
for(int i=0; i<7; i++)
{
if(students[i][0] = 21)
{
printf("%d", students[i][1]);
}
}

n表示学生数目,number表示要找的学生的学号

for (int i = 0; i < n; i++)
    {
        if (strcmp(number,students[i][1])==0)
        {
            cout << students[i][2] << endl;
        }
    }