<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                在已知數表中找出第一個與指定值相等的元素的下標和指針。這個實例還是比價簡單的。 我的思路是,首先創建一個struct結構,該結構中有兩個成員變量,一個是數組元素的下標,一個是數組元素的指針值,當程序進程查找的時候,將找到的結果保存到該結構上。下面是我的程序的實現部分: ~~~ #include <stdio.h> #define SIZE 100 /** * @brief The element struct * 元素的結構,包括元素的下標和元素的指針 */ struct element{ int subScript; int p; }; /** * @brief Search 在數組array中,尋找第一個與key相等的元素的下標和指針 * @param key 要尋找第一個與key相等的元素 * @param array 要被尋找的數組 * @param n 數組array中有幾個元素 * @return 返回含有元素下標和指針的結構 */ struct element Search(int key,int array[],int n){ int i = 0; struct element ele; for(i = 0;i < n;i++){ if(key == array[i]){ ele.subScript = i; ele.p = &array[i]; return ele; } } return ele; } /** * 在已知數表中找出第一個與指定值相等的元素的下標 * 和指針 * @brief main * @return */ int main(void) { int n; int i; int key; int array[SIZE]; printf("Please enter the length of the array:\n"); scanf("%d",&n); printf("Please enter the lements of the array:\n"); for(i = 0;i < n;i++){ scanf("%d",&array[i]); } printf("Please enter the key for searching:\n"); scanf("%d",&key); struct element searched = Search(key,array,n); //查看是否已經查到匹配的元素 if(searched.p == 0){ printf("There is no element equals to key!!\n"); }else{ printf("The subscript of the element is %d.\n",searched.subScript); printf("The pointer of the element is %d.\n",searched.p); } return 0; } ~~~ 下面是我的程序運行的截圖: ![這里寫圖片描述](https://box.kancloud.cn/2016-05-24_5743c07566375.jpg "")
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看