#include #include

using namespace std;

int main() { string n; int k; cin >> n >> k;

if (k >= 0) {
    if (k > n.length()) {
        cout << "Error" << endl;
    } else {
        cout << n.substr(0, k) << endl;
    }
} else {
    int absK = -k;
    if (absK > n.length()) {
        cout << "Error" << endl;
    } else {
        cout << n.substr(n.length() - absK) << endl;
    }
}

return 0;

}


原文地址: https://www.cveoy.top/t/topic/p83H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录