Roman Radu-Alexandru Calculatoare an II Lucrare pentru colocviu de practică Descriere: Aplicatia are ca scop functionalitatea unui decodificator si a unui codificator. Converteste un numar din zecimal in binar si din binar in zecimal. Dupa rulare:
Codul: public ref class Form1 : public System::Windows::Forms::Form int A,B,C,D; int temp; int x; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::NumericUpDown^ numericupdown5; 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::NumericUpDown^ numericupdown1; protected: private: System::Windows::Forms::NumericUpDown^ numericupdown2; private: System::Windows::Forms::NumericUpDown^ numericupdown3; private: System::Windows::Forms::NumericUpDown^ numericupdown4; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Button^ button1; protected: 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) this->numericupdown1 = (gcnew
System::Windows::Forms::NumericUpDown()); this->numericupdown2 = (gcnew System::Windows::Forms::NumericUpDown()); this->numericupdown3 = (gcnew System::Windows::Forms::NumericUpDown()); this->numericupdown4 = (gcnew System::Windows::Forms::NumericUpDown()); this->label1 = (gcnew System::Windows::Forms::Label()); this->button1 = (gcnew System::Windows::Forms::Button()); this->numericupdown5 = (gcnew System::Windows::Forms::NumericUpDown()); this->label2 = (gcnew System::Windows::Forms::Label()); this->label3 = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->label5 = (gcnew System::Windows::Forms::Label()); this->button2 = (gcnew System::Windows::Forms::Button()); >(this->numericupdown1))->begininit(); >(this->numericupdown2))->begininit(); >(this->numericupdown3))->begininit(); >(this->numericupdown4))->begininit(); >(this->numericupdown5))->begininit(); this->suspendlayout(); numericupdown1 this->numericupdown1->location = System::Drawing::Point(46, 111); this->numericupdown1->maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) 1, 0, 0, 0); this->numericupdown1->name = L"numericUpDown1"; this->numericupdown1->size = System::Drawing::Size(30, 20); this->numericupdown1->tabindex = 0; numericupdown2 this->numericupdown2->location = System::Drawing::Point(45, 151); this->numericupdown2->maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) 1, 0, 0, 0); this->numericupdown2->name = L"numericUpDown2"; this->numericupdown2->size = System::Drawing::Size(30, 20); this->numericupdown2->tabindex = 1; numericupdown3 this->numericupdown3->location = System::Drawing::Point(46, 189); this->numericupdown3->maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) 1, 0, 0, 0); this->numericupdown3->name = L"numericUpDown3"; this->numericupdown3->size = System::Drawing::Size(30, 20); this->numericupdown3->tabindex = 2; numericupdown4 this->numericupdown4->location = System::Drawing::Point(45, 231); this->numericupdown4->maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) 1, 0, 0, 0);
this->numericupdown4->name = L"numericUpDown4"; this->numericupdown4->size = System::Drawing::Size(30, 20); this->numericupdown4->tabindex = 3; label1 this->label1->autosize = true; this->label1->location = System::Drawing::Point(252, 184); this->label1->name = L"label1"; this->label1->size = System::Drawing::Size(35, 13); this->label1->tabindex = 4; this->label1->text = L"label1"; button1 this->button1->location = System::Drawing::Point(100, 307); this->button1->name = L"button1"; this->button1->size = System::Drawing::Size(123, 23); this->button1->tabindex = 5; this->button1->text = L"Decodifica"; this->button1->usevisualstylebackcolor = true; this->button1->click += gcnew System::EventHandler(this, &Form1::button1_Click); numericupdown5 this->numericupdown5->location = System::Drawing::Point(424, 181); this->numericupdown5->maximum = System::Decimal(gcnew cli::array< System::Int32 >(4) 15, 0, 0, 0); this->numericupdown5->name = L"numericUpDown5"; this->numericupdown5->size = System::Drawing::Size(40, 20); this->numericupdown5->tabindex = 6; label2 >AutoSize = true; >Location = System::Drawing::Point(664, 110); >Name = L"label2"; >Size = System::Drawing::Size(35, 13); >TabIndex = 7; >Text = L"label2"; label3 this->label3->autosize = true; this->label3->location = System::Drawing::Point(664, 152); this->label3->name = L"label3"; this->label3->size = System::Drawing::Size(35, 13); this->label3->tabindex = 8; this->label3->text = L"label3"; label4 this->label4->autosize = true; this->label4->location = System::Drawing::Point(664, 191); this->label4->name = L"label4"; this->label4->size = System::Drawing::Size(35, 13); this->label4->tabindex = 9; this->label4->text = L"label4"; label5 this->label5->autosize = true;
this->label5->location = System::Drawing::Point(664, 232); this->label5->name = L"label5"; this->label5->size = System::Drawing::Size(35, 13); this->label5->tabindex = 10; this->label5->text = L"label5"; button2 this->button2->location = System::Drawing::Point(501, 307); this->button2->name = L"button2"; this->button2->size = System::Drawing::Size(115, 23); this->button2->tabindex = 11; this->button2->text = L"Codifica"; this->button2->usevisualstylebackcolor = true; this->button2->click += gcnew System::EventHandler(this, &Form1::button2_Click); Form1 this->autoscaledimensions = System::Drawing::SizeF(6, 13); this->autoscalemode = System::Windows::Forms::AutoScaleMode::Font; this->clientsize = System::Drawing::Size(725, 372); this->controls->add(this->button2); this->controls->add(this->label5); this->controls->add(this->label4); this->controls->add(this->label3); this->controls->add(this->label2); this->controls->add(this->numericupdown5); this->controls->add(this->button1); this->controls->add(this->label1); this->controls->add(this->numericupdown4); this->controls->add(this->numericupdown3); this->controls->add(this->numericupdown2); this->controls->add(this->numericupdown1); this->name = L"Form1"; this->text = L"Aplicatie"; this->paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::desen); >(this->numericupdown1))->endinit(); >(this->numericupdown2))->endinit(); >(this->numericupdown3))->endinit(); >(this->numericupdown4))->endinit(); >(this->numericupdown5))->endinit(); this->resumelayout(false); this->performlayout(); #pragma endregion private: System::Void desen(system::object^ sender, System::Windows::Forms::PaintEventArgs^ e) Graphics^ g = e->graphics; g->clear(color::aliceblue); Pen^ creion_prim = gcnew Pen(Color::Black); creion_prim->width = 2; g->drawline(creion_prim,this->width/2,this- >Height,this->Width/2,0);
System::Drawing::SolidBrush^ pensula; pensula=gcnew System::Drawing::SolidBrush(System::Drawing::Color::Red); System::Drawing::Font^ fontul_meu; fontul_meu=gcnew System::Drawing::Font("Radu",10); g- >DrawString("Decodificator",fontul_meu,pensula,120,20); g->drawstring("codificator",fontul_meu,pensula,520,20); g->drawrectangle(creion_prim,110,80,100,200); System::Drawing::SolidBrush^ pensula2; pensula2=gcnew System::Drawing::SolidBrush(System::Drawing::Color::Black); System::Drawing::Font^ fontul_meu2; fontul_meu2=gcnew System::Drawing::Font("Radu",20); g->drawstring("dec.",fontul_meu2,pensula2,120,120); g->drawline(creion_prim,90,120,110,120); g->drawline(creion_prim,90,160,110,160); g->drawline(creion_prim,90,200,110,200); g->drawline(creion_prim,90,240,110,240); g->drawline(creion_prim,210,190,250,190); g->drawrectangle(creion_prim,510,80,100,200); g->drawline(creion_prim,480,190,510,190); g->drawstring("cod.",fontul_meu2,pensula2,520,120); g->drawline(creion_prim,610,120,640,120); g->drawline(creion_prim,610,160,640,160); g->drawline(creion_prim,610,200,640,200); g->drawline(creion_prim,610,240,640,240); (C*2)+(B*4)+(A*8)); int A=System::Convert::ToDouble(this->numericUpDown1- int B=System::Convert::ToDouble(this->numericUpDown2- int C=System::Convert::ToDouble(this->numericUpDown3- int D=System::Convert::ToDouble(this->numericUpDown4- this->label1->text=system::convert::tostring((d*1)+ x=system::convert::todouble(this->numericupdown5- if(x==1) this->label5- >Text=System::Convert::ToString("1"); this->label4- this->label3- else if(x<4) this->label5- this->label4- this->label3->text=system::convert::tostring(x
>Text=System::Convert::ToString(x/2); else if(x<8) this->label5- this->label4->text=system::convert::tostring(x temp=x/2; this->label3->text=system::convert::tostring(temp >Text=System::Convert::ToString(temp/2); else this->label5->text=system::convert::tostring(x temp=x/2; this->label4->text=system::convert::tostring(temp temp=temp/2; this->label3->text=system::convert::tostring(temp >Text=System::Convert::ToString(temp/2); private: System::Void button1_click(system::object^ sender, System::EventArgs^ e) this->label1- >Text=System::Convert::ToString((D*1)+(C*2)+(B*4)+(A*8)); private: System::Void button2_click(system::object^ sender, System::EventArgs^ e) x=system::convert::todouble(this->numericupdown5- if(x==1) this->label5- >Text=System::Convert::ToString("1"); this->label4- this->label3- else if(x<4) this->label5- this->label4- this->label3->text=system::convert::tostring(x >Text=System::Convert::ToString(x/2); else if(x<8) this->label5- this->label4->text=system::convert::tostring(x temp=x/2; this->label3->text=system::convert::tostring(temp >Text=System::Convert::ToString(temp/2);
else this->label5->text=system::convert::tostring(x temp=x/2; this->label4->text=system::convert::tostring(temp temp=temp/2; this->label3->text=system::convert::tostring(temp >Text=System::Convert::ToString(temp/2);