这是我的代码:
#include <stdio.h>
void scan(int* i)
{
int t=0;
char c;
bool negative=false;
c=getchar_unlocked();
while(c<'0'&&c>'9')
{
if(c=='-')
negative=true;
c=getchar_unlocked();
}
while(c>'0'&&c<'9')
{
t=(t<<3)+(t<<1)+c-'0';
c=getchar_unlocked();
}
if(negative)
t=~(t-1); //negative
*i=t;
}
int main(int argc, char const *argv[])
{
int i;
scan(&i);
return 0;
}
我知道这里定义的函数 as比编程竞赛scan
更快scanf
并且非常有用。但由于某种原因,这段代码不能在 Windows 上运行,而是在 Linux 上运行。我该怎么做才能让它在 Windows 上运行?我正在使用g++
Dev-C++ 的编译器。