zoukankan      html  css  js  c++  java
  • 读入输出优化

    读入优化(int)

    1 inline int getint()
    2 {
    3   int x=0,f=1;char ch=getchar();  
    4   while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    5   while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    6   return x*f;
    7 }

    读入优化(long long)

    1 inline int getLL()
    2 {
    3   long long x=0,f=1;char ch=getchar();  
    4   while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    5   while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    6   return x*f;
    7 }

    读入优化(string,char)

    1 inline char Getstring()
    2 {
    3   char s=getchar(); 
    4   while (s!='i'&&s!='u') s=getchar();
    5   for (char ch=getchar();ch!=' ';ch=getchar());
    6   return s;
    7 }

    输出优化

     1 inline void Writeln(int x)
     2 {
     3   if (x<0) putchar('-'),x=-x; 
     4   if (!x) putchar('0'); else 
     5   {
     6     int len=0; char s[30]; 
     7     while (x) s[++len]=x%10+'0',x/=10;
     8     while (len) putchar(s[len--]);
     9   } 
    10   putchar('
    ');
    11 }
  • 相关阅读:
    软件工程评分表
    评论
    团队成员介绍
    第九天冲刺
    第八天冲刺
    第七天冲刺
    第六天冲刺
    第五天冲刺
    第四天冲刺
    第三天冲刺
  • 原文地址:https://www.cnblogs.com/yangjiyuan/p/5387200.html
Copyright © 2011-2022 走看看