Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ACM cº¯Êý´óÈ«

º¯ÊýÃû: abs ¹¦  ÄÜ: ÇóÕûÊýµÄ¾ø¶ÔÖµ
Óà ·¨: int abs(int i);
³ÌÐòÀý:
#include <stdio.h>
#include <math.h>
int main(void)
{
  int number = -1234;
  printf("number: %d  absolute value: %d\n", number, abs(number));
  return 0;
}
º¯ÊýÃû: atof
¹¦  ÄÜ: °Ñ×Ö·û´®×ª»»³É¸¡µãÊý
Óà ·¨: double atof(const char *nptr);
³ÌÐòÀý:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   float f;
   char *str = "12345.67";
   f = atof(str);
   printf("string = %s float = %f\n", str, f);
   return 0;
}
º¯ÊýÃû: atoi
¹¦  ÄÜ: °Ñ×Ö·û´®×ª»»³É³¤ÕûÐÍÊý
Óà ·¨: int atoi(const char *nptr);
³ÌÐòÀý:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   int n;
   char *str = "12345.67";
   n = atoi(str);
   printf("string = %s integer = %d\n", str, n);
   return 0;
}
º¯ÊýÃû: atol
¹¦  ÄÜ: °Ñ×Ö·û´®×ª»»³É³¤ÕûÐÍÊý
Óà ·¨: long atol(const char *nptr);
³ÌÐòÀý:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
   long l;
   char *str = "98765432";
   l = atol(lstr);
   printf("string = %s integer = %ld\n", str, l);
   return(0);
}
º¯ÊýÃû: bsearch
¹¦  ÄÜ: ¶þ·Ö·¨ËÑË÷
Óà ·¨: void *bsearch(const void *key, const void *base, size_t *nelem,  size_t width, int(*fcmp)(const void *, const *));
³ÌÐòÀý:
#include <stdlib.h>
#include <stdio.h>
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
int numarray[] = {123, 145, 512, 627, 800, 933};
int numeric (const int *p1, const int *p2)
{
   return(*p1 - *p2);
}
int lookup(int key)
{
   int *itemptr;
   /* The cast of (int(*)(const void *,const void*))
      is needed to avoid a type mismatch error at
      compile time */
 &


Ïà¹ØÎĵµ£º

C/C++ÃæÊÔÌâ


1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
int countx = 0;
while(x)
{
countx
++;
x = x&(x-1);
}
return countx;
}
¼Ù¶¨x = 9999¡£ ´ð°¸£º8
˼·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓÔҪעÒâÄÄЩÎÊÌ⣿
´ð£ºÒýÓþÍÊÇij¸öÄ¿±ê±äÁ¿µÄ&l ......

C Runtime LibraryÏê½â

.¸ÅÂÛ
¡¡¡¡ÔËÐÐʱ¿âÊdzÌÐòÔÚÔËÐÐʱËùÐèÒªµÄ¿âÎļþ£¬Í¨³£ÔËÐÐʱ¿âÊÇÒÔLIB»òDLLÐÎʽÌṩµÄ¡£
    CÔËÐÐʱ¿âµ®ÉúÓÚ20ÊÀ¼Í70Äê´ú£¬µ±Ê±µÄ³ÌÐòÊÀ½ç»¹ºÜµ¥´¿£¬Ó¦ÓóÌÐò¶¼Êǵ¥Ï̵߳ģ¬¶àÈÎÎñ»ò¶àÏ̻߳úÖÆÔÚ´Ëʱ»¹ÊôÓÚйÛÄî¡£ËùÒÔÕâ¸öʱÆÚµÄCÔËÐÐʱ¿â¶¼Êǵ¥Ï̵߳ġ£
¡¡¡¡Ëæ×ŲÙ×÷ϵͳ¶àÏ̼߳¼ÊõµÄ·¢Õ¹£¬×î³õµÄCÔ ......

Ò»¸öC++µ÷ÓÃCµÄÀý×Ó

//cExample.h
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
#ifdef __cplusplus
extern "C"
{
#endif
int add(int x, int y);
#ifdef __cplusplus
}
#endif
#endif
---------------------------------
//cExample.c
#include"cExample.h"
int add(int x, int y)
{
 return x + y;
}
----------------- ......

dz̸C/C++ÄÚ´æй©¼°Æä¼ì²â¹¤¾ß

¡¡¡¡¶ÔÓÚÒ»¸öc/c++³ÌÐòÔ±À´Ëµ£¬ÄÚ´æй©ÊÇÒ»¸ö³£¼ûµÄÒ²ÊÇÁîÈËÍ·ÌÛµÄÎÊÌâ¡£ÒѾ­ÓÐÐí¶à¼¼Êõ±»Ñо¿³öÀ´ÒÔÓ¦¶ÔÕâ¸öÎÊÌ⣬±ÈÈçSmart Pointer£¬Garbage CollectionµÈ¡£Smart Pointer¼¼Êõ±È½Ï³ÉÊ죬STLÖÐÒѾ­°üº¬Ö§³ÖSmart PointerµÄclass£¬µ«ÊÇËüµÄʹÓÃËƺõ²¢²»¹ã·º£¬¶øÇÒËüÒ²²»Äܽâ¾öËùÓеÄÎÊÌ⣻Garbage Collection¼¼ÊõÔÚJavaÖÐ ......

#ifdef __cplusplus extern "C" { #endif µÄ½âÊÍ

¹ØÓÚ#ifdef __cplusplus extern 
ÃæÊÔʱ±»Îʵ½¹ý£¬²»ÉõÃ÷ÁË£¬ÍøÉÏ°Ù¶Èһϣ¬ÕûºÏÁËÁ½¸öÈÊÐÖµÄÎÄÕ£¬ÈçÏ¡£:-)
ʱ³£ÔÚcppµÄ´úÂëÖ®Öп´µ½ÕâÑùµÄ´úÂë:
#ifdef __cplusplus
extern "C" {
#endif
//Ò»¶Î´úÂë
#ifdef __cplusplus
}
#endif
¡¡¡¡
    ÕâÑùµÄ´úÂëµ½µ×ÊÇʲôÒâ˼ÄØ£¿Ê×ÏÈ£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ