请编写一个函数int fun(int n),其中n为自然数。函数fun()的功能是求出自然数n(包括n)以内所有素数的和,并返回其值。 注意;部分源程序已存在文件PROC11.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数fun()

admin2012-05-11  20

问题 请编写一个函数int fun(int n),其中n为自然数。函数fun()的功能是求出自然数n(包括n)以内所有素数的和,并返回其值。
   注意;部分源程序已存在文件PROC11.cpp中。
   请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。
   文件PROC11.cpp的内容如下:
   //PROC11.cpp
   #include<iostream>
   using namespace std;
   int fun(int n);
   int main()
   {
      int number;
      cout<<"Enter the number which you want to caculate: \n";
      cin>>number;
      cout<<"The result is:"<<fun(number)<<end1;
      return  0;
   }
   int fun(int n)
   {
      //* * * * * * * * *
   }

选项

答案

解析
转载请注明原文地址:https://kaotiyun.com/show/u7ID777K
0

最新回复(0)