1,while((ch = getchar()) != EOF){ putchar(ch);}2,while((ch=getchar()) != EOF){ if(ch '9'){ continue;}} //process only the digits3,while(scanf("%f",&v....
分类:
其他好文 时间:
2015-04-15 13:20:46
阅读次数:
127
VS2008中编写C/C++的程序时,调试运行,控制台窗口会在执行完毕后立即关闭,这样就无法看到运行的结果。为了解决这个问题,可以使用①system("pause");②getchar();例子程序如下int _tmain(int argc, _TCHAR* argv[]){std::cout <<...
分类:
其他好文 时间:
2015-04-12 23:59:24
阅读次数:
288
要写关键路径,发现图论早已忘得一塌糊涂,悲哀之余,抓紧复习。翻高级本时又看见了前面的贪心,于是就又把贪心练了一下。写了几道比较老的题目,像是积木大赛。之后还突发奇想练了栈一类的。总之,这两周的练习相当凌乱。下面贴一下近期做过的几道题目吧。
表达式求值专项训练
codevs1750 加法表达式
(自带吐槽:直接用读入优化那样的getchar()读入 但是要注意读不了的时候返回值是-1 所以不能...
分类:
其他好文 时间:
2015-04-11 18:03:01
阅读次数:
157
#include #include int main(){int y,n,sum;char x;while(scanf("%d",&n)!=EOF){while(n--){getchar();scanf("%c %d",&x,&y);if(x>='A'&&x<='Z')sum=x+y-'A'+1;e...
分类:
其他好文 时间:
2015-04-11 17:50:51
阅读次数:
92
1 void read(int &x) 2 { 3 int f = 1; x = 0; 4 char ch = getchar (); 5 while ((ch '9') && ch != '-') 6 ch = getchar (); 7 ...
分类:
其他好文 时间:
2015-04-10 22:18:52
阅读次数:
109
水题,求连通分量的个数,深搜一遍即可,之所以这么水还写下来,是因为样例一组有误的数据弄得我调试了一个多小时,白白浪费了很多精力和时间。最后一组数据的两个5后面多了一个空格:我用 getchar 来接收字符,所以因为它这个无故多出来的空格使得后面的字符全乱了,调试输出时才有了千奇百怪的结果,不得不.....
分类:
其他好文 时间:
2015-04-05 18:41:58
阅读次数:
130
原理:计算机读入字符比整数快输入外挂//适用于正负整数inline int read(){ char ch=getchar(); int x=0,f=1; while(ch>'9'||ch='0'){x=x*10+ch-'0';ch=getchar();} return x*f...
分类:
其他好文 时间:
2015-04-05 11:48:11
阅读次数:
151
#include class Animal{public: Animal(){}; virtual ~Animal(){}; virtual void Eat() { std::cout Eat(); getchar(); return 0;}
分类:
其他好文 时间:
2015-04-03 10:59:22
阅读次数:
118
每个程序都是纯读入与1个输出.输入数据分别有1e2,1e3,1e4,1e5,1e6,1e7个数.C++使用getchar()读入是最快的.流输入是非常非常慢! 比赛还是用gechar比较好...
分类:
其他好文 时间:
2015-04-02 23:48:45
阅读次数:
410
KM模版题。#include #include #include #include #include #include #include #define rep(i, l, r) for(int i=l; i'9') { if (ch=='-') f=-1; ch=getchar(); } whil...
分类:
其他好文 时间:
2015-03-31 22:09:49
阅读次数:
111