Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

tony_ming

@tony_ming
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • how to use recursive descent algorithm to compute an arithmetical expression?
    T tony_ming

    I want to use recursive descent algorithm to compute an arithmetical expression, but I can't get the right value,so please tell me how to write the code here is my grammar

    E→E+T|E-T|T
    T→T*F| T/F|F
    F→(E)|i

    the following is my code

    #include
    #include
    using namespace std;
    int pos = 0;
    string str = "1+2*3-4";
    double E();
    double T();
    double F();

    int main() {
    double v = E();
    printf("%f", v);
    getchar();
    return 0;
    }

    double E() {
    double v = 0;
    char c = str.at(pos);
    if (c == '+') {
    pos++;
    v = E() + T();
    }
    else if (c == '-') {
    pos++;
    v = E() - T();
    }
    else {
    pos++;
    v = T();
    }
    return v;
    }

    double T() {
    double v = 0;
    char c = str.at(pos);
    if (c == '*') {
    pos++;
    v = T() * F();
    }
    else if (c == '/') {
    pos++;
    v = T() / F();
    }
    else {
    pos++;
    v = F();
    }
    return v;
    }

    double F() {
    char c = str.at(pos);
    if (c == '(') {
    pos++;
    double v = E();
    c = str.at(pos);
    if (c == ')') {
    pos++;
    return v;
    }
    }
    else {
    string s = "";
    while (true) {
    c = str.at(pos);
    if (c >= '0' && c <= '9') {
    s += c;
    pos++;
    }
    else {
    break;
    }
    }

    	return atoi(s.c\_str());
    }
    return 0;
    

    }

    C / C++ / MFC algorithms tutorial question

  • How to start Java
    T tony_ming

    亲,Java快没落了,这年头再学习Java就是sb。 so,i recommend Dart

    Java tutorial java question learning

  • how to display panel just below input panel.?
    T tony_ming

    这么奇葩的需求

    Java tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups