关于inf的问题

详见实例

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<cstring>
 4 #include<cstdio>
 5 #include<vector>
 6 #include<queue>
 7 #include<cctype>
 8 #define INF 0x3f3f3f3f
 9 using namespace std;
10 int main(){
11     freopen("01.txt","w",stdout);
12     int a[101];
13     memset(a,127/3,sizeof(a));
14     cout<<a[0]<<endl;
15     cout<<0x3f3f3f3f<<endl<<0x7fffffff<<endl<<(1<<30);
16     return 0;
17 }

参考@DaisyGao的说法,也给出了样例,输出如下:

707406378
1061109567
2147483647
1073741824

可见还是memset(,0x3f,)和memset(,127/3,)比较好

如果memset(,127,)可能随便运算一下就爆了

定义INF还是按照第七行来吧

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!
原文地址:https://www.cnblogs.com/radiumlrb/p/5799022.html