//开始 50 次循环
FOR 50
     xxxxxxx代码
     //开始 60 次循环
FOR 60
   xxxxxxx代码
//结束循环
ENDFOR
//结束循环
ENDFOR
//开始 50 次循环
FOR 50
     xxxxxxx代码
     //开始 60 次循环
FOR 60
   xxxxxxx代码
                      FOR 60
   xxxxxxx代码
//结束循环
ENDFOR //结束循环
ENDFOR
//结束循环
ENDFOR里面的循环是根据用户写的来写成代码!
我的朋友他写出来了!
我想知道有别的方法来看!算法好的大哥帮说下!

解决方案 »

  1.   

    跟算法没有关系。产品中也没有什么价值。如果仅仅是特别的简单的参数调整,用不着搞成让用户去写代码这种形式。如果说用户上网浏览,都要到你的网站上去写一段c#代码才能浏览到内容,那么难保他不会乱写、甚至百分之九十九点九九的人都会失败而再也不用你的网站。而剩下的万分之一的能够手写打断代码还不出错的人,他们为什么不用自己的vs来编译出一个符合某个接口的dll然后上传给你的网站,偏要到你的网站上的破字符编辑器去写代码呢?
      

  2.   

    你写的不是源代码难道是去直接写exe?你想实现的是什么功能?
      

  3.   

    for循环的次数本来就可以通过用户指定的
      

  4.   

    这个知道!
    可是我是想在软件里现实!
    现在只能单循环!
    比如
    for 50
     for 60
       for 70
       endfor
     endfor
    endfor
      

  5.   

    就是循环里面有循环!
    上面的写成代码应该是
    for(int i=0;i<50;i++)
    {
      for(int j=0;j<60;i++)
     {
        for(int z=0;z<70;i++)
        {
        }
     }
    }
    如果用户又写成这样就应该这样!
    for 50
     for 60
       endfor
    endforfor(int i=0;i<50;i++)
    {
      for(int j=0;j<60;i++)
     {
        }
    }
      

  6.   


    //这是我朋友的代码大概如下
    void CUserItem::LoadActionList(void)
    {
    if(FilePath.IsEmpty())
    return;
    ActionList.ClearAll();
    CStdioFile cf(FilePath , CFile::modeRead);
    CString line;
    while(cf.ReadString(line))
    {
    line = line.Trim();
    if(line.Find(L"KEYPRESS ") == 0)
    {
    CString key;
    CString time;
    UINT ukey = 0;
    float utime = 0; line = line.Mid(9);
    int index = line.Find(L" ");
    if(index != -1)
    {
    key = line.Mid(0 ,index);
    time = line.Mid(index + 1);
    }
    else
    {
    key = line;
    time = L"0";
    }
    swscanf(key , L"%u" , &ukey);
    swscanf(time , L"%f" , &utime);
    if(ukey != 0)
    {
    CUserAction * ua = new CUserAction(ukey , utime);
    ActionList.push_back(ua);
    }
    }
    else if(line.Find(L"DELAY ") == 0)
    {
    line = line.Mid(6);
    float time = 1.0;
    swscanf(line , L"%f" , &time);
    CUserAction * ua = new CUserAction(time);
    ActionList.push_back(ua);
    }
    else if(line.Find(L"FOR ") == 0)
    {
    line = line.Mid(4);
    UINT count = 1;
    swscanf(line , L"%u" , &count);
    CUserAction * ua = new CUserAction(count);
    ActionList.push_back(ua);
    }
    else if(line.Find(L"ENDFOR") == 0)//我就是这里有点不明白
    {
    CUserAction * ua = new CUserAction();
    ActionList.push_back(ua);
    }
    }
    cf.Close();
    }//这是FOR 判断
    else if(line.Find(L"FOR ") == 0)
    {
    line = line.Mid(4);
    UINT count = 1;
    swscanf(line , L"%u" , &count);
    CUserAction * ua = new CUserAction(count);
    ActionList.push_back(ua);
    }
    else if(line.Find(L"ENDFOR") == 0) 
    {
    CUserAction * ua = new CUserAction();
    ActionList.push_back(ua);
    }
    //这是方法UINT CUserItem::RunActionThread(LPVOID param)
    {
    CUserItem * ui = (CUserItem *)param;
    int i = ui->RunCount;
    while(i == -1 || i-- > 0)
    {
    stack<ForStackItem> forstack;
    for(UINT i = 0 ; i < ui->ActionList.size() ; i++)
    {
    if(ui->Stopped)
    return 0;
    CUserAction * ua = ui->ActionList[i];
    switch(ua->Type)
    {
    case CUserAction::Delay :
    if(ua->FloatParam >= 0.1)
    Sleep(ua->FloatParam * 1000);
    break;
    case CUserAction::KeyPress:
    if(ua->FloatParam < 0.1)
    {
    ::PostMessage(ui->Hwnd , WM_KEYDOWN , ua->UIntParam , 0);
    ::PostMessage(ui->Hwnd , WM_KEYUP , ua->UIntParam , 0); 
    }
    else
    {
    ::PostMessage(ui->Hwnd , WM_KEYDOWN , ua->UIntParam , 0);
    ::Sleep(ua->FloatParam * 1000);
    ::PostMessage(ui->Hwnd , WM_KEYUP , ua->UIntParam , 0); 
    }
    break;
    case CUserAction::For :
    {
    ForStackItem si(i , ua->UIntParam);
    forstack.push(si);
    }
    break;
    case CUserAction::EndFor :
    if(forstack.size() > 0)
    {
    forstack.top().ForCountLeft--;
    if(forstack.top().ForCountLeft > 0)
    {
    i = forstack.top().IndexInList;
    }
    else
    {
    forstack.pop();
    }
    }
    break;
    }
    }
    }
    ui->Stopped = true;
    return 0;
    }
      

  7.   

    ....
    这个当然知道!
    那应该怎么写?
    怎么判断这个ENDFOR对应的FOR?
      

  8.   

    源代码我都有!
    现在就是不明他这里是怎么判断这个ENDFOR他是一行一行的读的 else if(line.Find(L"ENDFOR") == 0)//我就是这里有点不明白
            {
                CUserAction * ua = new CUserAction();
                ActionList.push_back(ua);    
            }
      

  9.   

    你比较着来看啊:
           else if(line.Find(L"FOR ") == 0)
            {
                line = line.Mid(4);
                UINT count = 1;
                swscanf(line , L"%u" , &count);
                CUserAction * ua = new CUserAction(count);  ActionList.push_back(ua);
            }
            else if(line.Find(L"ENDFOR") == 0)
            {
                CUserAction * ua = new CUserAction();            ActionList.push_back(ua);    
            }
    遇到for放入要count,需到endfor不放count,
    这样出栈的时候就知道了