Sito Eratostenesa: Różnice pomiędzy wersjami

[wersja przejrzana][wersja nieprzejrzana]
Usunięta treść Dodana treść
m Przywrócono starszą wersję, jej autor to Luckas-bot. Autor wycofanej edycji to 83.29.75.5.
dodanie programu w visual c++
Linia 313:
return 0;
}
</source>
 
 
Zobacz program w Visual C++
<source lang="cpp">
#pragma once
 
 
namespace parzyste {
 
System::Boolean czy_parzysta(System::Int32 liczba){
if ((liczba!=1)&&(liczba%2)&&(liczba%3)&&(liczba%5)&&(liczba%7)&&(liczba%11)&&(liczba%13))
return true;
else
return false;
}
 
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
 
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
 
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
 
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(107, 127);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(123, 35);
this->button1->TabIndex = 0;
this->button1->Text = L"Liczby Pierwsze";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// textBox1
//
this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->textBox1->Location = System::Drawing::Point(12, 12);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->RightToLeft = System::Windows::Forms::RightToLeft::Yes;
this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Both;
this->textBox1->Size = System::Drawing::Size(89, 427);
this->textBox1->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Stencil", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(238)));
this->label1->Location = System::Drawing::Point(107, 22);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(131, 18);
this->label1->TabIndex = 2;
this->label1->Text = L"Sito eratostenesa";
this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(107, 52);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(153, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"50 pierwszych liczb pierwszych";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::GradientInactiveCaption;
this->ClientSize = System::Drawing::Size(288, 451);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
 
}
 
 
 
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
 
 
 
 
 
 
 
array <System::Int32>^ tablica1 = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0};
Array^ tablica2=Array::CreateInstance(System::Int32::typeid,200);
 
for (System::Int32 i=0;i<200;i++)
{ tablica1[i]=i;
tablica2->SetValue(i,i);
}
 
Predicate<System::Int32>^maska=
gcnew Predicate<System::Int32>(czy_parzysta);
tablica2=System::Array::FindAll(tablica1,maska);
 
 
System::Collections::IEnumerator^ enum1=tablica1->GetEnumerator();
System::Collections::IEnumerator^ enum2=tablica2->GetEnumerator();
 
 
 
textBox1->AppendText("Liczby pierwsze : \r\n2 \r\n3 \r\n5 \r\n7 \r\n11 \r\n13" +System::Environment::NewLine);
 
 
while (( enum2->MoveNext())&&(enum2!=nullptr))
textBox1->AppendText(enum2->Current+System::Environment::NewLine);
 
 
}
 
 
 
 
 
 
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
};
}
 
 
</source>