Closed. This question is off-topic. It is not currently accepting answers. Learn more
想改进这个问题吗?Update the question所以堆栈溢出的值小于aa>。
5年前关闭。
我必须做一个程序,在用户定义的数字之前检查所有的数字,并存储主数字。目前,我正试图制作一个程序,检查这些数字是否是素数,但我在编译时得到一个错误代码:
#include <stdlib.h>
#include <stdio.h>

int main(void){

int *array;
int i,j,n;
array = malloc(sizeof(int));

printf("Ingrese su numero:");
scanf("%d",&n);

for(i=2;i<n;i+=1){
    for(j=2;j<=i;j+=1){
        if (i%j==0) $$ (j!=i){
            printf("%d: No Primo \n+",i);
            break;
        }
        else if (i=j){
            printf("%d: Primo \n+",i);
        }
    }
}



return 0;
}

它会抛出
Line 15  error: expected ';' before '}' token

我看不出有什么不对劲。非常感谢你的帮助。

最佳答案

似乎您的一个if语句缺少括号(而且,我假设您打算使用&¬$$):

    if ((i%j==0) && (j!=i)){
        printf("%d: No Primo \n+",i);
        break;
    }

关于c - 在C中编译时出错? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22888972/

10-12 18:30