关于C++的一个测试程序,本菜鸟求大家帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/21 05:52:50
#include <stdio.h>

typedef int KeyType;
typedef struct
{
KeyType key;
}DataTape;

void InsertSort(DataType a[],int n)
{
int i,j;
DataType temp;

for(i = 0; i <n-1 ; i++)
{
temp = a[i+1];
j = i;
while(j > -1 && temp.key < a[j].key)
{
a[j+1] = a[j];
j--;
}
a[j+1] = temp;
}
}
void main(void)
{
DataType test[6] = {64,5,7,89,6,24};
int i,n = 6;

InsertSort(test,n);

for(i=0; i<n; i++)
printf("%d ",test[i].key);
}
编译室提示这个程序的
void InsertSort(DataType a[],int n)
变量列表语法错误,我自学C++,没什么基础,请教大家,这到底是怎么一回事,还有,希望能给我一些学C的建议,在此谢过。

typedef struct
{
KeyType key;
}DataTape;

void InsertSort(DataType a[],int n)

你前面定义的是结构体变量DataTape, 后面却是DataType。。。。

多玩“大家来找茬”,可减少此类错误