Jump to content
Incepat0r

Explicare program C++

Recommended Posts

@Incepat0r - am deschis fisierul flproj2.cpp in Notepad++,si pare ca sunt comentate majoritatea liniilor.Mai multe nu pot sa spun pentru ca nu stiu C++.

@1000DotS - in spatele acelor caractere se afla un link criptat care duce spre fisierul flproj2.cpp.In consecinta...mai ramane se alegi manastirea (no offence)

@AlStar - parerea mea e ca uneori e ok sa criptezi linkurile,poate ai vrea sa pui un link care sa fie vazut doar de cine e pe forum,si sa nu fie indexat de google.

Edited by Renegade
Link to comment
Share on other sites

@Renegade

Da, m-am prins..numai ca nu ma pricep tare bine cu partea de crypt/decrypt...;))

Imi explici si mie te rog?...

Ia, ajuta-ma cu problema asta...X(...toti sunteti interesanti...

uc3stSSuYCF45JDGudcTJw==

@Incepat0r

Da, esti foarte interesant...pui un link criptat.....smart! X(

Daca tot suntem la informatica, pune si tu un text criptat binary/hexa/orice tine de C++

Edited by 1000DotS
Link to comment
Share on other sites

@AlStar - parerea mea e ca uneori e ok sa criptezi linkurile,poate ai vrea sa pui un link care sa fie vazut doar de cine e pe forum,si sa nu fie indexat de google.

Linkurile oricum pot fi vazute doar de userii inregistrati. In rezultatele google apare un mesaj pus intre [ ] in locul linkului, care zice ca tre' sa fii inregistrat.

De altfel, daca vrei sa primesti repede ajutor, macar spui cu ce ai criptat. Din intamplare, am ghicit din prima algoritmul, dar daca trebuia sa incerc mai multe variante, imi bagam organu'..

Link to comment
Share on other sites

L-am criptat pentru ca oricum cei care nu recunosc un simplu base64, ma gandesc ca nu prea ma pot ajuta cu mare lucru si deci ii scutesc de un efort (cu toate ca ei insista).

Stiiu ca unele linii sunt comentate, dar alea sunt cele mai simple, pe mine m-ar interesa mai mult ce se intampla in acel for principal si in multitudinea de else-uri si if-uri.

Merci anticipat

Link to comment
Share on other sites

Cea mai mare problema in acea sursa sunt numele de variabile. Sunt scrise in modul in care le scrie lumea la liceu. Variabile cu nume a,b,c etc... Chiar daca scrii tu acel program cu asa nume de variabile, dupa o luna daca te uiti peste el nu mai stii ce face, chiar daca are comentarii.

Vad ca sunt comentarii in dreptul variabilelor ia redenumeste acele variabile ceva de genu: s -> inputStr sau input_str sau inputString

c -> operands

etc...

Si schimbi asa pentru fieacare loc in care apar. O sa il intelegi mult mai usor. Nu am timp sa fac asta pentru ca sunt la servici dar incearca tu, nu pare complicat.

Link to comment
Share on other sites

L-am criptat pentru ca oricum cei care nu recunosc un simplu base64, ma gandesc ca nu prea ma pot ajuta cu mare lucru si deci ii scutesc de un efort (cu toate ca ei insista).

Da bine desteptule...esti mare maciuca...

Am incercat md5 din prima...asta mi-o picat in minte...iti dau si eu cateva criptari, sa vad daca le recunosti din prima...

Hai ca deja fac offtopic...

Link to comment
Share on other sites

pentru cei care au nevoie de denumirile mai "umane", aveti fisierul atasat mai jos. Nu am timp sa stau sa vad unde e buba din pacate. Din ce am testat eu, la orice introduc printeaza #|#.


// project 2
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
char strng[50] = " "; // input string s
char operands[30] = " "; // operands c
char operators[30] = " "; // operators p
int i, j, m; // iterators
int length_of_strng; // lenght of s
int len_of_operands = 0; // lenght of operands l
int len_of_operators = 2; // lenght of operators k
int prioriti[50]; // priority array
int tp[30]; // operator's priorities
int bracket_weigth = 0; // bracket weight g
int len_of_tp = 0; // lenght of tp h

// priorities
prioriti['#'] = 0;
prioriti['+'] = 1;
prioriti['-'] = 1;
prioriti['*'] = 2;
prioriti['/'] = 2;
prioriti['^'] = 3;

tp[0] = 0; // priority for #

cout << "expression: ";
cin >> strng;
cout << endl;

length_of_strng = strlen(strng); // find the lenght of s

strng[length_of_strng++] = '#'; // add # manually at the end of s
strng[length_of_strng] = '\0';

operators[0] = '|';
operators[1] = '#'; // add # manually at the beginning of o

for (i = 0; i < length_of_strng; i++)
{
if (strng[i] >= 'a' && strng[i] <= 'z') // if operand
{
if (operands[len_of_operands-1] == '(') // bracket was present just before
{
for (m = 1; operands[len_of_operands-m] == '('; m++)
;

operands[len_of_operands - m + 1] = '|';

for (j = 0; j < m - 2; j++)
operands[len_of_operands - j] = '(';

if (m == 2)
operands[len_of_operands] = '(';

len_of_operands++;

operands[len_of_operands++] = strng[i]; // add it to c
}
else
{
operands[len_of_operands++] = '|';
operands[len_of_operands++] = strng[i]; // add it to c
}
}

else if (strng[i] == '(') // if left bracket
{
bracket_weigth = bracket_weigth + 10; // increase weight
operands[len_of_operands++] = '(';
}

else if (strng[i] == ')') // if right bracket
{
bracket_weigth = bracket_weigth - 10; // decrease weight
operands[len_of_operands++] = ')';
}

else if (strng[i] == '+' || strng[i] == '-' || strng[i] == '*' || strng[i] == '^' || strng[i] == '/' || strng[i] == '#')
{ // if operator
tp[++len_of_tp] = prioriti[strng[i]] + bracket_weigth; // add the operator's weight in tp

operators[len_of_operators++] = '|';
operators[len_of_operators++] = strng[i]; // add it to o

for (m = 1; m < len_of_operators; m++) // print o
cout << operators[m];
cout << "\t\t";

for (m = 1; m < len_of_operands; m++) // print c
cout << operands[m];
cout << endl << endl;

while (tp[len_of_tp] <= tp[len_of_tp-1]) // compare the priority of the operators
{
if (operators[1] == '#' && operators[3] == '#')
break; // end case

for (j = len_of_operands - 1; operands[j] != '|'; j--)
; // find the first | going back

operands[j] = operators[len_of_operators - 3]; // replace | with the old (popped) operator
operators[len_of_operators - 3] = strng[i]; // replace the old operator with the new one
len_of_operators = len_of_operators - 2;

for (m = 1; m < len_of_operators; m++) // print o
cout << operators[m];
cout << "\t\t";

for (m = 1; m < len_of_operands; m++) // print c
cout << operands[m];
cout << endl << endl;

tp[len_of_tp-1] = tp[len_of_tp]; // since we popped an operator, remove it
len_of_tp--;
}
}
}

return 0;
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...