我第一次用c with stl做题

题意很简单,就是反转数字,但末尾的零不能反转.

#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    string in;
    int t;
    cin>>t;
    while (t--) {
        cin>>in;
        auto s=in.begin(),e=in.end();
        if(in[0]=='-'){
            s++;
            e--;
            while(e!=s){
                if(*e=='0'){
                    e--;
                }
                else{
                    break;
                }
            }
            reverse(s, ++e);
            cout<<in<<endl;
        }
        else{
            e--;
            while(e!=s){
                if(*e=='0'){
                    e--;
                }
                else{
                    break;
                }
            }
            reverse(s, ++e);
            cout<<in<<endl;
        }
    }
    return 0;
}

用STL代码确实骚气😎