Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.80/5: Рейтинг темы: голосов - 5, средняя оценка - 4.80
0 / 0 / 1
Регистрация: 06.11.2012
Сообщений: 20
1

Генерирование заданного количества точек со случайными координатами:

08.11.2012, 08:32. Показов 885. Ответов 2
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if (TabControl1->TabIndex==1) {
int x[35000],y[35000],x1[35000],y1[35000];
CSpinEdit3->MaxValue=35000;
Image1->Canvas->Brush->Color=clWhite;
Image2->Canvas->Brush->Color=clWhite;
Image1->Canvas->FillRect(Rect(0,0,Form1->Image1->ClientWidth,Form1->Image1->ClientHeight));
Image2->Canvas->FillRect(Rect(0,0,Form1->Image2->ClientWidth,Form1->Image2->ClientHeight));
Image1->Canvas->Pen->Width=2;
Image2->Canvas->Pen->Width=2;
Image1->Canvas->Rectangle(25,1,425,401);
Image2->Canvas->Rectangle(25,1,425,401);
Image1->Canvas->Pen->Width=1;
Image2->Canvas->Pen->Width=1;
Image1->Canvas->Brush->Color=clRed;
Image2->Canvas->Brush->Color=clRed;
randomize();
for (int i = 0; i < CSpinEdit3->Value; i++)
{
x[i]=rand()%100;
y[i]=rand()%100;
x1[i]=random(100);
y1[i]=random(100);
Image1->Canvas->Rectangle(25+x[i]*4,401-y[i]*4-4,25+x[i]*4+4,401-y[i]*4);
Image2->Canvas->Rectangle(25+x1[i]*4,401-y1[i]*4-4,25+x1[i]*4+4,401-y1[i]*4);
}
 
   }
Помогите переписать на Visual c++ с c++ Builder
• Заполнение экрана N точками со случайными координатами X и Y.

Добавлено через 9 часов 23 минуты
помогите,пожалуйста!
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
08.11.2012, 08:32
Ответы с готовыми решениями:

Подсчет количества точек с целочисленными координатами, находящихся внутри круга заданного радиуса
Напишите программу для подсчета числа точек с целочисленными координатами, находящихся внутри круга...

Из заданного множества точек на плоскости выбрать две различные точки так, чтобы количества точек различались наименьшим образом
Из заданного множества точек на плоскости выбрать две различные точки так, чтобы количества точек,...

Из заданного мн-ва точек на плоскости выбрать две различные точки так, чтобы количества точек, лежащих по разные стороны прямой, было равно.
Программный модуль! Из заданного мн-ва точек на плоскости выбрать две различные точки так, чтобы...

Найти площадь треугольника, заданного координатами трех точек
Найти площадь треугольника, заданного координатами трех точек. Использовать формулу Геррона.

2
873 / 771 / 173
Регистрация: 11.01.2012
Сообщений: 1,942
08.11.2012, 14:58 2
На форму нужно добавить 2 PictureBox-a
+ создать 2 объекта Graphics:
конструктор формы и объявление 2 объектов Graphics:

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    public:
        Form1(void)
        {
            InitializeComponent();
            /////////////////////
            
            rand = gcnew Random();
                           // создать два объекта Graphics
            graphicsPictureBox1 = pictureBox1->CreateGraphics();
            graphicsPictureBox2 = pictureBox2->CreateGraphics();
                         
               
        }
 
private:     Random^rand ;
    private: Graphics^ graphicsPictureBox1;
    private: Graphics^ graphicsPictureBox2;
остальной код перевод вашего
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (TabControl1->TabIndex == 1) {
        //   int x[35000],y[35000],x1[35000],y1[35000];
          numericUpDown1->Maximum = 35000;
 
graphicsPictureBox1->FillRectangle( Brushes::Cornsilk, pictureBox1->ClientRectangle);
graphicsPictureBox2->FillRectangle( Brushes::Cornsilk, pictureBox2->ClientRectangle);
graphicsPictureBox1->DrawRectangle(gcnew Pen(Color::Black, 2),pictureBox1->ClientRectangle);
graphicsPictureBox2->DrawRectangle(gcnew Pen(Color::Black, 2),pictureBox2->ClientRectangle);
 
 
for (int i = 0; i < numericUpDown1->Value; i++)
{
    
       graphicsPictureBox1->FillRectangle( Brushes::Red, rand->Next(pictureBox1->ClientRectangle.Width), pictureBox1->ClientRectangle.Height - (rand->Next(pictureBox1->ClientRectangle.Height)), 4, 4);
       graphicsPictureBox2->FillRectangle( Brushes::Red, rand->Next(pictureBox2->ClientRectangle.Width), pictureBox2->ClientRectangle.Height - (rand->Next(pictureBox1->ClientRectangle.Height)),  4, 4);
}
}
1
0 / 0 / 1
Регистрация: 06.11.2012
Сообщений: 20
09.11.2012, 15:43  [ТС] 3
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#pragma once
 
 
namespace k {
 
    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>
    /// Summary for Form1
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    ///          'Resource File Name' property for the managed resource compiler tool
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
               rand = gcnew Random();
                graphicsPictureBox1 = pictureBox1->CreateGraphics();
            //
            //TODO: Add the constructor code here
            //
        }
 
    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
        private:     Random^rand ;
    private: Graphics^ graphicsPictureBox1;
    private: System::Windows::Forms::PictureBox^  pictureBox1;
    private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
    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->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
            this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
            this->button1 = (gcnew System::Windows::Forms::Button());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
            this->SuspendLayout();
            // 
            // pictureBox1
            // 
            this->pictureBox1->Location = System::Drawing::Point(45, 50);
            this->pictureBox1->Name = L"pictureBox1";
            this->pictureBox1->Size = System::Drawing::Size(100, 50);
            this->pictureBox1->TabIndex = 0;
            this->pictureBox1->TabStop = false;
            // 
            // numericUpDown1
            // 
            this->numericUpDown1->Location = System::Drawing::Point(45, 136);
            this->numericUpDown1->Name = L"numericUpDown1";
            this->numericUpDown1->Size = System::Drawing::Size(120, 20);
            this->numericUpDown1->TabIndex = 1;
            this->numericUpDown1->Value += gcnew System::EventHandler(this, &Form1::numericUpDown1_Value);
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(153, 194);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(59, 26);
            this->button1->TabIndex = 2;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(284, 262);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->numericUpDown1);
            this->Controls->Add(this->pictureBox1);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
            this->ResumeLayout(false);
 
        }
#pragma endregion
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
             }
    
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             
if (TabControl1->TabIndex == 1) {
        //   int x[35000],y[35000],x1[35000],y1[35000];
          numericUpDown1->Maximum = 35000;
 
graphicsPictureBox1->FillRectangle( Brushes::Cornsilk, pictureBox1->ClientRectangle);
//graphicsPictureBox2->FillRectangle( Brushes::Cornsilk, pictureBox2->ClientRectangle);
graphicsPictureBox1->DrawRectangle(gcnew Pen(Color::Black, 2),pictureBox1->ClientRectangle);
//graphicsPictureBox2->DrawRectangle(gcnew Pen(Color::Black, 2),pictureBox2->ClientRectangle);
 
 
for (int i = 0; i < numericUpDown1->Value; i++)
{
    
       graphicsPictureBox1->FillRectangle( Brushes::Red, rand->Next(pictureBox1->ClientRectangle.Width), pictureBox1->ClientRectangle.Height - (rand->Next(pictureBox1->ClientRectangle.Height)), 4, 4);
       //graphicsPictureBox2->FillRectangle( Brushes::Red, rand->Next(pictureBox2->ClientRectangle.Width), pictureBox2->ClientRectangle.Height - (rand->Next(pictureBox1->ClientRectangle.Height)),  4, 4);
}
}
 }
    };
}
не идет,пишет ошибки
error C2039: 'numericUpDown1_Value' : is not a member of 'k::Form1'
see declaration of 'k::Form1'
error C2065: 'numericUpDown1_Value' : undeclared identifier
error C3350: 'System::EventHandler' : a delegate constructor expects 2 argument(s)
error C2065: 'TabControl1' : undeclared identifier
error C2227: left of '->TabIndex' must point to class/struct/union/generic type

Добавлено через 10 часов 32 минуты
Что здесь не так?

Добавлено через 6 часов 43 минуты
Кто-нибудь не может посмотреть?
0
09.11.2012, 15:43
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
09.11.2012, 15:43
Помогаю со студенческими работами здесь

Найти количество точек с целочисленными координатами внутри заданного отрезка
как мне найти количество точек с целочисленными координатами внутри отрезка. Вам даны начальные...

Вычислить длину отрезка, заданного координатами концевых точек (исправьте ошибки)
Отрезок задан координатами своих концевых точек. Требуется вычислить длину этого отрезка....

Подсчитать количество точек с целочисленными координатами, содержащихся в шаре заданного радиуса
Сколько точек целыми координатами содержатся в шаре радиуса R с центром в начале системы...

Определить, сколько точек с целочисленными координатами попадают в круг заданного радиуса с центром в начале координат
Вводится радиус круга R. Определить, сколько точек с целочисленными координатами попадают в круг...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru