问题链接:HDU1321 ZOJ1295 Reverse Text。基础训练级的题,用C语言编写。
这个问题是首先输入测试例子数量t,然后输入t行字符串,将每一行逆序输出。
利用堆栈后进先出的原理,逆序处理可以使用堆栈来实现。
程序中,使用了一个自行实现的堆栈,简单地实现逆序功能。
本程序使用getchar()函数处理输入流,除了输入字符压栈外,读入的字符直接输出输出,没有使用多余的缓存。...
分类:
其他好文 时间:
2016-07-29 15:44:16
阅读次数:
263
Regionals 2007 >> Asia - Seoul
问题链接:UVA1586 UVALive3900 Molar mass。基础练习题,用C++语言编写程序。
这个问题是根据分子式,求分子量。
原子量使用map表来存储,所以用C++来编程。
程序中,使用函数getchar()处理输入流,需要更高的编程技巧。
AC的C++语言程序如下:
/* UVA1586 U...
分类:
其他好文 时间:
2016-07-29 15:42:23
阅读次数:
228
1 #include <cstdio> 2 const int Maxn=100010; 3 inline void Get_Int(int &x) 4 { 5 char ch=getchar(); x=0; 6 while (ch<'0' || ch>'9') ch=getchar(); 7 wh ...
分类:
其他好文 时间:
2016-07-17 12:47:57
阅读次数:
188
dfs就好, 好久没用写dfs了,简单dfs还是Debug了好长时间, 尴尬⊙﹏⊙‖∣
记得把那些转移的东西写在参数里
读入char类型, 记得看看要不要用getchar吸掉换行空格什么的...
分类:
其他好文 时间:
2016-07-13 17:11:51
阅读次数:
204
1、题意:各种splay操作,一道好的模板题2333
2、分析:splay模板题,没啥解释QAQ
#include
#include
#include
#include
#include
using namespace std;
#define M 2000010
inline int read(){
char ch = getchar(); int x = 0, f ...
分类:
其他好文 时间:
2016-07-13 16:58:32
阅读次数:
169
1、题意:dijkstra模板题,存点模板
#include
#include
#include
#include
#include
using namespace std;
#define M 2000010
#define inf 1047483647
inline int read(){
char ch = getchar(); int x = 0, f = 1;
...
分类:
其他好文 时间:
2016-07-13 16:38:24
阅读次数:
99
用getchar时,在键盘上按一个字符后,要按回车才能读取进去;用getch时,在键盘上按一个字符马上就被读取进去,不用按回车,因此可以作为“按任意键继续”的执行语句。 getchar有一个int型的返回值.当程序调用getchar时.程序就等着用户按键.用户输入的字符被存放在键盘缓冲区中.直到用户 ...
分类:
其他好文 时间:
2016-07-11 12:09:48
阅读次数:
179
scanf可以一次按照设定的输入格式输入多个变量数据.如int d,float f,char str[20],scanf("%d%f%s",d,f,str);getchar()只能输入字符型,输入时遇到回车键才从缓冲区依次提取字符.如char ch;ch=getchar();输入abc\r(回车)c ...
分类:
其他好文 时间:
2016-07-09 22:15:11
阅读次数:
189
#include<stdio.h> int main(void) { int ch; while ((ch=getchar())!=EOF) putchar(ch); return 0; } 这个程序中,从键盘输出,从显示屏输出,直到键盘键入一种EOF的信号停止(可能是crtl+Z)。 文件,键盘, ...
分类:
其他好文 时间:
2016-07-09 17:42:24
阅读次数:
112
fflush(stdin)在gcc里不能够清空缓冲区,为了解决这个问题可以用getchar()处理这个问题,如下面代码所示: 如果没有这一行,结果如下: 加上这一行后输入如下: ...
分类:
系统相关 时间:
2016-07-03 11:49:40
阅读次数:
209