首页 > 其他 > 详细

__int128使用

时间:2018-10-06 11:27:13      阅读:877      评论:0      收藏:0      [点我收藏+]

输入输出模板

__int128无法使用cincout进行输入输出,所以只能自己写一个输入输出的模板:

技术分享图片
#include <bits/stdc++.h>

using namespace std;
 
void scan(__int128 &x)//输入
{
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == -) f = -f;
    else x = x*10 + ch-0;
    while((ch = getchar()) >= 0 && ch <= 9)
        x = x*10 + ch-0;
    x *= f;
}
void _print(__int128 x)
{
    if(x > 9) _print(x/10);
    putchar(x%10 + 0);
}
void print(__int128 x)//输出
{
    if(x < 0)
    {
        x = -x;
        putchar(-);
    }
    _print(x);
}
int main()
{
    __int128 a, b;
    scan(a); scan(b);
    print(a + b);
    return 0;
}
View Code

[注]:只能在Linux环境下使用__int128,具体参考参考1


参考

参考1

 

__int128使用

原文:https://www.cnblogs.com/solvit/p/9746808.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!