这是我的代码,无法理解错误在哪里
#include <iostream>
#include<iomanip>
using namespace std;
#define narray 8;// array size;
#define nbucket 5;// bucket size;
#define interval 10;// bucket range
struct node
{
int data;
struct node *next;
};
void BucketSort(int arr[]);
struct node *InsertionSort(struct Node *list);
void print(int arr[]);
void printBuckets(struct Node *list);
int getBucketIndex(int value);
void BucketSort(int arr[])
{
int i,j;
struct node **buckets;
buckets = (struct node **)malloc(sizeof(struct node*) * nbucket);
for (i=0;i<nbucket;i++){
buckets[i]=NULL;
}
for (int i=0;i<narray;i++){
struct node *current;
int pos=getBucketIndex(arr[i]);
current=(struct node *)malloc(sizeof(struct node));
current->data=arr[i];
current->next=buckets[pos];
buckets[pos]=current;
}
}
int main(){
return 0;
}
错误很多,例如
Error 1 error C2143: syntax error : missing ')' before ';' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 22 bucket_sort
Error 2 error C2059: syntax error : ')' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 22 bucket_sort
Error 3 error C2146: syntax error : missing ')' before identifier 'i' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 23 bucket_sort
Error 4 error C2059: syntax error : ';' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 23 bucket_sort
Error 5 error C2059: syntax error : ')' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 23 bucket_sort
Error 6 error C2143: syntax error : missing ';' before '{' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 23 bucket_sort
Error 7 error C2146: syntax error : missing ')' before identifier 'i' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 26 bucket_sort
Error 8 error C2059: syntax error : ';' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 26 bucket_sort
Error 9 error C2059: syntax error : ')' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 26 bucket_sort
Error 10 error C2143: syntax error : missing ';' before '{' c:\documents and settings\student\my documents\visual studio 2008\projects\bucket_sort\bucket_sort\bucket_sort.cpp 26 bucket_sort