java算法:折半查找(递归算法和非递归算法)来源:http://blog.csdn.net/undoner/article/details/8245870package Ceshi;public class biSearch { /** * @param args */ /* 折半查找--当查找表是有序表时,可采用折半查找; 基本……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1468浏览 2492个赞
java快速排序算法代码package Mypackage;public class QuickSort { public static void main(String[] args) { int[] arr = { 2, 5, 4, 3, 7, 0, 9, 1, 6, 8 }; quickSort(arr, 2, 7); for (……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3127浏览 2187个赞
java堆排序算法代码来源:http://blog.csdn.net/adam_zs/article/details/8262920package com.arithmetic;//堆排序(Heapsort)是指利用堆这种数据结构所设计的一种排序算法。堆是一个近似完全二叉树的结构,//并同时满足堆性质:即子结点的键值或索引总是小于(或者大于)它的父……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1526浏览 2426个赞
java组合排序算法代码来源:http://blog.csdn.net/adam_zs/article/details/8262598package wzs.sort;//用1、2、3、4、5这五个数字,用java写一个main函数,打印出所有不同的排列,如:51234、41235等。 public class Test_wzs012{ ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3298浏览 736个赞
java二分查找算法代码package wzs.seek;/** * 二分查找 * @author wWX154783 * */public class Test_wzs002{ public static void main(String[] args) { int[] intArray = ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3016浏览 1502个赞
C语言基础:通过指针遍历数组#include <stdio.h>int main(void) { int values[5] = {1, 2, 3, 4, 5}; int counter; int *iptr; iptr = values; for (counter = 0; counter < 5;……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1572浏览 1752个赞
C语言基础:多重指针代码演示#include <stdio.h>int what_is_the_value(int ***ptr) { return(***ptr); }int main(void) { int *level_1, **level_2, ***level_3, value = 1001; leve……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2945浏览 1904个赞
C语言基础:输出二维数组#include <stdio.h>int main(void) { int row, column; float table[3][5] = {{1.0, 2.0, 3.0, 4.0, 5.0}, {6.0, 7.0, 8.0, 9.0, 10.0},……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2650浏览 2621个赞
C语言基础:遍历输出三维数组#include <stdio.h>int main(void) { int row, column, table; float values[2][3][5] = { {{1.0, 2.0, 3.0, 4.0, 5.0}, ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2457浏览 826个赞
C语言基础:获取命令行传入的参数#include <stdio.h>int main (int argc, char **argv) { while (*argv) printf ("%s\n", *argv++);return 1; }……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2141浏览 2757个赞
将该段代码置于Onclose或自定的响应消息的函数中 TCHAR szPath[MAX_PATH]; // GetModuleFileName(NULL, szPath, MAX_PATH); //获取当前应用程序的全路径 //定义俩变量,具体的请参见msdn STARTUPINFO st……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3158浏览 1385个赞
C语言基础:atexit用法演示代码#include <stdio.h>#include <stdlib.h>void first(void) { printf("First function registered\n"); }void second(void) { printf(&q……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2148浏览 1176个赞
C语言基础:统计用户数组字符数量#include <stdio.h>int main (void) { long character_count = 0; getchar(); while (! feof(stdin)) { getchar(); character_count+……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2634浏览 1405个赞
C语言基础:输出当前日期和时间#include <stdio.h>#include <time.h>int main (void) { time_t current_time; time(¤t_time); // Get the time in seconds; printf(&qu……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2733浏览 2987个赞
单链表反转: 比如原链表为 head->1->2->3->NULL; 反转后:head->3->2->1->NULL; #include <stdio.h>#include <stdlib.h>typedef struct Node{ int data; struct Node *next;}*List;#defi……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2822浏览 2040个赞
C语言基础:延迟执行#include <stdio.h>#include <time.h>int main (void) { time_t current_time; time_t start_time; printf("About to delay 5 seconds\n");……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2261浏览 2333个赞
C语言基础:通过difftime判断时间间隔延迟执行#include <stdio.h>#include <time.h>int main (void) { time_t start_time; time_t current_time; time(&start_time); printf(&……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1753浏览 1496个赞
C语言基础:获得当前日期和时间#include <stdio.h>#include <time.h>int main (void) { struct tm *gm_date; time_t seconds; time(&seconds); gm_date = gmtime(&seco……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2977浏览 910个赞
C语言基础:计算儒略日#include <stdio.h>#include <time.h>int main(void) { time_t seconds; struct tm time_fields; time_fields.tm_mday = 4; time_fields.tm_mon = 7;……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2308浏览 1130个赞
C语言基础:localtime输出当前日期和时间#include <stdio.h>#include <time.h>int main (void) { struct tm *current_date; time_t seconds; time(&seconds); current_date……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1865浏览 1659个赞
C语言基础:mktime用法演示,输出时间差#include <stdio.h>#include <time.h>int main(void) { time_t seconds; struct tm time_fields; time_fields.tm_mday = 4; time_fields.……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2427浏览 2202个赞
C语言基础:设置Timezone#include <stdio.h>#include <stdlib.h>#include <time.h>int main(void) { putenv("TZ=PST8PDT"); tzset(); printf("Curre……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2312浏览 1698个赞
C语言基础:时间转换成字符串 strftime#include <stdio.h>#include <time.h>int main(void) { char buffer[128]; struct tm *datetime; time_t current_time; tzset(); tim……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2329浏览 107个赞
C语言基础:timezone时区显示#include <stdio.h>#include <time.h>int main(void) { tzset(); printf("Difference between local and GMT is %d hours\n", timez……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1944浏览 2569个赞
C语言去掉字符串首尾的 空格 换行 回车/*去掉字符串首尾的 \x20 \r \n 字符by sincoder*/void clean_string(char *str){ char *start = str - 1; char *end = str; char *p = str; while(*p) { switch(*p)……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1521浏览 1363个赞
C语言基础:timezone名字显示#include <stdio.h>#include <time.h>int main(void) { tzset(); printf("Current time zone is %s\n", tzname[0]); if (tzname[1]) ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2715浏览 821个赞
C语言基础:文件拷贝#include <stdio.h>int main(void) { FILE *input, *output; int letter; if ((input = fopen("\\CONFIG.SYS", "r")) == NULL) printf……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2690浏览 2734个赞
C语言变成:磁盘检测代码片段#include <stdio.h>#include <dos.h>#include <malloc.h>void main(void) { struct fatinfo fat; long sector, total_sectors; void *buffer;……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3080浏览 486个赞
C语言基础:创建文件#include <stdio.h>#include <dos.h>#include <io.h>void main(void) { int handle; if ((handle = creatnew("NEW.DAT", 0)) == -1) ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2648浏览 379个赞
C语言基础:创建临时文件夹#include <stdio.h>#include <dos.h>#include <io.h>void main(void) { char path[64] = "C:\\TEMP\\"; int handle; if ((handle = ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2192浏览 1071个赞
在N个元素中查找第K大元素,一般比较简单的方法就是先快速排序,然后直接返回array[N – K]或者利用扫描法,每一次扫描都找到当前数组中最大的元素,这个其实就是部分冒泡排序。前一种算法的时间复杂度是O(NlogN),后一种算法的时间复杂度是K*N。当然,这里我们不打算具体讨论以上两种方案,接下来看看其他方法。 &……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3506浏览 557个赞
C++获取zip文件列表 // ZipFile.h #ifndef ZIPFILE_H#define ZIPFILE_H#include <string>#include <vector>#define ZIP_O……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2438浏览 1640个赞
正则表达式c语言经典实现/* * test.c * * Created on: 2012-12-4 * Author: Administrator */#include <stdio.h>int matchhere(char *,char *);int matchstar(int c,char *regexp,c……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2393浏览 1685个赞
一个简单的C语言随机数生成器int random(int start,int end){ int h; float k; h=(int)malloc(sizeof(int)); h=h%10000; k=((float)h)/10000; k=start+(end-start)*k; return k;}/** end of http……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1440浏览 2453个赞
C语言设计的简单的随机数字游戏,猜数字的游戏,只能在windows下运行/********************************************************************************************| C O M M E N T……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3019浏览 2516个赞
C语言最大公约数和最小公倍数算法实现#include <iostream>#include <cstdio>#define MAX(a,b) (a > b ? a : b)template <class T>T gcd(T a, T b){ return a > b ? (b == 0 ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2145浏览 1942个赞
克努特 – 莫里斯 – 普拉特算法的C语言实现/* Copyright 2011 Shao-Chuan Wang <shaochuan.wang AT gmail.com> Permission is hereby granted, free of charge, to any person obtai……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3316浏览 2552个赞
C语言位操作代码片段/* Copyright 2011 Shao-Chuan Wang <shaochuan.wang AT gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this s……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2144浏览 460个赞
C语言[二分图最大匹配] 匈牙利算法const int INF = 0x3f3f3f3f; const int MAXN=510;int uN,vN;//u,v数目int g[MAXN][MAXN];//构图int link[MAXN]; //link[v]=u表示右边对左边的匹配bool used[MAXN];//是否访问过bool ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2826浏览 609个赞
C++数组实现二叉树遍历来源:http://blog.csdn.net/fx397993401/article/details/6271686# includestruct node{ int l,r;};struct node tree[100];int path[100];int ans;void init(){ i……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2968浏览 1941个赞
利用UIImageView加载一序列的图像,可以实现动态图像的效果。 感谢开发者@龙龙酱丶 提供代码片段NSMutableArray * images = [NSMutableArray arrayWithCapacity:6];for (int i = 1; i <= 6; i++) { NSString * imageName =……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1580浏览 1286个赞
Objective C判断设备当前的方向UIDevice *device = [UIDevice currentDevice];switch (device.orientation;) { case UIDeviceOrientationFaceUp: NSLog(@"螢幕朝上平躺"……继续阅读 » 水墨上仙 5年前 (2021-03-14) 2861浏览 170个赞
注意保存图片引用的images不能是autorelease的- (void) saveImagesToPhotosAlbum:(NSMutableSet *)images { if (images.count == 0) { [images release]; return; } ……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1473浏览 2143个赞
iOS自带的照相机功能拍照之后,可以继续保留在拍照界面- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo……继续阅读 » 水墨上仙 5年前 (2021-03-14) 1620浏览 327个赞
objective C判断一个字符串 是否包含另外一个字符串+(BOOL)stringContentString:(NSString *)motherString subString:(NSString *)sonString{ if ([motherString rangeOfString:sonString].location!=NSNot……继续阅读 » 水墨上仙 5年前 (2021-03-14) 3568浏览 1032个赞