//run on VS 2010
#include <stdlib.h>
#define N 10
void QSort_int(int *s, int l, int r){
int i, j, x;
if (l < r){
i = l; j = r; x = s[i];while (i < j){
while(i < j && s[j] > x)
j--; if(i < j)
s[i++] = s[j];while(i < j && s[i] < x)
i++; if(i < j)
s[j--] = s[i];
"step=%d, x=%d\n",++step, x);
printf(for (int ii = 0; ii < N; ii++)
"%d ",s[ii]);
printf("\n");
printf(
}
s[i] = x;
"i=%d, x=%d\n",i,x);
printf(for (int ii = 0; ii < N; ii++)
"%d ",s[ii]);
printf("\n");
printf(
1);
QSort_int(s, l, i-1, r);
QSort_int(s, i+
}
}
int main(){
int i,j;
int b[100], c[100];
1);
srand(for (i = 0; i < 100; i++) b[i] = rand() % 100;
1000);
srand(for (i = 0; i < 100; i++) c[i] = rand() % 100;
"b[i]=");
printf(for (i = 0; i < N; i++)
"%d\t",b[i]);printf("\n");
printf(
0,N-1);
QSort_int(b,
"b[i]=");
printf(for (i = 0; i < N; i++)
"%d\t",b[i]);printf("\n");
printf(
fflush(stdin);
getchar();return 0;
}
//run on VS 2010
#include <stdlib.h>
int findp(double *a, int n, double val){
int half, tmp, up, low;
1; low = 0;
up = n-while(up-low>1){
tmp = up-low;2;
half=low+tmp/if(val==a[half]) return half;
else if(val<a[half]) up = half;
else low = half;
}if(val==a[low]) tmp=low;
else if(val==a[up]) tmp=up;
else tmp = -1;
return tmp;
}
int main(){
int i, j;
double b[100], c[100];
1);
srand(for (i = 0; i < 100; i++) b[i] = (rand() % 100) / 100.0;
"b[i]=");
printf(for (i = 0; i < 100; i++)
"%f\t",b[i]);printf("\n");
printf(int index = findp(b,100,0.24);
"%d\n",index);
printf(
fflush(stdin);
getchar();return 0;
}
#include <stdlib.h>
pf2(int *a1, int *b1, int *Lab, int N){
void
int i,La,ta,tb,ta1,tb1;if(N<=1) {
0]=3;b1[0]=2;
a1[0]=Lab[1]=1;
Lab[
}else{
pf2(a1, b1, Lab, N-1);
=tb=0;La=Lab[0];
tafor(i=0;i<La;i++){
=a1[i]*3+b1[i]*4+ta;
ta1=a1[i]*2+b1[i]*3+tb;
tb1=ta1%10;
a1[i]=tb1%10;
b1[i]=ta1/10;
ta=tb1/10;
tb
}0]=La;
Lab[1]=La;
Lab[if(ta){
=ta;
a1[i]0]++;
Lab[
}if(tb){
++]=tb;
b1[i1]++;
Lab[
}
}
}
main(int argc,char* arg[]){
int
int i;
100], b[100], Lab[2];
int a[for (i = 0; i < 100; i++) a[i]=b[i]=0;
pf2(a,b,Lab,50);
printf("p=");
for(i=Lab[0]-1;i>=0;i--)
printf("%d",a[i]);
printf(" q=");
for(i=Lab[1]-1;i>=0;i--)
printf("%d",b[i]);printf("\n");
getchar();
0;
return }
#include <stdlib.h>
main(int argc,char* arg[]){
int = atoi(arg[1]), b = atoi(arg[2]);
int a printf("a+b=%d\n",a+b);
0;
return }
10 32 add
-o add gcc add.c
10 32 add
-o add gcc add.c
/add 10 32 .
-o add gcc add.c
/add 10 32 .