Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Anna2812

Как конвертировать код студии 5.0 под студию 10?

25.05.2013, 12:40. Показов 564. Ответов 0
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Помогите плиз конвертнуть код из 5.0 в 10, надо курсач сдавать а препод придереться к старому коду((
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
Form1.h
 
#pragma once
#include "Game.h"
namespace Fifteen {
     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();
               //
               //TODO: Add the constructor code here
               //
          }
     protected:
          /// <summary>
          /// Clean up any resources being used.
          /// </summary>
          ~Form1()
          {
               if (components)
               {
                    delete components;
               }
          }
     private: System::Windows::Forms::MenuStrip^  menuStrip1;
     protected: 
     private: System::Windows::Forms::ToolStripMenuItem^  menuGame;
     private: System::Windows::Forms::ToolStripMenuItem^  новаяИграToolStripMenuItem;
     private: System::Windows::Forms::ToolStripMenuItem^  выходToolStripMenuItem;
     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->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
              this->menuGame = (gcnew System::Windows::Forms::ToolStripMenuItem());
              this->новаяИграToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
              this->выходToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
              this->menuStrip1->SuspendLayout();
              this->SuspendLayout();
              // 
              // menuStrip1
              // 
              this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->menuGame});
              this->menuStrip1->Location = System::Drawing::Point(0, 0);
              this->menuStrip1->Name = L"menuStrip1";
              this->menuStrip1->Size = System::Drawing::Size(143, 24);
              this->menuStrip1->TabIndex = 0;
              this->menuStrip1->Text = L"menuStrip1";
              // 
              // menuGame
              // 
              this->menuGame->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->новаяИграToolStripMenuItem, 
                  this->выходToolStripMenuItem});
              this->menuGame->Name = L"menuGame";
              this->menuGame->Size = System::Drawing::Size(43, 20);
              this->menuGame->Text = L"Игра";
              // 
              // новаяИграToolStripMenuItem
              // 
              this->новаяИграToolStripMenuItem->Name = L"новаяИграToolStripMenuItem";
              this->новаяИграToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::N));
              this->новаяИграToolStripMenuItem->Size = System::Drawing::Size(181, 22);
              this->новаяИграToolStripMenuItem->Text = L"Новая игра";
              this->новаяИграToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::новаяИграToolStripMenuItem_Click);
              // 
              // выходToolStripMenuItem
              // 
              this->выходToolStripMenuItem->Font = (gcnew System::Drawing::Font(L"Tahoma", 8.25F));
              this->выходToolStripMenuItem->ForeColor = System::Drawing::SystemColors::ControlText;
              this->выходToolStripMenuItem->Name = L"выходToolStripMenuItem";
              this->выходToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Control | System::Windows::Forms::Keys::Q));
              this->выходToolStripMenuItem->Size = System::Drawing::Size(181, 22);
              this->выходToolStripMenuItem->Text = L"Выход";
              this->выходToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::выходToolStripMenuItem_Click);
              // 
              // Form1
              // 
              this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
              this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
              this->ClientSize = System::Drawing::Size(137, 162);
              this->Controls->Add(this->menuStrip1);
              this->MainMenuStrip = this->menuStrip1;
              this->Name = L"Form1";
              this->Text = L"Form1";
              this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
              this->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseClick);
              this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
              this->menuStrip1->ResumeLayout(false);
              this->menuStrip1->PerformLayout();
              this->ResumeLayout(false);
              this->PerformLayout();
 
          }
 
#pragma endregion
     private: Game^ game;
     private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
                     game = gcnew Game();     
                     game->clearGame();          
                }
     private: System::Void Form1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
                     Graphics ^ g = e->Graphics;     
                     System::Drawing::Pen^ pen = gcnew System::Drawing::Pen(System::Drawing::Color::Red);
                     System::Drawing::Font^ font = gcnew System::Drawing::Font("Arial",16);
                     System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(System::Drawing::Color::Blue);
 
                     for (int i = 0; i < 4; i++)     {
                          for (int j = 0; j < 4; j++)     {
                               g->DrawRectangle(pen, 1 + (34 * i), 1 + (34 * j) + menuStrip1->Height, 32, 32);
                               g->DrawString(game->getCellString(i, j), font, brush, 1 + (34 * i), 1 + (34 * j) + 4 + menuStrip1->Height);
                          }
                     }
                     delete pen;
                     delete font;
                     delete brush;
                     delete g;
                }
     private: System::Void Form1_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
                     int x = ((e->X / 34));                                   
                     int y = (((e->Y - menuStrip1->Height) / 34));     
                     game->moveCell(x, y);     
                     this->Refresh();          
                     if (game->checkWin()) this->Text = "WIN!";
                     if (game->checkLose()) this->Text = "LOSE!";
                }
     private: System::Void новаяИграToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
                     game->startGame();   
                     this->Text = "Form1";
                     this->Refresh();                   
       }
private: System::Void выходToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
             Close();
         }
};
}
 
 
 
Game.h
 
#pragma once
using namespace System;
ref class Game
{
private:
     array<Int32, 2> ^ game;               
     array<Int32, 1> ^ zeroPos;          
     array<Int32, 1> ^ winComb;  
     array<Int32, 1> ^ loseComb;
public:
     Game(void);                                        
     void startGame(void);                         
     void clearGame(void);                         
     int getCell(int i, int j);                    
     String^ getCellString(int i, int j);     
     void moveCell(int i, int j);               
     bool checkWin();
     bool checkLose();
};
 
 
Game.cpp
 
#include "StdAfx.h"
#include "Game.h"
using namespace System;
Game::Game(void)
{
     game = gcnew array<Int32, 2>(4, 4);
     zeroPos = gcnew array<Int32, 1>(2);
     winComb = gcnew array<Int32, 1>(16);
     for (int i = 1; i <= 15; i++)     {
          winComb[i - 1] = i;
     }
     winComb[15] = 0;
     loseComb = gcnew array<Int32, 1>(16);
     for (int i = 1; i <= 13; i++)     {
          loseComb[i - 1] = i;
     }
     loseComb[13] = 15;
     loseComb[14] = 14;
     loseComb[15] = 0;
}
void Game::startGame(void)
{
     int length = 15;     
     int cur;               
     Random rnd;               
     array<Int32, 1>^ numbers = gcnew array<Int32, 1>(16);
     for (int i = 0; i <= length; i++)     {
          numbers[i] = i;
     }
          for (int i = 0; i < 4; i++)     {
          for (int j = 0; j < 4; j++)     {
               cur = rnd.Next(0, length);          
               game[i, j] = numbers[cur];                         
               if (numbers[cur] == 0)     {
                    zeroPos[0] = i;
                    zeroPos[1] = j;
               }
               numbers[cur] = numbers[length];     
               length--;                              
          }
     }
}
void Game::clearGame(void)
{
     for (int i = 0; i < 4; i++)     {
          for (int j = 0; j < 4; j++)     {
               game[i, j] = i + (j * 4) + 1;
          }
     }
     game[3, 3] = 0;          
          zeroPos[0] = 3;
     zeroPos[1] = 3;
}
int Game::getCell(int i, int j)
{
     return game[i, j];
}
String^ Game::getCellString(int i, int j)
{
     int integ = game[i, j];                              
     String^ str = integ.ToString();                  
     if (integ == 0) return "";                         
     if (str->Length == 1)     str = " " + str;     
     return str;                                             
}
void Game::moveCell(int i, int j)
{
     if (i >= 0 && i <= 3 && j >= 0 && j <= 3)     {
          
          if     (( (((zeroPos[0] + 1) == i) || ((zeroPos[0] - 1) == i)) && (zeroPos[1] == j)     ) ||
               ( (((zeroPos[1] + 1) == j) || ((zeroPos[1] - 1) == j)) && (zeroPos[0] == i)     ))     {
               game[zeroPos[0], zeroPos[1]] = game[i, j];     
               game[i, j] = 0;          
               zeroPos[0] = i;
               zeroPos[1] = j;
          }
     }
}
bool Game::checkWin()
{
     int pos = 0;          
     bool check = true;     
     for (int i = 0; i < 4; i++)     {
          for (int j = 0; j < 4; j++, pos++)     {
               check = check && game[j, i] == winComb[pos];
          }
     }
     return check;          
}
 
bool Game::checkLose()
{
     int pos = 0;          
     bool check = true;     
     for (int i = 0; i < 4; i++)     {
          for (int j = 0; j < 4; j++, pos++)     {
               check = check && game[j, i] == loseComb[pos];
          }
     }
     return check;          
}
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
25.05.2013, 12:40
Ответы с готовыми решениями:

Как создать проект MFC если его нет в студии? Как расширить студию?
Парни, надо напрогать в проекте MFC окно, клац в свою студию - а у меня только винапи и с/с++/с# ? Я так понял студия расширяется (у...

Конвертировать код Delphi под Pascal. Симплекс Метод
Доброго времени суток. Возникла проблема. Есть код симплекс алгоритма под Delphi и необходимо его перевести в код PascalABC. program...

Код выполняемый из студии с пометкой debag, работает не так как уже компилированный код
Здравствуйте, столкнулся с такой проблемой. Код выполняемый из студии с пометкой debag, работает не так как уже компилированный код....

0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
25.05.2013, 12:40
Помогаю со студенческими работами здесь

код, который прекрасно выполняет Code::Blocks не выполняеться в Студии, как сделатьь так чтобы Студия воспринимала этот код??
Ребята, обьясните мне чего код, который прекрасно выполняет Code::Blocks не выполняеться в Студии, там требуються существенно другие...

Как конвертировать (разобраться) маленький PHP код в «псевдо» код?
Доброго времени суток! Я отел бы разобраться в одном алгоритме который к сожалению написан на PHP синтаксис которого мне не ясен. Мог бы...

Как включить дизасемблированный код в студии?
Во время отладки.

Где взять STLPort под 13 студию?
Сабж. З.Ы В гугле был.

Рабочая станция под стримы и звуковую студию
Прошу помочь подобрать комплектующие для ПК. Рабочая станция будет использоваться для стримов современных игр аля батфилд 1, resedent evil...


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

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Новые блоги и статьи
SDL3 для Desktop (MinGW): Рисуем цветные прямоугольники с помощью рисовальщика SDL3 на Си и C++
8Observer8 17.03.2026
Содержание блога Финальные проекты на Си и на C++: finish-rectangles-sdl3-c. zip finish-rectangles-sdl3-cpp. zip
Символические и жёсткие ссылки в Linux.
algri14 15.03.2026
Существует два типа ссылок — символические и жёсткие. Ссылка в Linux — это запись в каталоге, которая может указывать либо на inode «файла-ИСТОЧНИКА», тогда это будет «жёсткая ссылка» (hard link),. . .
[Owen Logic] Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора
ФедосеевПавел 14.03.2026
Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора ВВЕДЕНИЕ Выполняя задание на управление насосной группой заполнения резервуара,. . .
делаю науч статью по влиянию грибов на сукцессию
anaschu 13.03.2026
прикрепляю статью
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога Финальные проекты на Си и на C++: hello-sdl3-c. zip hello-sdl3-cpp. zip Результат:
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд. Даже если у вас. . .
Модульная разработка через nuget packages
DevAlt 07.03.2026
Сложившийся в . Net-среде способ разработки чаще всего предполагает монорепозиторий в котором находятся все исходники. При создании нового решения, мы просто добавляем нужные проекты и имеем. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru