题解 | 找x
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main() {
    int n;
    int arr[200] = {0};
    int tofind; // 带寻找的元素
    while (cin >> n) {
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        cin >> tofind;
        int idx;
        for (idx = n - 1; idx >= 0; idx--)
            if (arr[idx] == tofind)
                break;
        cout << idx << endl;
    }
    return 0;
}
查看14道真题和解析