Miért nem fut le az alábbi C++ program? Valamit még mellé kellene írnom?
#pragma once
namespace WindowsFormApplication {
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
/// </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::ListBox^ listBox1;
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->listBox1 = (gcnew System::Windows::Forms::ListBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// listBox1
//
this->listBox1->FormattingEnabled = true;
this->listBox1->Location = System::Drawing::Point(12, 45);
this->listBox1->Name = L"listBox1";
this->listBox1->Size = System::Drawing::Size(223, 199);
this->listBox1->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(12, 12);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
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, 261);
this->Controls->Add(this->button1);
this->Controls->Add(this->listBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
double f, D, fi, fi1, fi2, nd1, nd2, nf1, nf2, v1, v2;
double A1, A2, B1, B2, C1, C2, E, F, G, H, x, y;
double R1, R11, R12, R2, R3, R31, R32, R4, r1, r2, r3, r4;
double n = 0;
double n1, n1_, n2, n2_, n3, n3_, d1, d2, s1, s1_, s2, s2_, s3, s3_;
double f_piros, f_kekakro, f_keksima, delta_f_akromalt, delta_f_sima;
double d;
double N;
double negyzetre(double a)
{
return Math::Pow(a, 2);
}
void konstansok() //adatok deklarálása, és fi1, f2
{
D = 123;
f = 310;
fi = 1 / f;
v1 = 63.8; v2 = 33.7;
nd1 = 1.51651; nd2 = 1.64934;
nf1 = 1.52212; nf2 = 1.663;
fi2 = fi / (1 - v1 / v2);
fi1 = fi2*-1 * v1 / v2;
A1 = nd1*Math::Pow(fi1, 2) / (nd1 - 1);
A2 = nd2*Math::Pow(fi2, 2) / (nd2 - 1);
B1 = (nd1 + 1)*fi1 / nd1;
B2 = (nd2 + 1)*fi2 / nd2;
C1 = (nd1 + 2)*fi1 / nd1;
C2 = (nd2 + 2)*fi2 / nd2;
E = negyzetre(A1) / fi1 + negyzetre(A2) / fi2 + (3 * nd2 + 1) / nd2*A2*fi1 + (3 * nd2 + 2) / nd2*negyzetre(fi1)*fi2;
F = (2 * nd1 + 1)*A1 / nd1;
G = A2*(2 * nd2 + 1) / nd2 + 4 * B2*fi1;
H = (2 * nd2 + 1) / nd2 * fi1 * fi2;
x = (A1 + A2 + H) / B1;
y = B2 / B1;
}
void sugarak()
{
R31 = (2 * x*y*C1 - F*y + G + Math::Sqrt(negyzetre(-2 * x*y*C1 + F*y - G) - 4 * (C1*negyzetre(y) + C2)*(C1*negyzetre(x) - F*x + E))) / 2 * (C1*negyzetre(y) + C2);
R32 = (2 * x*y*C1 - F*y + G - Math::Sqrt(negyzetre(-2 * x*y*C1 + F*y - G) - 4 * (C1*negyzetre(y) + C2)*(C1*negyzetre(x) - F*x + E))) / 2 * (C1*negyzetre(y) + C2);
R11 = x - y*R31;
R12 = x - y*R32;
if (Math::Abs(R31 - (R11 - fi1 / (nd1 - 1))) < Math::Abs(R32 - (R12 - fi1 / (nd1 - 1))))
{
R3 = R31; R1 = R11;
}
else
{
R3 = R32; R1 = R12;
}
R2 = R1 - fi1 / (nd1 - 1);
r2 = 1 / R2; r3 = 1 / R3;
while (Math::Abs(r2 - r3) > 0.00001)
{
R3 = R2;
R1 = x - y*R3;
R2 = R1 - fi1 / (nd1 - 1);
r2 = 1 / R2; r3 = 1 / R3;
n++;
}
R2 = R1 - fi1 / (nd1 - 1);
R4 = R3 - fi2 / (nd2 - 1);
r1 = 1 / R1; r2 = 1 / R2; r3 = 1 / R3; r4 = 1 / R4;
}
double keplet(double n, double n_, double s, double R)
{
return n_ / (n / s + (n_ - n) / R);
}
void fokusz_piros()
{
d1 = 20; d2 = 5;
n1 = 1; n1_ = nd1; n2 = nd1; n2_ = nd2; n3 = nd2; n3_ = 1;
R1 = r1;
s1_ = n1_ / ((n1_ - n1) / R1);
s2 = s1_ - d1;
R2 = s2 / s1_*r2;
s2_ = keplet(n2, n2_, s2, R2);
s3 = s2_ - d2;
R3 = s2*s3 / s1_ / s2_*r4;
s3_ = keplet(n3, n3_, s3, R3);
f_piros = s1_*s2_*s3_ / (s2 * s3);
}
void fokusz_kek()
{
d1 = 20; d2 = 5;
n1 = 1; n1_ = nf1; n2 = nf1; n2_ = nf2; n3 = nf2; n3_ = 1;
s1_ = n1_ / ((n1_ - n1) / R1);
s2 = s1_ - d1;
s2_ = keplet(n2, n2_, s2, R2);
s3 = s2_ - d2;
s3_ = keplet(n3, n3_, s3, R3);
f_kekakro = s1_*s2_*s3_ / (s2 * s3);
}
void referencia()
{
d = d1 + d2;
R2 = f*(nd1 - 1)*(R1*nd1 - (nd1 - 1)*d) / (nd1*R1 - f*(nd1 - 1)* nd1);
f_keksima = 1 / ((nf1 - 1) * (1 / R1 + 1 / R2 - (nf1 - 1) / nf1*d / (R1*R2)));
f_piros = 1 / ((nd1 - 1) * (1 / R1 + 1 / R2 - (nd1 - 1) / nd1*d / (R1*R2)));
delta_f_sima = Math::Abs(f - f_keksima);
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
konstansok();
sugarak();
listBox1->Items->Add("f= " + f);
listBox1->Items->Add("D= " + D);
listBox1->Items->Add("r1= " + r1);
listBox1->Items->Add("r2= " + r2);
listBox1->Items->Add("r3= " + r3);
listBox1->Items->Add("r4= " + r4);
listBox1->Items->Add(n + " lepesbol kiszamolva");
fokusz_piros();
listBox1->Items->Add("f_piros= " + f_piros);
fokusz_kek();
listBox1->Items->Add("f_kek= " + f_kekakro);
delta_f_akromalt = Math::Abs(f_kekakro - f_piros);
listBox1->Items->Add("delta f= " + delta_f_akromalt);
referencia();
listBox1->Items->Add("referencia:");
listBox1->Items->Add("f_kek simaval= " + f_keksima);
listBox1->Items->Add("delta f simaval= " + delta_f_sima);
N = delta_f_sima / delta_f_akromalt;
listBox1->Items->Add(N + "-szer jobb az akromalt lencse");
}
};
}
System-ekre az elején hogy name must be a namespace name
publicra hogy expected a declaration
A hibaüzenetek alapján nem tudja a fordító hogy ez nem C++ hanem C++/CLI. Állítsd be.
Amúgy ez obfuszkált kód?
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!