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

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


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[])
vector <int> vect;
vector <int> :: iterator it;

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;

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;

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

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

return 0;


sjteo said...

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

Anonymous said...

& l t;

Anonymous said...

testing this command sorry for flooding & l t;

sjteo said...

& l t ;
without the spaces
you would get <