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:

sjteo said...

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);

Alina Wu (DCPE/2B04) said...

#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;

}

sjteo said...

alina can you please post it in the correct post????
thx

Anonymous said...

& l t;

Anonymous said...

testing this command sorry for flooding & l t;

sjteo said...

& l t ;
without the spaces
you would get <