Wednesday, October 8, 2008

[ALGO] pasting code on blog in comments

comments takes html code , thus c++ code with "<" ">" are not accepted in comments.
Old method I pasted add spaces, the code looks weird and not eye pleasing.

this is the new method, using characters entities to represent "<" and ">".

1. copy code to notepad
2. press ctrl+H
3. replace all "<" with "_&_l_t;"
without the 2x quotes and the underscore
4. repeat all ">" with "_&_g_t;"
without the 2x quotes and the underscore
5. paste to comments of that post


OLD METHOD
//======================================
to fix it
1. copy code to note pad
2. press ctrl+H
3. replace all "<....." with "< ....." note the space, without the 2x quotes
4. repeat for > 
5. paste to comments

6 comments:

  1. work for comment


    #include <iostream> //use by cin cout

    using namespace std;

    typedef map<int, int> CMapFac; // dec my may

    int main(int argc, char * argv[])
    {
    //Q1.=====vector=======================
    //i--------------
    vector <int> vect;
    vector <int> :: iterator it;
    vect.push_back(3);
    vect.push_back(5);

    ReplyDelete
  2. #include _&_l_t;iostream_&_g_t;
    #include _&_l_t;string_&_g_t;

    using namespace std;

    void whyCallMe(string input)
    {
    if (input == "urgent")
    cout _&_l_t;_&_l_t; "because it is urgent lar" _&_l_t;_&_l_t; endl;
    else if (input == "miss you")
    cout _&_l_t;_&_l_t; "you wait long long"_&_l_t;_&_l_t;endl;

    else
    cout _&_l_t;_&_l_t; "Not answering your calls";
    }

    void plsDunCallMe()
    {

    string a = "there is more then one way to skin the cat";
    cout _&_l_t;_&_l_t; a _&_l_t;_&_l_t; endl;
    }

    int func1(int x, int y)
    {
    int result = 0;
    result = x + y;
    return result;
    }

    int main()
    {


    int result = 0;
    string strIn;
    cout _&_l_t;_&_l_t; "Spot the common mistake(s)" _&_l_t;_&_l_t; endl;

    result = func1(10,20);
    cout _&_l_t;_&_l_t; "sum 10+20: " _&_l_t;_&_l_t; result _&_l_t;_&_l_t; endl;
    plsDunCallMe();

    while (1)
    {
    cout _&_l_t;_&_l_t; "Why You Called?";
    cin _&_g_t;_&_g_t; strIn;

    if (strIn == "urgent")
    {
    whyCallMe(strIn);
    cout _&_l_t;_&_l_t; endl; break;
    }
    }

    return 0;

    }

    ReplyDelete
  3. alina can you please post it in the correct post????
    thx

    ReplyDelete
  4. testing this command sorry for flooding & l t;

    ReplyDelete
  5. & l t ;
    without the spaces
    you would get <

    ReplyDelete