本地测试都没错,为什么too many or too few lines

P1307 [NOIP2011 普及组] 数字反转

l57140773 @ 2016-04-14 14:07:19

#include<iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int n , N[15] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} , minus = 0 , i;
    freopen("reverse.in","r",stdin);
    freopen("reverse.out","w",stdout);
    cin >> n;
    if(n < 0) 
    {
        minus = 1;
        n = -n;
    }
    if(n == 0) {cout << 0; return 0;}
    while(n % 10 == 0) n /= 10;
    for(i = 0;n > 0;n /= 10 , i++)
    {
        N[i] = n%10;
    }
    if(minus) cout <<"-";
    for(i = 0; N[i] != -1; i++)
        cout<< N[i];
    fclose(stdin);
    fclose(stdout);
    return 0;
}

by 麻爷在线 @ 2016-04-19 20:30:41

去掉freopen 和 fclose


|