简单的程序错误...请帮助 [英] Simple simple program error...please help

查看:175
本文介绍了简单的程序错误...请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的简单程序中我收到此错误..请帮助


我想找到整数,其中65537i + 3551j = 1


错误:无法将`__complex__ int''转换为'long int''

赋值

#include< iostream>

# include< complex>

#include< cmath>


使用命名空间std;


int main( )

{

long x = 0;

int y = 0;


for( long i = 0; i< 65537; i ++)

{

for(long j = 0; j< 3511; j ++)

{

x = 65337i + 3511j;

if(x = 1)

cout<<" i:"<< i<< " j:"<< J<<结束;

}

}


返回0;

}

In my simple program I am getting this error..please help

I am trying to find integers where 65537i + 3551j = 1

error: cannot convert `__complex__ int'' to `long int'' in
assignment
#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

int main ()
{
long x=0;
int y=0;

for (long i=0; i<65537; i++)
{
for (long j=0; j<3511; j++)
{
x=65337i + 3511j;
if (x=1)
cout <<"i: "<< i << " j: "<< j<< endl;
}
}

return 0;
}

推荐答案



< ta ****** @ gmail.com>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...

<ta******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
在我的简单程序中我得到了这个错误..请帮助

我试图找到整数,其中65537i + 3551j = 1

错误:无法转换`在
任务中__complex__ int''到'long int''

#include< iostream>
#include< complex>
#include< cmath>

使用命名空间std;

int main()
{
长x = 0;
int y = 0;

for(long i = 0; i< 65537; i ++)
{
for(long j = 0; j< 3511; j ++)
{
x = 65337i + 3511j;


这是什么? 3511j不是数字。 65537i可能不是数字,

虽然它可能是65537作为int。


我想你想要x = i + j;这里

if(x = 1)
cout<<" i:"<< i<< " j:"<< J<< endl;
}

返回0;
}
In my simple program I am getting this error..please help

I am trying to find integers where 65537i + 3551j = 1

error: cannot convert `__complex__ int'' to `long int'' in
assignment
#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

int main ()
{
long x=0;
int y=0;

for (long i=0; i<65537; i++)
{
for (long j=0; j<3511; j++)
{
x=65337i + 3511j;
What is this? 3511j is not a number. 65537i is probably not a number,
although it might be 65537 as an int.

I think you want x = i + j; here
if (x=1)
cout <<"i: "<< i << " j: "<< j<< endl;
}
}

return 0;
}



ta ****** @ gmail.com 写道:
ta******@gmail.com wrote:
在我的简单程序中我得到这个错误..请帮助

我试图找到整数,其中65537i + 3551j = 1

错误:无法将`__complex__ int''转换为`long int '
分配

#include< iostream>
#include< complex>
#include< cmath>


抛弃最后两个标题:无论如何都不要使用它们。

使用命名空间std;

int main()<对于(long i = 0; i< 65537; i ++)
{
for(long j = 0; j <3511; j ++)
{
x = 65337i + 3511j;


如下:


x = 65337 * i + 3511 * j;

if(x = 1)


可能你的意思是:


if(x == 1)

cout<<"我:"<< i<< " j:"<< J<< endl;
}

返回0;
}
In my simple program I am getting this error..please help

I am trying to find integers where 65537i + 3551j = 1

error: cannot convert `__complex__ int'' to `long int'' in
assignment
#include <iostream>
#include <complex>
#include <cmath>
ditch the last two headers: you do not use them anyway.

using namespace std;

int main ()
{
long x=0;
int y=0;

for (long i=0; i<65537; i++)
{
for (long j=0; j<3511; j++)
{
x=65337i + 3511j;
make that:

x= 65337*i + 3511*j;
if (x=1)
probably you mean:

if ( x == 1 )
cout <<"i: "<< i << " j: "<< j<< endl;
}
}

return 0;
}




另外:


a)运行纠正的程序,你可能会有点意外。这个
找不到任何数字的诀窍:你被任意限制

i和j的搜索空间,你的界限很远(注意它是

根本不能用于i和j都是正面的!)。


b)你可以考虑阅读GCD和欧几里德算法。它可以是

扩展来解决你的问题。


最好


Kai-Uwe Bux



Also:

a) running the corrected program, you might be in for a little surprise. It
will not find any numbers doing the trick: you are arbitrarily restricted
the search space for i and j, and your bounds are way off (note that it
simply cannot work for i and j both positive!).

b) You might consider reading on GCDs and the Euclidean Algorithm. It can be
extended to solve your problem.

Best

Kai-Uwe Bux


Kai ...非常感谢您的建议


为什么我受限制?我认为c ++整数可以跨越某个

的空间......也就是2 ^ 32的行.. ???


我熟悉算法,我需要写自己的班级

来完成这项工作吗?

Kai...thanks so much for your advice

why am i restricted? i thought that c++ integers can span a certain
space..along the lines of 2^32..???

i''m familiar with the algorithms, am i required to write my own class
to make this work?


这篇关于简单的程序错误...请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆