码迷,mamicode.com
首页 > 其他好文 > 详细

__int128输出

时间:2019-10-13 12:37:48      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:int   div   str   cout   pre   return   stream   ems   for   

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即可。

__int128输出

标签:int   div   str   cout   pre   return   stream   ems   for   

原文地址:https://www.cnblogs.com/St-Lovaer/p/11661639.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!