void 求峰谷个数(int* a, int aa, int* aaa)
{//缘由https://bbs.csdn.net/topics/395236094
int d = 1;
while (d<aa - 1)
if ((a[d]>a[d + 1] && a[d]>a[d - 1]) || (a[d]<a[d + 1] && a[d]<a[d - 1]))
(*aaa)++, cout << a[d++] << " " << *aaa << "\t"; else ++d;
}
int a[9] = { 12, 45, 32, 0, 14, 25, 62, 48, 51 }, b[9] = { 0 }, n = 0; memcpy(b, a, sizeof(int) * sizeof(a) / sizeof(a[0]));
求峰谷个数(a, 9, &n); cout << n;
C++求峰谷个数
最新推荐文章于 2023-12-23 08:23:44 发布