C/C++ ѧϰ±Ê¼Ç[03].È¥µôC·ç¸ñµÄ×¢ÊÍ
ÍøÉÏËÑË÷ÁËÒ»´ó¶ÑÈ¥µô/*ºÍ*/Ö®¼ä×¢Ê͵ĴúÂë,¾ÍÏñ<The C Programming Language>Á·Ï°1-23ÀïÓÐÈË˵µÄÒ»Ñù
´ó²¿·Ö¶¼»á±»ÒÔϵijÌÐòbroken,Õâ¸ö¹¦ÄÜ¿´ÆðÀ´¼òµ¥,ʵ¼ÊÉϺÜÓÐÄѶÈ.ÍøÉÏʵÏֵĴúÂë,³ýÁËÎÒÕÒµ½µÄÒ»¸öÓÃÎļþÖ¸ÕëʵÏÖµÄûÓÐÎÊÌâÍâ,ÆäÓàµÄ¶¼´æÔÚ¸÷ÖÖbug,²»ÐŵĻ°¾ÍÓÃÒÔϵijÌÐò²âÊÔÒ»ÏÂ:-),µ±È»Õâ¸ö³ÌÐòÒ²²»¹»ÍêÉÆ.
»¹ÊÇÓÐÏÞ״̬×Ô¶¯»úʵÏÖÆðÀ´¸üÑϽ÷Ò²ÈÝÒ×Àí½âµÃ¶à:
/* krx123tp.c - a test program to serve as input to krx123*.c
*
* This is a shameless copy of Ben Pfaff's solution, to which I have
* added a few extra statements to further test the candidate programs
* for this exercise. As Ben says, this program already contains lots
* of examples of comments and not-quite-comments. I've just made it
* a little tougher.
*
*/
/* K&R2 1-23: Write a program to remove all comments from a C program.
Don't forget to handle quoted strings and character constants
properly. C comments do not nest.
This solution does not deal with other special cases, such as
trigraphs, line continuation with \, or <> quoting on #include,
since these aren't mentioned up 'til then in K&R2. Perhaps this is
cheating.
Note that this program contains both comments and quoted strings of
text that looks like comments, so running it on itself is a
reasonable test. It also contains examples of a comment that ends
in a star and a comment preceded by a slash. Note that the latter
will break C99 compilers and C89 compilers with // comment
extensions.
Interface: The C source file is read from stdin and the
comment-less output is written to stdout. **/
#include <stdio.h>
int
main(void)
{
/* State machine's current state. */
enum {
PROGRAM,
SLASH,
COMMENT,
STAR,
QUOTE,
LITERAL
} state;
/* If state == QUOTE, then ' or ". Otherwise, undefined. */
int quote;
state = PROGRAM;
for (;;) {
int c = getchar();
if (c == EOF)
Ïà¹ØÎĵµ£º
#include<windows.h>
void Birthday();
int main()
{
Birthday();
return 0;
}
void Birthday()
{
unsigned frequency[]={392,392,440,392,523,494,
392,392,440,392,587,523,
......
C++ѧϰ±Ê¼Ç--Linuxϱà³Ì
Ò»¡¢¹ØÓÚBoostµÄʹÓ㬼¸ÖÖ³£Ó÷½·¨£¬Ö»ÊÇ×Ô¼º¹¤×÷¡¢Ñ§Ï°ÖÐ×ܽáµÄ£¬ÓÐЩ·½·¨µÄÈ·ÓÐЩ·±Ëö£¬ÄÜÂú×ãÐèÇó£¬Ó¦¸Ã»¹Óиü¼Ó¼òµ¥¿ì½ÝµÄ·½Ê½£¬´ý¸Ä½ø¡£
1¡¢ÅжÏ×Ö·û´®ÓëÕýÔò±í´ïʽÊÇ·ñÆ¥Å䣨ÍêÈ«Æ¥Å䣩
bool IsMatch(const char* data,const char * regx)
{
boost::regex express ......
ÈçºÎÖÕÖ¹Ï̵߳ÄÔËÐУ¨C/C++£©
ÏëÒªÖÕÖ¹Ï̵߳ÄÔËÐУ¬¿ÉÒÔʹÓÃÒÔÏ·½·¨£º
1¡¢Ï̺߳¯Êý·µ»Ø£¨×îºÃʹÓø÷½·¨£©¡£
2¡¢Í¨¹ýµ÷ÓÃExitThreadº¯Êý£¬Ï߳̽«×ÔÐг·Ïû£¨×îºÃ²»Ê¹Óø÷½·¨£©¡£
3¡¢Í¬Ò»¸ö½ø³Ì»òÁíÒ»¸ö½ø³ÌÖеÄÏ̵߳÷ÓÃTerminateThreadº¯Êý£¨Ó¦±ÜÃâʹÓø÷½·¨£©¡£
4¡¢ExitProcessºÍTerminateProcessº¯ÊýÒ²¿ÉÒÔÓÃÀ ......
µ±LinuxÄÚºËÔÚÌåϵ½á¹¹²îÒì½Ï´óµÄƽ̨֮¼äÒÆֲʱ£¬»á²úÉúÓëÊý¾ÝÀàÐÍÏà¹ØµÄÎÊÌâ¡£
.ÔÚ±àÒëÄÚºËʱʹÓà -Wall -W strict-prototypes Ñ¡Ïî, ¿ÉÒÔ±ÜÃâºÜ¶à´íÎóµÄ·¢Éú
.ÄÚºËʹÓõĻù±¾Êý¾ÝÀàÐÍÖ÷ÒªÓÐ:
int ±ê×¼CÓïÑÔÕûÊýÀàÐÍ
&n ......
JAVAºÍC++¶¼ÊÇÃæÏò¶ÔÏóÓïÑÔ¡£Ò²¾ÍÊÇ˵£¬ËüÃǶ¼Äܹ»ÊµÏÖÃæÏò¶ÔÏó˼Ï루·â×°£¬¼Ì³Ë£¬¶à̬£©¡£
C++Äܱ»²Ù×÷ϵͳ£¨Window£¬Linux£©Ö±½ÓÔËÐУ¬¶øJava²»ÐУ¬ÐèÒªÓиöJVM¡£
javaÓïÑÔ¸ø¿ª·¢ÈËÔ±ÌṩÁ˸üΪ¼ò½àµÄÓï·¨£»È¡ÏûÁËÖ¸Õë´øÀ´¸ü¸ßµÄ´úÂëÖÊÁ¿£»ÍêÈ«ÃæÏò¶ÔÏ󣬶ÀÌصÄÔËÐлúÖÆÊÇÆä¾ßÓÐÌìÈ»µÄ¿ÉÒÆÖ²ÐÔ¡£
1£®Ö¸Õë
JAVA ......