lyzmyy 2016-02-22 02:20 采纳率: 0%
浏览 1458
已结题

c/c++关于结构体的函数中调用时如何存储数据并实现排序

template
struct acc_med
{

inline acc_med(int poolHeight, int poolWidth, type derOutput = 0)
:
value(-std::numeric_limits::infinity()),
derOutput(derOutput),
derDataActivePt(NULL)
{ }
int i; type* array;
inline void accumulate_forward(type x) {
/*value = std::max(value, x) ;*/
array[i]=x;
for (int k=1;k for(int j=0;j if(array[j]>array[i]){
int temp= array[i];
for(int p=i;p>j;p--){
array[p]=array[p-1];

}
array[j]=temp;
break;
}

}
if (i<8)
i++;

else
value=array[4];
i=0;
}
如题,这个代码是一个结构体的一部分, 外面调用accumulate_forward函数时每次会传入一个值,本来是取最大值(注释掉的那句),现在想修改,想要该函数实现排序功能,然后返回中值,应该怎么写。编程很差,尤其是对结构体类的处理不理解,希望各位耐心指教

  • 写回答

3条回答

  • HeroKern 博客专家认证 2016-02-22 02:41
    关注

    推荐两篇文章你应该能够自己找到答案 http://m.blog.csdn.net/article/details?id=50436089

    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?