您的位置:首页 > 编程语言 > C语言/C++

Datastructure c++ note 2

2005-12-02 16:17 260 查看
     ASCII      DECIMAL     BINARY
    空格        32      0010 0000
    十进制数码       48 – 57       0110 0000 
    大写字母       65 – 90      0100 0001
    小写字母       97 - 122 
 

1. 
 
2. enum Boolean {False , True };Boolean Done = False;
 
 
3. char *pName = “c://china.exe”;  Char *p = strrchr(pName, ‘//’) + 1;
 
 
4. 变量在使用前要初始化数组在使用之前一定要初始化   char *myArr = "this is my first word program!";

char arr[50];memset(arr, 0, 50);int    arr[50];for (int i=0; i<50; i++)        arr[i] = 0;

myArr     0x004240c8 "this is my first word program!"      char *
myArr     0x004240c8 "this is my first word program!"      char *arr   0x0012fe88 "烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫this is my first word program!"      char [50]
 
 
5.

//顺序查找(循环多次)

int SeqSearch(int arr[], int start, int n, int key)

{

     int pos = -1;

     for (int i = start; i < n; i++)

     {

         if (arr[i] == key)

              pos = i;

     }

     return pos;

}

 
 
//顺序查找

int SeqSearch2(int arr[], int start, int n, int key)

{

     for (int i=start; i<n; i++)

     {

         if (arr[i] == key)

              return i;

     }

     return -1;

}

 
 
//重复查找

int searchCount(int arr[], int start, int n, int key)

{

     int pos = 0;

     int count = 0;

     while ((pos = SeqSearch2(arr, pos, n, key)) != -1)

     {

        count ++;

         //找到后指针后移

         pos ++;

     }

     return count;

}
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++ c