随笔分类 - C
摘要:#include #include #define Num 1000int main(){ int i = 0,j = 0,k,count = 0,h = 0,c; char str1[Num],str2[Num],str3[Num]; printf("Please input t...
阅读全文
摘要:#include #include #include int aoti(char c){ if(c >= 'A' && c <= 'Z') return c-'A'+'a'; else return c;}int main(){ int i = 0; ...
阅读全文
摘要:举例如下:char a[10];1、定义的时候直接用字符串赋值char a[10]="hello";注意:不能先定义再给它赋值,如char a[10];a[10]="hello";这样是错误的!2、对数组中字符逐个赋值char a[10]={'h','e','l','l','o'};3、利用strc...
阅读全文
摘要:#include "stdio.h"#define Num 100void reverse(char words[]){ int i, j, c, n=0; while(words[n]!='\0') n++; for(i=0,j=n-1;i<j;i++,j--) { c = wor...
阅读全文
摘要:#include #define MAXLINE 10int getLine(char s[], int lim);void copy(char to[], char from[]);int calcLen(char s[]);int main(){ int len, index, row; ...
阅读全文
摘要:#include #define MAXLINE 100#define MAX 8int getline(char line[],int maxline);void copy(char to[],char from[]);int main(){ int len; int max; ...
阅读全文
摘要:#include #define MAXLINE 10int getline(char line[],int maxline);void copy(char to[],char from[]);int main(){ int len; int max; char line[MAXL...
阅读全文
摘要:#include #define MAXLINE 1000int getline(char line[],int maxline);void copy(char to[],char from[]);int main(){ int len; int max; char line[MA...
阅读全文
摘要:#include #define Num 20int power(int base,int n){ int p = 1; int i; for(i = 0;i #define Num 20int power(int a,int b);int main(){ int base ...
阅读全文
摘要:#include #define Num 10int main(){ int wor = 0; int arr[Num] = {0}; int c,count = 0,i; int flag = 0; printf("Please input at most 10 wo...
阅读全文
摘要:#include int main(){ int c; while((c = getchar()) != EOF) { if(c != '\n' && c != ' ' && c != '\t') { putchar(...
阅读全文
摘要:#include int main(){ int lin = 0,wor = 0,cha = 0; int flag = 0; int c; while((c = getchar()) != EOF) { if(c == '\n') ...
阅读全文
摘要:#include int main(){ int c; int flag = 0; while((c = getchar()) != EOF) { if(c == ' ') { if(flag == 0) ...
阅读全文
摘要:#include int main(){ int spa = 0,lin = 0,tab = 0; int c; /* spa代表空格个数,tab代表制表符个数,lin代表换行符个数 */ while((c = getchar()) != EOF) { if...
阅读全文
摘要:昨天忘发了,现在补上。#include "stdio.h"#include "stdlib.h"#define Num 10void MinHeapFixdown(int a[], int i, int n){ int j, temp; temp = a[i]; j = 2 * i + 1; ...
阅读全文
摘要:今天才算静下心来看明白了堆排序的想法:1、数组“放进”堆中;2、堆化操作;3、利用堆的插入或者删除操作,依次找出堆中最大或者最小的数;4、将找到的数一个一个按顺序排起来,排序完成。想看详细的请移步:http://blog.csdn.net/morewindows/article/details/67...
阅读全文
摘要:1: /* 2: 输入:数组A,堆的长度hLen,以及需要调整的节点i 3: 功能:调堆 4: */ 5: 6: void AdjustHeap(int A[], int hLen, int i) 7: { 8: int left = Left...
阅读全文
摘要:这篇文章写的很好,明天自己编程实现算法。点击打开链接
阅读全文
摘要:下面是 armijo线搜索+最速下降法的小程序,matlab用的很不熟,费了不少劲。函数:function g=fun_obj(x)syms a bf = 1/2*a^2+b^2-a*b-2*a;a=x(1);b=x(2);g=eval(f);求梯度:function g=fun_grad(x)sy...
阅读全文
摘要:希尔排序的关键在于步长的选取。希尔排序的复杂度比较复杂,主要跟步长的选择有关,大概是 O(n logn^2),一般认为就是介于 O(n^2) 和 O(n logn) 之间。最好步长比较复杂,一般第一次取序列的一半,以后每次减半,直到步长为1。 对于希尔排序为什么明显优于直接插入排序:“希尔排序通过...
阅读全文

浙公网安备 33010602011771号