欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

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

求素?cái)?shù),用vector存儲的實(shí)現(xiàn)方法

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

PS:如有不足之處,還望指正!

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

// tentotwo.cpp : 定義控制臺應(yīng)用程序的入口點(diǎn)。
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
void GetPrimer(int n, vector<int>& vet)
{
 for (int i = 2; i <= n; i++)
 {
  vet.push_back(i);
 }
 vector<int>::iterator ite = vet.begin();
 while (ite != vet.end())
 {
  vector<int>::iterator tmpite = ite + 1;
  while (tmpite != vet.end())
  {
   if ((*tmpite)%(*ite) == 0)
   {
    tmpite = vet.erase(tmpite);
   }
   else
   {
    tmpite ++;
   }
  }  
  ite ++;
 } 
}
int _tmain(int argc, _TCHAR* argv[])
{
 vector<int> vet;
 GetPrimer(100, vet);
 vector<int>::iterator ite = vet.begin();
 while (ite != vet.end())
 {
  cout << *ite << " ";
  ite ++;
 }
 cout << endl;
 return 0;
}

上一篇:探討:將兩個鏈表非降序合并為一個鏈表并依然有序的實(shí)現(xiàn)方法

欄    目:C語言

下一篇:C++中virtual繼承的深入理解

本文標(biāo)題:求素?cái)?shù),用vector存儲的實(shí)現(xiàn)方法

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/4418.html

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

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

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

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