This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************* | |
[Name]: | |
init_list.c | |
[Description]: | |
This is example to describe: | |
[Author]: | |
[email protected] | |
[Revision]: 2013/4/23 下午 07:41:52 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
#--- OUTPUT : | |
0.1 | |
0.02 | |
0.005999999999999999 | |
0.012 | |
0.030000000000000002 | |
0.12000000000000001 | |
0.3 | |
1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Simple function as argument. | |
// [email protected] | |
#include<stdio.h> | |
double f(double x); | |
double sum_square(double (*)(double x), int lower, int upper) ; | |
int main(){ | |
printf("%lf\n",sum_square(f,1,10)); | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//********************************************************************** | |
//** Easy Example for describing the usage of function pointer in C ** | |
//********************************************************************** | |
#include<stdio.h> | |
//A simple funtion which return its parameter. | |
int p(int x){ return x ;} | |
typedef int (*functionPointer)(int x) ; | |
typedef struct _Interface { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//常用算法经典代码(C++版) | |
//*快速排序 | |
void qsort(int x,int y) //待排序的数据存放在a[1]..a[n]数组中 | |
{//调用:qsort(1,n)即可实现数组a中元素有序。适用于n比较大的排序 | |
int h=x,r=y; | |
int m=a[(x+y)>>1]; //取中间的那个位置的值 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
If you want to find prime numbers less than N | |
then use each prime number form 2 to N**0.5 to test. | |
=end | |
print "2, 3, 5, 7, " | |
for i in (10..100) | |
if (i%2 != 0 and i%3 != 0 and i%5!=0 and i%7!=0) | |
print "#{i}, " | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(){ | |
int i = 0 ; | |
printf("Plz enter a number:") ; | |
scanf("%d",&i) ; | |
printf("Base_10: %d\n",i) ; | |
printf("Base_8: %o\n",i) ; | |
printf("Base_16: %x\n",i) ; | |
return 0; | |
} |