gpt4 book ai didi

c - 二进制上的无效操作有 int 和complex int

转载 作者:行者123 更新时间:2023-11-30 15:35:49 24 4
gpt4 key购买 nike

我收到以下错误(以及更多我可以纠正的语法错误)。知道为什么以及如何解决它吗?

In function 'main':|

21|error: invalid operands to binary < (have 'int' and 'complex int')|


24|error: invalid operands to binary % (have 'complex int' and 'int')|

26|error: invalid operands to binary <= (have 'int' and 'complex int')|

28|error: invalid operands to binary <= (have 'int' and 'complex int')|

来源:

#include<stdio.h>
main()
{
int t,flag,i,j,k,no[20];
scanf("%d",&t);
for(i=1;i<=t;i++)
scanf("%d",&no[i]);

for(j=1;j<=t;j++){

if(no[j]%3==0){
for(i=1;i<=no[j];i++){
printf("5");}
printf("\n");}


else{
i=1;
flag=0;
while(flag==0){
if(no[j]<5i)
printf("-1");

else if((no[j]-5i)%3==0){
flag=1;
for(k=1;k<=(no[j]-5i);k++)
printf("5");
for(k=1;k<=5i;k++)
printf("3");}
else
i++;
}

最佳答案

5icomplex number (At least in gcc it is)。只需使用 5 。 (或者 5*i 因为你说你打算乘法。)

<小时/>

将来您可以通过几个简单的步骤自行解决此类问题:

  1. 读取错误:

    21|error: invalid operands to binary < (have 'int' and 'complex int')|

  2. 找到行:

    if(no[j]<5i)

  3. 思考:

    < 的操作数是no[j]5i 。我明白了no[j]声明为int所以它一定是在治疗5i作为“复杂整数”

  4. 加上一点搜索来验证:

    "c language complex numbers"没有出现任何结果,但是 "gcc support for complex numbers"做到了。

关于c - 二进制上的无效操作有 int 和complex int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22791264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com