📄 quick_sort.cpp
字号:
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <winsock2.h>
#include <math.h>
#define IA 16807
#define IM 2147483647
#define AM (1.0/IM)
#define IQ 127773
#define IR 2836
#define MASK 123459876
void swap(int array[],int low,int high)
{
int temp;
temp = array[low];
array[low] = array[high];
array[high] = temp;
}
void sort(int array[],int low,int high)
{
int temp;
int first,last;
first = low;
last = high;
if(low >= high)
return;
temp = array[low];
while(low < high)
{
while(low<high && array[high] >= temp)high--;
array[low] = array[high];
while(low < high && array[low] <= temp)low++;
array[high] = array[low];
}
array[low] = temp;
sort(array,first,low);
sort(array,low+1,last);
}
//-------------------------------------------------
double ran01( long *idum )
/*
FUNCTION: generate a random number that is uniformly distributed in [0,1]
INPUT: pointer to variable with the current seed
OUTPUT: random number uniformly distributed in [0,1]
(SIDE)EFFECTS: random number seed is modified (important, this has to be done!)
ORIGIN: numerical recipes in C
*/
{
long k;
double ans;
k =(*idum)/IQ;
*idum = IA * (*idum - k * IQ) - IR * k;
if (*idum < 0 ) *idum += IM;
ans = AM * (*idum);
return ans;
}
//--------------------------------------------------
void main()
{
int i,j,h;
FILE *fp;
char buffer[16];
int cood[48][2];
i =0;
j = 0;
h = 0;
int count = 48;
char *ch="大家";
if((fp=fopen("tsp.txt","r"))==NULL)
cout<<"can not open"<<endl;
// fread(ch,2,2,fp);
cout<<sizeof(ch)<<endl;
cout<<ch<<endl;
/*
while(!feof(fp))
{
fscanf(fp,"%d %d %d",&i,&h,&j);
cood[i-1][0] = h;
cood[i-1][1] = j;
}
*/
fclose(fp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -