ITfeng

 

2012年5月9日

折半查找

摘要: 折半查找的前提是有序的,与中间值进行比较,如果有序的则返回;否则,改变始末位置,再进行查找实现方法:1 循环实现 2 递归实现1 循环实现#include<stdio.h>int binary_search(int *array,int n,int data);int main(){int array[10]={1,2,3,4,5,6,7,8,9,10};printf("please input the number that you want search\n");int num;scanf("%d",&num);int resul 阅读全文

posted @ 2012-05-09 19:09 ITfeng 阅读(181) 评论(0) 推荐(0) 编辑

linux---概念性东西

摘要: 1.进程和线程的差别。线程是指进程内的一个执行单元,也是进程内的可调度实体.与进程的区别:(1)调度:线程作为调度和分配的基本单位,进程作为拥有资源的基本单位(2)并发性:不仅进程之间可以并发执行,同一个进程的多个线程之间也可并发执行(3)拥有资源:进程是拥有资源的一个独立单位,线程不拥有系统资源,但可以访问隶属于进程的资源. (4)系统开销:在创建或撤消进程时,由于系统都要为之分配和回收资源,导致系统的开销明显大于创建或撤消线程时的开销。2.测试方法 人工测试:个人复查、抽查和会审机器测试:黑盒测试和白盒测试2.Heap与stack的差别。Heap是堆,stack是栈。Stack的空间由操作 阅读全文

posted @ 2012-05-09 16:56 ITfeng 阅读(145) 评论(0) 推荐(0) 编辑

C语言考点2

摘要: 1static全局变量与普通的全局变量有什么区别?static局部变量和普通局部变量有什么区别?static函数与普通函数有什么区别?全局变量改成静态是限制了它的使用范围,局部变量改成static是改变存储方式和生命周期static全局变量与普通的全局变量有什么区别:static全局变量只初使化一次,防止在其他文件单元中被引用;static局部变量和普通局部变量有什么区别:static局部变量只被初始化一次,下一次依据上一次结果值;static函数与普通函数有什么区别:static函数在内存中只有一份,普通函数在每个被调用中维持一份拷贝程序的局部变量存在于(堆栈)中,全局变量存在于(静态区 ) 阅读全文

posted @ 2012-05-09 14:15 ITfeng 阅读(154) 评论(0) 推荐(0) 编辑

约瑟夫环-----数数

摘要: #include<stdio.h>#include<stdlib.h>typedef struct list{int data;struct list*next;}List;List*insert_list(List*head,int data){List*newnode=(List*)malloc(sizeof(List));List*tail=head;newnode->data=data;if(head==NULL){newnode->next=newnode;return newnode;}while(tail->next!=head){tai 阅读全文

posted @ 2012-05-09 14:06 ITfeng 阅读(184) 评论(0) 推荐(0) 编辑

C语言考点

摘要: 1 static的作用1)在函数体,一个被声明为静态的变量在这一函数被调用过程中维持其值不变。2) 在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所用函数访问,但不能被模块外其它函数访问。它是一个本地的全局变量。3) 在模块内,一个被声明为静态的函数只可被这一模块内的其它函数调用。那就是,这个函数被限制在声明它的模块的本地范围内使用2 引用和指针的区别(1)引用必须被初始化,指针不必(2)引用在初始化后不能改变,而指针可以改变所指的对象(3)不存在指向空值的引用,但是存在指向空值的指针3 描述实时操作系统的特性在特定时间内完成特定任务,实时性和可靠性4. 全局变量和局部变量在内存 阅读全文

posted @ 2012-05-09 11:12 ITfeng 阅读(168) 评论(0) 推荐(0) 编辑

2012年5月8日

经典递归程序----反向输出字符串

摘要: #include<stdio.h>void reverse(char*s);int main(){char *a="hello world";reverse(a);}void reverse(char*s){if(*s=='\0')return ;reverse(s+1);printf("%c",*s);} 阅读全文

posted @ 2012-05-08 21:34 ITfeng 阅读(160) 评论(0) 推荐(0) 编辑

Linux---文件操作

摘要: 将1.txt中的数字读出来,再逆序输出到2.txt中去,要求逆序熟悉 fopen fclose fprintf,fscanf的用法#include<stdio.h>#include<stdlib.h>#define INCREASE 20int main(){int max=10;FILE*fp1;FILE*fp2;int *array=(int*)malloc(max*sizeof(int));int *temp;fp1=fopen("1.txt","r");if(fp1==NULL){printf("open 1.t 阅读全文

posted @ 2012-05-08 21:18 ITfeng 阅读(159) 评论(0) 推荐(0) 编辑

浮点数转成字符串

摘要: #include<stdio.h> #include<stdlib.h>char*func(double num,char str[]){int i,temp,j=0;temp=(int)num;//先取整数部分while(temp){str[j++]=temp%10+'0';temp/=10;}//注意数是逆序的 ,需要转换for(i=0;i<j/2;i++){temp=str[i];str[i]=str[j-i-1];str[j-i-1]=temp;} str[j++]='.';num-=(int)num;for(i=0;i&l 阅读全文

posted @ 2012-05-08 20:51 ITfeng 阅读(277) 评论(0) 推荐(0) 编辑

两个有序链表合成一个有序链表

摘要: #include<stdio.h>#include<stdlib.h>typedef struct list{int data;struct list*next;}List;List*hebin(List*head1,List*head2){List*head,*rear;if(head1==NULL)return head2;if(head2==NULL)return head1;if(head1->data<head2->data){rear=head=head1;head1=head1->next;}else{ rear=head=head 阅读全文

posted @ 2012-05-08 20:50 ITfeng 阅读(644) 评论(0) 推荐(0) 编辑

2012年4月26日

带头结点链表逆序实现

摘要: #include<stdlib.h>#include<stdio.h>typedef struct list{int data;struct list*next;} List;List* insert_list_last();List*reverse(List*head);int main(){List*head;List*p;head=insert_list_last();p=head->next;while(p){printf("%d\n",p->data);p=p->next;}printf("affter reve 阅读全文

posted @ 2012-04-26 22:16 ITfeng 阅读(383) 评论(0) 推荐(0) 编辑

导航