#24120: 要怎麼修改 才不會TLE


es911080 (Jiahaw)


#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
   int n;
    cin >>n;
    while(n%10==0){
        n=n/10;
}
    while(n>0){
        cout <<n%10;
        n=n/10;
    }

    return 0;
}

#26057: Re: 要怎麼修改 才不會TLE


1066108@tjps.tp.edu.tw (Sunday)


 while(n%10==0){

        n=n/10;
}

這段會有無盡迴圈的問題(若n=0),需要在迴圈內另外判斷n是否等於0,若是直接輸出0即可。