#include<iostream>
#include<vector>
int main()
{
using namespace std;
vector<int> x,y;
for(int a=6;a<=30;++a)
for(int b=15;b<=36;++b)
if((a*2+b*5)==126)
{
x.push_back(a);
y.push_back(b);
}
vector<int>::iterator ix=x.begin(),iy=y.begin();
while(ix!=x.end())
{
cout << "(" << *ix << "," << *iy << ")" << endl;
++ix;
++iy;
}
system("pause");
return(0);
}
思想是对的。。
但是main()得用int定义
cout前面少个std::
还有在优先级没弄清楚前最好判断里加个括号总没错。。不过你这样也是对的
最后返回return(0);
#include<iostream>
int main()
{
using namespace std;
for(int a=6;a<=30;a++)
for(int b=15;b<=36;b++)
if((2*a+5*b)==126)
cout<<"("<<a<<","<<b<<")"<<endl;
system("pause");
return(0);
}
[此贴子已经被作者于2007-7-9 3:09:45编辑过]