powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / где же ошибка?
25 сообщений из 25, страница 1 из 1
где же ошибка?
    #39384152
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Перевод из 10-ой системы счисления в 13-ую.
При вводе от 10-12 цифр в целом числе с отрицательным знаком программа выдает не корректный ответ.
Все остальное работает кроме этой проблемы.
Скорее всего там что то не так с кодом, буквально в одной-двух строчках.


Код: plaintext
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.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
597.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.
617.
618.
619.
620.
621.
622.
623.
624.
625.
626.
627.
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
645.
646.
647.
648.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
#pragma once
#include "MyForm2.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <ctype.h>
#include <math.h>
#include <conio.h>

namespace Project1 {

	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 MyForm
	/// </summary>
	std::string perevod(int celoe)
	{
		std::string str = "";
		int b;
		bool otr = false;
		if (celoe < 0)
		{
			celoe = -celoe;
			otr = true;
		}
		if (celoe == 0)
		{
			str = "0";
			return str;
		}
		while (celoe)
		{
			b = celoe % 13;
			celoe /= 13;
			switch (b)
			{
			case 10:str.append("A"); break;
			case 11: str.append("B"); break;
			case 12: str.append("C"); break;
			default:
				str.append(std::to_string(b));
				break;
			}
		}
		if (otr)
		{
			str.append("-");
		}
		std::reverse(str.begin(), str.end());
		return str;
	}

	std::string perevoddrob(float drob)
	{
		std::string str = "";
		int c;
		for (int i = 0; i < 6; ++i)
		{
			drob = drob * 13;
			c = (int)drob;
			drob = drob - c;
			switch (c)
			{
			case 10: str.append("A"); break;
			case 11: str.append("B"); break;
			case 12: str.append("C"); break;
			default:
				str.append(std::to_string(c));
				break;
			}
		}
		return str;
	}
	public ref class MyForm : public System::Windows::Forms::Form
	{
		bool vvod = false;
		
	public:
		MyForm(void)
		{	
			
			InitializeComponent();
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~MyForm()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  label1;
	protected:
	private: 
		System::Windows::Forms::Button^  button4;
		System::Windows::Forms::Button^  button7;
		System::Windows::Forms::Button^  button8;
		System::Windows::Forms::Button^  button9;
		System::Windows::Forms::Button^  button10;
		System::Windows::Forms::Button^  button11;
		System::Windows::Forms::Button^  button12;
		System::Windows::Forms::Button^  button13;
		System::Windows::Forms::Button^  button14;
		System::Windows::Forms::Button^  button15;
		System::Windows::Forms::Button^  button16;
		System::Windows::Forms::Button^  button17;
	private: System::Windows::Forms::Button^  dot;

		System::Windows::Forms::Button^  button5;
		System::Windows::Forms::Button^  button6;
		System::Windows::Forms::Label^  label2;

		System::Windows::Forms::TextBox^  textBox1;
		System::Windows::Forms::TextBox^  textBox2;
		MyForm2 form2;
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  файлToolStripMenuItem;
	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->label1 = (gcnew System::Windows::Forms::Label());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->button7 = (gcnew System::Windows::Forms::Button());
			this->button8 = (gcnew System::Windows::Forms::Button());
			this->button9 = (gcnew System::Windows::Forms::Button());
			this->button10 = (gcnew System::Windows::Forms::Button());
			this->button11 = (gcnew System::Windows::Forms::Button());
			this->button12 = (gcnew System::Windows::Forms::Button());
			this->button13 = (gcnew System::Windows::Forms::Button());
			this->button14 = (gcnew System::Windows::Forms::Button());
			this->button15 = (gcnew System::Windows::Forms::Button());
			this->button16 = (gcnew System::Windows::Forms::Button());
			this->dot = (gcnew System::Windows::Forms::Button());
			this->button5 = (gcnew System::Windows::Forms::Button());
			this->button6 = (gcnew System::Windows::Forms::Button());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->файлToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->закрытьToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->справкаToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->button17 = (gcnew System::Windows::Forms::Button());
			this->menuStrip1->SuspendLayout();
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(30, 50);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(169, 13);
			this->label1->TabIndex = 0;
			this->label1->Text = L"10-ричное представление числа";
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(186, 157);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(96, 81);
			this->button4->TabIndex = 4;
			this->button4->Text = L"BackSpace";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &MyForm::button4_Click);
			// 
			// button7
			// 
			this->button7->Location = System::Drawing::Point(33, 244);
			this->button7->Name = L"button7";
			this->button7->Size = System::Drawing::Size(44, 38);
			this->button7->TabIndex = 7;
			this->button7->Text = L"7";
			this->button7->UseVisualStyleBackColor = true;
			this->button7->Click += gcnew System::EventHandler(this, &MyForm::button7_Click);
			// 
			// button8
			// 
			this->button8->Location = System::Drawing::Point(84, 244);
			this->button8->Name = L"button8";
			this->button8->Size = System::Drawing::Size(44, 38);
			this->button8->TabIndex = 8;
			this->button8->Text = L"8";
			this->button8->UseVisualStyleBackColor = true;
			this->button8->Click += gcnew System::EventHandler(this, &MyForm::button8_Click);
			// 
			// button9
			// 
			this->button9->Location = System::Drawing::Point(134, 244);
			this->button9->Name = L"button9";
			this->button9->Size = System::Drawing::Size(44, 38);
			this->button9->TabIndex = 9;
			this->button9->Text = L"9";
			this->button9->UseVisualStyleBackColor = true;
			this->button9->Click += gcnew System::EventHandler(this, &MyForm::button9_Click);
			// 
			// button10
			// 
			this->button10->Location = System::Drawing::Point(33, 288);
			this->button10->Name = L"button10";
			this->button10->Size = System::Drawing::Size(44, 38);
			this->button10->TabIndex = 10;
			this->button10->Text = L"4";
			this->button10->UseVisualStyleBackColor = true;
			this->button10->Click += gcnew System::EventHandler(this, &MyForm::button10_Click);
			// 
			// button11
			// 
			this->button11->Location = System::Drawing::Point(84, 288);
			this->button11->Name = L"button11";
			this->button11->Size = System::Drawing::Size(44, 38);
			this->button11->TabIndex = 11;
			this->button11->Text = L"5";
			this->button11->UseVisualStyleBackColor = true;
			this->button11->Click += gcnew System::EventHandler(this, &MyForm::button11_Click);
			// 
			// button12
			// 
			this->button12->Location = System::Drawing::Point(134, 288);
			this->button12->Name = L"button12";
			this->button12->Size = System::Drawing::Size(44, 38);
			this->button12->TabIndex = 12;
			this->button12->Text = L"6";
			this->button12->UseVisualStyleBackColor = true;
			this->button12->Click += gcnew System::EventHandler(this, &MyForm::button12_Click);
			// 
			// button13
			// 
			this->button13->Location = System::Drawing::Point(33, 332);
			this->button13->Name = L"button13";
			this->button13->Size = System::Drawing::Size(44, 38);
			this->button13->TabIndex = 13;
			this->button13->Text = L"1";
			this->button13->UseVisualStyleBackColor = true;
			this->button13->Click += gcnew System::EventHandler(this, &MyForm::button13_Click);
			// 
			// button14
			// 
			this->button14->Location = System::Drawing::Point(84, 332);
			this->button14->Name = L"button14";
			this->button14->Size = System::Drawing::Size(44, 38);
			this->button14->TabIndex = 14;
			this->button14->Text = L"2";
			this->button14->UseVisualStyleBackColor = true;
			this->button14->Click += gcnew System::EventHandler(this, &MyForm::button14_Click);
			// 
			// button15
			// 
			this->button15->Location = System::Drawing::Point(134, 332);
			this->button15->Name = L"button15";
			this->button15->Size = System::Drawing::Size(44, 38);
			this->button15->TabIndex = 15;
			this->button15->Text = L"3";
			this->button15->UseVisualStyleBackColor = true;
			this->button15->Click += gcnew System::EventHandler(this, &MyForm::button15_Click);
			// 
			// button16
			// 
			this->button16->Location = System::Drawing::Point(33, 376);
			this->button16->Name = L"button16";
			this->button16->Size = System::Drawing::Size(44, 38);
			this->button16->TabIndex = 16;
			this->button16->Text = L"0";
			this->button16->UseVisualStyleBackColor = true;
			this->button16->Click += gcnew System::EventHandler(this, &MyForm::button16_Click);
			// 
			// dot
			// 
			this->dot->Location = System::Drawing::Point(134, 376);
			this->dot->Name = L"dot";
			this->dot->Size = System::Drawing::Size(44, 38);
			this->dot->TabIndex = 18;
			this->dot->Text = L".";
			this->dot->UseVisualStyleBackColor = true;
			this->dot->Click += gcnew System::EventHandler(this, &MyForm::button18_Click);
			// 
			// button5
			// 
			this->button5->Location = System::Drawing::Point(186, 244);
			this->button5->Name = L"button5";
			this->button5->Size = System::Drawing::Size(96, 82);
			this->button5->TabIndex = 19;
			this->button5->Text = L"Clear";
			this->button5->UseVisualStyleBackColor = true;
			this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
			// 
			// button6
			// 
			this->button6->Location = System::Drawing::Point(186, 332);
			this->button6->Name = L"button6";
			this->button6->Size = System::Drawing::Size(96, 82);
			this->button6->TabIndex = 20;
			this->button6->Text = L"=";
			this->button6->UseVisualStyleBackColor = true;
			this->button6->Click += gcnew System::EventHandler(this, &MyForm::button6_Click);
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(30, 105);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(217, 13);
			this->label2->TabIndex = 21;
			this->label2->Text = L"Тринадцатиричное  представление числа";
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(33, 66);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(166, 20);
			this->textBox1->TabIndex = 23;
			// 
			// textBox2
			// 
			this->textBox2->Location = System::Drawing::Point(33, 121);
			this->textBox2->MaxLength = 10;
			this->textBox2->Name = L"textBox2";
			this->textBox2->ReadOnly = true;
			this->textBox2->Size = System::Drawing::Size(166, 20);
			this->textBox2->TabIndex = 24;
			// 
			// menuStrip1
			// 
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {
				this->файлToolStripMenuItem,
					this->справкаToolStripMenuItem
			});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(294, 24);
			this->menuStrip1->TabIndex = 25;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// файлToolStripMenuItem
			// 
			this->файлToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) { this->закрытьToolStripMenuItem });
			this->файлToolStripMenuItem->Name = L"файлToolStripMenuItem";
			this->файлToolStripMenuItem->Size = System::Drawing::Size(48, 20);
			this->файлToolStripMenuItem->Text = L"Файл";
			// 
			// закрытьToolStripMenuItem
			// 
			this->закрытьToolStripMenuItem->Name = L"закрытьToolStripMenuItem";
			this->закрытьToolStripMenuItem->Size = System::Drawing::Size(120, 22);
			this->закрытьToolStripMenuItem->Text = L"Закрыть";
			this->закрытьToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::закрытьToolStripMenuItem_Click);
			// 
			// справкаToolStripMenuItem
			// 
			this->справкаToolStripMenuItem->Name = L"справкаToolStripMenuItem";
			this->справкаToolStripMenuItem->Size = System::Drawing::Size(65, 20);
			this->справкаToolStripMenuItem->Text = L"Справка";
			this->справкаToolStripMenuItem->Click += gcnew System::EventHandler(this, &MyForm::ToolStripMenuItem_Click);
			// 
			// button17
			// 
			this->button17->Location = System::Drawing::Point(84, 376);
			this->button17->Name = L"button17";
			this->button17->Size = System::Drawing::Size(44, 38);
			this->button17->TabIndex = 17;
			this->button17->Text = L"+/-";
			this->button17->UseVisualStyleBackColor = true;
			this->button17->Click += gcnew System::EventHandler(this, &MyForm::button17_Click);
			// 
			// MyForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(294, 429);
			this->Controls->Add(this->textBox2);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->button6);
			this->Controls->Add(this->button5);
			this->Controls->Add(this->dot);
			this->Controls->Add(this->button17);
			this->Controls->Add(this->button16);
			this->Controls->Add(this->button15);
			this->Controls->Add(this->button14);
			this->Controls->Add(this->button13);
			this->Controls->Add(this->button12);
			this->Controls->Add(this->button11);
			this->Controls->Add(this->button10);
			this->Controls->Add(this->button9);
			this->Controls->Add(this->button8);
			this->Controls->Add(this->button7);
			this->Controls->Add(this->button4);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->Name = L"MyForm";
			this->Text = L"Перевод числа";
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::
		Void ToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
		{
		form2.Show();
		}
		
	private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
		if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "7");
			textBox1->Text = s;
		}
		private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "8");
			textBox1->Text = s;
		}
		private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "9");
			textBox1->Text = s;
		}
		private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "4");
			textBox1->Text = s;
		}
		private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "5");
			textBox1->Text = s;
		}
		private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "6");
			textBox1->Text = s;
		}
		private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "1");
			textBox1->Text = s;
		}
		private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "2");
			textBox1->Text = s;
		}
		private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			s = String::Concat(s, "3");
			textBox1->Text = s;
		}
		private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e)
		{
			if (vvod == 1)
			{
				textBox1->Clear();
				textBox2->Clear();
				vvod = 0;
			}
			auto s = textBox1->Text;
			if (textBox1->Text->Length >= 12 + textBox1->Text->Contains(".")) return;
			if (textBox1->Text == "0") s = String::Concat(s, ".");
			s = String::Concat(s, "0");
			textBox1->Text = s;
		}
		private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e)
		{
			textBox1->Clear();
			textBox2->Clear();
		}
		private: System::Void закрытьToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
		{
			Application::Exit();
		}
		private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			auto s = textBox1->Text;
			if (s->Length <= 1) 
			{
				textBox1->Clear();
				return;
			}
			s = s->Substring(0, s->Length - 1);
			textBox1->Text = s;
		}
		private: System::Void button18_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			auto s = textBox1->Text;
			if (s->Length == 12) return;
			if ((s->Length == 0) || (textBox1->Text == "-"))
			{
				s = String::Concat(s, "0.");
				textBox1->Text = s;
				if (s->Contains("."))
					return;
			}
			if (s->Contains("."))
				return;
			s = String::Concat(s, ".");
			textBox1->Text = s;
		}
		private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) 
		{
			bool cont = false;
			for each (char s in textBox1->Text)
			{
				if (s != '0' && s != '.') cont = true;
			}
			if (!cont) return;
			auto s = textBox1->Text;
			if (s->Contains("-"))
			{
				s = s->Replace("-", "");
			}
			else
				s = String::Concat("-", s);

			textBox1->Text = s;
		}
		private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e)
				 {
					 auto in = textBox1->Text;
					 String ^ celoe, ^ drob;
					 wchar_t wb[20];
					 char b[20];
					 int pos;
					 vvod = true;
					 bool contains = in->Contains(".");
					 if (contains)
					 {
						 pos = in->IndexOf(".");
						 celoe = in->Substring(0, pos);
						 drob = in->Substring(pos + 1, in->Length - pos - 1);
					 }
					 else
					 {
						 celoe = in->Substring(0, in->Length);
					 }

					 memset(b, 0, 20);
					 memset(wb, 0, 20);
					 for (int i = 0; i < celoe->Length; ++i)
					 {
						 wb[i] = celoe[i];
					 }
					 wcstombs(b, wb, 20);
					 std::string res = perevod(atoi(b));
					 celoe = gcnew String(res.c_str());

					 if (contains)
					 {
						 memset(b, 0, 20);
						 memset(wb, 0, 20);

						 for (int i = 0; i < drob->Length; ++i)
						 {
							 wb[i] = drob[i];
						 }
						 wcstombs(b, wb, 20);
						 std::string buf = "0.";
						 buf.append(b);
						 std::string dr = perevoddrob(atof(buf.c_str()));

						 drob = gcnew String(dr.c_str());
						 textBox2->Text = celoe + "." + drob;
					 }
					 else
						 textBox2->Text = celoe;
						  if (in->Contains("-0."))
						  {
							  textBox2->Text = "-" + textBox2->Text;

						  }
				 }
};
}


...
Рейтинг: 0 / 0
где же ошибка?
    #39384162
Dimitry Sibiryakov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_Скорее всего там что то не так с кодом, буквально в одной-двух строчках.

Пошаговая отладка покажет где твоё представление о работе этого кода начинает расходиться
с реальностью.
Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
где же ошибка?
    #39384165
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
а нет возможности, отсутствует студия под рукой
...
Рейтинг: 0 / 0
где же ошибка?
    #39384183
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
1. Такие портянки надо под спойлер прятать.
2. Не надо сюда писать то, что к вопросу не относиться.

Давай только код функции, которая не работает, и с какими параметрами ее вызвать.
...
Рейтинг: 0 / 0
где же ошибка?
    #39384189
ermak.nn
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_, предлагаю вам начать с простого:
вручную посчитать значения чисел с 1 по 14 и с -14 по -1 в 13-чном формате

выполнить вашу программу для чисел с 1 по 14 и с -14 по -1

сравнить результаты

найти связь между X (целого положительного) в 13-чном формате и -X в 13-чном формате. Когда вы поймете формулу, у вас все сложится и программа заработает
...
Рейтинг: 0 / 0
где же ошибка?
    #39384302
Siemargl
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_,

В 4 байта многоцифр не влезаетЪ
...
Рейтинг: 0 / 0
где же ошибка?
    #39384382
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
а как, где и чем можно расширить эти 4 байта
...
Рейтинг: 0 / 0
где же ошибка?
    #39384388
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
'это поменять int?
...
Рейтинг: 0 / 0
где же ошибка?
    #39384419
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
применить, например, float или double?
...
Рейтинг: 0 / 0
где же ошибка?
    #39384455
Фотография MasterZiv
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_,

std::vector< char >
...
Рейтинг: 0 / 0
где же ошибка?
    #39384472
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_'это поменять int?
int64_t - 18 десятичных знаков

Про float забудь, там точность 7 десятичных знаков, double - 15, но работая с ним учитывай погрешности, недавно почти тоже самое было 20077393
...
Рейтинг: 0 / 0
где же ошибка?
    #39384920
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
использую __int64, НО всё равно
при вводе от 10 цифр в целом числе программа выдает не корректный ответ.

что же не так?
...
Рейтинг: 0 / 0
где же ошибка?
    #39384929
Фотография MasterZiv
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_,
ошибка в твоей программе...
...
Рейтинг: 0 / 0
где же ошибка?
    #39384930
Фотография MasterZiv
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_использую __int64, НО всё равно
при вводе от 10 цифр в целом числе программа выдает не корректный ответ.

что же не так?
а на каком языке вообще эта программа?
...
Рейтинг: 0 / 0
где же ошибка?
    #39384931
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
c++
...
Рейтинг: 0 / 0
где же ошибка?
    #39384932
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
а какая ошибка может быть?
...
Рейтинг: 0 / 0
где же ошибка?
    #39385074
Фотография mayton
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Признаться я был поражён увидев такое подобие "Талмуда".

Определённо.. это не С++. Особенно со всякими gcnew.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385075
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_а какая ошибка может быть?
Какая-то. Хочешь помощи: будь добр оформить вопрос, я уже писал выше "Давай только код функции, которая не работает, и с какими параметрами ее вызвать". Твои портянки изучать не интересно.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385087
egorych
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
maytonОпределённо.. это не С++.ага, это managed уродец.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385092
ПГС
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
В своё время, я на ABAP (это язык из SAP) писал, похожий модуль.

Там был один цикл, в нем вызов трёх подпрограмм.
В каждой подпрограмме от двух до 5 строк.
В принципе можно и внутри цикла всё сделать.
Подпрограммы только для наглядности.

Не знаю, зачем столько "букв в коде" у ТС ?
Задача разбивается на три части.

Начало цикла: На входе исходное число.

1. Исходное число разделить нацело на систему счисления.
2. Остаток от целочисленного деления преобразовать в соответствующий символ (цифру) системы счисления.
3. Положить найденную цифру в позицию с правой части итоговой строки. Номер позиции = номеру текущей итерации цикла.
4. С частным от деления в первом пункте перейти к началу цикла.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385093
Фотография mayton
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Забавные лабы стали придумывать преподы. Ну кому нужна 13-ричная система?
Даже такому искателю реликтов как я можно было-бы придумать Вавилонскую 60-ричную,
или "трехполярную" АКА Сетунь.

Дак эти хоть существовали.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385105
Dima T
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Я 62-ричную пользовал. 0-9, a-z, A-Z. И то только потому что в DBF числовые типы хранились строкой цифр, с появлением Integer надобность отпала.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385110
ПГС
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Я в своём случае делал 36-ричную.
Надо было упаковать банковский номер счета (20 цифр) в SAP-овский - 10 символов.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385793
Пётр Седов
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
kasper_использую __int64, НО всё равно
при вводе от 10 цифр в целом числе программа выдает не корректный ответ.

что же не так?Надо ещё заменить atoi → _atoi64.

kasper_
Код: plaintext
1.
2.
3.
					 wchar_t wb[20];
					 ...
					 memset(wb, 0, 20);

Если хотите массив wchar_t заполнить нулями, то это надо делать либо так:
Код: plaintext
1.
memset(wb, 0, 20 * sizeof(wchar_t));

либо так:
Код: plaintext
1.
std::fill_n(wb, 20, 0); // нужен «#include <algorithm>»

Но вообще, по-нормальному, где-то в коде должна быть функция преобразования String → std::string. Простейший вариант, только для ASCII-подмножества:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
#include <stdexcept>

std::string std_string_from_cli_string(String^ s) {
  int len = s->Length;
  std::string result(len, ' ');
  for (int i = 0; i < len; i++) {
    wchar_t e = s[i];
    if (e >= 128) throw std::runtime_error("Unexpected character.");
    result[i] = static_cast<char>(e);
  }
  return result;
}

Код не компилировал. В «настоящем» коде надо делать преобразование UTF-16 → UTF-8.

MasterZivа на каком языке вообще эта программа?Это C++/CLI, Microsoft-овский диалект C++ для работы с .NET. Кстати, вторая попытка. Первая попытка (Managed C++) мертва.
...
Рейтинг: 0 / 0
где же ошибка?
    #39385807
kasper_
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вот
Пётр СедовНадо ещё заменить atoi - _atoi64

СПАСИБО!
...
Рейтинг: 0 / 0
25 сообщений из 25, страница 1 из 1
Форумы / C++ [игнор отключен] [закрыт для гостей] / где же ошибка?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]