VS2015出现编译错误,可以帮楼主解决吗?= =
vs2015吧
全部回复
仅看楼主
level 2
zyuanwei 楼主
从二楼开始说~
2016年04月07日 13点04分 1
level 11
从我说起。。。
这是一个很长的故事啊。。。。。。。。。。
2016年04月07日 13点04分 2
level 2
zyuanwei 楼主
这是我的源代码,是用C++编写的~
#include<iostream>
using namespace std;
/////////////////定义部分///////////////////
#define MAXSIZE 50 /*顺序表的最大长度*/
typedef int keytype;
typedef int Elemtype;
typedef struct
{
keytype key;
Elemtype other;
}RecdType;//记录类型的定义
typedef struct
{
RecdType r[MAXSIZE+1]; /*零号存储单元不存放记录*/
int length;
}SqList; /*顺序表类型*/
/////////////////实现部分///////////////////
void DisplayList(SqList L)
{
cout<<"The result after sorting:"<<endl;
for(int i=1;i<=L.length;i++)
cout<<L.r[i].key<<" ";
}
void InsertSort(SqList &L)//直接插入排序的实现
{
int j;
for(int i=2;i<=L.length;++i)
if(L.r[i].key<L.r[i-1].key)
{
L.r[0]=L.r[1];//r[0]充当哨兵
for(int j=i-1;L.r[0].key<L.r[j].key;--j)
L.r[j+1]=L.r[j];//记录后移
L.r[j+1]=L.r[0];//插入到正确位置
}
DisplayList(L);
}//InsertSort
/*int Partition(RcdType R[],int low,int high)//快速排序算法的实现
{
R[0]=R[low];//设置枢轴
pivotkey=R[low].key;//枢轴记录关键字
while(low<high)
{
while(low<high && R[high].key>=pivotkey)
--high;
if(low<high)
R[low++]=R[high];
while(low<high && R[low].key<=pivotkey)
++low;
if(low<high)
R[high--]=R[0];
}
R
}
}*/
void BubbleSort(SqList &L)//冒泡排序法的实现
{
RecdType W;
int i=L.length;
while(i>1)//大于1表明上一次曾进行过交换
{
int lastExchangeIndex=1;
for(int j=1;j<i;j++)
{
if(L.r[j+1].key<L.r[j].key)
{
W=L.r[j];
L.r[i]=L.r[i+1];
L.r[j+1]=W;
}//if
}//for
}//while
DisplayList(L);
}//BubbleSort
void SelectSort(SqList L)//简单选择排序的实现
{
RecdType temp;
for(int i=1;i<L.length;++i)
{
int k=i;
for(int j=i+1;j<L.length;++j)
if(L.r[j].key<L.r[k].key)
k=j;
if(k!=i)
{
temp=L.r[i];
L.r[i]=L.r[k];
L.r[k]=temp;
}//if
}//for
DisplayList(L);
}//SelactSort
int main()
{
int i;
int choose;
SqList L;
cout<<"***Welcome To Use The Sorting Problem***"<<endl;
cout<<"Please Enter The Length Of Numbers For Sorting:"<<endl;
cin>>L.length;
cout<<"Please Enter Numbers:"<<endl;
for(i=1;i<=L.length;i++)
cin>>L.r[i].key;
cout<<" Please Select The Sorting Methods: "<<endl;
cout<<"*******************************************"endl;
cout<<" 0 for Exit"<<endl;
cout<<" 1 for Insertion Sort"<<endl;
cout<<" 2 for Bubble Sort"<<endl;
cout<<" 3 for Selection Sort"<<endl;
cout<<" 4 for Quick Sort"<<endl;
cout << "*******************************************" << endl;
while (1)
{
cout<<"Please Enter The Method You Select:"<<endl;
cin>>choose;
if(choose>=0 && choose<= 3)
{
switch(choose)
{
case 0:
return 0;
case 1:
cout<<"Insertion Sort:"<<endl;
InsertSort(L);
continue;
case 2:
cout<<"Bubble Sort:"<<endl;
BubbleSort(L);
continue;
case 3:
cout<<"Selection Sort:"<<endl;
SelectSort(L);
continue;
/*case 4:
cout<<"Quick Sort:"<<endl;
QuickSort(L);
continue;*/
}//While
}
return 0;
}
2016年04月07日 13点04分 3
level 2
zyuanwei 楼主
错误列表 ...
2016年04月07日 13点04分 5
level 2
zyuanwei 楼主
我感觉是不是编译器坏了,怎么解决呢?急~ 在线等! 大神求帮助哦·~~~~[呼~][呼~][呼~]
2016年04月07日 13点04分 6
1