雷火电竞-中国电竞赛事及体育赛事平台

歡迎來(lái)到入門(mén)教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

輸出1000以?xún)?nèi)的素?cái)?shù)的算法(實(shí)例代碼)

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊:

代碼如下所示:

復(fù)制代碼 代碼如下:

#include "stdafx.h"
#include <iostream>
#include <math.h>
bool IsSushu(int n)
{
 bool IsSushuFlg = true;
 if( n <= 1)
 {
  return false;
 }
 for( int i = 2; i <= (int)sqrt((double)n); i++ )
 {
  if( 0 == n % i )
  {
   IsSushuFlg = false;
   break;
  }
 }
 return IsSushuFlg;
}
#define N 1000
int main()
{
 printf("Su shu is: /n");
 for( int i = 2; i < N; i++)
 {
  bool IsSushuFlg = IsSushu(i);
  if( IsSushuFlg )
  {
   printf("%d /n", i);
  }
 }

 system("pause");
 return 0;
}

上一篇:基于C++內(nèi)存分配、函數(shù)調(diào)用與返回值的深入分析

欄    目:C語(yǔ)言

下一篇:c++ 虛函數(shù)與純虛函數(shù)的區(qū)別(深入分析)

本文標(biāo)題:輸出1000以?xún)?nèi)的素?cái)?shù)的算法(實(shí)例代碼)

本文地址:http://www.jygsgssxh.com/a1/Cyuyan/4445.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有