数组匹配?(家庭作业) [英] Array matching?(home work)

查看:81
本文介绍了数组匹配?(家庭作业)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一维和3维数据矩阵匹配,1d数据为行矩阵,3d数据为一行或一列.根据1d数据查找3D数据的对应匹配数据.

例如

1.获取1d和3d数据文件.
1 d具有一组元素22、33、44、55、66
具有1至100个元素的3d,32至35和72至75 ..(例如32,32.1,32.2至35和72,72.1,.. 75)
2.hers匹配第一组轮廓,即22、33、44、55、66到1到100个元素找到公共点,即仅22、33、44、55、66. 3.这里v得到5点kw..ie 5数据.那么这3d数据包含32到35和72到75. 22,33,44,55,66数据找到每个值32到35和72到75.(此值每隔这样间隔..lik32.2,32.6…3​​5和72.1到75 ..每组值都包含100个元素(如tat)..
22,33,44,55,66在这些数据之间找到对应的(32至35和72至75).
要进行c语言编程……………………..代码…………………….请发送给我..urgent….

1dimensional and 3dimensional data matrix matching,1d data are row matrix and 3d data are one row or columns.find corresponding matching data of 3D data according to 1d data.

for example

1.Take 1d and 3d data files.
1 d having set of elements 22,33,44,55,66
3d having 1 to 100 elements, 32 to 35 and 72 to 75..(like 32,32.1,32.2 to 35 and 72,72.1,..75)
2.hers match this 1st set of profiles ie 22,33,44,55,66 to 1 to 100 elements find the common point ie nothing but 22,33,44,55,66 only.
3.here v getting 5 points kw..ie 5 data.then this 3d data are contains 32 to 35 and 72 to 75.according to
22,33,44,55,66 data find each values of 32 to 35 and 72 to 75.(this values u take wat ever interval like that..lik 32.2,32.6…35 and 72.1 to75..each set of values contains 100 elements lke tat)..
22,33,44,55,66 find corresponding (32 to35 and 72 to 75) in between these data.
Want c programming ……………………..codes………………….please send to me..urgent….

推荐答案

不,该站点上的人员不会在这里帮助您作弊.
No, people on this site are not here to help you cheat on your course work.


假设,您可以实现两个功能:

Assumed, you can implement two functions:

typedef enum {
  e3DRowData,        // X-Dump
  e3DColData,        // Y-Dump
  e3DStkData         // Z-Dump
} eDataOrientation;

// 1. Building of the 1D arrays data dump
BOOL Get1D_Dump(BYTE* pcDataDump, UINT& uiDataLen,
                int iXPos);

// 2. Building of the 3D arrays data dump
BOOL Get3D_Dump(BYTE* pcDataDump, UINT& uiDataLen,
                int iXPos, int iYPos, int iZPos, eDataOrientation);


...以及功能:


...and the function:

// Finding of "What" in "Where", returning of the found matching index or (-1)
int TryToFind(BYTE* pbyWhere, BYTE* pbyWhat,
              UINT uiWhereLen, UINT uiWhatLen,
              size_t sizeBytesPerElement)
{
  BYTE* pbyPos   = pbyWhere;
  while (pbyPos &&
         uiWhereLen > (pbyPos - pbyWhere)) {
    // seek to the first byte matching
    pbyPos = (BYTE*) memchr(pbyPos, pbyWhat[0],
                            uiWhereLen - (pbyPos - pbyWhere));
    if (pbyPos) {
      UINT uiRest = pbyPos % sizeBytesPerElement;
      if (uiRest) {
        // it was not an edge our elements type
        pbyPos += (sizeBytesPerElement - uiRest);
        countinue; 
      }
      if (0 == memcmp(pbyPos, pbyWhat, uiWhatLen)) {
        // whole matching, done
        return int((pbyPos - pbyWhere) / sizeBytesPerElement);
      }
      // there was no whole matching, forwards...
      pbyPos += sizeBytesPerElement;
    }
  }
  return (-1);
}


...然后您可以写:):


...then you could write :) :

// preparing of an 1d double array
...
// preparing of an 3d double array
...

// try to find the whole 1d array at the Stack{0, 0} of the 3d array:
BYTE* pc1DData    = NULL;
UINT  ui1DDataLen = 0;
BYTE* pc3DData    = NULL;
UINT  ui3DDataLen = 0;
if (Get1D_Dump(pc1DData, ui1DDataLen,
               0 /*whole array*/) &&
    Get3D_Dump(pc3DData, ui3DDataLen,
               0 /*DataBeginningX*/,
               0 /*DataBeginningY*/,
               0 /*DataBeginningZ*/,
               e3DStkData /*a stack please*/)) {
  // The Core :)
  int iFoundPos = TryToFind(pc3DData, pc1DData,
                            ui3DDataLen, ui1DDataLen,
                            sizeof(double) /*our arrays elements type*/);
  if (-1 != iFoundPos) {
    // the 1d array is placed at the index iFoundPos
    // of the 3d arrays Stack{0, 0} :)
  }
}


这篇关于数组匹配?(家庭作业)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆