zoukankan      html  css  js  c++  java
  • 【清北学堂 】Day 4 总结

    (tui)了这么多天,终于有时间认(sui)(bian)做做总结了

    随便开始:(反正也没听

    一:读入输出优化

      1 输入优化

         <1>快读   

        废话不多说上代码

    1 inline int read(){
    2    int s=0,w=1;
    3    char ch=getchar();
    4    while(ch<='0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    5    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    6    return s*w;
    7 }
    1 inline void read(long long &x) {
    2     x = 0; char c = getchar();
    3     while(!isdigit(c)) c = getchar();
    4     while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
    5 }

       

     这是2个读入int类型的快读;(好像后一个快一点

            <2> 指令

     ios::sync_with_stdio(false);

        这行代码可以将cin>>a;优化到接近scanf;

      2.输出优化

        较少用(毕竟输出到TXT时间还是比较快的)

     1 void print(int x)
     2 {
     3     if(x<0)//负数
     4     {
     5         putchar('-');
     6         x=-x;
     7     }
     8     if(x>9)//只要x还是2位数或更多就继续分解
     9         print(x/10);
    10     putchar(x%10+'0');//输出(要把int型变为char型,加'0'即可)
    11 }

    二.课件的下载

     

     

  • 相关阅读:
    git
    switch切换
    js object 常用方法总结
    pod install速度慢的终极解决方案
    MacBook Pro 初体验
    LINQ以及LINQ to Object 和LINQ to Entities
    WebService/WCF/WebAPI 之间的区别
    owin
    回车和刷新以及Ctr+F5的区别
    ASP.NET Core 启动流程图
  • 原文地址:https://www.cnblogs.com/luv-letters/p/9337738.html
Copyright © 2011-2022 走看看