help with running the code

JuliaRossa

New member
Joined
Apr 8, 2021
Messages
2
Programming Experience
Beginner
C#:
используя Систему;
using System.Windows.Forms;

пространство имен CB
{
    общедоступный частичный класс Form1: Форма
    {
        частная строка alf = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
        общедоступная форма Form1 ()
        {
            InitializeComponent ();
        }

        private void Ecnrypt_Click (отправитель объекта, EventArgs e)
        {
            строка inp = InputText.Text;
            строка outp = string.Empty;
            int value = (int) Number.Value;
            для (int i = 0; i <inp.Length; i ++)
            {
                char currs = inp [I];
                int curri = alf.IndexOf (currs);
                int step = curri + значение;
                if (step> alf.Length) step% = alf.Length;
                outp + = alf [шаг];
            }
            OutputText.Text = outp;
        }

        private void Decrypt_Click (отправитель объекта, EventArgs e)
        {
            строка inp = InputText.Text;
            строка outp = string.Empty;
            int value = (int) Number.Value;
            для (int i = 0; i <inp.Length; i ++)
            {
                char currs = inp [I];
                int curri = alf.IndexOf (currs);
                int step = curri - значение;
                if (step <0) // Задача
                outp + = alf [шаг];
            }
            OutputText.Text = outp;
        }
    }
}





namespace CB
{
    partial class Form1
    {
        /// <summary>
        /// Обязательная переменная конструктора.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Код, автоматически созданный конструктором форм Windows

        /// <summary>
        /// Требуемый метод для поддержки конструктора — не изменяйте 
        /// содержимое этого метода с помощью редактора кода.
        /// </summary>
        private void InitializeComponent()
        {
            this.InputText = new System.Windows.Forms.RichTextBox();
            this.Number = new System.Windows.Forms.NumericUpDown();
            this.OutputText = new System.Windows.Forms.RichTextBox();
            this.Ecnrypt = new System.Windows.Forms.Button();
            this.Decrypt = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.Number)).BeginInit();
            this.SuspendLayout();
            // 
            // InputText
            // 
            this.InputText.Location = new System.Drawing.Point(12, 12);
            this.InputText.Name = "InputText";
            this.InputText.Size = new System.Drawing.Size(217, 250);
            this.InputText.TabIndex = 0;
            this.InputText.Text = "";
            // 
            // Number
            // 
            this.Number.Location = new System.Drawing.Point(235, 13);
            this.Number.Name = "Number";
            this.Number.Size = new System.Drawing.Size(150, 26);
            this.Number.TabIndex = 1;
            this.Number.Value = new decimal(new int[] {
            3,
            0,
            0,
            0});
            // 
            // OutputText
            // 
            this.OutputText.Location = new System.Drawing.Point(391, 12);
            this.OutputText.Name = "OutputText";
            this.OutputText.ReadOnly = true;
            this.OutputText.Size = new System.Drawing.Size(217, 250);
            this.OutputText.TabIndex = 2;
            this.OutputText.Text = "";
            // 
            // Ecnrypt
            // 
            this.Ecnrypt.Location = new System.Drawing.Point(235, 45);
            this.Ecnrypt.Name = "Ecnrypt";
            this.Ecnrypt.Size = new System.Drawing.Size(150, 31);
            this.Ecnrypt.TabIndex = 3;
            this.Ecnrypt.Text = "Зашифровать";
            this.Ecnrypt.UseVisualStyleBackColor = true;
            this.Ecnrypt.Click + = новый System.EventHandler (this.Ecnrypt_Click);
            // 
            // Расшифровать
            // 
            this.Decrypt.Location = новый System.Drawing.Point (235, 82);
            this.Decrypt.Name = "Расшифровать";
            this.Decrypt.Size = новый System.Drawing.Size (150, 31);
            this.Decrypt.TabIndex = 4;
            this.Decrypt.Text = "Расшифровать";
            this.Decrypt.UseVisualStyleBackColor = true;
            this.Decrypt.Click + = новый System.EventHandler (this.Decrypt_Click);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = новый System.Drawing.SizeF (9F, 20F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = новый System.Drawing.Size (621, 282);
            this.Controls.Add (this.Decrypt);
            this.Controls.Add (this.Ecnrypt);
            this.Controls.Add (this.OutputText);
            this.Controls.Add (this.Number);
            this.Controls.Add (this.InputText);
            this.Name = "Form1";
            this.Text = "Form1";
            ((System.ComponentModel.ISupportInitialize) (this.Number)). EndInit ();
            this.ResumeLayout (ложь);

        }

        #endregion

        частный System.Windows.Forms.RichTextBox InputText;
        частный System.Windows.Forms.NumericUpDown Number;
        частный System.Windows.Forms.RichTextBox OutputText;
        частный System.Windows.Forms.Button Ecnrypt;
        частный System.Windows.Forms.Button Decrypt;
    }
}
[/I][/I]
 
Last edited by a moderator:
This is an English language forum, please post your code in English.

Also please tell us what problem you are running into, and what you have tried or thought of to try to fix the problem.
 
Back
Top Bottom