ACM輸入輸出掛

寫這篇博客不爲什麼,就是是爲了紀念一下我複雜得心情!!!
以下的圖片都是來自同一個水題!!!

scanf和cin+ios::sync_with_stdio(false)輸入

在這裏插入圖片描述

cin+ios::sync_with_stdio(false)+cin.tie(0)+cout.tie(0)輸入;

在這裏插入圖片描述

快讀輸入

在這裏插入圖片描述

快讀+快寫

在這裏插入圖片描述
在這裏給大家找了一個相對快的快讀,見下面。
(如果與哪位老兄的衝突了,還請見諒,當時打開博客太多了,然後全都直接關了,忘了複製鏈接了…)

#include <bits/stdc++.h>
using namespace std;
//快讀
inline int read() {
    int num=0, w=0;
    char ch=0;
    while (!isdigit(ch)) {
        w|=ch=='-';
        ch = getchar();
    }
    while (isdigit(ch)) {
        num = (num<<3) + (num<<1) + (ch^48);
        ch = getchar();
    }
    return w? -num: num;
}
//快寫
inline void write(int x)
{
    if(x<0) {
        putchar('-');
        x = -x;
    }
    if(x>9) write(x / 10);
    putchar(x % 10 + '0');
}


int main(){
    int a;
    a = read();     //讀入到t中
    write(t);       //輸出t
    putchar('\n');
}

下面這個是浮點數的

inline bool scan_lf(double &num)  
{
        char in;double Dec=0.1;
        bool IsN=false,IsD=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&in!='.'&&(in<'0'||in>'9'))
                in=getchar();
        if(in=='-'){IsN=true;num=0;}
        else if(in=='.'){IsD=true;num=0;}
        else num=in-'0';
        if(!IsD){
                while(in=getchar(),in>='0'&&in<='9'){
                        num*=10;num+=in-'0';}
        }
        if(in!='.'){
                if(IsN) num=-num;
                return true;
        }else{
                while(in=getchar(),in>='0'&&in<='9'){
                        num+=Dec*(in-'0');Dec*=0.1;
                }
        }
        if(IsN) num=-num;
        return true;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章