Skip to content

Instantly share code, notes, and snippets.

View iziang's full-sized avatar

Ziang Guo iziang

View GitHub Profile
@iziang
iziang / ls.c
Last active January 3, 2016 00:39
指针一定要初始化,给其分配指向的内存地址!!!!!
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
if (argc != 2) {
@iziang
iziang / second_max_number.cc
Last active January 2, 2016 11:29
从前向后遍历数组,每一个元素都先和max比较 (1)如果大于max,则更新max和second_max (2)如果小于max,再和second_max比较,如果大于second_max,则更新second_max
#include<stdio.h>
int second_max_length(int array[], const int length, int &second_max)
{
if((array == NULL) || (length < 2)){
return 0;
}
int i;