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

时间:2014-04-01 16:12:32

标签: c

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

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++;
    }

1 个答案:

答案 0 :(得分:1)

5icomplex numberAt 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视为&#34;复杂的int&#34;

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

    "c language complex numbers"没有发现任何事情,但"gcc support for complex numbers"确实如此。