|
编译完出现以下错误:
[code:1]
send.c: In function `QuickSort':
send.c:83: warning: passing arg 1 of `QuickPass' from incompatible pointer type
send.c:84: warning: passing arg 1 of `QuickSort' from incompatible pointer type
send.c:85: warning: passing arg 1 of `QuickSort' from incompatible pointer type
[/code:1]
该如何改呢??
[code:1]
/*
**QuickSort
*/
#include <stdio.h>
#include <stdlib.h>
#define maxsize 20
typedef struct reclist
{
int key;
} records;
typedef struct table
{
records item[maxsize + 1];
int last;
} sqtable;
int CreateSqtable (sqtable *R)
{
int input;
int count = 1;
R -> last = 0;
printf("Input Some data(0 to end):");
scanf("%d", &input);
while (input)
{
R -> item[count].key = input;
R -> last++;
count++;
scanf("%d", &input);
}
return 1;
}
int PrintSqtable (sqtable *R)
{
int i;
printf("list:\n");
for (i = 1; i <= R -> last; i++)
printf("(%d):%d ", i, R -> item[i].key);
printf("\n");
return 1;
}
/*QuickPass*/
int QuickPass (sqtable *R, int low, int high)
{
int pivotkey;
pivotkey = R -> item[low].key;
while (low < high)
{
while ((low < high) && (R -> item[high].key >= pivotkey))
high--;
if (low < high)
{
R -> item[low].key = R -> item[high].key;
low++;
}
while ((low < high) && (R -> item[low].key <= pivotkey))
low++;
if (low < high)
{
R -> item[high].key = R -> item[low].key;
high--;
}
}
R -> item[low].key = pivotkey;
return (low);
}
int QuickSort (sqtable *R, int low, int high)
{
int pivotloc;
if (low < high)
{
pivotloc = QuickPass (&R, low, high);
QuickSort (&R, low, pivotloc - 1);
QuickSort (&R, pivotloc + 1, high);
}
return 1;
}
int main (void)
{
sqtable R;
int choose;
int low, high;
CreateSqtable (&R);
printf("\nBefore,");
PrintSqtable (&R);
while (1)
{
printf("\n%s\n%s",
"1:***** 2:****** 3:QuickPass",
"Choose(0 to exit):");
scanf("%d", &choose);
switch (choose)
{
case 1:
break;
case 2:
break;
case 3:
low = 1;
high = R.last;
QuickSort (&R, low, high);
printf("\nAfte,");
PrintSqtable (&R);
break;
case 4:
break;
case 0:
exit (0);
default:
printf("\nErr Choose!\n");
}
}
return 0;
}
[/code:1] |
|