样例过了,但零分

P5705 【深基2.例7】数字反转

Nian_Gao @ 2023-09-29 13:10:49

代码:

#include<bits/stdc++.h>

using namespace std;

string s;
int main(){

    cin >> s;
    for(int i = s.size();i >= 0;i--){
        cout << s[i];
    }   

    return 0;
}

by hexuchen @ 2023-09-29 13:13:50

@Nian_Gao 字符串的下标最大只有s.size()-1


by hexuchen @ 2023-09-29 13:14:44

@Nian_Gao

#include<bits/stdc++.h>

using namespace std;

string s;
int main(){

    cin >> s;
    for(int i = s.size()-1;i >= 0;i--){
        cout << s[i];
    }   

    return 0;
}

by hexuchen @ 2023-09-29 13:15:22

求关注~


by Nian_Gao @ 2023-09-29 13:20:13

谢谢大佬


|