
小错误
搏风雨
倘若不坚强,懦弱给谁看。
展开
-
fatal error C1071: unexpected end of file found in comment
#includeusing namespace std;int set[maxn];int sum;int set_find(int d){if(set[d]return d;return set[d]=set_find(set[d]);}void join(int p,int q){p=set_find(p);q=set_find(原创 2014-07-28 09:47:58 · 1483 阅读 · 0 评论 -
造成segmentation fault的可能原因分析
一 造成segment fault,产生core dump的可能原因1.内存访问越界 a) 由于使用错误的下标,导致数组访问越界 b) 搜索字符串时,依靠字符串结束符来判断字符串是否结束,但是字符串没有正常的使用结束符 c) 使用strcpy, strcat, sprintf, strcmp, strcasecmp等字符串操作函数,将目标字符串读/写爆。应该使用st转载 2014-07-21 19:19:21 · 7533 阅读 · 0 评论 -
Visual C++中min()和max()函数的使用
标准库在头中定义了两个模板函数std::min() 和 std::max()。通常用它可以计算某个值对的最小值和最大值。可惜在 Visual C++ 无法使用它们,因为没有定义这些函数模板。原因是名字min和max与中传统的min/max宏定义有冲突。为了解决这个问题,Visual C++ 定义了另外两个功能相同的模板:_cpp_min() 和 _cpp_max()。我们可以用它们来代替std转载 2014-08-07 18:06:33 · 24155 阅读 · 0 评论 -
Wrong Answer,Memory Limit Exceeded
1.做题时遇到一个奇葩错误,原创 2014-08-12 17:07:03 · 2683 阅读 · 0 评论 -
c++能过,g++过不了
可能原因:1.printf("%.3lf\n",n);原创 2014-09-04 19:29:54 · 852 阅读 · 0 评论 -
g++能过,c++过不了
可能原因:1.在递归的时候,递归函数中忘记加返回return。(详见原创 2014-09-04 19:36:13 · 669 阅读 · 0 评论 -
EOF的使用
1.我疑惑了 char a[20]; while(scanf("%s",a)!=EOF){ cout<<"hello"<<endl; }为什么要按两下原创 2014-10-09 21:17:47 · 1106 阅读 · 1 评论 -
有时候,Visual C++代码中加中文注释会导致错误!
今天做题发现了个奇葩错误,以此警戒自己。在Visual C++原创 2014-10-18 15:29:19 · 2723 阅读 · 2 评论 -
小错误集锦
1.栈不要忘了清空!虽然错误不大,但是今天还真犯了这个错,用了原创 2014-10-18 16:15:59 · 604 阅读 · 1 评论 -
&&、||和&、|的区别
1.未完待续。原创 2014-09-22 20:58:44 · 495 阅读 · 0 评论 -
Compilation error 未完待续
1.code.cpp:1:21: fatal error: iostream : No such file or directory #include ^compilation terminated.这个原创 2014-08-06 18:51:42 · 1024 阅读 · 0 评论 -
string 中的 length函数 和size函数 返回值问题
// 例1// string a="abcd";// -1 和 a.length() 的比较结果原创 2014-07-30 09:41:59 · 1413 阅读 · 0 评论 -
pow,sqrt使用时需注意
1.pow函数声明: double pow (double base , double exponent); float pow (float base , float exponent);long double pow (long double base, long double exponent); double pow (double原创 2014-08-06 14:17:13 · 760 阅读 · 0 评论 -
error: reference to 'max' is ambiguous
zidi变量名字与库里面的重名了,即冲突了原创 2014-07-27 20:39:52 · 17518 阅读 · 0 评论 -
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 错误类型: 缺失类型表述 错误原因: 函数前未写函数的返回类型,由此导致了这个错误 解决方法: 以后写转载 2014-07-26 16:55:24 · 1200 阅读 · 0 评论 -
name lookup of 'res' changed for new ISO 'res' scoping
#includeusing namespace std;int pow ( int val, int exp );int main(){int val = 2;int exp = 10;cout }int pow( int val, int exp ){转载 2014-07-23 19:21:06 · 1001 阅读 · 0 评论 -
0-----------假 , 非0----------------真
以此警告自己!!0----------假 非0-------真原创 2014-07-28 16:13:32 · 622 阅读 · 0 评论 -
Runtime Error(ACCESS_VIOLATION)
1. while(scanf("%d",&n)!=EOF)原创 2014-08-01 18:13:04 · 1022 阅读 · 0 评论 -
runtime error 的原因
1.数组访问越界2.分母原创 2014-07-29 11:18:11 · 1480 阅读 · 0 评论 -
while( c= getchar(c) &&c!='\n')为什么错误
#includeusing namespace std;int main(){ char c; int m=0; while( c= getchar(c) &&c!='\n') { m++; cout<<"case:"<<m<<endl; cout<<c<<endl; } return 0;}原创 2014-08-04 15:13:43 · 1357 阅读 · 0 评论 -
超时原因
1.做题时偶然发现,else if()语句太多,也会造成超时,原创 2014-08-05 09:41:33 · 1606 阅读 · 0 评论 -
fflush(stdin)的对错?
C和C++的标准里从来没有定义过 fflush(stdin)。也许有人会说:“可是我用 fflush(stdin) 解决了这个问题,你怎么能说是错的呢?”的确,某些编译器(如VC6)支持用 fflush(stdin) 来清空输入缓冲,但是并非所有编译器都要支持这个功能(linux 下的 gcc 就不支持),因为标准中根本没有定义 fflush(stdin)。MSDN 文档里也清楚地写着fflush原创 2014-08-05 15:16:54 · 649 阅读 · 0 评论 -
scanf ---------未完待续
1.#include#includeusing namespace std;int main(){ char c[50]; scanf("%s",c); printf("%s",c); return 0;}不可读入空格原创 2014-08-05 15:41:40 · 535 阅读 · 0 评论 -
double转int时精度不一致问题
float和double类型的主要设计目的是为了科学计算和工程计算。它们执行二进制浮点运算,这是为了在广域数值范围上提供较为精确的快速近似计算而精心设计的。然而,它们没有提供完全精确的结果,所以不应该被用于要求精确结果的场合。float和double类型对于货币计算尤为不合适,因为要让一个float或者double精确地表示0.1(或者10的任何负数次方值)是不可能的,比如System.out.p转载 2015-05-03 19:49:32 · 3073 阅读 · 0 评论