定义栈的数据结构,要求添加一个min函数,能够得到栈的最小元素。
要求函数min、push以及pop的时间复杂度都是O(1)。
算法:在栈中设置一个辅助栈来保存最小值
代码:
/**
为栈增加一个min函数,获取栈中的最小值,复杂度为1
** author :xiaozhi xiong
** date:2014-02-08
**/
#include "stdio.h"
#includ...
分类:
其他好文 时间:
2015-02-08 11:35:41
阅读次数:
190
Problem Description
As a unicorn, the ability of using magic is the distinguishing feature among other kind of pony. Being familiar with composition and decomposition is the fundamental course ...
分类:
移动开发 时间:
2015-02-06 21:52:01
阅读次数:
226
在AWS的EC2上编译nagios-plugins报错:./stdio.h:456:1:error:‘gets’undeclaredhere(notinafunction)make[4]:***[localcharset.o]Error1make[4]:Leavingdirectory`/root/nagios-plugins-1.4.16/gl‘make[3]:***[all-recursive]Error1make[3]:Leavingdirectory`/root/nagios-pl..
分类:
移动开发 时间:
2015-02-06 16:56:21
阅读次数:
171
今天在一个CSDN博客上看了一篇文章,是关于数组与指针的问题,感觉挺好的,大致描述如下:
#include "stdio.h"
int main()
{
int a[5]={1,-100,3,2,5};
int *ptr=(int *)(&a+1);
printf("%d,%d",*(a+1),*(ptr-1));
}
输出为:-100,5
请...
分类:
编程语言 时间:
2015-02-06 13:13:05
阅读次数:
208
C语言实现cgiwebshell#include<stdio.h>
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
..
分类:
系统相关 时间:
2015-02-05 18:45:18
阅读次数:
332
#include<stdio.h>
voidsp_to_dish(constchar*str);
voidmain()
{
sp_to_dish("thisisanapple");
}
voidsp_to_dish(constchar*str)
{
while(*str)
{
if(*str==‘‘)
printf("-");//此处不能用*str="-",会提示错误const定义变量的值无法更改
elseprintf("%c",*str..
分类:
其他好文 时间:
2015-02-05 07:13:00
阅读次数:
172
一、数据的输入与输出 1.stdio.h中包含的函数: getchar(输入字符) gets(输入字符串) printf(格式输出) putchar(输出字符) puts(输出字符串) scanf(格式输入) flushall(刷新缓冲区) 等等 2.flushall(); ...
分类:
编程语言 时间:
2015-02-04 09:23:16
阅读次数:
233
父进程创建子进程后,子进程拥有父进程的栈、数据段和堆的拷贝,父子进程的这些空间独立存在; 而子进程会获得父进程的所有打开文件描述符的副本,这些副本指向相同的打开文件列表,即类似于dup.进程调用exit结束时,会调用退出处理程序和刷新stdio缓冲区。一般原则:在创建子进程的应用中,典型情况下仅有一...
分类:
系统相关 时间:
2015-02-02 22:47:09
阅读次数:
238
------- android培训、java培训、期待与您交流! ----------一、printf函数和scanf函数,都被定义在头文件stdio.h里,因此在使用scanf函数时要加上#include 。二、printf函数1.定义:printf()函数是格式化输出函数, 一般用于向终端按规定...
分类:
其他好文 时间:
2015-02-01 23:12:31
阅读次数:
142
getchar():从stdio流中读字符。eof(end of file):文件结束符,在while循环中以eof作为文件结束标志。可以是文件(file),这种以EOF作为文件结束标志的文件必须是文本文件,在文本本件中,数据都是以字符的 ASCII代码值的形式存放,我们知道ASCII代码值的范围0...
分类:
其他好文 时间:
2015-01-30 01:23:10
阅读次数:
162