fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory这个错误怎么改 5
#include<iostream.h>usingnamespacestd;template<typenameDataType>classQuickSortTemp{pu...
#include <iostream.h>
using namespace std;
template<typename DataType>
class QuickSortTemp
{
public:
QuickSortTemp()
{
}
~QuickSortTemp()
{
}
public:
static void QuickSort(DataType* Array, int nLower, int nUpper)
{
if (nLower < nUpper)
{
int nSplit = Partition (Array, nLower, nUpper);//数据切分为两个部分
QuickSort (Array, nLower, nSplit - 1);//左半部分递归排序
QuickSort (Array, nSplit + 1, nUpper);//右半部分递归排序
}
}
static int Partition (DataType* Array, int nLower, int nUpper)
{
int nLeft = nLower + 1;
DataType Pivot = Array[nLower];
int nRight = nUpper;
DataType Swap;
while (nLeft <= nRight)
{
while (nLeft <= nRight && Array[nLeft].CompareTo(Pivot) <= 0)
nLeft = nLeft + 1;
while (nLeft <= nRight && Array[nRight].CompareTo(Pivot) > 0)
nRight = nRight - 1;
if (nLeft < nRight)
{
Swap = Array[nLeft];
Array[nLeft] = Array[nRight];
Array[nRight] = Swap;
nLeft = nLeft + 1;
nRight = nRight - 1;
}
}
Swap = Array[nLower];
Array[nLower] = Array[nRight];
Array[nRight] = Swap;
return nRight;
}
};
struct MyPoint
{
MyPoint()
{
}
MyPoint(int x, int y)
{
this->x = x;
this->y = y;
}
int CompareTo(MyPoint& b)
{
if(this->x < b.x)
return -1;
else if(this->x > b.x)
return 1;
else
{
if(this->y > b.y)
return 1;
else if(this->y < b.y)
return -1;
else
return 0;
}
}
int x;
int y;
};
int i;
int _tmain(int argc, int * argv[], int * envp[])
{
int nRetCode = 0;
//Point数组
MyPoint points[10] = {MyPoint(1,1), MyPoint(2,5), MyPoint(7,11), MyPoint(100,2),
MyPoint(1, 7), MyPoint(9,32), MyPoint(7, 1), MyPoint(2,2),
MyPoint(1,1), MyPoint(9,5)};
int count = 10;
//排序前
cout<<"before quicksort"<<endl;
for(int i = 0 ; i <count ; i ++)
cout<< points[i].x<< points[i].y<<endl;
//调用模板类排序
QuickSortTemp<MyPoint>::QuickSort(points, 0, count - 1);
//排序后
cout<<"after quicksort"<<endl;
for(i = 0 ; i <count ; i ++)
cout<< points[i].x<< points[i].y<<endl;
return nRetCode;
}
这个程序的错误怎么改我真的很急啊各位帮帮忙 展开
using namespace std;
template<typename DataType>
class QuickSortTemp
{
public:
QuickSortTemp()
{
}
~QuickSortTemp()
{
}
public:
static void QuickSort(DataType* Array, int nLower, int nUpper)
{
if (nLower < nUpper)
{
int nSplit = Partition (Array, nLower, nUpper);//数据切分为两个部分
QuickSort (Array, nLower, nSplit - 1);//左半部分递归排序
QuickSort (Array, nSplit + 1, nUpper);//右半部分递归排序
}
}
static int Partition (DataType* Array, int nLower, int nUpper)
{
int nLeft = nLower + 1;
DataType Pivot = Array[nLower];
int nRight = nUpper;
DataType Swap;
while (nLeft <= nRight)
{
while (nLeft <= nRight && Array[nLeft].CompareTo(Pivot) <= 0)
nLeft = nLeft + 1;
while (nLeft <= nRight && Array[nRight].CompareTo(Pivot) > 0)
nRight = nRight - 1;
if (nLeft < nRight)
{
Swap = Array[nLeft];
Array[nLeft] = Array[nRight];
Array[nRight] = Swap;
nLeft = nLeft + 1;
nRight = nRight - 1;
}
}
Swap = Array[nLower];
Array[nLower] = Array[nRight];
Array[nRight] = Swap;
return nRight;
}
};
struct MyPoint
{
MyPoint()
{
}
MyPoint(int x, int y)
{
this->x = x;
this->y = y;
}
int CompareTo(MyPoint& b)
{
if(this->x < b.x)
return -1;
else if(this->x > b.x)
return 1;
else
{
if(this->y > b.y)
return 1;
else if(this->y < b.y)
return -1;
else
return 0;
}
}
int x;
int y;
};
int i;
int _tmain(int argc, int * argv[], int * envp[])
{
int nRetCode = 0;
//Point数组
MyPoint points[10] = {MyPoint(1,1), MyPoint(2,5), MyPoint(7,11), MyPoint(100,2),
MyPoint(1, 7), MyPoint(9,32), MyPoint(7, 1), MyPoint(2,2),
MyPoint(1,1), MyPoint(9,5)};
int count = 10;
//排序前
cout<<"before quicksort"<<endl;
for(int i = 0 ; i <count ; i ++)
cout<< points[i].x<< points[i].y<<endl;
//调用模板类排序
QuickSortTemp<MyPoint>::QuickSort(points, 0, count - 1);
//排序后
cout<<"after quicksort"<<endl;
for(i = 0 ; i <count ; i ++)
cout<< points[i].x<< points[i].y<<endl;
return nRetCode;
}
这个程序的错误怎么改我真的很急啊各位帮帮忙 展开
1个回答
2011-12-26
展开全部
#include <iostream.h>
using namespace std;
改为:
#include <iostream> //这里!这里!这里!这里!这里!这里!
using namespace std;
using namespace std;
改为:
#include <iostream> //这里!这里!这里!这里!这里!这里!
using namespace std;
追问
不是吧
追答
要么就用:
#include
要么就用:
#include
using namespace std;
这么用是错的:
#include
using namespace std;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询