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 */
&
Ïà¹ØÎĵµ£º
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 ......
1.ÓÐn¸öÕûÊý£¬Ê¹Ç°Ãæ¸÷Êý˳ÐòÏòºóÒÆm¸öλÖã¬×îºóm¸öÊý±ä³É×îÇ°Ãæm¸öÊý¡£
#include<stdio.h>
int f(int *);
int main()
{
int *p,a[10];
for(p=a;p<a+10;p++)
scanf("%d",p);
f(a);
for(p=a;p<a+10;p++)
printf("%d ",*p);
return 0;
}
int f(int *a)
{
int i,*p ......
»Ø¹Ë֮ǰµÄƪ·ù£¬CÓïÑÔµÄÖ÷Ì岿·Ö»ù±¾ÒѾ½éÉÜÍêÁË¡£Ö®ËùÒÔûÓнéÉÜC++µÄÏà¹ØÌØÐÔÊÇÒòΪÔÚ֮ǰµÄÎÄÕÂÖÐCºÍC++ÔÚÕâЩ·½Ã涼Óй²ÐÔ£¬ËùÒÔÔÚÃæÏò¶ÔÏó֮ǰ¡£ÎÒÃÇÏÈ°ÑÕâЩ¹²ÐÔ¸ø½éÉÜÍê¡£Ò²¾ÍÊÇ˵ÔÚ½éÉÜÃæÏò¶ÔÏó֮ǰ£¬ËùÓеÄÎÄÕ¶¼ÊÇCC++Öж¼ÄÜʹÓõġ£´ÓÕâµãÉÏÀ´¿´£¬ÏÖÔÚÕý¼«Á¦·Ü¶·ÓÚC++Õ½ÏßÉϵijõѧÕß»¹ÊǺÜÓÐÓô¦µÄ¡£
±¾Æª¼ ......
C/SģʽºÍB/SģʽµÄÇø±ð
¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£
¡«¡«Ê²Ã´ÊÇB/Sģʽ
B/Sģʽ£¬¼´ä¯ÀÀÆ÷/·þÎñÆ÷ģʽ£¬ÊÇÒ»ÖÖ´Ó´«Í³µÄ¶þ²ãCSģʽ·¢Õ¹ÆðÀ´µÄеÄÍøÂç½á¹¹Ä£Ê½£¬Æä±¾ÖÊÊÇÈý²ã½á¹¹C/Sģʽ¡£B/SÍøÂç½á¹¹Ä£Ê½ÊÇ»ùÓÚIntr ......
²Ù×÷º¯Êý,ËùÔÚº¯Êý¿âΪstring.h¡¢mem.h
mem…²Ù×÷´æÖüÊý×é
void *memccpy(void *destin,void *source,unsigned char ch,unsigned n)
void *memchr(void *s,char ch,unsigned n)
void *memcmp(void *s1,void *s2,unsigned n)
int memicmp(void *s1,void *s2,unsigned n)
void *memmove(void *destin ......