- 博客(50)
- 资源 (3)
- 收藏
- 关注
原创 循环-计算sum的值
16. 计算SUM的值已知公式:SUM = 1 + 1/2 + 1/3 + 1/4 + ... + 1/n输入: n输出: 表达式 sum 的值。结果保留 6 位小数。 测试输入期待的输出时间限制内存限制额外进程测试用例 1
2012-11-09 13:57:26
4231
原创 希尔排序
【代码】#include #include #include "time.h"#define N 20void Init(int *arr);void Output(int *arr);int Compare(int x, int y);void ShellSort(int * arr);void ShellInsert(int * arr, int dk);int
2012-08-07 22:03:29
390
原创 插入排序(简单插入&折半插入)
一、简单插入排序1、代码#include #include #include "time.h"#define N 20void Init(int *arr);void Output(int *arr);void InsertSort(int *arr);int Compare(int x, int y);int main(){ int arr[N+1]; Ini
2012-08-07 20:42:05
461
原创 ASIHttpRequest登录与Basic验证
一、ASIHttpRequest组件的添加在我的其他Blog里有介绍,这里不予赘述。二、基本的request- (IBAction)grabURL:(id)sender{ NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; ASIHTTPRequest *request = [ASIHTTPReq
2012-04-23 17:35:07
1852
原创 ASIHttpRequest组件添加
第一步:下载源代码。第二步:将其源代码拖入你的工程。第三布:添加类库第四步:在build setting中的header search path 中加入 ${SDK_DIR}/usr/include/libxml2(这个貌似官网没写)
2012-04-21 21:04:03
1399
原创 屏幕旋转
一、屏幕旋转的支持处理屏幕旋转支持的代码在ViewController.m文件里,函数如下。- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ // Return YES for supported orientations
2012-04-19 19:49:49
641
原创 线程同步之自旋锁(SpinLock)
自旋锁线程被阻塞时,不进行线程上下文切换,而是空转等待。对于多核CPU而言,减少了切换线程上下文的开销,从而提高了性能。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading; namespace Thread_SpinLock
2012-04-10 22:04:45
1082
原创 线程同步之等待句柄
1、WaitHandle类是个抽象类,有方法:WaitOne()、WaitAll()、WaitAny(), 功能实现由其子类完成。2、互斥同步对象Mutex,派生自WaitHandle类,有两个状态:onwed、unowned。private Mutex m = new Mutex();public void DoSomething(){ m.WaitOne()
2012-04-10 22:00:22
678
原创 线程同步之Monitor
1、Monitor.Enter(obj);申请对obj(非静态字段)的独立访问权;2、对静态字段加锁时,使用Monitor.Enter(typeof(共享类名));示例:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;
2012-04-10 21:53:43
759
原创 C#线程模拟生产者消费者
【需求说明】生产者消费者问题 • 一个大小为3的缓冲区,初始为空 • 2个生产者 – 随机等待一段时间,往缓冲区添加数据, – 若缓冲区已满,等待消费者取走数据后再添加 – 重复6次 • 3个消费者 – 随机等待一段时间,从缓冲区读取数据 – 若缓冲区为空,等待生产者添加数据后再读取 – 重复4次说明: • 显示每次添加
2012-03-26 19:16:25
3422
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅