#include <stdio.h>
#include <stdlib.h>
int main()
struct record;
{
int key;
int otheritem;
};
typedef struct record REC;
REC R[N];
void insert(REC R[],int n);
void print();
void print()
{
int i;
for(i=1;i<=10;i++)
printf("%6d",R[i].key);
printf("\n");
}
void insert(REC R[],int n)
{
int i,j;
for(i=2;i<=n;i++)
{
R[0]=R[i];
j=i-1;
while(R[0].key<R[j].key)
{ R[j+1]=R[j];
j--;
}
R[j+1]=R[0];
}
}
int main()
{
int k;
printf("请输入数据:\n");
for(k=1;k<=10;k++)
{
scanf("%d",R[k].key);
R[k].otheritem=k;
}
print();
return 0;
}
报错的图传不上来......文字如下:
C:\Users\Administrator\Desktop\排序的基本算法.cpp(4) : warning C4518: 'record ' : storage-class or type specifier(s) unexpected here; ignored
C:\Users\Administrator\Desktop\排序的基本算法.cpp(5) : error C2447: missing function header (old-style formal list?)
C:\Users\Administrator\Desktop\排序的基本算法.cpp(10) : error C2065: 'N' : undeclared identifier
C:\Users\Administrator\Desktop\排序的基本算法.cpp(10) : error C2057: expected constant expression
C:\Users\Administrator\Desktop\排序的基本算法.cpp(10) : error C2466: cannot allocate an array of constant size 0
C:\Users\Administrator\Desktop\排序的基本算法.cpp(20) : error C2036: 'struct record *' : unknown size
C:\Users\Administrator\Desktop\排序的基本算法.cpp(20) : error C2027: use of undefined type 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(9) : see declaration of 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(20) : error C2228: left of '.key' must have class/struct/union type
C:\Users\Administrator\Desktop\排序的基本算法.cpp(29) : error C2036: 'struct record []' : unknown size
C:\Users\Administrator\Desktop\排序的基本算法.cpp(29) : error C2036: 'struct record []' : unknown size
C:\Users\Administrator\Desktop\排序的基本算法.cpp(29) : error C2582: 'record' : 'operator =' function is unavailable
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2036: 'struct record []' : unknown size
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2027: use of undefined type 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(9) : see declaration of 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2228: left of '.key' must have class/struct/union type
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2036: 'struct record []' : unknown size
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2027: use of undefined type 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(9) : see declaration of 'record'
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : error C2228: left of '.key' must have class/struct/union type
C:\Users\Administrator\Desktop\排序的基本算法.cpp(31) : fatal error C1903: unable to recover from previous error(s); stopping compilation