16212

Арифметика

Лабораторная работа

Информатика, кибернетика и программирование

ОТЧЕТ по лабораторной работе №4 по дисциплине Программирование на тему Арифметика Вариант 24 1 Постановка задачи Найти первые m более чем 2разрядных чиселпалиндромов то есть чисел десятичная запись которых читается одинаково в прямом и обратном направлениях...

Русский

2013-06-20

70.04 KB

1 чел.

ОТЧЕТ

по лабораторной работе №4

по дисциплине Программирование

на тему «Арифметика»

Вариант 24

1 Постановка задачи

Найти первые m более чем 2-разрядных чисел-палиндромов, то есть чисел, десятичная запись которых читается одинаково в прямом и обратном направлениях.

2 Блок-схема


3 Исходный код

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace WindowsFormsApplication1

{

   public partial class Form1 : Form

   {

       public int size;

       public Form1()

       {

           InitializeComponent();

       }

       public bool IsPalindrome(int input)

       {

           int revers_input = 0, c = input;

           while (c > 0)

           {

               revers_input = revers_input * 10 + c % 10;

               c = c / 10;

           }

           if (input == revers_input)

           { return (true); }

           else

           { return (false); };

       }

       private void textBox1_TextChanged(object sender, EventArgs e)

       {

           if (int.TryParse(input_textBox1.Text, out size))

           { run_button1.Enabled = true; }

           else run_button1.Enabled = false;

       }

       private void button1_Click(object sender, EventArgs e)

       {

           output_textBox2.Text = "";

           int i = 100, j = 0;

           run_progressBar1.Maximum = size;

           while ((j != size))

           {

               if (IsPalindrome(i))

               {

                   output_textBox2.Text = output_textBox2.Text + Convert.ToString(i) + Environment.NewLine;

                   j++;

                   run_progressBar1.Value = j;

               }

               i++;

           }

       }

   }

}

4 Пример работы

На рисунке 1 показан пример работы программы:

Рисунок 1 Выполнение программы


 

А также другие работы, которые могут Вас заинтересовать

53994. Environmental problems 46.5 KB
  In my opinion, rubbish is the biggest problem. People put a lot of rubbish into rubbish dumps. This pollutes the ground and the water. My family tries to help the environment. At home we recycle most of our rubbish. We put paper, glass and plastic into special containers outside our house. In my view, this is a great system because it really helps the environment.
53995. The Best Place for Holidays 81.5 KB
  Today at the lesson we’ll speak about the best place for holidays, listen to the dialogue about visiting Malta, revise and identify the past tenses, put the verbs in brackets into the correct tense, read Vicky’s letter about her holidays in Madrid, in groups write the letter to a pen friend according to the plan, get to know if you “can taste the flower seeds”.
53996. Modern Inventions. The Internet 68 KB
  Communication in social networks was chosen as the object of our lesson because communication has always been an important part of young people's lives. Today they can choose between traditional and new ways of communication. Traditionally the young meet after classes with their school friends, make parties and go to the movies or disco clubs to have fun, relax and acquire new friends.
53997. CLOTHES ACCORDING TO THE SEASON 189 KB
  Now children, listen to me and guess: what season it is. 1. It often rains. The leaves are falling. They are red and brown. 2. It is hot and sunny. There are many flowers. They are red, yellow, pink and white. 3. It is warm. There are small green leaves on the trees. The birds are singing.
53998. Our Fafourite Holidays 81.5 KB
  Today we’re going to discuss very pleasant and interesting things. We’ll speak about holidays. We do love holidays, don’t we? By the end of the lesson you should be able to actively use the target vocabulary in your talk about some holidays’ celebrations.
53999. It Often Rains 58.5 KB
  Express your opinion in a chain. Mind the colour of your card. If you’ve got a green card you tell us about good points of the rainy weather; if your card is red you tell us about bad points of it.
54000. Science and Inventions “Scientists and their Contributions to the World Science” 134 KB
  Glad to hear that. The more so because I am going to give you some food for thought. As at the previous lessons we spoke about science and how it is important in our life, I think it won`t be difficult for you to understand and explain the meaning of the following words which were once said by a famous writer B.Shaw...
54001. Sports. Plural (irregular nouns) 223.5 KB
  On February we’ll have the world sport competitions which called the Olympic Games. There are winter and summer Olympic Games. The last summer Olympic Games were in Perkin in China. The next winter Olympic Games will take part in Vancouver in Canada. The team of our country will take part in these competitions.
54002. What’s the weather like? 148 KB
  Today we are going to speak about the weather, about your favourite seasons. You know, the weather is a safe topic for a conversation. That's why we should be good at it.