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

__int128 输入输出模板

时间:2018-02-22 10:47:58      阅读:1257      评论:0      收藏:0      [点我收藏+]

标签:div   oid   pos   its   post   include   puts   put   get   

 

#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 < 0)
    {
        x = -x;
        putchar(-);
    }
     if(x > 9) print(x/10);
    putchar(x%10 + 0);
}

int main()
{
    __int128 a, b;
    scan(a); scan(b);
    print(a + b);
    puts("");
    print(a*b);
    return 0;
}

 

__int128 输入输出模板

标签:div   oid   pos   its   post   include   puts   put   get   

原文地址:https://www.cnblogs.com/TQCAI/p/8458047.html

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