为什么通不过呢?

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

freygera @ 2023-03-02 12:09:55

#include<stdio.h>
#include<string.h>
int main()
{
    char a[8]={'\0'};
    gets(a);
    for (int i = strlen(a); i > -1; --i)
    {
        printf("%c", a[i]);
    }
    return 0;

}

by Joseph__Joestar @ 2023-03-02 12:22:24

输出前面有个空格


by Tjaweiof @ 2023-03-08 13:38:16

@freygera 这样试试

#include <bits/stdc++.h>
using namespace std;
int main(){
    char a[6];
    for (int i = 1; i <= 5; i++){
        cin >> a[i];
    }
    for (int i = 5; i >= 1; i--){
        cout << a[i];
    }
    return 0;
}

我觉得这是最水的题^_^


|