標(biāo)題: C語言計(jì)算數(shù)組里兩次最大值的差值程序 不知道怎么寫 [打印本頁]

作者: 李冬    時(shí)間: 2022-3-7 08:25
標(biāo)題: C語言計(jì)算數(shù)組里兩次最大值的差值程序 不知道怎么寫
  1. uint c[2][2];// 兩次 最大值和下標(biāo)。



  2. void xb( ????) //  想把二維數(shù)組的指針做形參不知道怎么寫。變量i可以寫進(jìn) 形參里嗎
  3. {

  4.          uint max = ADC_Buff1[0];


  5.      for (  i4 = 1; i4 < 125; i4++)
  6.         {


  7.          if (max <ADC_Buff1[i4])
  8.                                          {
  9.              max = ADC_Buff1[i4];
  10.                   
  11.          }
  12.      }
  13.   C[i][0]=max;
  14.   C[i++][1]=i4;

  15. }

  16. void main(void)
  17. {
  18.         while (1)
  19.     {
  20. xb(????);
  21. if(i>=2)
  22. {
  23. 計(jì)算數(shù)組里兩次最大值的差值
  24. }

  25. }


  26. }
復(fù)制代碼

作者: 13205495918    時(shí)間: 2022-3-7 09:17
#include <iostream>
using namespace std;
int main()
{
   int c[2][2]={{1,2},{3,4}};
        int (*p)[2];
        int m;
        p = c;
        m = *(*(p+0)+0);
        cout<<m<<endl;
        p = c;
        m = *(*(p+0)+1);
        cout<<m<<endl;
        p = c;
        m = *(*(p+1)+0);
        cout<<m<<endl;
        p = c;
        m = *(*(p+1)+1);
        cout<<m<<endl;
}
answer:1,2,3,4;
你看看這樣你有思路嗎?我喜歡用指針數(shù)組去處理二維數(shù)組,嘿嘿嘿
作者: 13205495918    時(shí)間: 2022-3-7 09:26
是數(shù)組指針,剛才說錯(cuò)了。
作者: 李冬    時(shí)間: 2022-3-7 14:54
13205495918 發(fā)表于 2022-3-7 09:17
#include
using namespace std;
int main()

太繞,看不懂




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1