- 最後登錄
- 2010-4-10
- 在線時間
- 38 小時
- 註冊時間
- 2009-2-11
- 閱讀權限
- 30
- 精華
- 0
- UID
- 5824491
- 帖子
- 946
- 積分
- 2494 點
- 潛水值
- 9421 米
| 如果瀏覽伊莉時速度太慢或無法連接,可以使用其他分流瀏覽伊莉,www01.eyny.com(02,03)。 Form1.h
參考吧- #pragma once
- namespace SUM3 {
- 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>
- /// Form1 的摘要
- ///
- /// 警告: 如果您變更這個類別的名稱,就必須變更與這個類別所依據之所有 .resx 檔案關聯的
- /// Managed 資源編譯器工具的 'Resource File Name' 屬性。
- /// 否則,這些設計工具
- /// 將無法與這個表單關聯的當地語系化資源
- /// 正確互動。
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: 在此加入建構函式程式碼
- //
- }
- protected:
- /// <summary>
- /// 清除任何使用中的資源。
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::TextBox^ textBox1;
- protected:
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Button^ button3;
- private: System::Windows::Forms::TextBox^ textBox2;
- private:
- /// <summary>
- /// 設計工具所需的變數。
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改這個方法的內容。
- ///
- /// </summary>
- void InitializeComponent(void)
- {
- this->textBox1 = (gcnew System::Windows::Forms::TextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->button3 = (gcnew System::Windows::Forms::Button());
- this->textBox2 = (gcnew System::Windows::Forms::TextBox());
- this->SuspendLayout();
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(85, 32);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(120, 22);
- this->textBox1->TabIndex = 0;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(29, 99);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(73, 34);
- this->button1->TabIndex = 1;
- this->button1->Text = L"button1";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(118, 100);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(68, 32);
- this->button2->TabIndex = 2;
- this->button2->Text = L"button2";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
- //
- // button3
- //
- this->button3->Location = System::Drawing::Point(212, 102);
- this->button3->Name = L"button3";
- this->button3->Size = System::Drawing::Size(56, 29);
- this->button3->TabIndex = 3;
- this->button3->Text = L"button3";
- this->button3->UseVisualStyleBackColor = true;
- this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(71, 161);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(134, 22);
- this->textBox2->TabIndex = 4;
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(292, 266);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->button3);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox1);
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- int i=Int32::Parse(textBox1->Text);
- int j,sum=0;
- for(j=1;j<=i;j++)
- sum+=j;
- textBox2->Text=sum+"";
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- int i=Int32::Parse(textBox1->Text);
- int j,sum=0;
- for(j=1;j<=i;j+=2)
- sum+=j;
- textBox2->Text=sum+"";
-
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
- int i=Int32::Parse(textBox1->Text);
- int j,sum=0;
- for(j=2;j<=i;j+=2)
- sum+=j;
- textBox2->Text=sum+"";
-
- }
- };
- }
複製代碼 ... |
|