2012年7月18日

error: invalid use of incomplete type 'struct word'|

摘要: 发生错误的程序:#include <stdio.h>#include <string.h>#include <algorithm>int cmp(const void* x,const void* y){ struct word* xx=(word*)x; struct word* yy=(word*)y; return strcmp(xx->a,yy->a);}struct word{ char a[26];}w[1000];int main(){……}错因:结构体的声明和定义在cmp函数之后 阅读全文

posted @ 2012-07-18 23:06 铁树银花 阅读(2881) 评论(0) 推荐(0) 编辑

cin、cin.get()、cin.getline()、getline()、gets()等函数的用法

摘要: 转载,并经过本人补充cin、cin.get()、cin.getline()、getline()、gets()等函数的用法2007/10/27 22:51学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行)转载请保留作者信息;1、cin1、cin.get()2、cin.getline()3、getline()4、gets()5、getchar()1、cin>>用法1:最基本,也是最常用的用法,输入一个数字:#include <iostream>using n 阅读全文

posted @ 2012-07-18 22:22 铁树银花 阅读(192) 评论(0) 推荐(0) 编辑

<cf>Square

摘要: B. Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square painted on a piece of paper, the square's side equalsnmeters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corne 阅读全文

posted @ 2012-07-18 11:54 铁树银花 阅读(423) 评论(0) 推荐(0) 编辑

[置顶] 错误存档

摘要: 1.当n是short int ,m是long long int时,语句m=4*n,使用GNU,得到的m是short int的范围,因此当n稍大时,m就可能溢出。2.输出字符串时,遇到‘\0’结束输入,如果没有适当地设置'\0',可能会出现问题。比如有struct node{ char s[10];}n[2];如果w[0].s中没有‘\0’,则scanf("%s",n[0].s)不会只输出n[0]中字符数组s中的内容,因为这一个输出语句是输出以n[0].s为首地址直到'\0'为止的内容。3.当用memset给char型以外的数组初始化时,只能初 阅读全文

posted @ 2012-07-18 11:50 铁树银花 阅读(190) 评论(0) 推荐(0) 编辑

<cf>A. Exams

摘要: A. Examstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day the Codeforces round author sat exams. He hadnexams and he needed to get an integer from2to5for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark2.The 阅读全文

posted @ 2012-07-18 00:13 铁树银花 阅读(158) 评论(0) 推荐(0) 编辑

导航