小编use*_*960的帖子

错误"在int之前预期的primary-expression"

我正在编写一个代码(希望)允许用户输入一个数字,并输出2和该数字(包括)之间的素数之和.但是,我在代码的倒数第二行遇到了一个问题.我已经查找了这个问题的其他解决方案,但它们似乎并不是由与我相同的错误引起的.这是代码:

#include <iostream>

using namespace std;

int Q;

int sum_primes(int N) {

    cout << "Enter a number and I will generate the sums of the primes up to (and including) that number: ";
    cin >> Q;

    int i, count, sum = 0;

    for(N = 1; N <= Q; N++) {    
         count = 0;

         for(i = 2; i <= N/2; i++) {
             if (N % i == 0) {
                 count++;
                 break;
             }
         }

         if (count == 0 && N != 1) …
Run Code Online (Sandbox Code Playgroud)

c++ function

2
推荐指数
1
解决办法
665
查看次数

标签 统计

c++ ×1

function ×1