这段代码为何在vc下通不过?在cb下可以啊。
Functions.cpp
\cpp\helloworld\functions.cpp(84) : error C2374: 'i' : redefinition; multiple initialization
cpp\helloworld\functions.cpp(82) : see declaration of 'i'
cpp\helloworld\functions.cpp(84) : error C2374: 'j' : redefinition; multiple initialization
cpp\helloworld\functions.cpp(80) : see declaration of 'j'
Error executing cl.exe.
Creating browse info file...
unsigned int const m = 10;
void BucketSort(unsigned int a[],unsigned int n)
{
int buckets[m];
for(unsigned int j=0;j<m;++j)
buckets[j]=0;
for(unsigned int i=0;i<n;++i)
++buckets[a[i]];
for(unsigned int i=0,j=0;j<m;++j)//这里通不过!
{
for(unsigned int k=buckets[j];k>0;--k)
a[i++]=j;
}
}
unsigned int a[]={2,3,5,3,3,6,9,8};
BucketSort(a,sizeof(a)/sizeof(a[0]));
for(unsigned int i=0;i<sizeof(a)/sizeof(a[0]);i++)
cout << a[i] << endl;