__int128输出

ostream& operator<<(ostream& os, __int128 t) {
    if (t==0) return os << "0";
    if (t<0) {
        os<<"-";
        t=-t;
    }
    int a[50],ai=0;
    memset(a,0,sizeof a);
    while (t!=0){
        a[ai++]=t%10;
        t/=10;
    }
    for (int i=1;i<=ai;i++) os<<abs(a[ai-i]);
    return os<<"";
}

使用cout即可。

posted @ 2019-10-13 11:58  Lovaer  阅读(422)  评论(0编辑  收藏  举报