下面这段代码是我建立的结构体和整形变量时的影射表
#include<iostream>
#include<map>
using namespace std;struct line
{
double slope;
double intercept;
};int data[701][2];
int main(void)
{
int n,i=0,j;
cin>>n;
while(1)
{
int a1,a2;
cin>>a1;
if(a1==0)
break;
cin>>a2;
data[i][0]=a1;
data[i][1]=a2;
i++;
}
map<line,int> mp;
int max=0;
for (i = 0; i < n-1; i++)
{
while(0);
for (j = i+1; j < n; j++)
{ line l;
l.slope=(data[i][1]-data[j][1])/(data[i][0]-data[j][0]);
l.intercept=(data[j][1]*data[i][0]-data[i][1]*data[j][0])/(data[i][0]-data[j][0]);
++mp[l];
while(0);
}
}
map<line,int>::const_iterator it;
for(it=mp.begin();it!=mp.end();it++)
if(it->second>max)
max=it->second;
cout<<max<<endl;
return 0;
}
编译的时候总是报错『error C2784: 'bool __cdecl std::operator <(const class std::multimap<_K,_Ty,_Pr,_A> &,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce template argument for 'const
class std::multimap<_K,_Ty,_Pr,_A> &' from 'const struct line'』
这是为什么,请高手指点一下!!!
#include<iostream>
#include<map>
using namespace std;struct line
{
double slope;
double intercept;
};int data[701][2];
int main(void)
{
int n,i=0,j;
cin>>n;
while(1)
{
int a1,a2;
cin>>a1;
if(a1==0)
break;
cin>>a2;
data[i][0]=a1;
data[i][1]=a2;
i++;
}
map<line,int> mp;
int max=0;
for (i = 0; i < n-1; i++)
{
while(0);
for (j = i+1; j < n; j++)
{ line l;
l.slope=(data[i][1]-data[j][1])/(data[i][0]-data[j][0]);
l.intercept=(data[j][1]*data[i][0]-data[i][1]*data[j][0])/(data[i][0]-data[j][0]);
++mp[l];
while(0);
}
}
map<line,int>::const_iterator it;
for(it=mp.begin();it!=mp.end();it++)
if(it->second>max)
max=it->second;
cout<<max<<endl;
return 0;
}
编译的时候总是报错『error C2784: 'bool __cdecl std::operator <(const class std::multimap<_K,_Ty,_Pr,_A> &,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce template argument for 'const
class std::multimap<_K,_Ty,_Pr,_A> &' from 'const struct line'』
这是为什么,请高手指点一下!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货