طراحی کامپایلر ساده
#c_sharp_programming, #c_plus_plus_programming
پروژه شماره یک:
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبان C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
و در ادامه ، برنامههاي مربوط به توليد مفسر و كامپايلر را طوري تغيير دهيد كه اگر در برنامه ورودي خطايي وجود داشت آن را گزارش كند. به عنوان مثال هر دو برنامه بايد با دريافت عبارات ذيل پيغام خطاي مناسب ارائه كنند.
A = 2 * 4
B =3
C= A % B
B=2
A= B * C
در اين عبارات استفاده از % غير مجاز است و همچنين انجام عمليات مستقيم روي اعداد نيز غير مجاز است.
پروژه شماره دوم:
هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامه به زبان c#نوشته شود.
توسط خریدار:
اطلاعات بیشتر:
http://pc0.ir/p/208486
@ParscodersCom
#c_sharp_programming, #c_plus_plus_programming
پروژه شماره یک:
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبان C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
و در ادامه ، برنامههاي مربوط به توليد مفسر و كامپايلر را طوري تغيير دهيد كه اگر در برنامه ورودي خطايي وجود داشت آن را گزارش كند. به عنوان مثال هر دو برنامه بايد با دريافت عبارات ذيل پيغام خطاي مناسب ارائه كنند.
A = 2 * 4
B =3
C= A % B
B=2
A= B * C
در اين عبارات استفاده از % غير مجاز است و همچنين انجام عمليات مستقيم روي اعداد نيز غير مجاز است.
پروژه شماره دوم:
هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامه به زبان c#نوشته شود.
توسط خریدار:
کاربر250882اطلاعات بیشتر:
http://pc0.ir/p/208486
@ParscodersCom
open gl, setmypixel, glint
🔸 فوری
#opengl
شکل ضمیمه شده را با الگوریتم خط شیبدار انجم دهید لطفا.
#include<GL/glut.h>
#include<math.h>
void mySetPixel(GLdouble x, GLdouble w)
{
glBegin(GL_POINTS);
glVertex2d(x, w);
glEnd();
}
void floatLine(GLint X1, GLint Y1, GLint X2, GLint Y2)
{
GLint X, Y, Temp;
float m, z, w;
if ((X2 - X1) > (Y2 - Y1))
{
if (X1 > X2)
{
Temp = X1;
X1 = X2;
X2 = Temp;
Temp = Y1;
Y1 = Y2;
Y2 = Temp;
}
m = (float)(Y2 - Y1) / (X2 - X1);
for (X = X1; X <= X2; X++)
{
w = m*(X - X1) + Y1;
mySetPixel(X, round(w));
}
}
else
{
if (Y1 > Y2)
{
Temp = X1;
X1 = X2;
X2 = Temp;
Temp = Y1;
Y1 = Y2;
Y2 = Temp;
}
m = (float)(X2 - X1) / (Y2 - Y1);
for (Y = Y1; Y <= Y2; Y++)
{
z = m*(Y - Y1) + X1;
mySetPixel(round(z), Y);
}
}
}
توسط خریدار:
اطلاعات بیشتر:
http://pc0.ir/p/236040
@ParscodersCom
🔸 فوری
#opengl
شکل ضمیمه شده را با الگوریتم خط شیبدار انجم دهید لطفا.
#include<GL/glut.h>
#include<math.h>
void mySetPixel(GLdouble x, GLdouble w)
{
glBegin(GL_POINTS);
glVertex2d(x, w);
glEnd();
}
void floatLine(GLint X1, GLint Y1, GLint X2, GLint Y2)
{
GLint X, Y, Temp;
float m, z, w;
if ((X2 - X1) > (Y2 - Y1))
{
if (X1 > X2)
{
Temp = X1;
X1 = X2;
X2 = Temp;
Temp = Y1;
Y1 = Y2;
Y2 = Temp;
}
m = (float)(Y2 - Y1) / (X2 - X1);
for (X = X1; X <= X2; X++)
{
w = m*(X - X1) + Y1;
mySetPixel(X, round(w));
}
}
else
{
if (Y1 > Y2)
{
Temp = X1;
X1 = X2;
X2 = Temp;
Temp = Y1;
Y1 = Y2;
Y2 = Temp;
}
m = (float)(X2 - X1) / (Y2 - Y1);
for (Y = Y1; Y <= Y2; Y++)
{
z = m*(Y - Y1) + X1;
mySetPixel(round(z), Y);
}
}
}
توسط خریدار:
کاربر274377اطلاعات بیشتر:
http://pc0.ir/p/236040
@ParscodersCom
طراحی کامپایلر ساده
#c_sharp_programming, #c_plus_plus_programming
پروژه شماره یک:
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبان C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/256042/طراحی-کامپایلر-ساده
t.me/ParscodersCom
#c_sharp_programming, #c_plus_plus_programming
پروژه شماره یک:
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبان C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
توسط خریدار:
کاربر300893اطلاعات بیشتر:
https://parscoders.com/project/256042/طراحی-کامپایلر-ساده
t.me/ParscodersCom
پروژه سی پلاس پلاس(27078)+
#c_plus_plus_programming
:
سلام وقت بخير كدي به زبان سي پلاس پلاس دارم اما داراي مشكل هستش ميتونيد اصلاحش كنيد؟
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
/*
function to read grammar from a file
the function pushes each production in vector pro
*/
void ReadGrammar(string file, vector<string>& pro)
{
string line;
ifstream myfile;
myfile.open(file);
while (getline(myfile, line))
{
pro.push_back(line);
}
}
/*
function to check if we can derive string str[\]
using productions in pro
*/
bool RecognizeString(vector<string>& pro, string str)
{
int n, v, s, p, i, l;
n = str.length();
v = pro.size();
/*
3D vector dp[n+1, n+1, 26\]
*/
vector< vector< vector<bool> > > dp(n + 1, vector< vector <bool> >(n + 1, vector<bool>(26, false)));
/*
the following loop recognize substrings of length 1
*/
for (s = 0; s < n; ++s)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length == 4 then it means that the production pro[i\]
is in form P->a
pro[i\][3\] == str[s\] checks if production P->a can recognize the character str[s\]
*/
if (pro[i\].length() == 4 && pro[i\][3\] == str[s\])
{
dp[1\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
/*
the following loop recognize substrings of length > 1
l is the length of the current substring
*/
for (l = 2; l <= n; ++l)
{
/* s is the starting index of substring */
for (s = 0; s < n - l + 1; ++s)
{
/* p is the size of left partition of the substring */
for (p = 1; p <= l - 1; ++p)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length() == 5 then it implies that the production is in form P->AB
dp[ p \][ s \][ pro[i\][3\]-'A'\] checks if we can derive left partition using A
dp[ l-p \][ s+p \][ pro[i\][4\]-'A' \] checks if we can derive the right partition using B
*/
if (pro[i\].length() == 5 && dp[p\][s\][pro[i\][3\] - 'A'\] && dp[l - p\][s + p\][pro[i\][4\] - 'A'\])
{
dp[l\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
}
}
return dp[n\][0\]['S' - 'A'\];
}
int main()
{
vector<string> pro;
string str;
ofstream myfile("text.txt");
ReadGrammar("text.txt", pro);
cout << "Context-free Grammar" << endl;
for (int i = 0; i < pro.size(); ++i)
{
cout << pro[i\] << endl;
}
cout << "Enter a String: ";
cin >> str;
if (RecognizeString(pro, str))
cout << "The input string can be derived using given CFL" << endl;
else
cout << "The input string cannot be derived using given CFL" << endl;
}
Context-free Grammar
S->AB
A->a
A->BB
B->AS
B->b
Enter a String: aabbb
The input string can be derived using given CFL
خروجي بايد به اين صورت باشه اما خروجي درستي تحويل نمي
#c_plus_plus_programming
:
سلام وقت بخير كدي به زبان سي پلاس پلاس دارم اما داراي مشكل هستش ميتونيد اصلاحش كنيد؟
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
/*
function to read grammar from a file
the function pushes each production in vector pro
*/
void ReadGrammar(string file, vector<string>& pro)
{
string line;
ifstream myfile;
myfile.open(file);
while (getline(myfile, line))
{
pro.push_back(line);
}
}
/*
function to check if we can derive string str[\]
using productions in pro
*/
bool RecognizeString(vector<string>& pro, string str)
{
int n, v, s, p, i, l;
n = str.length();
v = pro.size();
/*
3D vector dp[n+1, n+1, 26\]
*/
vector< vector< vector<bool> > > dp(n + 1, vector< vector <bool> >(n + 1, vector<bool>(26, false)));
/*
the following loop recognize substrings of length 1
*/
for (s = 0; s < n; ++s)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length == 4 then it means that the production pro[i\]
is in form P->a
pro[i\][3\] == str[s\] checks if production P->a can recognize the character str[s\]
*/
if (pro[i\].length() == 4 && pro[i\][3\] == str[s\])
{
dp[1\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
/*
the following loop recognize substrings of length > 1
l is the length of the current substring
*/
for (l = 2; l <= n; ++l)
{
/* s is the starting index of substring */
for (s = 0; s < n - l + 1; ++s)
{
/* p is the size of left partition of the substring */
for (p = 1; p <= l - 1; ++p)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length() == 5 then it implies that the production is in form P->AB
dp[ p \][ s \][ pro[i\][3\]-'A'\] checks if we can derive left partition using A
dp[ l-p \][ s+p \][ pro[i\][4\]-'A' \] checks if we can derive the right partition using B
*/
if (pro[i\].length() == 5 && dp[p\][s\][pro[i\][3\] - 'A'\] && dp[l - p\][s + p\][pro[i\][4\] - 'A'\])
{
dp[l\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
}
}
return dp[n\][0\]['S' - 'A'\];
}
int main()
{
vector<string> pro;
string str;
ofstream myfile("text.txt");
ReadGrammar("text.txt", pro);
cout << "Context-free Grammar" << endl;
for (int i = 0; i < pro.size(); ++i)
{
cout << pro[i\] << endl;
}
cout << "Enter a String: ";
cin >> str;
if (RecognizeString(pro, str))
cout << "The input string can be derived using given CFL" << endl;
else
cout << "The input string cannot be derived using given CFL" << endl;
}
Context-free Grammar
S->AB
A->a
A->BB
B->AS
B->b
Enter a String: aabbb
The input string can be derived using given CFL
خروجي بايد به اين صورت باشه اما خروجي درستي تحويل نمي
پروژه سی پلاس پلاس(28078)+
#c_plus_plus_programming
:
سلام وقت بخير كدي به زبان سي پلاس پلاس دارم اما داراي مشكل هستش ميتونيد اصلاحش كنيد؟
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
/*
function to read grammar from a file
the function pushes each production in vector pro
*/
void ReadGrammar(string file, vector<string>& pro)
{
string line;
ifstream myfile;
myfile.open(file);
while (getline(myfile, line))
{
pro.push_back(line);
}
}
/*
function to check if we can derive string str[\]
using productions in pro
*/
bool RecognizeString(vector<string>& pro, string str)
{
int n, v, s, p, i, l;
n = str.length();
v = pro.size();
/*
3D vector dp[n+1, n+1, 26\]
*/
vector< vector< vector<bool> > > dp(n + 1, vector< vector <bool> >(n + 1, vector<bool>(26, false)));
/*
the following loop recognize substrings of length 1
*/
for (s = 0; s < n; ++s)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length == 4 then it means that the production pro[i\]
is in form P->a
pro[i\][3\] == str[s\] checks if production P->a can recognize the character str[s\]
*/
if (pro[i\].length() == 4 && pro[i\][3\] == str[s\])
{
dp[1\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
/*
the following loop recognize substrings of length > 1
l is the length of the current substring
*/
for (l = 2; l <= n; ++l)
{
/* s is the starting index of substring */
for (s = 0; s < n - l + 1; ++s)
{
/* p is the size of left partition of the substring */
for (p = 1; p <= l - 1; ++p)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length() == 5 then it implies that the production is in form P->AB
dp[ p \][ s \][ pro[i\][3\]-'A'\] checks if we can derive left partition using A
dp[ l-p \][ s+p \][ pro[i\][4\]-'A' \] checks if we can derive the right partition using B
*/
if (pro[i\].length() == 5 && dp[p\][s\][pro[i\][3\] - 'A'\] && dp[l - p\][s + p\][pro[i\][4\] - 'A'\])
{
dp[l\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
}
}
return dp[n\][0\]['S' - 'A'\];
}
int main()
{
vector<string> pro;
string str;
ofstream myfile("text.txt");
ReadGrammar("text.txt", pro);
cout << "Context-free Grammar" << endl;
for (int i = 0; i < pro.size(); ++i)
{
cout << pro[i\] << endl;
}
cout << "Enter a String: ";
cin >> str;
if (RecognizeString(pro, str))
cout << "The input string can be derived using given CFL" << endl;
else
cout << "The input string cannot be derived using given CFL" << endl;
}
Context-free Grammar
S->AB
A->a
A->BB
B->AS
B->b
Enter a String: aabbb
The input string can be derived using given CFL
خروجي بايد به اين صورت باشه اما خروجي درستي تحويل نميده
+++
#c_plus_plus_programming
:
سلام وقت بخير كدي به زبان سي پلاس پلاس دارم اما داراي مشكل هستش ميتونيد اصلاحش كنيد؟
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;
/*
function to read grammar from a file
the function pushes each production in vector pro
*/
void ReadGrammar(string file, vector<string>& pro)
{
string line;
ifstream myfile;
myfile.open(file);
while (getline(myfile, line))
{
pro.push_back(line);
}
}
/*
function to check if we can derive string str[\]
using productions in pro
*/
bool RecognizeString(vector<string>& pro, string str)
{
int n, v, s, p, i, l;
n = str.length();
v = pro.size();
/*
3D vector dp[n+1, n+1, 26\]
*/
vector< vector< vector<bool> > > dp(n + 1, vector< vector <bool> >(n + 1, vector<bool>(26, false)));
/*
the following loop recognize substrings of length 1
*/
for (s = 0; s < n; ++s)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length == 4 then it means that the production pro[i\]
is in form P->a
pro[i\][3\] == str[s\] checks if production P->a can recognize the character str[s\]
*/
if (pro[i\].length() == 4 && pro[i\][3\] == str[s\])
{
dp[1\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
/*
the following loop recognize substrings of length > 1
l is the length of the current substring
*/
for (l = 2; l <= n; ++l)
{
/* s is the starting index of substring */
for (s = 0; s < n - l + 1; ++s)
{
/* p is the size of left partition of the substring */
for (p = 1; p <= l - 1; ++p)
{
/* reading each production */
for (i = 0; i < v; ++i)
{
/*
if pro[i\].length() == 5 then it implies that the production is in form P->AB
dp[ p \][ s \][ pro[i\][3\]-'A'\] checks if we can derive left partition using A
dp[ l-p \][ s+p \][ pro[i\][4\]-'A' \] checks if we can derive the right partition using B
*/
if (pro[i\].length() == 5 && dp[p\][s\][pro[i\][3\] - 'A'\] && dp[l - p\][s + p\][pro[i\][4\] - 'A'\])
{
dp[l\][s\][pro[i\][0\] - 'A'\] = true;
}
}
}
}
}
return dp[n\][0\]['S' - 'A'\];
}
int main()
{
vector<string> pro;
string str;
ofstream myfile("text.txt");
ReadGrammar("text.txt", pro);
cout << "Context-free Grammar" << endl;
for (int i = 0; i < pro.size(); ++i)
{
cout << pro[i\] << endl;
}
cout << "Enter a String: ";
cin >> str;
if (RecognizeString(pro, str))
cout << "The input string can be derived using given CFL" << endl;
else
cout << "The input string cannot be derived using given CFL" << endl;
}
Context-free Grammar
S->AB
A->a
A->BB
B->AS
B->b
Enter a String: aabbb
The input string can be derived using given CFL
خروجي بايد به اين صورت باشه اما خروجي درستي تحويل نميده
+++
تبديل ++c به #c
#apache, #c_sharp_programming, #c_plus_plus_programming
#include <bits/stdc++.h>
using namespace std;
void ShiftLeft(string &str, int cnt)
{
int n = str.length();
if(n == 0)
return;
string newstr = "";
cnt %= n;
for(int i=0; i<n; i++)
newstr += str[(i+cnt+n)%n\];
str = newstr;
}
void ShiftRight(string &str, int cnt)
{
int n = str.length();
if(n == 0)
return;
string newstr = "";
cnt %= n;
for(int i=0; i<n; i++)
newstr += str[(i-cnt+n)%n\];
str = newstr;
}
void Extend(string &str, int cnt)
{
for(int i=0; i<cnt; i++)
str += '*';
}
void Shrink(string &str, int cnt)
{
if(cnt >= str.length())
str = "";
else
str = str.substr(0, (int)str.length()-cnt);
}
void Reverse(string &str)
{
reverse(str.begin(), str.end());
}
void Put(string &str, int i, char c)
{
if(i > str.length()) return;
str[i-1\] = c;
}
void Print(string str)
{
cout << str << endl;
}
int main()
{
string order, str="";
getline(cin, str);
cin >> order;
while(order != "EXIT")
{
//cout << order << endl;
//cout << str << endl;
if(order == "SHIFT-R" || order == "SHIFT-L")
{
int cnt;
cin >> cnt;
if(order[6\] == 'L')
ShiftLeft(str, cnt);
else
ShiftRight(str, cnt);
}
else if(order == "EXTEND")
{
int cnt;
cin >> cnt;
Extend(str, cnt);
}
else if(order == "SHRINK")
{
int cnt;
cin >> cnt;
Shrink(str, cnt);
}
else if(order == "REVERSE")
{
Reverse(str);
}
else if(order == "PUT")
{
int i;
char c;
cin >> i >> c;
Put(str, i, c);
}
else if(order == "PRINT")
{
Print(str);
}
cin >> order;
}
return 0;
}
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/289895/تبديل-plus-plus-c-به-sharp-c
t.me/ParscodersCom
#apache, #c_sharp_programming, #c_plus_plus_programming
#include <bits/stdc++.h>
using namespace std;
void ShiftLeft(string &str, int cnt)
{
int n = str.length();
if(n == 0)
return;
string newstr = "";
cnt %= n;
for(int i=0; i<n; i++)
newstr += str[(i+cnt+n)%n\];
str = newstr;
}
void ShiftRight(string &str, int cnt)
{
int n = str.length();
if(n == 0)
return;
string newstr = "";
cnt %= n;
for(int i=0; i<n; i++)
newstr += str[(i-cnt+n)%n\];
str = newstr;
}
void Extend(string &str, int cnt)
{
for(int i=0; i<cnt; i++)
str += '*';
}
void Shrink(string &str, int cnt)
{
if(cnt >= str.length())
str = "";
else
str = str.substr(0, (int)str.length()-cnt);
}
void Reverse(string &str)
{
reverse(str.begin(), str.end());
}
void Put(string &str, int i, char c)
{
if(i > str.length()) return;
str[i-1\] = c;
}
void Print(string str)
{
cout << str << endl;
}
int main()
{
string order, str="";
getline(cin, str);
cin >> order;
while(order != "EXIT")
{
//cout << order << endl;
//cout << str << endl;
if(order == "SHIFT-R" || order == "SHIFT-L")
{
int cnt;
cin >> cnt;
if(order[6\] == 'L')
ShiftLeft(str, cnt);
else
ShiftRight(str, cnt);
}
else if(order == "EXTEND")
{
int cnt;
cin >> cnt;
Extend(str, cnt);
}
else if(order == "SHRINK")
{
int cnt;
cin >> cnt;
Shrink(str, cnt);
}
else if(order == "REVERSE")
{
Reverse(str);
}
else if(order == "PUT")
{
int i;
char c;
cin >> i >> c;
Put(str, i, c);
}
else if(order == "PRINT")
{
Print(str);
}
cin >> order;
}
return 0;
}
توسط خریدار:
کاربر331179اطلاعات بیشتر:
https://parscoders.com/project/289895/تبديل-plus-plus-c-به-sharp-c
t.me/ParscodersCom
برنامه نویسی طراحی کامپایلر
#c_plus_plus_programming
پروژه شماره یک:هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:in operandout operandبرنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند. A = 2B =3C= A+BB=2A= B * Cبرنامهاي به زبان C++ به صورت ذيل توليد میشود. #include<iostream.h>int main(){int A,B,C,D;A=2;B=3;C=A + B;B=2;A= B * C;cout<<A;return 0;}با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////پروژه شماره دوم: هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:in operandout operandبرنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند. A = 2B =3C= A+BB=2A= B * C
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
چون تازه یاد گرفتیم استاد انتظار کد حرفه ای ازمون ندارهفقط میخواد ببینه میتونیم کد بنویسیم یا نهچندین بار هم تاکید کرده کدهاتون ساده باشه و یه برنامه مورد قبول بنویسید قبوله گفته برنامه حرفه ای ازتون نمیخوام
توضیح کد هم لازم دارم یا بصورت فیلم یا متن چون باید ارائه بدم
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/306569/برنامه-نویسی-طراحی-کامپایلر
t.me/ParscodersCom
#c_plus_plus_programming
پروژه شماره یک:هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:in operandout operandبرنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند. A = 2B =3C= A+BB=2A= B * Cبرنامهاي به زبان C++ به صورت ذيل توليد میشود. #include<iostream.h>int main(){int A,B,C,D;A=2;B=3;C=A + B;B=2;A= B * C;cout<<A;return 0;}با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////پروژه شماره دوم: هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:in operandout operandبرنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند. A = 2B =3C= A+BB=2A= B * C
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
چون تازه یاد گرفتیم استاد انتظار کد حرفه ای ازمون ندارهفقط میخواد ببینه میتونیم کد بنویسیم یا نهچندین بار هم تاکید کرده کدهاتون ساده باشه و یه برنامه مورد قبول بنویسید قبوله گفته برنامه حرفه ای ازتون نمیخوام
توضیح کد هم لازم دارم یا بصورت فیلم یا متن چون باید ارائه بدم
توسط خریدار:
کاربر344799اطلاعات بیشتر:
https://parscoders.com/project/306569/برنامه-نویسی-طراحی-کامپایلر
t.me/ParscodersCom
زبان برنامه نویسی
#c_programming
سلام
بندل از کد داریم بعد کمپایل میخاد سه عدد وارید کنیم تا این متن "exactly good job "پرنت کلان سه عدد و توضیح کد لازم اس
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
static int64_t metallica[\] = { 32538, 37741, 89540, 14627, 34272, 58765 };
const static int N = sizeof(metallica)/sizeof(*metallica);
static void fail(){
puts("Nope!");
exit(EXIT_FAILURE);
}
static void the_beatles(int64_t h, int64_t s, int64_t i){
if ( h - i / 7 + 3 * s / 11 )
fail();
}
static void anthrax(int z, int64_t j){
int64_t p = j;
for(; z<N; ++z) {
if ((z % 2) == 0)
continue;
p += metallica[z\];
}
if (p != 69857)
fail();
}
static void eagles(int k, int64_t d){
if (k<N) {
if (k % 2)
eagles(++k, d);
else eagles(k + 1, d * metallica[k\]);
} else if (d != 1269229500)
fail();
}
int main(){
int64_t a, e, y;
printf("Please enter the right three numbers: ");
fflush(stdout);
if (scanf("%" SCNd64 " %" SCNd64 " %" SCNd64, &a, &e, &y) != 3)
fail();
metallica[0\] = a;
metallica[5\] = e;
metallica[4\] = y;
anthrax(0, 15916);
eagles(1, 9);
the_beatles(a, e, y);
puts("Exactly! Good job.");
}
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/310971/زبان-برنامه-نویسی
t.me/ParscodersCom
#c_programming
سلام
بندل از کد داریم بعد کمپایل میخاد سه عدد وارید کنیم تا این متن "exactly good job "پرنت کلان سه عدد و توضیح کد لازم اس
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
static int64_t metallica[\] = { 32538, 37741, 89540, 14627, 34272, 58765 };
const static int N = sizeof(metallica)/sizeof(*metallica);
static void fail(){
puts("Nope!");
exit(EXIT_FAILURE);
}
static void the_beatles(int64_t h, int64_t s, int64_t i){
if ( h - i / 7 + 3 * s / 11 )
fail();
}
static void anthrax(int z, int64_t j){
int64_t p = j;
for(; z<N; ++z) {
if ((z % 2) == 0)
continue;
p += metallica[z\];
}
if (p != 69857)
fail();
}
static void eagles(int k, int64_t d){
if (k<N) {
if (k % 2)
eagles(++k, d);
else eagles(k + 1, d * metallica[k\]);
} else if (d != 1269229500)
fail();
}
int main(){
int64_t a, e, y;
printf("Please enter the right three numbers: ");
fflush(stdout);
if (scanf("%" SCNd64 " %" SCNd64 " %" SCNd64, &a, &e, &y) != 3)
fail();
metallica[0\] = a;
metallica[5\] = e;
metallica[4\] = y;
anthrax(0, 15916);
eagles(1, 9);
the_beatles(a, e, y);
puts("Exactly! Good job.");
}
توسط خریدار:
کاربر352589اطلاعات بیشتر:
https://parscoders.com/project/310971/زبان-برنامه-نویسی
t.me/ParscodersCom
48779 سی پلاس پلاس
#c_plus_plus_programming
سلام وقتتون بخیر باشه .
من یه پروژه کوچیک برای ماتریس دارم . و کِی میتوانید تحویل بدهید ؟ :)))))
این پروژه هستش با c++ و ۴ روز هم وقت دارم بعد خودم اینقدرشو زدم ولی چون وسط امتحانم وقت نمیشه ادامش بدم یا تکمیل کنم ایراداشو در بیارم متاسفانه :))
Sajede❄️ Mehrdad, [1/17/2023 11:56 PM\]
#include <iostream>
using namespace std;
int x,y;
typedef int matrix[x\][y\];
void rotate90(matrix D){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=D[x-j-1\][i\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
D[i\][j\]=temp[i\][j\];
}
}
}
void rotate180(matrix C){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=C[x-i-1\][y-j-1\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
C[i\][j\]=temp[i\][j\];
}
}
}
void rotate270(matrix E){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=E[j\][y-i-1\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
E[i\][j\]=temp[i\][j\];
}
}
}
int main(){
int m,n,p,q;
cin>>m>>n>>p>>q;
int a[m\][n\];
int b[p\][q\];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i\][j\];
}
}
for(int i=0;i<p;i++){
for(int j;j<q;j++){
cin>>b[i\][j\]
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(a[i\][j\]==b[p\][q\] a[i\][j\]==rotate90(matrix b) a[i\][j\]==rotate180(matrix b) || a[i\][j\]==rotate270(matrix b)){
a[i\][j\]=b[p\][q\];
}
else
a[i\][j\]=2;
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<a[i\][j\];
}
}
}
}
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/375435/48779 سی-پلاس-پلاس
t.me/ParscodersCom
#c_plus_plus_programming
سلام وقتتون بخیر باشه .
من یه پروژه کوچیک برای ماتریس دارم . و کِی میتوانید تحویل بدهید ؟ :)))))
این پروژه هستش با c++ و ۴ روز هم وقت دارم بعد خودم اینقدرشو زدم ولی چون وسط امتحانم وقت نمیشه ادامش بدم یا تکمیل کنم ایراداشو در بیارم متاسفانه :))
Sajede❄️ Mehrdad, [1/17/2023 11:56 PM\]
#include <iostream>
using namespace std;
int x,y;
typedef int matrix[x\][y\];
void rotate90(matrix D){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=D[x-j-1\][i\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
D[i\][j\]=temp[i\][j\];
}
}
}
void rotate180(matrix C){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=C[x-i-1\][y-j-1\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
C[i\][j\]=temp[i\][j\];
}
}
}
void rotate270(matrix E){
matrix temp;
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
temp[i\][j\]=E[j\][y-i-1\];
}
}
for(int i=0;i<x;i++){
for(int j=0;j<y;j++){
E[i\][j\]=temp[i\][j\];
}
}
}
int main(){
int m,n,p,q;
cin>>m>>n>>p>>q;
int a[m\][n\];
int b[p\][q\];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i\][j\];
}
}
for(int i=0;i<p;i++){
for(int j;j<q;j++){
cin>>b[i\][j\]
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(a[i\][j\]==b[p\][q\] a[i\][j\]==rotate90(matrix b) a[i\][j\]==rotate180(matrix b) || a[i\][j\]==rotate270(matrix b)){
a[i\][j\]=b[p\][q\];
}
else
a[i\][j\]=2;
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cout<<a[i\][j\];
}
}
}
}
توسط خریدار:
nikotexاطلاعات بیشتر:
https://parscoders.com/project/375435/48779 سی-پلاس-پلاس
t.me/ParscodersCom
49303 پروژه سی پلاس پلاس
#c_plus_plus_programming
:
پروژه سی پلاس پلاس
سلام
یه بازی ساد ox میخوام
c++
کدنویسی انجام دادم خطا میده نمیاره بالا
#include<iostream>
using namespace std;
char matris[3\][3\] = {'1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9'}
void game(){
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
cout<< matris[i\][j\] <<endl;
}
}
}
void input()
{
int n;
cout<< "enter number";
cin>>n;
if(n==1)
matris[0\][0\];
else if(n==2)
matris[0\][1\];
else if(n==3)
matris[0\][2\];
else if(n==4)
matris[1\][0\];
else if(n==5)
matris[1\][1\];
else if(n==6)
matris[1\][2\];
else if(n==7)
matris[2\][0\];
else if(n==8)
matris[2\][1\];
else if(n==9)
matris[2\][2\];
}
void flag(){
if (player== 'x')
player = 'o';
else
player = 'x';
char win()
//player aval
if(matris[0\][0\] == 'x' && matris[0\][1\] == 'x' && matris[0\][2\] == 'x')
if(matris[1\][0\] == 'x' && matris[1\][1\] == 'x' && matris[1\][2\] == 'x')
if(matris[2\][0\] == 'x' && matris[2\][1\] == 'x' && matris[2\][2\] == 'x')
if(matris[0\][0\] == 'x' && matris[1\][1\] == 'x' && matris[2\][2\] == 'x')
if(matris[2\][0\] == 'x' && matris[1\][1\] == 'x' && matris[0\][2\] == 'x')
if(matris[0\][2\] == 'x' && matris[1\][2\] == 'x' && matris[2\][2\] == 'x')
if(matris[0\][1\] == 'x' && matris[1\][1\] == 'x' && matris[2\][1\] == 'x')
if(matris[0\][0\] == 'x' && matris[1\][0\] == 'x' && matris[2\][0\] == 'x')
//player dovom
if(matris[0\][0\] == 'o' && matris[0\][1\] == 'o' && matris[0\][2\] == 'o')
if(matris[1\][0\] == 'o' && matris[1\][1\] == 'o' && matris[1\][2\] == 'o')
if(matris[2\][0\] == 'o' && matris[2\][1\] == 'o' && matris[2\][2\] == 'o')
if(matris[0\][0\] == 'o' && matris[1\][1\] == 'o' && matris[2\][2\] == 'o')
if(matris[2\][0\] == 'o' && matris[1\][1\] == 'o' && matris[0\][2\] == 'o')
if(matris[0\][2\] == 'o' && matris[1\][2\] == 'o' && matris[2\][2\] == 'o')
if(matris[0\][1\] == 'o' && matris[1\][1\] == 'o' && matris[2\][1\] == 'o')
if(matris[0\][0\] == 'o' && matris[1\][0\] == 'o' && matris[2\][0\] == 'o')
}
int main(){
game();
input();
if(win() == 'x'){
cout<<"x is winer"<<endl;
}
else if(win() == 'o'){
cout<<"o is winer"<<endl;
}
flag();
return 0;
}
برای امروز میخوامش
چقدر واریزشه؟
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/377317/49303-پروژه-سی-پلاس-پلاس
t.me/ParscodersCom
#c_plus_plus_programming
:
پروژه سی پلاس پلاس
سلام
یه بازی ساد ox میخوام
c++
کدنویسی انجام دادم خطا میده نمیاره بالا
#include<iostream>
using namespace std;
char matris[3\][3\] = {'1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9'}
void game(){
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
cout<< matris[i\][j\] <<endl;
}
}
}
void input()
{
int n;
cout<< "enter number";
cin>>n;
if(n==1)
matris[0\][0\];
else if(n==2)
matris[0\][1\];
else if(n==3)
matris[0\][2\];
else if(n==4)
matris[1\][0\];
else if(n==5)
matris[1\][1\];
else if(n==6)
matris[1\][2\];
else if(n==7)
matris[2\][0\];
else if(n==8)
matris[2\][1\];
else if(n==9)
matris[2\][2\];
}
void flag(){
if (player== 'x')
player = 'o';
else
player = 'x';
char win()
//player aval
if(matris[0\][0\] == 'x' && matris[0\][1\] == 'x' && matris[0\][2\] == 'x')
if(matris[1\][0\] == 'x' && matris[1\][1\] == 'x' && matris[1\][2\] == 'x')
if(matris[2\][0\] == 'x' && matris[2\][1\] == 'x' && matris[2\][2\] == 'x')
if(matris[0\][0\] == 'x' && matris[1\][1\] == 'x' && matris[2\][2\] == 'x')
if(matris[2\][0\] == 'x' && matris[1\][1\] == 'x' && matris[0\][2\] == 'x')
if(matris[0\][2\] == 'x' && matris[1\][2\] == 'x' && matris[2\][2\] == 'x')
if(matris[0\][1\] == 'x' && matris[1\][1\] == 'x' && matris[2\][1\] == 'x')
if(matris[0\][0\] == 'x' && matris[1\][0\] == 'x' && matris[2\][0\] == 'x')
//player dovom
if(matris[0\][0\] == 'o' && matris[0\][1\] == 'o' && matris[0\][2\] == 'o')
if(matris[1\][0\] == 'o' && matris[1\][1\] == 'o' && matris[1\][2\] == 'o')
if(matris[2\][0\] == 'o' && matris[2\][1\] == 'o' && matris[2\][2\] == 'o')
if(matris[0\][0\] == 'o' && matris[1\][1\] == 'o' && matris[2\][2\] == 'o')
if(matris[2\][0\] == 'o' && matris[1\][1\] == 'o' && matris[0\][2\] == 'o')
if(matris[0\][2\] == 'o' && matris[1\][2\] == 'o' && matris[2\][2\] == 'o')
if(matris[0\][1\] == 'o' && matris[1\][1\] == 'o' && matris[2\][1\] == 'o')
if(matris[0\][0\] == 'o' && matris[1\][0\] == 'o' && matris[2\][0\] == 'o')
}
int main(){
game();
input();
if(win() == 'x'){
cout<<"x is winer"<<endl;
}
else if(win() == 'o'){
cout<<"o is winer"<<endl;
}
flag();
return 0;
}
برای امروز میخوامش
چقدر واریزشه؟
توسط خریدار:
nikotexاطلاعات بیشتر:
https://parscoders.com/project/377317/49303-پروژه-سی-پلاس-پلاس
t.me/ParscodersCom
پروژه سی پلاس پلاس(6026)
#c_plus_plus_programming
پروژه شماره یک:
مهلت تحویل : اخرین جلسه کلاس و به صورت حضوری
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
پروژه شماره دوم:
مهلت تحویل: آخرین جلسه کلاس و به صورت حضوری
هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند.
A = 2
B =3
C= A+B
B=2
A= B * C
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/400326/پروژه-سی-پلاس-پلاس-6026
t.me/ParscodersCom
#c_plus_plus_programming
پروژه شماره یک:
مهلت تحویل : اخرین جلسه کلاس و به صورت حضوری
هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم.
زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند.
A = 2
B =3
C= A+B
B=2
A= B * C
برنامهاي به زبان C++ به صورت ذيل توليد میشود.
#include<iostream.h>
int main()
{
int A,B,C,D;
A=2;
B=3;
C=A + B;
B=2;
A= B * C;
cout<<A;
return 0;
}
با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
پروژه شماره دوم:
مهلت تحویل: آخرین جلسه کلاس و به صورت حضوری
هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است.
operand = num
operand = operand operator operand
همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است:
in operand
out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند.
A = 2
B =3
C= A+B
B=2
A= B * C
توسط خریدار:
کاربر110164اطلاعات بیشتر:
https://parscoders.com/project/400326/پروژه-سی-پلاس-پلاس-6026
t.me/ParscodersCom
24018 - دو پروژه ویژوال.
#visual_basic, #software_engineering
پروژه شماره یک: مهلت تحویل : اخرین جلسه کلاس و به صورت حضوری هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است: in operand out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند. A = 2 B =3 C= A+B B=2 A= B * C برنامهاي به زبان C++ به صورت ذيل توليد میشود. #include<iostream.h> int main() { int A,B,C,D; A=2; B=3; C=A + B; B=2; A= B * C; cout<<A; return 0; } با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
پروژه شماره دوم: مهلت تحویل: آخرین جلسه کلاس و به صورت حضوری هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است: in operand out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند. A = 2 B =3 C= A+B B=2 A= B * C
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/401366/24018-دو-پروژه-ویژوال
t.me/ParscodersCom
#visual_basic, #software_engineering
پروژه شماره یک: مهلت تحویل : اخرین جلسه کلاس و به صورت حضوری هدف از اين پروژه ساخت يك كامپايلر ساده براي يك زبان جديد است. براي توليد كامپايلر يك زبان جديد میتوان از امكانات زبانهاي موجود بهره برداري كرد. به اين منظور ابتدا زبان جديد را به يكي از زبانهاي موجود مانند C++ تبدیل كرده و با استفاده از كامپايلر زبان موجود، برنامه را به زبان ماشين و قابل اجرا ترجمه میكنيم. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است: in operand out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند و اين عبارات را به زبان C++ ترجمه كند. به عنوان مثال اگرورودي، عبارات ذيل باشند. A = 2 B =3 C= A+B B=2 A= B * C برنامهاي به زبان C++ به صورت ذيل توليد میشود. #include<iostream.h> int main() { int A,B,C,D; A=2; B=3; C=A + B; B=2; A= B * C; cout<<A; return 0; } با كامپايل اين برنامه و اجراي برنامه، عدد 10 چاپ خواهد شد كه نتيجه برنامه مبدا است.
پروژه شماره دوم: مهلت تحویل: آخرین جلسه کلاس و به صورت حضوری هدف از اين پروژه ساخت يك مفسر ساده براي يك زبان است. زبان ساده اي را با ساختار ذيل در نظر بگيريد. در اين عبارات operator يكي از عملگرهاي + ,/ ,* , - و operand شناسه یا عدد است و num يك عدد صحيح است. operand = num operand = operand operator operand همچنین دستور in عددی را از کاربر خوانده و در متغیر قرار می دهد دستور out مقدار متغیری را نشان می دهد. ساختار این دستورات به صورت زیر است: in operand out operand
برنامه اي بنويسيد كه عبارات با ساختارهای فوق را از یک فایل بخواند عمليات ها را انجام داده نتیجه را نمایش دهد. به عنوان مثال اگر ورودي عبارات ذيل باشد برنامه عدد 10 را چاپ ميكند. A = 2 B =3 C= A+B B=2 A= B * C
توسط خریدار:
مهندس خوباطلاعات بیشتر:
https://parscoders.com/project/401366/24018-دو-پروژه-ویژوال
t.me/ParscodersCom
65807 سی پلاس پلاس
#c_plus_plus_programming
سلام
[align=right\]#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> nums(8);
int main()
{
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=8;
int range=(highest-lowest)+1;
int cnt=0;
while(cnt<8)
{
random_integer = lowest+(int)(range*rand()/(RAND_MAX + 1.0));
if (find( nums.begin(), nums.end(),random_integer) == nums.end())
{
cnt++;
nums.push_back(random_integer);
cout << random_integer << endl;
}
}
}[/align\]
اینو میتونم بنویسم جای اعداد ۱ و ۸ بزارم ۰ و ۹
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/454822/65807-سی-پلاس-پلاس
t.me/ParscodersCom
#c_plus_plus_programming
سلام
[align=right\]#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> nums(8);
int main()
{
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=8;
int range=(highest-lowest)+1;
int cnt=0;
while(cnt<8)
{
random_integer = lowest+(int)(range*rand()/(RAND_MAX + 1.0));
if (find( nums.begin(), nums.end(),random_integer) == nums.end())
{
cnt++;
nums.push_back(random_integer);
cout << random_integer << endl;
}
}
}[/align\]
اینو میتونم بنویسم جای اعداد ۱ و ۸ بزارم ۰ و ۹
توسط خریدار:
nikotexاطلاعات بیشتر:
https://parscoders.com/project/454822/65807-سی-پلاس-پلاس
t.me/ParscodersCom
پروژه آردوینو (78420)
#arduino
پروژه حضور غیاب این هست که با rfid rc522 باید کارت هارو شناسایی کنه و با ماژول وای فا esp01s به وب سرور بفرسته اطلاعات از برد یونو هم استفاده کردمحالا کد هارو زدم و کار میکنه اما ماژول وای فا به وب سرور و اینترنت وصل نمیشه//ESP8266 Code: #include <ESP8266WiFi.h>#include "Adafruit_MQTT.h"#include "Adafruit_MQTT_Client.h"// WiFi parameters#define WLAN_SSID "GalaxyA05s"#define WLAN_PASS "m13871387"// Adafruit IO#define AIO_SERVER "io.adafruit.com"#define AIO_SERVERPORT 1883#define AIO_USERNAME "mahdiabbasi"#define AIO_KEY "aio_LZNe916ieuzRODahhhWPcSj0oqyg" // Obtained from account info on io.adafruit.com.// Create an ESP8266 WiFiClient class to connect to the MQTT server.WiFiClient client;// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);Adafruit_MQTT_Publish Attendance = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/feed name");char ID;/* Sketch Code **/void setup() { Serial.begin(115200); Serial.println(F("Adafruit IO Example")); // Connect to WiFi access point. Serial.println(); Serial.println(); delay(10); Serial.print(F("Connecting to ")); Serial.println(WLAN_SSID); WiFi.begin(WLAN_SSID, WLAN_PASS); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(F(".")); } Serial.println(); Serial.println(F("WiFi connected")); Serial.println(F("IP address: ")); Serial.println(WiFi.localIP()); // connect to adafruit io connect();}// connect to adafruit io via MQTTvoid connect() { Serial.print(F("Connecting to Adafruit IO... ")); int8_t ret; while ((ret = mqtt.connect()) != 0) { switch (ret) { case 1: Serial.println(F("Wrong protocol")); break; case 2: Serial.println(F("ID rejected")); break; case 3: Serial.println(F("Server unavail")); break; case 4: Serial.println(F("Bad user/pass")); break; case 5: Serial.println(F("Not authed")); break; case 6: Serial.println(F("Failed to subscribe")); break; default: Serial.println(F("Connection failed")); break; } if(ret >= 0) mqtt.disconnect(); Serial.println(F("Retrying connection...")); delay(5000); } Serial.println(F("Adafruit IO Connected!"));}void loop() { // ping adafruit io a few times to make sure we remain connected if(! mqtt.ping(3)) { // reconnect to adafruit io if(! mqtt.connected()) connect(); } if ( Serial.available() ) { // Update and send only after 1 seconds char a = Serial.read(); ID = a; if (! Attendance.publish(ID)) { //Publish to Adafruit Serial.println(F("Failed")); } else { Serial.println(F("Sent!")); }}}من این کد رو برای اتصال به وای فا و adafruit دارم ولی موقعی که آپلود میکنم کد رو نه به وای فا وصل میشه نه به adafruitبرنامه موقع کامپایل ران میشه و ارور هم نمیده ولی به وای فا و adafruit وصل نمیشه
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/503839/پروژه-آردوینو-78420
t.me/ParscodersCom
#arduino
پروژه حضور غیاب این هست که با rfid rc522 باید کارت هارو شناسایی کنه و با ماژول وای فا esp01s به وب سرور بفرسته اطلاعات از برد یونو هم استفاده کردمحالا کد هارو زدم و کار میکنه اما ماژول وای فا به وب سرور و اینترنت وصل نمیشه//ESP8266 Code: #include <ESP8266WiFi.h>#include "Adafruit_MQTT.h"#include "Adafruit_MQTT_Client.h"// WiFi parameters#define WLAN_SSID "GalaxyA05s"#define WLAN_PASS "m13871387"// Adafruit IO#define AIO_SERVER "io.adafruit.com"#define AIO_SERVERPORT 1883#define AIO_USERNAME "mahdiabbasi"#define AIO_KEY "aio_LZNe916ieuzRODahhhWPcSj0oqyg" // Obtained from account info on io.adafruit.com.// Create an ESP8266 WiFiClient class to connect to the MQTT server.WiFiClient client;// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);Adafruit_MQTT_Publish Attendance = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/feed name");char ID;/* Sketch Code **/void setup() { Serial.begin(115200); Serial.println(F("Adafruit IO Example")); // Connect to WiFi access point. Serial.println(); Serial.println(); delay(10); Serial.print(F("Connecting to ")); Serial.println(WLAN_SSID); WiFi.begin(WLAN_SSID, WLAN_PASS); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(F(".")); } Serial.println(); Serial.println(F("WiFi connected")); Serial.println(F("IP address: ")); Serial.println(WiFi.localIP()); // connect to adafruit io connect();}// connect to adafruit io via MQTTvoid connect() { Serial.print(F("Connecting to Adafruit IO... ")); int8_t ret; while ((ret = mqtt.connect()) != 0) { switch (ret) { case 1: Serial.println(F("Wrong protocol")); break; case 2: Serial.println(F("ID rejected")); break; case 3: Serial.println(F("Server unavail")); break; case 4: Serial.println(F("Bad user/pass")); break; case 5: Serial.println(F("Not authed")); break; case 6: Serial.println(F("Failed to subscribe")); break; default: Serial.println(F("Connection failed")); break; } if(ret >= 0) mqtt.disconnect(); Serial.println(F("Retrying connection...")); delay(5000); } Serial.println(F("Adafruit IO Connected!"));}void loop() { // ping adafruit io a few times to make sure we remain connected if(! mqtt.ping(3)) { // reconnect to adafruit io if(! mqtt.connected()) connect(); } if ( Serial.available() ) { // Update and send only after 1 seconds char a = Serial.read(); ID = a; if (! Attendance.publish(ID)) { //Publish to Adafruit Serial.println(F("Failed")); } else { Serial.println(F("Sent!")); }}}من این کد رو برای اتصال به وای فا و adafruit دارم ولی موقعی که آپلود میکنم کد رو نه به وای فا وصل میشه نه به adafruitبرنامه موقع کامپایل ران میشه و ارور هم نمیده ولی به وای فا و adafruit وصل نمیشه
توسط خریدار:
Hamyarprozheاطلاعات بیشتر:
https://parscoders.com/project/503839/پروژه-آردوینو-78420
t.me/ParscodersCom
Ardiuno ide 81562 /
#arduino
#کد_پروژه: 81562
موضوع: پروژه Ardiuno ide /
#include <SoftwareSerial.h>
SoftwareSerial sim800(10, 11); // RX, TX
void setup() {
// Start the serial communication with the computer
Serial.begin(9600);
// Start the serial communication with the SIM800C
sim800.begin(9600);
Serial.println("Initializing SIM800C...");
delay(1000);
// Check if the SIM800C is ready
if (sendATCommand("AT", "OK")) {
Serial.println("SIM800C is ready.");
} else {
Serial.println("SIM800C is not responding.");
return;
}
// Check the module's signal quality
sendATCommand("AT+CSQ", "OK");
// Check the network registration status
sendATCommand("AT+CREG?", "OK");
}
void loop() {
// Nothing to do here
}
bool sendATCommand(String command, String expectedResponse) {
sim800.println(command);
long int time = millis();
while ((time + 5000) > millis()) { // Wait for 5 seconds
while (sim800.available()) {
String response = sim800.readString();
Serial.println(response);
if (response.indexOf(expectedResponse) != -1) {
return true;
}
}
}
return false;
}
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/515156/ardiuno-ide-81562
t.me/ParscodersCom
#arduino
#کد_پروژه: 81562
موضوع: پروژه Ardiuno ide /
#include <SoftwareSerial.h>
SoftwareSerial sim800(10, 11); // RX, TX
void setup() {
// Start the serial communication with the computer
Serial.begin(9600);
// Start the serial communication with the SIM800C
sim800.begin(9600);
Serial.println("Initializing SIM800C...");
delay(1000);
// Check if the SIM800C is ready
if (sendATCommand("AT", "OK")) {
Serial.println("SIM800C is ready.");
} else {
Serial.println("SIM800C is not responding.");
return;
}
// Check the module's signal quality
sendATCommand("AT+CSQ", "OK");
// Check the network registration status
sendATCommand("AT+CREG?", "OK");
}
void loop() {
// Nothing to do here
}
bool sendATCommand(String command, String expectedResponse) {
sim800.println(command);
long int time = millis();
while ((time + 5000) > millis()) { // Wait for 5 seconds
while (sim800.available()) {
String response = sim800.readString();
Serial.println(response);
if (response.indexOf(expectedResponse) != -1) {
return true;
}
}
}
return false;
}
توسط خریدار:
khaneprozheاطلاعات بیشتر:
https://parscoders.com/project/515156/ardiuno-ide-81562
t.me/ParscodersCom
ارور در اکسپرت
#metatrader, #expert_advisor, #forex
سلام
اکسپرت نوشتم دکمه نمایش نمی دهد
#include<Trade\Trade.mqh> CTrade trade; double Ask, Bid;//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+void OnDeinit(const int reason) {//--- }//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+void OnTick() { Ask=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_ASK), _Digits); Bid=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_BID), _Digits); ObjectCreate(_Symbol,"BuyButton",OBJ_BUTTON,0,0,0); ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_XDISTANCE, 200); // set width ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_XSIZE, 200); // set distance from border ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_YDISTANCE, 200); // set height ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_YSIZE, 50);// set Chart corner ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_CORNER, 2); ObjectSetString (_Symbol, "BuyButton", OBJPROP_TEXT, "BUY"); }//+------------------------------------------------------------------+void OnChartEvent (const int id, const long &lparam, const double &dparam, const string &sparam) { if (id==CHARTEVENT_OBJECT_CLICK) { if (sparam=="BuyButton") { Comment (sparam+" was pressed"); trade. Buy (0.10, NULL, Ask, (Bid-300* _Point), (Ask+250 * _Point), NULL);
}}}
ممنون می شم بررسی کنید
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/537268/ارور-در-اکسپرت
t.me/ParscodersCom
#metatrader, #expert_advisor, #forex
سلام
اکسپرت نوشتم دکمه نمایش نمی دهد
#include<Trade\Trade.mqh> CTrade trade; double Ask, Bid;//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+void OnDeinit(const int reason) {//--- }//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+void OnTick() { Ask=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_ASK), _Digits); Bid=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_BID), _Digits); ObjectCreate(_Symbol,"BuyButton",OBJ_BUTTON,0,0,0); ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_XDISTANCE, 200); // set width ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_XSIZE, 200); // set distance from border ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_YDISTANCE, 200); // set height ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_YSIZE, 50);// set Chart corner ObjectSetInteger (_Symbol, "BuyButton", OBJPROP_CORNER, 2); ObjectSetString (_Symbol, "BuyButton", OBJPROP_TEXT, "BUY"); }//+------------------------------------------------------------------+void OnChartEvent (const int id, const long &lparam, const double &dparam, const string &sparam) { if (id==CHARTEVENT_OBJECT_CLICK) { if (sparam=="BuyButton") { Comment (sparam+" was pressed"); trade. Buy (0.10, NULL, Ask, (Bid-300* _Point), (Ask+250 * _Point), NULL);
}}}
ممنون می شم بررسی کنید
توسط خریدار:
شهرزاد1402اطلاعات بیشتر:
https://parscoders.com/project/537268/ارور-در-اکسپرت
t.me/ParscodersCom
45288 - پروژه زبان C++
#c_plus_plus_programming
یه برنامه به زبان C++ داشتم
خروجی و برنامه یه گراف ساده با الگوریتم داکسترا میخواستم
// A C++ program for Dijkstra's single source shortest path algorithm. // The program is for adjacency matrix representation of the graph #include <stdio.h> #include <limits.h> // Number of vertices in the graph #define V 9 // A utility function to find the vertex with minimum distance value, from // the set of vertices not yet included in shortest path tree int minDistance(int dist[\], bool sptSet[\]) { // Initialize min value int min = INT_MAX, min_index; for (int v = 0; v < V; v++) if (sptSet[v\] == false && dist[v\] <= min) min = dist[v\], min_index = v; return min_index; } // A utility function to print the constructed distance array int printSolution(int dist[\], int n) { printf("Vertex Distance from Source\n"); for (int i = 0; i < V; i++) printf("%d tt %d\n", i, dist[i\]); } // Function that implements Dijkstra's single source shortest path algorithm // for a graph represented using adjacency matrix representation void dijkstra(int graph[V\][V\], int src) { int dist[V\]; // The output array. dist[i\] will hold the shortest // distance from src to i bool sptSet[V\]; // sptSet[i\] will be true if vertex i is included in shortest // path tree or shortest distance from src to i is finalized // Initialize all distances as INFINITE and stpSet[\] as false for (int i = 0; i < V; i++) dist[i\] = INT_MAX, sptSet[i\] = false; // Distance of source vertex from itself is always 0 dist[src\] = 0; // Find shortest path for all vertices for (int count = 0; count < V-1; count++) { // Pick the minimum distance vertex from the set of vertices not // yet processed. u is always equal to src in the first iteration. int u = minDistance(dist, sptSet); // Mark the picked vertex as processed sptSet[u\] = true; // Update dist value of the adjacent vertices of the picked vertex. for (int v = 0; v < V; v++) // Update dist[v\] only if is not in sptSet, there is an edge from // u to v, and total weight of path from src to v through u is // smaller than current value of dist[v\] if (!sptSet[v\] && graph[u\][v\] && dist[u\] != INT_MAX && dist[u\]+graph[u\][v\] < dist[v\]) dist[v\] = dist[u\] + graph[u\][v\]; } // print the constructed distance array printSolution(dist, V); } // driver program to test above function int main() { /* Let us create the example graph discussed above */ int graph[V\][V\] = {{0, 4, 0, 0, 0, 0, 0, 8, 0}, {4, 0, 8, 0, 0, 0, 0, 11, 0}, {0, 8, 0, 7, 0, 4, 0, 0, 2}, {0, 0, 7, 0, 9, 14, 0, 0, 0}, {0, 0, 0, 9, 0, 10, 0, 0, 0}, {0, 0, 4, 14, 10, 0, 2, 0, 0}, {0, 0, 0, 0, 0, 2, 0, 1, 6}, {8, 11, 0, 0, 0, 0, 1, 0, 7}, {0, 0, 2, 0, 0, 0, 6, 7, 0} }; dijkstra(graph, 0); return 0; }
یه نمونه کد حل شده بود
"برای درک بهتر موضوع، مثال زیر مورد بررسی قرار خواهد گرفت.مجموعه sptSet در ابتدا خالی است و فاصله...
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/549549/45288-پروژه-زبان-c-plus-plus
t.me/ParscodersCom
#c_plus_plus_programming
یه برنامه به زبان C++ داشتم
خروجی و برنامه یه گراف ساده با الگوریتم داکسترا میخواستم
// A C++ program for Dijkstra's single source shortest path algorithm. // The program is for adjacency matrix representation of the graph #include <stdio.h> #include <limits.h> // Number of vertices in the graph #define V 9 // A utility function to find the vertex with minimum distance value, from // the set of vertices not yet included in shortest path tree int minDistance(int dist[\], bool sptSet[\]) { // Initialize min value int min = INT_MAX, min_index; for (int v = 0; v < V; v++) if (sptSet[v\] == false && dist[v\] <= min) min = dist[v\], min_index = v; return min_index; } // A utility function to print the constructed distance array int printSolution(int dist[\], int n) { printf("Vertex Distance from Source\n"); for (int i = 0; i < V; i++) printf("%d tt %d\n", i, dist[i\]); } // Function that implements Dijkstra's single source shortest path algorithm // for a graph represented using adjacency matrix representation void dijkstra(int graph[V\][V\], int src) { int dist[V\]; // The output array. dist[i\] will hold the shortest // distance from src to i bool sptSet[V\]; // sptSet[i\] will be true if vertex i is included in shortest // path tree or shortest distance from src to i is finalized // Initialize all distances as INFINITE and stpSet[\] as false for (int i = 0; i < V; i++) dist[i\] = INT_MAX, sptSet[i\] = false; // Distance of source vertex from itself is always 0 dist[src\] = 0; // Find shortest path for all vertices for (int count = 0; count < V-1; count++) { // Pick the minimum distance vertex from the set of vertices not // yet processed. u is always equal to src in the first iteration. int u = minDistance(dist, sptSet); // Mark the picked vertex as processed sptSet[u\] = true; // Update dist value of the adjacent vertices of the picked vertex. for (int v = 0; v < V; v++) // Update dist[v\] only if is not in sptSet, there is an edge from // u to v, and total weight of path from src to v through u is // smaller than current value of dist[v\] if (!sptSet[v\] && graph[u\][v\] && dist[u\] != INT_MAX && dist[u\]+graph[u\][v\] < dist[v\]) dist[v\] = dist[u\] + graph[u\][v\]; } // print the constructed distance array printSolution(dist, V); } // driver program to test above function int main() { /* Let us create the example graph discussed above */ int graph[V\][V\] = {{0, 4, 0, 0, 0, 0, 0, 8, 0}, {4, 0, 8, 0, 0, 0, 0, 11, 0}, {0, 8, 0, 7, 0, 4, 0, 0, 2}, {0, 0, 7, 0, 9, 14, 0, 0, 0}, {0, 0, 0, 9, 0, 10, 0, 0, 0}, {0, 0, 4, 14, 10, 0, 2, 0, 0}, {0, 0, 0, 0, 0, 2, 0, 1, 6}, {8, 11, 0, 0, 0, 0, 1, 0, 7}, {0, 0, 2, 0, 0, 0, 6, 7, 0} }; dijkstra(graph, 0); return 0; }
یه نمونه کد حل شده بود
"برای درک بهتر موضوع، مثال زیر مورد بررسی قرار خواهد گرفت.مجموعه sptSet در ابتدا خالی است و فاصله...
توسط خریدار:
مهندس خوباطلاعات بیشتر:
https://parscoders.com/project/549549/45288-پروژه-زبان-c-plus-plus
t.me/ParscodersCom
پروژه سیستم عامل..
#machine_learning, #software_engineering
پروژه سیستم عامل
تا چهارشنبه نهایت
ولی خیلی برام مهمه تک تک چیزایی که توش گفته شده انجام بشع
-
https://github.com/deep-observability-lab/OS-Tracing/tree/main/Lab%201
-
A simple C program is provided Here . Compile the program and run/trace it using strace; Explain all the system calls that are made. Run it for a second time -f flag and see how different the output is.stress-ng is a tool used to stress-test various system resources (CPU, memory, I/O, etc.) to evaluate system performance or stability under load. One of the tests include matrix multiplication. The goal is to engage a few number of your cores with matrix multiplication and trace the load. For events, include sched_switch and all sched_wak* events, interrupts, sched_process_fork and sched_process_exit. For contexts, include Virtual process ID, Virutal Thread ID, Process Name and Priority. Explain how the scheduler works, observe state transitions and identify patterns. stress-ng --matrix <number of cores> --matrix-size 128 --timeout 10s
-
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(){ int num; FILE *file_ptr; file_ptr = fopen("output.txt", "w"); if (file_ptr == NULL) { exit(1); } fprintf(file_ptr, "Hello World!\n"); fclose(file_ptr); pid_t pid = fork(); if (pid < 0) { return 1; } else if (pid == 0) { printf("This is the child process"); printf(" (PID: %d)\n", getpid()); } else { printf("This is the Parent process"); printf(" (PID: %d, Child PID: %d)\n", getpid(), pid); } return 0;}
-
برای انجام این پروژه نیاز بهماشین مجازیاوبنتو ۲۰.۰۴ داریمبعد روی اوبنتو lttng و trace compass نصب می کنیمبعد کد رو داخل ماشین مجازی میژنیم و با تریس کامپس تحلیل اش می کنیم
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/588479/پروژه-سیستم-عامل
t.me/ParscodersCom
#machine_learning, #software_engineering
پروژه سیستم عامل
تا چهارشنبه نهایت
ولی خیلی برام مهمه تک تک چیزایی که توش گفته شده انجام بشع
-
https://github.com/deep-observability-lab/OS-Tracing/tree/main/Lab%201
-
A simple C program is provided Here . Compile the program and run/trace it using strace; Explain all the system calls that are made. Run it for a second time -f flag and see how different the output is.stress-ng is a tool used to stress-test various system resources (CPU, memory, I/O, etc.) to evaluate system performance or stability under load. One of the tests include matrix multiplication. The goal is to engage a few number of your cores with matrix multiplication and trace the load. For events, include sched_switch and all sched_wak* events, interrupts, sched_process_fork and sched_process_exit. For contexts, include Virtual process ID, Virutal Thread ID, Process Name and Priority. Explain how the scheduler works, observe state transitions and identify patterns. stress-ng --matrix <number of cores> --matrix-size 128 --timeout 10s
-
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(){ int num; FILE *file_ptr; file_ptr = fopen("output.txt", "w"); if (file_ptr == NULL) { exit(1); } fprintf(file_ptr, "Hello World!\n"); fclose(file_ptr); pid_t pid = fork(); if (pid < 0) { return 1; } else if (pid == 0) { printf("This is the child process"); printf(" (PID: %d)\n", getpid()); } else { printf("This is the Parent process"); printf(" (PID: %d, Child PID: %d)\n", getpid(), pid); } return 0;}
-
برای انجام این پروژه نیاز بهماشین مجازیاوبنتو ۲۰.۰۴ داریمبعد روی اوبنتو lttng و trace compass نصب می کنیمبعد کد رو داخل ماشین مجازی میژنیم و با تریس کامپس تحلیل اش می کنیم
توسط خریدار:
مهندس خوباطلاعات بیشتر:
https://parscoders.com/project/588479/پروژه-سیستم-عامل
t.me/ParscodersCom
112169 - پروژه الکترونیک
#arduino, #electronics
سلام
: من روی یه پروژه روباتیکی کار میکنم امکانش هست توضیحاتش رو براتون بفرستم و بررسیش کنیدو مشکلاتش رو بگید ؟
تا پنچشنبه زمان دارم
همه کار هاش رو انجام دادم و کار هم میکنه فقط وقتی که اوت سنسور ها رو به ای اس پی 32 وصل میکنم ای اس پی به شدت داغ میکنه
چیزی که دارم میسازم یک وسیله پوشیدنی که برای ورزش های رزمی استفاده میشه
لیست وسایلی که استفاده کردم اینهاست
باتری لیتیوم یون 3.7v سایز 18650 سرتخت 2000mAh (چهار عدد)
سنسور اثر هال افکت a3144 ( برای هر جلیقه 45 عدد)
برد esp32s( دو عدد )
ماژول ساخت پاوربانک دارای Type-C و دو خروجی USB مدل LX-LBU2C (دو عدد )
قراره که سنسور های هال روی جلیقه باشند و دادهاشون بصورت رشته ای توسط بلوتوث ای اس پی ارسال بشه برای نرم افزار روی سیستم
چند تا ناحیه درست کردم روی جلیقه که هر کدوم 15 تا سنسور دارند و هر جلیقه سه تا ازین ها دارند
Gnd ، 5v رو با یو اس بی به پاوربانک وصل کردم و از
Gndیک سیم به زمین روی ای اس پی وصل کردم
و سه سیم اوت رو به پایه های رو ای اس پی وصل کردم
کدی که روی ای اس پی 32 دارم اینه
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
const int hallPins[12\] = {34, 35, 32, 33, 25, 26, 27, 14, 12, 13, 22, 23}; // پینهای سنسورها
int hallStates[12\]; // وضعیت سنسورها
String deviceName = "HOGO_BLUE"; // نام بلوتوث
void setup() {
Serial.begin(115200);
SerialBT.begin(deviceName);
Serial.println("Bluetooth started: " + deviceName);
for (int i = 0; i < 12; i++) {
pinMode(hallPins[i\], INPUT);
}
}
void loop() {
String data = "";
for (int i = 0; i < 12; i++) {
hallStates[i\] = digitalRead(hallPins[i\]);
data += String(hallStates[i\]);
if (i < 11) data += ",";
}
SerialBT.println(data); // ارسال داده به صورت رشتهای
delay(100); // تأخیر ۱۰۰ میلیثانیهای
}
و این روهم اضافه کنم که من کل این پروژه رو با هوش مصنوعی درست کردم و خودم دانش کافی برای این پروژه ندارم
برنامه روی سیستم هم نوشته شده و اونهم دادها رو دریافت میکنه و امتیاز ها رو هم ثبت میکنه
مشکلی که دارم اینه که سنسور های هال دامنه پوشش کافی ندارند
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/605968/112169-پروژه-الکترونیک
t.me/ParscodersCom
#arduino, #electronics
سلام
: من روی یه پروژه روباتیکی کار میکنم امکانش هست توضیحاتش رو براتون بفرستم و بررسیش کنیدو مشکلاتش رو بگید ؟
تا پنچشنبه زمان دارم
همه کار هاش رو انجام دادم و کار هم میکنه فقط وقتی که اوت سنسور ها رو به ای اس پی 32 وصل میکنم ای اس پی به شدت داغ میکنه
چیزی که دارم میسازم یک وسیله پوشیدنی که برای ورزش های رزمی استفاده میشه
لیست وسایلی که استفاده کردم اینهاست
باتری لیتیوم یون 3.7v سایز 18650 سرتخت 2000mAh (چهار عدد)
سنسور اثر هال افکت a3144 ( برای هر جلیقه 45 عدد)
برد esp32s( دو عدد )
ماژول ساخت پاوربانک دارای Type-C و دو خروجی USB مدل LX-LBU2C (دو عدد )
قراره که سنسور های هال روی جلیقه باشند و دادهاشون بصورت رشته ای توسط بلوتوث ای اس پی ارسال بشه برای نرم افزار روی سیستم
چند تا ناحیه درست کردم روی جلیقه که هر کدوم 15 تا سنسور دارند و هر جلیقه سه تا ازین ها دارند
Gnd ، 5v رو با یو اس بی به پاوربانک وصل کردم و از
Gndیک سیم به زمین روی ای اس پی وصل کردم
و سه سیم اوت رو به پایه های رو ای اس پی وصل کردم
کدی که روی ای اس پی 32 دارم اینه
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
const int hallPins[12\] = {34, 35, 32, 33, 25, 26, 27, 14, 12, 13, 22, 23}; // پینهای سنسورها
int hallStates[12\]; // وضعیت سنسورها
String deviceName = "HOGO_BLUE"; // نام بلوتوث
void setup() {
Serial.begin(115200);
SerialBT.begin(deviceName);
Serial.println("Bluetooth started: " + deviceName);
for (int i = 0; i < 12; i++) {
pinMode(hallPins[i\], INPUT);
}
}
void loop() {
String data = "";
for (int i = 0; i < 12; i++) {
hallStates[i\] = digitalRead(hallPins[i\]);
data += String(hallStates[i\]);
if (i < 11) data += ",";
}
SerialBT.println(data); // ارسال داده به صورت رشتهای
delay(100); // تأخیر ۱۰۰ میلیثانیهای
}
و این روهم اضافه کنم که من کل این پروژه رو با هوش مصنوعی درست کردم و خودم دانش کافی برای این پروژه ندارم
برنامه روی سیستم هم نوشته شده و اونهم دادها رو دریافت میکنه و امتیاز ها رو هم ثبت میکنه
مشکلی که دارم اینه که سنسور های هال دامنه پوشش کافی ندارند
توسط خریدار:
khaneprozheاطلاعات بیشتر:
https://parscoders.com/project/605968/112169-پروژه-الکترونیک
t.me/ParscodersCom
الکترونیک - 115145
#electronics
سلام خسته نباشیدحدودا هزینش چقدر میشه؟#include “stm8s.h” #include “stm8s_clk.h” #include “stm8s_gpio.h” #include “stm8s_tim4.h”// ———————–– // پینها // ———————–– #define LEFT_PORT GPIOD #define LEFT_PIN GPIO_PIN_2#define RIGHT_PORT GPIOD #define RIGHT_PIN GPIO_PIN_3#define RELAY_PORT GPIOB #define RELAY_PIN GPIO_PIN_5// ———————–– // millis() // ———————–– volatile uint32_t g_millis = 0;uint32_t myMillis(void) { uint32_t ms; disableInterrupts(); ms = g_millis; enableInterrupts(); return ms; }INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) { TIM4_ClearITPendingBit(TIM4_IT_UPDATE); g_millis++; }// ———————–– // تبدیل پالس چشمکزن به حالت پایدار // ———————–– bool stableIndicator(GPIO_TypeDef* port, GPIO_Pin_TypeDef pin, uint32_t* lastOn) { uint32_t now = myMillis(); bool raw = (GPIO_ReadInputPin(port, pin) == RESET);if (raw) *lastOn = now;// اگر در 250ms اخیر روشن بوده → هنوز روشن حساب کنif (now - *lastOn < 250) return true;return false;}// ———————–– // متغیرها // ———————–– uint32_t lastLeft = 0; uint32_t lastRight = 0;bool waiting = false; bool relayOn = false; bool holdPhase = false; bool lastWasLeft = false;uint32_t tStart = 0; uint32_t tOffDelay = 0;// ———————–– // Setup // ———————–– void setup() { CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);GPIO_Init(LEFT_PORT, LEFT_PIN, GPIO_MODE_IN_PU_NO_IT);GPIO_Init(RIGHT_PORT, RIGHT_PIN, GPIO_MODE_IN_PU_NO_IT);GPIO_Init(RELAY_PORT, RELAY_PIN, GPIO_MODE_OUT_PP_LOW_FAST);TIM4_TimeBaseInit(TIM4_PRESCALER_128, 124);TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);TIM4_Cmd(ENABLE);enableInterrupts();}// ———————–– // Loop // ———————–– void loop() { uint32_t now = myMillis();bool leftOn = stableIndicator(LEFT_PORT, LEFT_PIN, &lastLeft);bool rightOn = stableIndicator(RIGHT_PORT, RIGHT_PIN, &lastRight);// مرحله 1: شروع با یک جهتif (!relayOn && !waiting && !holdPhase){ if (leftOn) { waiting = true; lastWasLeft = true; tStart = now; } else if (rightOn) { waiting = true; lastWasLeft = false; tStart = now; }}// مرحله 2: جهت دوم زیر 1 ثانیهif (waiting){ if (lastWasLeft && rightOn && (now - tStart < 1000)) { GPIO_WriteHigh(RELAY_PORT, RELAY_PIN); relayOn = true; waiting = false; holdPhase = true; } if (!lastWasLeft && leftOn && (now - tStart < 1000)) { GPIO_WriteHigh(RELAY_PORT, RELAY_PIN); relayOn = true; waiting = false; holdPhase = true; } if ((now - tStart) >= 1000) waiting = false;}// مرحله 3: نگه داشتن رله تا خاموش شدن واقعی جهت دومif (holdPhase){ if (lastWasLeft) { if (!rightOn) { tOffDelay = now; // شروع تایمر 3 ثانیه holdPhase = false; } } else { if (!leftOn) { tOffDelay = now; holdPhase = false; } }}// مرحله 4: خاموش کردن رله بعد از 3 ثانیهif (!holdPhase && relayOn){ // اگر دوباره پالس آمد → تایمر ریست شود if (lastWasLeft && rightOn) { holdPhase = true; } else if (!lastWasLeft && leftOn) { holdPhase = true; } else { // اگر 3 ثانیه کامل گذشت و هیچ...
توسط خریدار:
اطلاعات بیشتر:
https://parscoders.com/project/611696/الکترونیک-115145
t.me/ParscodersCom
#electronics
سلام خسته نباشیدحدودا هزینش چقدر میشه؟#include “stm8s.h” #include “stm8s_clk.h” #include “stm8s_gpio.h” #include “stm8s_tim4.h”// ———————–– // پینها // ———————–– #define LEFT_PORT GPIOD #define LEFT_PIN GPIO_PIN_2#define RIGHT_PORT GPIOD #define RIGHT_PIN GPIO_PIN_3#define RELAY_PORT GPIOB #define RELAY_PIN GPIO_PIN_5// ———————–– // millis() // ———————–– volatile uint32_t g_millis = 0;uint32_t myMillis(void) { uint32_t ms; disableInterrupts(); ms = g_millis; enableInterrupts(); return ms; }INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) { TIM4_ClearITPendingBit(TIM4_IT_UPDATE); g_millis++; }// ———————–– // تبدیل پالس چشمکزن به حالت پایدار // ———————–– bool stableIndicator(GPIO_TypeDef* port, GPIO_Pin_TypeDef pin, uint32_t* lastOn) { uint32_t now = myMillis(); bool raw = (GPIO_ReadInputPin(port, pin) == RESET);if (raw) *lastOn = now;// اگر در 250ms اخیر روشن بوده → هنوز روشن حساب کنif (now - *lastOn < 250) return true;return false;}// ———————–– // متغیرها // ———————–– uint32_t lastLeft = 0; uint32_t lastRight = 0;bool waiting = false; bool relayOn = false; bool holdPhase = false; bool lastWasLeft = false;uint32_t tStart = 0; uint32_t tOffDelay = 0;// ———————–– // Setup // ———————–– void setup() { CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);GPIO_Init(LEFT_PORT, LEFT_PIN, GPIO_MODE_IN_PU_NO_IT);GPIO_Init(RIGHT_PORT, RIGHT_PIN, GPIO_MODE_IN_PU_NO_IT);GPIO_Init(RELAY_PORT, RELAY_PIN, GPIO_MODE_OUT_PP_LOW_FAST);TIM4_TimeBaseInit(TIM4_PRESCALER_128, 124);TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);TIM4_Cmd(ENABLE);enableInterrupts();}// ———————–– // Loop // ———————–– void loop() { uint32_t now = myMillis();bool leftOn = stableIndicator(LEFT_PORT, LEFT_PIN, &lastLeft);bool rightOn = stableIndicator(RIGHT_PORT, RIGHT_PIN, &lastRight);// مرحله 1: شروع با یک جهتif (!relayOn && !waiting && !holdPhase){ if (leftOn) { waiting = true; lastWasLeft = true; tStart = now; } else if (rightOn) { waiting = true; lastWasLeft = false; tStart = now; }}// مرحله 2: جهت دوم زیر 1 ثانیهif (waiting){ if (lastWasLeft && rightOn && (now - tStart < 1000)) { GPIO_WriteHigh(RELAY_PORT, RELAY_PIN); relayOn = true; waiting = false; holdPhase = true; } if (!lastWasLeft && leftOn && (now - tStart < 1000)) { GPIO_WriteHigh(RELAY_PORT, RELAY_PIN); relayOn = true; waiting = false; holdPhase = true; } if ((now - tStart) >= 1000) waiting = false;}// مرحله 3: نگه داشتن رله تا خاموش شدن واقعی جهت دومif (holdPhase){ if (lastWasLeft) { if (!rightOn) { tOffDelay = now; // شروع تایمر 3 ثانیه holdPhase = false; } } else { if (!leftOn) { tOffDelay = now; holdPhase = false; } }}// مرحله 4: خاموش کردن رله بعد از 3 ثانیهif (!holdPhase && relayOn){ // اگر دوباره پالس آمد → تایمر ریست شود if (lastWasLeft && rightOn) { holdPhase = true; } else if (!lastWasLeft && leftOn) { holdPhase = true; } else { // اگر 3 ثانیه کامل گذشت و هیچ...
توسط خریدار:
nikotexاطلاعات بیشتر:
https://parscoders.com/project/611696/الکترونیک-115145
t.me/ParscodersCom