VC.NET链表

#pragma once
# include "linklist.h"
# include "common.h"
#include   "stdlib.h "
#include   "string"
#include   "string.h"
namespace list {
    using namespace std;
 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 文件关联的托管资源编译器工具的
 ///          “资源文件名”属性。否则,
 ///          设计器将不能与此窗体的关联
 ///          本地化资源正确交互。
 /// </summary>
  LinkList L=NULL;
 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::Button^  button1;
 private: System::Windows::Forms::TextBox^  textBox1;
 private: System::Windows::Forms::Button^  button2;

 private: System::Windows::Forms::TextBox^  textBox2;

 private: System::Windows::Forms::Button^  button3;
 private: System::Windows::Forms::Button^  button4;
 private: System::Windows::Forms::TextBox^  textBox3;
 private: System::Windows::Forms::Label^  label1;
 private: System::Windows::Forms::Label^  label2;
 private: System::Windows::Forms::Label^  label3;
 protected:

 private:
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
  /// <summary>
  /// 设计器支持所需的方法 - 不要
  /// 使用代码编辑器修改此方法的内容。
  /// </summary>
  void InitializeComponent(void)
  {
   this->button1 = (gcnew System::Windows::Forms::Button());
   this->textBox1 = (gcnew System::Windows::Forms::TextBox());
   this->button2 = (gcnew System::Windows::Forms::Button());
   this->textBox2 = (gcnew System::Windows::Forms::TextBox());
   this->button3 = (gcnew System::Windows::Forms::Button());
   this->button4 = (gcnew System::Windows::Forms::Button());
   this->textBox3 = (gcnew System::Windows::Forms::TextBox());
   this->label1 = (gcnew System::Windows::Forms::Label());
   this->label2 = (gcnew System::Windows::Forms::Label());
   this->label3 = (gcnew System::Windows::Forms::Label());
   this->SuspendLayout();
   //
   // button1
   //
   this->button1->Location = System::Drawing::Point(12, 8);
   this->button1->Name = L"button1";
   this->button1->Size = System::Drawing::Size(75, 23);
   this->button1->TabIndex = 0;
   this->button1->Text = L"建立链表";
   this->button1->UseVisualStyleBackColor = true;
   this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
   //
   // textBox1
   //
   this->textBox1->Location = System::Drawing::Point(73, 89);
   this->textBox1->Name = L"textBox1";
   this->textBox1->Size = System::Drawing::Size(39, 21);
   this->textBox1->TabIndex = 1;
   //
   // button2
   //
   this->button2->Location = System::Drawing::Point(140, 89);
   this->button2->Name = L"button2";
   this->button2->Size = System::Drawing::Size(75, 23);
   this->button2->TabIndex = 2;
   this->button2->Text = L"向前插入";
   this->button2->UseVisualStyleBackColor = true;
   this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
   //
   // textBox2
   //
   this->textBox2->Location = System::Drawing::Point(73, 48);
   this->textBox2->Name = L"textBox2";
   this->textBox2->Size = System::Drawing::Size(39, 21);
   this->textBox2->TabIndex = 4;
   //
   // button3
   //
   this->button3->Location = System::Drawing::Point(140, 46);
   this->button3->Name = L"button3";
   this->button3->Size = System::Drawing::Size(75, 23);
   this->button3->TabIndex = 6;
   this->button3->Text = L"计算结点数";
   this->button3->UseVisualStyleBackColor = true;
   this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
   //
   // button4
   //
   this->button4->Location = System::Drawing::Point(12, 133);
   this->button4->Name = L"button4";
   this->button4->Size = System::Drawing::Size(75, 23);
   this->button4->TabIndex = 7;
   this->button4->Text = L"表中数据显示";
   this->button4->UseVisualStyleBackColor = true;
   this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
   //
   // textBox3
   //
   this->textBox3->Location = System::Drawing::Point(12, 162);
   this->textBox3->Name = L"textBox3";
   this->textBox3->Size = System::Drawing::Size(268, 21);
   this->textBox3->TabIndex = 8;
   //
   // label1
   //
   this->label1->AutoSize = true;
   this->label1->Location = System::Drawing::Point(14, 57);
   this->label1->Name = L"label1";
   this->label1->Size = System::Drawing::Size(41, 12);
   this->label1->TabIndex = 9;
   this->label1->Text = L"结点数";
   //
   // label2
   //
   this->label2->AutoSize = true;
   this->label2->Location = System::Drawing::Point(14, 94);
   this->label2->Name = L"label2";
   this->label2->Size = System::Drawing::Size(53, 12);
   this->label2->TabIndex = 10;
   this->label2->Text = L"数据元素";
   //
   // label3
   //
   this->label3->AutoSize = true;
   this->label3->Location = System::Drawing::Point(35, 221);
   this->label3->Name = L"label3";
   this->label3->Size = System::Drawing::Size(107, 12);
   this->label3->TabIndex = 11;
   this->label3->Text = L"qianjin_w@126.com";
   //
   // Form1
   //
   this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
   this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
   this->ClientSize = System::Drawing::Size(292, 262);
   this->Controls->Add(this->label3);
   this->Controls->Add(this->label2);
   this->Controls->Add(this->label1);
   this->Controls->Add(this->textBox3);
   this->Controls->Add(this->button4);
   this->Controls->Add(this->button3);
   this->Controls->Add(this->textBox2);
   this->Controls->Add(this->button2);
   this->Controls->Add(this->textBox1);
   this->Controls->Add(this->button1);
   this->Name = L"Form1";
   this->Text = L"链表";
   this->ResumeLayout(false);
   this->PerformLayout();

  }
#pragma endregion
 

 
 private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

 init_linklist(&L);
 textBox2->Text="0";

    }
 private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
 ElemType x;
 char ch;
 String ^s;
 s=textBox1->Text;
 ch=s[0];
 InsList(L,1,ch);
 textBox1->Text="";
    }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
 int len=0;
 LinkList p;
 p=L->next;
 while(p!=NULL)
 { p=p->next;
  len++;
 }
 textBox2->Text=len.ToString();
   }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
int i=0;
LinkList p;
char *w,ch[20];
String ^s="";
string ss="asd";


p=L->next;
while(p!=NULL)
{  
 ch[i]=p->data;
 p=p->next;
 i++;
}
ch[i]='/0';
s=gcnew String(ch);
textBox3->Text=s;

   }
};
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值